if (!(hRC=wglCreateContext(hDC))) // Are we able to get a rendering context?
{
KillGLWindow(); //Reset the display
MessageBox(NULL,"Can't create a GL rendering context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
Can anyone explain what's going on and how to fix it?
Thanks
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Tutorial 1 problem
Hi all,
I'm trying to advance my C++ skills past the "Intro" books, and decided to give the NeHe tutorials a try.
I typed up the first tutorial, compiled, linked, and built it.
Then when I run the program one of the error catchers trips.
"Can't create a GL rendering context."
from this code:
Quote: Original post by enigma555
"Can't create a GL rendering context."
from this code:if (!(hRC=wglCreateContext(hDC))) // Are we able to get a rendering context? { KillGLWindow(); //Reset the display MessageBox(NULL,"Can't create a GL rendering context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; }
Thanks
I think it's because : (hRC=wglCreateContext(hDC))= false, this happened could be a lot of reason, maybe you need to get the last error.
wglCreateContext
GetLastError
Thanks for helping!
OK. I added in a GetLastError() line and with a breakpoint got error# 2000 which says that the pixel format is invalid.
Here is the code relating to that section.
How do I get the scrollable window?
OK. I added in a GetLastError() line and with a breakpoint got error# 2000 which says that the pixel format is invalid.
Here is the code relating to that section.
static PIXELFORMATDESCRIPTOR pfd= //pfd tells windows how we want things to be { sizeof(PIXELFORMATDESCRIPTOR), // size of this pixel format descriptor 1, // Version number PFD_DRAW_TO_WINDOW | //Format must support window PFD_SUPPORT_OPENGL | //Format must support OpenGL PFD_DOUBLEBUFFER, //Must support double buffering PFD_TYPE_RGBA, //Request an RGBA format bits, //select our color depth 0, 0, 0, 0, 0, 0, //Color bits ignored 0, //No alpha buffer 0, //Shift bit ignored 0, //No accumulation buffer 0, 0, 0, 0, //Accumulation bits ignored 16, //16Bit Z-Buffer (Depth Buffer) 0, //No Stencil buffer 0, //No auxiliary buffer PFD_MAIN_PLANE, //Main drawing layer 0, //Reserved 0, 0, 0 //Layer Masks Ignored }; if (!(hDC=GetDC(hWnd))) //Did we get a device context? { KillGLWindow(); //Reset the display MessageBox(NULL,"Can't create a GL device context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (!(PixelFormat=ChoosePixelFormat(hDC, &pfd))) //Did windows find a matching pixel format? { KillGLWindow(); //Reset the display MessageBox(NULL,"Can't set the PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; } if (!(hRC=wglCreateContext(hDC))) // Are we able to get a rendering context? { ertest=GetLastError(); KillGLWindow(); //Reset the display MessageBox(NULL,"Can't create a GL rendering context.", "ERROR", MB_OK | MB_ICONEXCLAMATION); return FALSE; }
How do I get the scrollable window?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement