Jump to content

  • Log In with Google      Sign In   
  • Create Account


Rendered Objects Won't Appear In Windowed Mode


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Readarmon0   Members   -  Reputation: 102

Like
0Likes
Like

Posted 04 March 2013 - 04:27 PM

I'm in the midst of learning OpenGL, using the Win API as opposed to GLEW/GLUT that's often recommended, and I'm currently plowing through Nehe's OpenGL Tutorial. I'm attempting to render a pair of three-dimensional objects and to an extent was successful. While the objects appear on the screen in fullscreen mode, if I choose to begin with or switch to windowed mode, the objects won't appear. I'm assuming it has something to do with the CreateGLWindow function that handles creating the windows regardless of display mode, because the DrawGLScene function at least remains consistent in continually drawing the same image, rendering only the background if windowed and rendering the background and objects if fullscreen. Below is the link to the source code discussed. Any assistance would be greatly appreciated, thanks.

 

https://gist.github.com/anonymous/5086149



Sponsor:

#2 __SKYe   Members   -  Reputation: 932

Like
0Likes
Like

Posted 04 March 2013 - 04:55 PM

GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL
{
	if (height == 0) { // Prevent A Divide By Zero By
		height = 1;    // Making Height Equal One
	}
 
	glViewport(0, 0, width, height); // Reset The Current Viewport
 
	glMatrixMode(GL_PROJECTION);     // Select The Projection Matrix

	...

	// Calculate the Aspect Ratio Of The Window
	gluPerspective(45.0f, (GLfloat) width / (GLfloat) height, 0.1f, 100.0f);
 
	glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
	glLoadIdentity();           // Reset The Modelview Matrix

    //gluLookAt(0.0f, 5.0f, 10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
}

 

You're missing a glLoadIdentity() after the glMatrixMode(GL_PROJECTION);



#3 Readarmon0   Members   -  Reputation: 102

Like
0Likes
Like

Posted 04 March 2013 - 05:16 PM

Brilliant! Thanks, and sorry for the inconvenience. Can someone follow up on how the missing glLoadIdentity() function affected the matrices? Does the projection matrix not being properly reset mean that the gluPerspective function determines some improper aspect ratio for windowed mode and a proper aspect ratio in fullscreen mode?



#4 __SKYe   Members   -  Reputation: 932

Like
0Likes
Like

Posted 04 March 2013 - 05:23 PM

Maybe calling gluPerspective() will multiply or add with the old projection matrix, and without setting the projection matrix to the identity first, will produce incorrect results, but i'm not really sure... Though i can't really explain why it works in fullscreen mode, when the resize function is exactly the same.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS