Advertisement

if (!wglMakeCurrent(NULL,NULL))

Started by February 16, 2002 09:47 AM
9 comments, last by branhield 22 years, 7 months ago
What does this piece of code do? if (!wglMakeCurrent(NULL,NULL))
Tells OpenGL to release its device context(s) so that you can cleanly close the corresponding window(s).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
i dont understand that...its an if statement...i would believe it just checks if ''not unable to release it''....
yes, you would want to be sure you released the rendering context. let''s say you are in the middle of a "glBegin/glEnd" block, OpenGL may still be sending rendering commands. at this moment in time you probably won''t be able to release the rendering context.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
yeah..but i dont see anything in that statement that would release the RC..it only checks if ''unable to release'' then do this
{
code
}
wglMakeCurrent(NULL,NULL) releases the context...
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
yeah...i have no problem understanding that...
but when in an if statement....
from the MSDN....

The wglMakeCurrent function makes a specified OpenGL rendering context the calling thread''s current rendering context. All subsequent OpenGL calls made by the thread are drawn on the device identified by hdc. You can also use wglMakeCurrent to change the calling thread''s current rendering context so it''s no longer current.

BOOL wglMakeCurrent(
HDC hdc, // device context of device that OpenGL calls are
// to be drawn on
HGLRC hglrc // OpenGL rendering context to be made the calling
// thread''s current rendering context
);

Parameters
hdc
Handle to a device context. Subsequent OpenGL calls made by the calling thread are drawn on the device identified by hdc.
hglrc
Handle to an OpenGL rendering context that the function sets as the calling thread''s rendering context.
If hglrc is NULL, the function makes the calling thread''s current rendering context no longer current, and releases the device context that is used by the rendering context. In this case, hdc is ignored.

Return Values
When the wglMakeCurrent function succeeds, the return value is TRUE; otherwise the return value is FALSE. To get extended error information, callGetLastError.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
I dunno how far off I am, but are you aware that

if (!wglMakeCurrent(NULL,NULL))

actually calls the function wglMakeCurrent(), and then checks its return value to see if it has succeeded or failed?

Sorry if I''m way off, I just got the feeling that''s what was stumping you.
yeah....thats exactly what was stumping(?) me.....
thanks dark avanger

This topic is closed to new replies.

Advertisement