Advertisement

got problem rendering a scene

Started by January 28, 2002 03:36 PM
4 comments, last by azaxaca 23 years ago
im using gametutorial.com''s base code for my opengl program and the problem is that my triangle wont show untill i have minimized/maximized or whatever else i could do. In other words, when i first run it, the screen is black, but when i click the maximize button on the top right corner, the triangle shows up. please tell me howto make the triangle show up as soon as i run the program... ps: original code from gametutorials.com works just fine I didnt copy and paste, i tried doing it on my own piece by piece to understand it beter. i checked manya times to see if the codes are identical, and they are ------------------------ ..I still dont get the difference between c and c++...
..I still dont get the difference between c and c++...
don''t know for sure, but is it possible that you are not resizing your scene when you the size of your window changes?
When you receive the WM_SIZE message you should do something like:

  	if (Height == 0)	{	      Height = 1;	// avoid div by 0	}	glViewport(0,0,Width,Height);	gluPerspective(45.0f,(float)Width/(float)Height,1.0f,1000.0f);  


Width and Height are your scene dimensions. At least this worked for me with the same problem. ;-)
Advertisement
ya i am
i think thats why my triangle shows evertime the scene is resized

but my problem is tat the triangle doesnt show up as soon as the program starts

....................

..I still dont get the difference between c and c++...
..I still dont get the difference between c and c++...
What if you call your resize-scene function at startup? That should do the trick then. I had the same problem and it worked for me.
In your window initialization function, are you calling these:
glViewport(0,0,Width,Height);
gluPerspective(45.0f,(float)Width/(float)Height,1.0f,1000.0f);

???
Thanks for the help!!

teh solution was so obvious, like you said, i called resizescene
function right before scene renders and the triangle shows up right from the start!!!
Thanks!!

ps: yea, glviewport and gluperspective is inside the resize function

===========================

..I still dont get the difference between c and c++...
..I still dont get the difference between c and c++...

This topic is closed to new replies.

Advertisement