How do I draw text using OpenGL, SDL and C++?
I heard about SDL_TFF which I read about here but I don't understand how am I supposed to connect the TrueType2 library. Maybe there is something better out there? ...
I heard about SDL_TFF which I read about here but I don't understand how am I supposed to connect the TrueType2 library. Maybe there is something better out there? ...
A friend and I were discussing C++ templates. He asked me what this should do: #include <iostream> template <bool> struct A { A(bool) { std::cout << "bool\n"; } A(void*) { std::cout << "void*\n"; } }; int main() { A<true> *d = 0; const int b = 2; const int c = 1; new A< b > (c) > (d); } The last line in main...
Anyone know this compiler feature? It seems GCC support that. How does it work? What is the potential gain? In which case it's good? Inner loops? (this question is specific, not about optimization in general, thanks) ...
In the STL almost all containers have an erase function. The question I have is in a vector, the erase function returns an iterator pointing to the next element in the vector. The map container does not do this. Instead it returns a void. Anyone know why there is this inconsistancy? ...
Does any one know how the event handler manages the posted events? In my app i have two threads(1:guiThread and 2:computationThread). After an exception is thrown I call postEvent(..)to an existing dialog. The Qt-Event-Handler holds this one back until the dialog is closed. ...
Ulimately I just wanted to extract strings from the .rc file so I could translate them, but anything that goes with .rc files works for me. ...
Which compiles to faster code: "ans = n * 3" or "ans = n+(n*2)"? Assuming that n is either an int or a long, and it is is running on a modern Win32 Intel box. Would this be different if there was some dereferencing involved, that is, which of these would be faster? long a; long *pn; long ans; ... *pn = some_number; ans = ...
Do you normally set your compiler to optimize for maximum speed or smallest code size? or do you manually configure individual optimization settings? Why? I notice most of the time people tend to just leave compiler optimization settings to their default state, which with visual c++ means max speed. I've always felt that the default set...
Java has a convenient split method: String str = "The quick brown fox"; String[] results = str.split(" "); Is there an easy way to do this in C++? ...
How does the comma operator work in C++? For instance, if I do: a = b, c; Does a end up equaling b or c? (Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.) Update: This question has exposed a nuance when using the comma operator. Just to document this: a = b, c; // a is set ...
I have two threads, one updating an int and one reading it. This value is a statistic where the order of the read and write is irrelevant. My question is, do I need to synchronize access to this multi-byte value anyway? Or, put another way, can part of the write be complete and get interrupted, and then the read happen. For example, ...
In what scenarios is it better to use a struct vs a class in C++? ...
Hi, i'm wondering if there is any nice and neat tool to replace the GNU Autotools or Make to build a very large C++ project, which are such a complicated thing to use. It is simple to generate all the files that de Autotools require if the project is small, but if the source code is divided in many directories, with multiple third part...
I'm trying to optimize several bottlenecks on an application which is supposed to run on a really wide range of CPUs and architectures (some of them very close to embeded devices). The results of my profiler, however, aren't really significant because of the speed of my CPU. Is there any way (preferably under Windows or Mac OS X) to lim...
I have a class to parse a matrix that keeps the result in an array member: class Parser { ... double matrix_[4][4]; }; The user of this class needs to call an API function (as in, a function I have no control over, so I can't just change its interface to make things work more easily) that looks like this: void api_func(const doub...
I have a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this. template<typename ImplemenationClass> class WrapperClass { // the code goes here } Now, how do I make sure that ImplementationClass can be derived from a set of classes only, s...
Looking at the C# project templates in VS2k8 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and .NET? ...
I'm having some trouble getting Boost Xpressive to work as I expect. I'm trying to split a line of text into fields delimited by tab characters: wstring ws = L"Field1\tField2\tField3"; wsregex_token_iterator fieldIt(ws.begin(), ws.end(), as_xpr(L'\t'), -1); wsregex_token_iterator endIt; So far, so good; the above works fine. The pr...
I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time. int globalgarbage; unsigned int anumber = 42; But what about static ones defined within a function? void doSomething() { static bool globalish = true; // ... } When is the space for globalish allocated? I'm...
This came up from this answer to a previous question of mine. Is it guaranteed for the compiler to treat array[4][4] the same as array[16]? For instance, would either of the below calls to api_func() be safe? void api_func(const double matrix[4][4]); // ... { typedef double Matrix[4][4]; double* array1 = new double[16]; double ...