Skip to main content
gamedev.net
🔒 Locked

Stupid Win32 GL problem

Started by AnCcE Jun 27, 2000 at 11:49 PM 3 replies 350+ views
Original Post
AnCcE
AnCcE
Okay, I''ve written OpenGL in Win32 before, but this problem eludes me... there''s bound to be something i''m forgetting here. Here''s my function that is supposed to enable opengl: void EnableOpenGL() dc = GetDC(global_hwnd); PIXELFORMATDESCRIPTOR pfd; int format; ZeroMemory(&pfd, sizeof (pfd)); pfd.nSize = sizeof ( PIXELFORMATDESCRIPTOR ); pfd.nVersion = 1; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iPixelType = PFD_TYPE_RGBA; pfd.dwFlags = PFD_DOUBLEBUFFER / PFD_DRAW_TO_WINDOW / PFD_SUPPORT_OPENGL; format = ChoosePixelFormat(dc, &pfd); SetPixelFormat(dc, format, &pfd); rc = wglCreateContext(dc); wglMakeCurrent(dc, rc); } DC and RC are both global, everything compiles/links fine, except that when I issue OpenGL commands nothing happens. It''s probably something simple that I''m missing, but please clue me in. Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Void
Void
That looks correct but have you set the view port, perspective and matrix mode at GL_MODELVIEW?

Also try testing error return values..
AnCcE
AnCcE
Yes, I set everything later in the program... The point is that I couldn''t even get it to clear to black. Also, if I remove the PFD_DOUBLEBUFFER and don''t swap the buffers later, everything works... I know i''m calling SwapBuffers with the right DC, too.

Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
CyCloNe
CyCloNe
If your still having problems check the source code on NeHe''s site

http://nehe.gamedev.net

also try setting the main drawing layer to PFD_MAIN_PLANE

AnCcE
AnCcE
Okay, I fixed the problem by moving the code from EnableOpenGL to a point in WinMain right after I created the window... I still don''t know what was wrong with the first code but at least now it works. The main drawing layer thing doesn''t have any effect anymore, according to the MSDN documentation.

Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.