Device Context :(
I didn't search for any similar message in this forum, but the error is the following:
I i get an erro when creating the window and when closing. I wanted to restarted the lessons all again, so i'm getting from the start, duhh.. I get an error when "Releasing Rendering Context Failed" and "Releasing DC and RC Failed". Could someone Help me? I'm in the lesson 07 and the code is below:
GLvoid KillGLWindow(GLvoid)
if (hRC) // Do We Have A Rendering Context?
{
wglMakeCurrent(NULL,NULL);
wglDeleteContext(hRC);
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
if (!InitGL()) // Initialize Our Newly Created GL Window
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
Thanx for any help!
[edited by - lobravo on September 17, 2003 9:40:46 PM]
"There are people who live in the reality. We recreate it!"
Hi lobravo,
There are a couple of problems with the order and way you are releasing items.
try this:
Note that in the first part of your code you had already released DC and RC and then deleted hRC before the if statements. Your code was trying to do things twice and on the second attempt fails because the first attempt already succeeded.
Hope that helps.
[edited by - nfz on September 17, 2003 11:11:57 PM]
There are a couple of problems with the order and way you are releasing items.
try this:
GLvoid KillGLWindow(GLvoid){ if (hRC) // Do We Have A Rendering Context? { if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC? { MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } hRC=NULL; // Set RC To NULL }}
Note that in the first part of your code you had already released DC and RC and then deleted hRC before the if statements. Your code was trying to do things twice and on the second attempt fails because the first attempt already succeeded.
Hope that helps.
[edited by - nfz on September 17, 2003 11:11:57 PM]
Really thanks. I was blind about it, i don''t know how i didn''t see it.
What about the Initialization?
Here is the InitGL()
int InitGL(GLvoid)
{
if (!LoadGLTextures()) // Jump To Texture Loading Routine ( NEW )
{
return FALSE; // If Texture Didn''t Load Return FALSE ( NEW )
}
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
I think there''s no problem in it!
What about the Initialization?
Here is the InitGL()
int InitGL(GLvoid)
{
if (!LoadGLTextures()) // Jump To Texture Loading Routine ( NEW )
{
return FALSE; // If Texture Didn''t Load Return FALSE ( NEW )
}
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
I think there''s no problem in it!
"There are people who live in the reality. We recreate it!"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement