🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

I'm back, you know you love it....

Started by
8 comments, last by Miraj 24 years, 3 months ago
ROFL... wait till you here this I am quite the programmer, I managed to create a 3d room in opengl, with a console, and I even added a little extra ''undocumented'' feature. You can actually walk around the console in 3d space! hehehe. Okay seriously, heh, how do I go about making the dang console static while I move around? Like in normal games It would kinda suck when your talking to a buddy, you turn around to grab some food from a merchant and you leave the console there! ROFL... -Miraj
-Miraj
Advertisement
A hint even? ; )

*begins to hand out candy bribes and various gadgets*


-Miraj
-Miraj
Since I''m a sucker for candy

You must reset the modelview matrix before rendering the console. You do this with LoadIdentity(). You may also need to reset the projection matrix if you allow the user to change field of view manually.
Great, thanks

That sounds simple enough, I''ll give it a whirl.


-Miraj
-Miraj
Hey, where''s my candy?
*keeps the candy for a sec*

Ok ok, one sec though .. heh.


I tried and it just doesn''t seem to work. See, this is how i positioned the console the first time, upon bringing it up. This is a snippet from the drawing function:

glPushMatrix();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glRasterPos2i(0, 0);
glTranslatef(0.0f, 0.18f, 0.0f);

That seems to work fine, but if I attempt the same thing later to refresh the console, to make sure it stays, it doesn''t work. It truly has a mind of its own and it doesn''t want to follow

I even put the code in the message loop to make sure it refreshes every time it updates the scene but still nothing

Its funny, I thought this was going to be the easy part, and what hurts is its the last step and I''m done. Doh.

Could I interest you in some more candy? LOL...



-Miraj
-Miraj
You seem to have a slight misunderstanding of how to use glPushMatrix() and glPopMatrix() both of these operate on the matrix that was last chosen in glMatrixMode(), as does every matrix modifying calls.

Try to do your rendering like this

// Setup the projection matrix when resizing the windowglMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective();// Setup the camera when it moves (or first in frame)glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt();// Render scenefor( every_object ){  // Save view matrix  glPushMatrix();  // Move object to its world coordinates  glRotate();  glTranslate();  // Render the object;  glBegin();  glEnd();  // Restore view matrix  glPopMatrix();}// Save the view matrixglPushMatrix();glLoadIdentity();// Save the projection matrixglMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();glOrtho();// Render the consoleglBegin();glEnd();// Restore projection matrixglPopMatrix();// Restore view matrixglMatrixMode(GL_MODELVIEW);glPopMatrix();


Now, can I please have my candy? *getting cranky*


YES! It worked!

You were definatly right about my use of glPushMatrix and glPopMatrix. I''ve known about them for a long time but never actually used them, so I was going through the gl commands in msdn and sort of got the gist of it but I still wasn''t too clear.

Anyway, I made an update function for the console and did things in the order you said and it worked

THANK YOU!!

The candy is on me!

One last thing, I added glBindTexture to the update function as well, so the font I''m using for the console could update too. No errors but when I run it, it performs an illegal operation, any idea why? I debugged it and it pointed to that line.

Oh well, who cares at this point I''m so happy I''ll live with a console without font if i had to. hehe.




-Miraj
-Miraj
*eats candy*

You''re not allowed to call glBindTexture() between glBegin() and glEnd()
WWW.WHATISTHEMATRIX.COM.............(?)....
/NEWBIE...

Jewelaye

This topic is closed to new replies.

Advertisement