With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
The Grade of the Solution
The Zone Rank of the Expert Providing the Solution
The Number of Author and Expert Comments
The Number of Experts Contributing
The Feedback of the Community
Your Input Matters Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.
If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.
Tags:
Microsoft, plus device drivers, Visual Studio and OpenGL, 2005 and 1.2, standalone application development, for Windows XP, C
I have a C/C++ application, which makes heavy use of OpenGL for rendering 2 dimensional vector data. There is a need to create hardcopy output of some of the "plots". However, the plots need to be substantially bigger than the size of the GUI's window, so i create an offscreen pixmap to draw into:
static int allocMemhDC(int w, int h, HPIXMAP *dib, HDC *memDC)
I then create an OpenGL Rendering context, using the memory Device Context (memDC) created above:
// HDC is passed in here: its either unset if plotting to a window, else set to an existing window's // HDC if wanting to draw into a pixmap (strange logic, but a holdover from previous work):
PIXELFORMATDESCRIPTOR pfd = { sizeof(pfd), 1, (hdc ? PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL : PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER), PFD_TYPE_RGBA, 24, // 24 bit color depth 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha color 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored 0, // 32 bit z buffer 8, // stencil bits 0, // no auxiliary buffer PFD_MAIN_PLANE, 0, // reserved 0, 0, 0 // ignore layer masks }; GLint iPixelFormat; HGLRC hglrc;
if (hdc == 0) hdc = GetDC(handle); else if (!allocMemhDC(w, h, &dib, &hdc)) { fprintf(stderr, "Cant create off-screen memory for rendering"); return 0; } if ((iPixelFormat = ChoosePixelFormat(hdc, &pfd)) == 0) { fprintf(stderr, "Cannot choose pixel format"); return 0; } if (SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE) { fprintf(stderr, "Cannot set pixel format"); return 0; }
I then set up to capture the output of my rendering into the OpenGL feedback buffer (via a call to a 3rd party function, which does the following):
if (anything_fails...) return FAILURE; glFeedbackBuffer(size, GL_3D); glRenderMode(GL_FEEDBACK); return SUCCESS;
I then render a bunch of vectors, which should get captured in the feedback buffer. However, they dont: they end up being drawn into the pixmap (i know, because i've checked what picture in the pixmap looks like).
Now, if i use a normal window's rendering context, instead of using the pixmap's, everything works perfectly: the feedback buffer fills up as expected, and the window is not 'drawn into'.
So, the question is: does anyone know what i might be doing wrong, or what i can change to get things to work properly?
I have uncovered my problem. It turns out that a latent exposure event on the GUI's graphics window (which was issued long after setting up my pixmap opengl Rendering Context) caused my software to auto-revert back to using the GUI window's RC. This (through a series of callbacks, etc) had a side effect of causing the opengl "feedback buffer capture" to be shut off, and hence the picture ended up being drawn into the pixmap.