Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mirex

OpenGL how to init OpenGl properly

This topic is 5330 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys ... i''ll post how do I init OpenGl in my applications ... program runs ok, but im troubling about load of error debug messages which my MSVC gives "First-chance exception''s in my.exe (GDI32.DLL): 0xC0000005: Access Violation." Initialization goes by EnableOpenGL( any_window_as_you_wish->m_hWnd ); thanks for help HWND WindowHandle = NULL; HDC DeviceContextHandle; HGLRC GlHandleContext; int OpenGlEnabled = 0; void EnableOpenGL( HWND hWnd ) { HDC *hDC = &DeviceContextHandle; HGLRC *hRC = &GlHandleContext; if ( OpenGlEnabled == 1 ) return; WindowHandle = hWnd; PIXELFORMATDESCRIPTOR pfd; int format; // get the device context (DC) *hDC = GetDC( hWnd ); // set the pixel format for the DC ZeroMemory( &pfd, sizeof( pfd ) ); pfd.nSize = sizeof( pfd ); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 32; pfd.iLayerType = PFD_MAIN_PLANE; format = ChoosePixelFormat( *hDC, &pfd ); SetPixelFormat( *hDC, format, &pfd ); // create and enable the render context (RC) *hRC = wglCreateContext( *hDC ); wglMakeCurrent( *hDC, *hRC ); OpenGlEnabled = 1; } void DisableOpenGL( ) { HWND hWnd = WindowHandle; HDC hDC = DeviceContextHandle; HGLRC hRC = GlHandleContext; if ( OpenGlEnabled == 0 ) return; if ( hWnd == NULL ) return; wglMakeCurrent( NULL, NULL ); wglDeleteContext( hRC ); ReleaseDC( hWnd, hDC ); OpenGlEnabled = 0; }

Share this post


Link to post
Share on other sites
Advertisement
I forgot to say that i use it this way because i dont have to create any windows for it, and I can use it on any Dialog''s subwindow (STATIC_FRAME or something)

Share this post


Link to post
Share on other sites
"First-chance exception''s in my.exe (GDI32.DLL): 0xC0000005: Access Violation."

those are not your faults but windows''s fault. it''s written somewhere in a knowledge base article. those first-chance exceptions outside your code (here in gdi32.dll) are exceptions which are thrown and immediatly caught inside the given dll. debuggers just get this as an information. it''s nasty crap but doesn''t harm in any form. it''s like this:

try{
// some faulty code
}catch(...){
// we now this gonna fail so do nothing
}

it''s a bit lazy coding but like stated, won''t harm.

Share this post


Link to post
Share on other sites
Yeah, those errors are normal. I always get them when debugging gl code. I think it has to do something with not playing nicely with the os kernel because d3d is kernel aware and gl isn't. Gl runs on top in user space. I never got any problems with my d3d during debugging. D3d is super in this respect but sucks in all others, imo.

PS. dufam ze ti to pomohlo trosku

[edited by - JD on April 14, 2004 3:59:34 AM]

Share this post


Link to post
Share on other sites
Albatross: it happends anytime during prog. execution. Probably when openGl scene is redrawed.

I''m happy to hear that its nothing tragic guys.

JD hey

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!