c++

Is there a way to run ActiveX components in Firefox through the use of a plugin?

I have an ActiveX plugin that we need (if possible) to run in Firefox. Is there a plugin (or other way) for Firefox that will allow this? ...

I need to combine several methods without adding some data members. Any ideas?

Lets say I need to write several functions processing some data. These functions are performing a single task - some mathematical calculations. I suppose there is no need to combine them with some data members. Shall I use: a class without data members and declare these functions as static methods so I can use them without creating cl...

Multithreaded image processing in C++

I am working on a program which manipulates images of different sizes. Many of these manipulations read pixel data from an input and write to a separate output (e.g. blur). This is done on a per-pixel basis. Such image mapulations are very stressful on the CPU. I would like to use multithreading to speed things up. How would I do th...

Will repeated calls to srand() in c++ use the same seed?

If I have srand(2) declared in my main of my driver file, do I need to declare srand(2) in my code file which is being linked with my driver? Thanks. edit (from user's comment below) If I do, srand(2); srand(2); will I get the seed as 2? or something else? ...

Best way to calculate if there is a 1/4 chance something will happen in C++?

Hi, I was wondering if there is a smart way to find out There is a 1/4 chance something happens. I know we can do this with rand() % 4 and checking if it is equal to 0, but is there a way without using rand()? In c++, thanks. ...

A loop to create neighbor nodes in 3d space

Hi everybody, I want to create the 26 neighbors of a cubic-voxel-node in 3-d space. The inputs are the x,y,z position of the node and the size of the cube side . I am trying to do this using a for loop but haven't managed yet. I am quite newbie in programming please help me. ...

using a vector of column names, to generate a sql statement.

A problem that we need to solve regularly at my workplace is how to build sql statements based on user supplied table/column names. The issue I am trying to address is the commas between column names. One technique looks something like this. selectSql = "SELECT "; for (z = 0; z < columns.size(); z++) { selectSql += columns[z]....

Spline, B-Spline and NURBS C++ library

Does anyone know of a library or set of classes for splines - specifically b-splines and NURBS (optional). A fast, efficient b-spline library would be so useful for me at the moment. ...

SDL_event KEYDOWN behavior problem

Here is the problem, I have written an event loop to detect keydown and keyup events. The problem I am running into is that a keydown event is generating a keydown and a keyup event when the key is pressed and held down. I am using the arrow keys to move an object and then to stop moving when the key is released(keyup). Any help would...

Can I optimize code that has 3 for loops and 4 ifs?

Hi everybody i made another post here where I asked how to create the 26 neighbors of a cubic-voxel-node in 3-d space. I got a very good answer and implemented it. To that I added some MIN MAX Position checking. I would like to know if there is way, in relationship to the 3 for loops and 4 if used, to improve the execution time of t...

C++ - passing references to boost::shared_ptr

If I have a function that needs to work with a shared_ptr, wouldn't it be more efficient to pass it a reference to it (so to avoid copying the shared_ptr object)? What are the possible bad side effects? I envision two possible cases: 1) inside the function a copy is made of the argument, like in ClassA::take_copy_of_sp(boost::shared_pt...

OpenGL and monochrome texture

Is it possible to pump monochrome (graphical data with 1 bit image depth) texture into OpenGL? I'm currently using this: glTexImage2D( GL_TEXTURE_2D, 0, 1, game->width, game->height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, game->culture[game->phase] ); I'm pumping it with square array of 8 bit unsigned integers in GL_LUMINANCE mode (one 8...

Convert wide character strings to boost dates

I need to convert several million dates stored as wide strings into boost dates The following code works. However, it generates a horrible compiler warning and does not seem efficient. Is there a better way? #include "boost/date_time/gregorian/gregorian.hpp" using namespace boost::gregorian; #include <string> using namespace std; ...

How to load bmp into GLubyte array?

All, I am trying to load up a bmp file into a GLubyte array (without using aux). It is unbelievable how what I thought would have been a trivial task is sucking up hours of my time. Can't seem to find anything on Google! This is what I hacked together but it's not quite working: // load texture GLubyte *customTexture; string fileN...

Python for C++ Developers

I'm a long time C++/Java developer trying to get into Python and am looking for the stereotypical "Python for C++ Developers" article, but coming up blank. I've seen these sort of things for C#, Java, etc, and they're incredibly useful for getting up to speed on language features and noteworthy differences. Anyone have any references? ...

C++: delete vs. free and performance

Consider: char *p=NULL; free(p) // or delete p; What will happen if i use free and delete on p? If a program taking more time for execution, suppose 10 minutes, is there any way to reduce its running time to 5 minutes? ...

How do i check if a file is a regular file in C++?

How do i check in C++ if a file is a regular file (and is not a directory, a pipe, etc.)? I need a function isFile(). DIR *dp; struct dirent *dirp; while ((dirp = readdir(dp)) != NULL) { if ( isFile(dirp)) { cout << "IS A FILE!" << endl; i++; } I've tried comparing dirp->d_type with (unsigned char)0x8, but it seems not portable...

How to use std::sort with a vector of structures and compare function?

Thanks for a solution in C, now I would like to achieve this in C++ using std::sort and vector: typedef struct { double x; double y; double alfa; } pkt; vector< pkt > wektor; filled up using push_back(); compare function: int porownaj(const void *p_a, const void *p_b) { pkt *pkt_a = (pkt *) p_a; pkt *pkt_b = (pkt *) p_b; ...

How to reduce linkage time for large project written in native Visual C++ ?

I am working with a large bunch of sources written in Visual C++. The target is dll library. Linkage time consumes several minutes. How this time can be reduced? Library depends on other dlls and libs, which are in the same solution. The first thing which can be done is to split source into several projects, but it is a time consuming...

Accessing stored structures for which I have an xml description

I have set up a sort of introspection-enabling C++ library that allows, using minimum macros and a fair amount of template trickery, to declare structures and classes that get enriched with some meta-information. This meta-information captures all important details about each field of the struct/class that you declare, and at the end of...