OpenGL Init & SERIOUS Window BUG

Started by
7 comments, last by blue_fireball01 22 years, 11 months ago
My application creates a Window and then calls a function called OpenGLInit() that is supposed to do all init work and for some VERY odd reason the Windowed 640x480(Run on 800x600) program appears to go full screen when it hits the OpenGL and it seems that the system is frozen(Though if WinAmp is playing it continues). Could anyone help me out? int InitOpenGL() { GLuint PixelFormat; HDC DC; static PIXELFORMATDESCRIPTOR pfd= { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; if (!(DC=GetDC(Wnd))) { return FALSE; } if (!(PixelFormat=ChoosePixelFormat(DC,&pfd))) { return FALSE; } if(!SetPixelFormat(DC,PixelFormat,&pfd)) { return FALSE; } if (!(RC=wglCreateContext(DC))) { return FALSE; } if(!wglMakeCurrent(DC,RC)) { return FALSE; } ShowWindow(Wnd,SW_SHOW); SetForegroundWindow(Wnd); SetFocus(Wnd); if (sheight==0) // Prevent A Divide By Zero By { sheight=1; // Making Height Equal One } width=swidth; height=sheight; glViewport(0,0,swidth,sheight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); return 1; }
Advertisement
if you set the pixel format, it will go fullscreen.

As for the application freezing, I''d bet it''s because your rendering loop does nothing (maybe clear the screen). So you''re basically taking all the CPU resources
That''s very odd....... In NeHe''s tutorials it doesn''t go fullscreen even when setting the pixel format........
Also my program is supposed to quit when Escape is pressed.......
oops I''m sorry!

I meant if you call "ChangeDisplaySettings()", it will go fullscreen. So make sure you don''t call it when trying to go in windowed mode.
Of course I didn''t! Though I deceided to try letting it operate fullscreen and added that in and so it changed the display mode before creating the window and went fullscreen and then same as before no input and no drawing by OpenGL(It''s supposed to draw primitives when idle).
Does it have anything to do with PFD_DOUBLEBUFFER ?

Just because you requested a certain pixelformat by calling
ChoosePixelFormat doesn''t mean OpenGL will give that to you
in all cases. It might give you something totally different.

Check out the pixel format that was returned and see if it
really does support all those features you requested.

you are requesting a 16-bit window- is your screen mode 16bpp or other? maybe it''s forcing a change to accomodate your bpp requirement?



How would I check the pixel format? I''m trying to learn from NeHe''s tutorials and that''s the pixelformat he used and his examples when I downloaded them worked(Even if I modified them) though I tried to use his way to create a window and it does this.
Ranger_One, I''m using 16bpp (High Color(16 bit)). I use 16 because I heard that that''s the best for a Voodoo 3 and in 24bpp things are slightly different(Yellow shadow on message box information icon).

This topic is closed to new replies.

Advertisement