c++

OpenGL Video Memory Usage

Hello, is there an API or profiler application that can track the video memory usage of my application? I am using C++/OpenGL on Windows, but I am open to suggestions on other platforms as well. ...

IGraphBuilder::RenderFile() failing with VFW_E_BAD_KEY - 0x800403f2

Continuing investigation on a embedded WindowsMediaPlayer problem, i am trying to do simple file playback via a DirectShow in-process server: ::CoInitializeEx(0, COINIT_MULTITHREADED); CComPtr<IGraphBuilder> spGraph; spGraph.CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER); CComQIPtr<IMediaControl> spMediaControl(spGraph); ...

C++ Force Template Parameter

I want this code to be possible. template<typename K, typename T, typename Comparer> class AVLTree { ... void foo() { ... int res = Comparer::compare(key1, key2); ... } ... }; Specifically, I want to force Comparer class to have a static int compare(K key1, K key2) function. I was thinking about using ...

Callbacks and Delays in a select/poll loop

One can use poll/select when writing a server that can service multiple clients all in the same thread. select and poll, however need a file descriptor to work. For this reason, I am uncertain how to perform simple asynchronous operations, like implementing a simple callback to break up a long running operation or a delayed callback with...

Reactor, Leaders/followers , Proactor - Client/Server

Hey, I'm looking to implement a pretty scalable client-server program. I look into 3 patterns, and my conclustion were : Reactor - pretty efficient but i have 2 concerns : 1. doesn't take advantage of multipreccosor machine (it's basically single threaded) 2. if one of the hooking methods are blocking, the entire application is blocke...

how to create a gui to invoke a .exe or .cpp file ?

i have a compiler project and i have used c++ , flex and bison in it so bison and flex produce .cpp files to me and i can compile and run them but i want to make a gui to my project so i want to learn a technique to make a gui (in java or qt) to write input to my project and get output ...

hash_map crashing in c++ stl

Hi, i am relatively experienced in Java coding but am new to C++. I have written the following C++ code as solution to the USACO training problem which I have reproduced at this url This code looks fine to me. However it crashes on the sample test case given. On isolating the error, I found that if the second for loop is not run for th...

'Bracket initializing'. (C++)

I'm learning C++ at the moment, C++ Primer plus. But I just felt like checking out the cplusplus website and skip a little forward to file handling. I pretty much know the basics of file handling coming from java, php, visual basic. But I came across a pretty weird line. ostream os(&fb); fb represents a filebuf. I just don't get the ...

Blt'ing through memoryDC does not work

HDC hdcScreen = GetDC(NULL); HDC hdcWindow = GetDC(mWin); HDC hdcMem = CreateCompatibleDC(hdcScreen); if (!hdcScreen || !hdcWindow || !hdcMem){ MessageBox(NULL, "could not locate hdc's", "Viewer", MB_ICONERROR); } if (!StretchBlt(hdcMem, 0, 0, 300, 300, hdcScreen, 0, 0, 300, 300, SRCCOPY)){ MessageBox(NULL, "stretchblt failed", "Viewe...

when is a v-table created in C++?

When exactly does the compiler create a virtual function table? 1) when the class contains at least one virtual function. OR 2) when the immediate base class contains at least one virtual function. OR 3) when any parent class at any level of the hierarchy contains at least one virtual function. A related question to this: Is it p...

shared memory, MPI and queuing systems

My unix/windows C++ app is already parallelized using MPI: the job is splitted in N cpus and each chunk is executed in parallel, quite efficient, very good speed scaling, the job is done right. But some of the data is repeated in each process, and for technical reasons this data cannot be easily splitted over MPI (...). For example: 5...

Check Windows version

How I can check in C++ if Windows version installed on computer is Windows Vista and higher (Windows 7)? ...

Tetris: Layout of Classes

Hi all. I've written a working tetris clone but it has a pretty messy layout. Could I please get feedback on how to restructure my classes to make my coding better. I focuses on making my code as generic as possible, trying to make it more an engine for games only using blocks. Each block is created seperately in the game. My game has ...

stack of characters, stack of character string, stack of integers, stack of integer arrays etc

I want to make a generic stack using the c++ templates. The prototype of the push method of stack is given by Void push( t* ptr) Where t is the template argument. Now the pointer ptr may point to an integer, or an array of integers, it may point to a single character or array of characters , it may point to a single double number or an a...

SetCursorPos and GetCursorPos not working at login screen?

When I attempt to use SetCursorPos at the Windows Vista/7 login screen, true is returned which at first made me think it was working. However, when I call GetCursorPos it gives me: -858993460,-858993460 Any thoughts why? Is this a "security feature" or am I using it incorrectly? The code works fine on non-login (i.e. normal) desktop. ...

c++ test if 2 sets are disjoint

I know the STL has set_difference, but I need to just know if 2 sets are disjoint. I've profiled my code and this is slowing my app down quite a bit. Is there an easy way to see if 2 sets are disjoint, or do I need to just roll my own code? EDIT: I also tried set_intersection but it took the same time... ...

How to make a C++ class compatible with stringstream objects?

I would like to be able to serialize my C++ classes using standard techniques like std::stringstream or boost::lexical_cast. For example if I have a Point object (2, 4) then I would like to serialize it to "(2, 4)", and also be able to construct a Point object from this string. I have some code already but with a few issues. Point to s...

How to interpret g++ warning

Hello I've got a very strange g++ warning when tried to compile following code: #include <map> #include <set> class A { public: int x; int y; A(): x(0), y(0) {} A(int xx, int yy): x(xx), y(yy) {} bool operator< (const A &a) const { return (x < a.x || (!(a.x < x) && y < a.y)); } }; struct B { std...

Displaying exception debug information to users

Hi, I'm currently working on adding exceptions and exception handling to my OSS application. Exceptions have been the general idea from the start, but I wanted to find a good exception framework and in all honesty, understand C++ exception handling conventions and idioms a bit better before starting to use them. I have a lot of experien...

Why does my program run way faster when I enable profiling?

I have a program that's running pretty slowly (takes like 20 seconds even on release) so, wanting to fix it, I tried to use Visual Studio's built in profiler. However, when I run the program with profiling enabled, it finishes in less than a second. This makes it very difficult to find a bottleneck. I would post the code but it is long. ...