c++

Which light C++ event/delegate (signal/slot) library should I choose?

Hi there, I know that the question has already been asked and answered, but it was more than one year ago and it looks like there are new alternatives out there. So I'm coding a game with the SFML library (which I'm starting to find pretty much cool actually) and I'm looking for a light and fast event/delegate library. After doing som...

makefiles and using eclipse for Linux programs and C++

Hi there, can anyone point me in the direction of a good tutorial on how makefiles work and also how to start a basic program from scratch using eclipse? I am using eclipse version 3.4.1 for fedora and C++. Thanks in advance. ...

Sorting a vector using threads

Hi, Are the vectors defined in the C++ STL re-entrant or thread safe? Can I use two threads and work(in this case sort) on two halfs of a vector without using a mutex? For example: int size = (Data_List.size())/2; Thread A() { ................ // Do we need to lock Data_list with a mutex sort(Data_List.begin(),Data_List.begin()+size...

Using a std::string iterator to find the start and end of it's string

Hi, Given just a std::string iterator, is it possible to determine the start and end points of the string? Supposing that I don't have access to the string object and so cannot call string.begin() and string.end(), and all I can do is increment or decrement the iterator and test the value. Thanks, Phil ...

Can normal maps be generated from a texture?

Hi, If I have a texture, is it then possible to generate a normal-map for this texture, so it can be used for bump-mapping? Or how is normal maps usually made? Sandra ...

How to Lock Queue Variable Address instead of using Critical Section ?

Hi, I have 2 threads and global Queue, one thread (t1) push the data and another one(t2) pops the data, i wanted to sync this operation without using function where we can use that queue with critical section using windows API. The Queue is global, and i wanted to know how to sync, is it done by locking address of Queue?. Answers wil...

Read variable-length records from a buffer - weird memory issues

Hi, I'm trying to implement an i/o intensive quicksort (C++ qsort) on a very large dataset. In the interests of speed, I'd like to read in a chunk of data at a time into a buffer and then use qsort to sort it inside the buffer. (I am currently working with text files but would like to move to binary soon.) However, my data is composed o...

Image conversion : RGBA to RGB

assuming i had RGBA (32 bits) output from frame-grabber, with alpha channel unused (values retained while filled by frame-grabbers), is there any effective conversion method to RGB (24 bits) ? I am dealing with 5 MegaPixels streaming images so speed does matter too. keep in mind that data in alpha channel can be discarded. ...

Tinyxml to print attributes

I'm trying to get std::string from attribute's value with TinyXml. The only thing I can get is a const char * val, and I can't find any way to convert from const char * to a std::string. so two possible answers to that: 1. How to get a string of an attribute with TinyXml? 2. How to convert const char * val to string val. this is the co...

Inheriting both abstract class and class implementation in C++

I hope this is a simple question. Can I inherit both an abstract class and it's implementation? That is, can the following be made to work? class A { virtual void func1() = 0; } class B { void func1() { /* implementation here */ } } class C : public A, public B { } I've tried a few variations, and am getting compile errors...

Creating a Cross-Platform C++ Library

Hello people, I wanted to create a cross-platform 2D game engine, and I would like to know how to create a cross-platform project with Makefile, so I can compile it to the platforms I choose with custom rule for any platform. I'm working on the windows enviroment with Visual C++ Express 2008, so it would be nice if I can use Visual C++ E...

What is the use of a C++ class containing an "implementation" and "interface" pointer to itself?

I'm studying some source codes and I'm just wondering why a class (or classes) is often implemented this way: class EventHandler { ... EventDispatcher* m_Dispatcher; virtual bool ProcEvent( EventHandler* Sender, int Task, int Event, void* Param ); ... }; class ClassA: public EventHandler { ... ClassA* m_Impl; ClassA* m...

How to prevent VC++ 9 linker from linking unnecessary global variables?

I'm playing with function-level linking in VC++. I've enabled /OPT:REF and /OPT:ICF and the linker is happy to eliminate all unused functions. Not so with variables. The following code is to demonstrate the problem only, I fully understand that actually having code structured that way is suboptimal. //A.cpp SomeType variable1; //B.cpp...

how to tell if a stream is closed in C before calling fclose()

I have a failing C program, and i've narrowed it down to a fork()ed child trying to close stdout and stderr, which were closed by its parent process before calling fork() - i assume those streams were passed on to the child process. how can i tell if a stream is closed in C before attempting to close it using something like fclose(stdou...

Where is `%p` useful with printf?

After all, both these statements do the same thing... int a = 10; int *b = &a; printf("%p\n",b); printf("%x\n",b); So, is there some good use of the %p option? ...

Can I catch an exception relating to a .DLL file not been found

I have a 3rd party component that includes a .LIB and .DLL file. In order to use the component I link the .LIB into my C++ program, and distribute the .DLL with application. The functionality provided is very specific, and only relevent to a small sub-set of my users, but distributing the .DLL incurs a license fee. One work around her...

iphone compiler inherited templated base classes with passed through type not being expanded in time (just look)

Try this out: template <typename T> class Base { public: int someBaseMember; }; template <typename T> class Test: public Base<T> { public: void testFunc() { someBaseMember = 0; } }; In vc++ and the psp compiler (and any other compiler ...

An unhandled win32 exception occurred in MyApp.exe

WinXP used. When I click the default cross icon to close my application. The win form of my application disappeared, but MyApp process still alive in the processes list when I open the task manager window. About 5 seconds later, throw out the unhandled win32 exception error. Where can I set the break point? I don't know how to debug it...

[C++/C] C++ program gets undefined reference to a dynamic C library during linking

I've created a dynamic networking library in C. When I try to link it in my C++ program I get an undefined reference the first time I call one of my functions in the library. What I can't understand is that I created a little test program in C that uses the library and it links just fine. Could someone help with my problem? Here are the...

synchronous Vs asynchronous ruminations

Hey, Lets say I have my netwrok thread , which inside it I get Data regarding some people,and each record(of 1 man) is being put inside a queue. I have another Calcthread who reads from that queue and performs some calculation and DB actions. Since the calculation and DB actions take quite amount of time, I though doing the calculation...