Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Eber Kain

I used to know what i was doing, or i thought so

This topic is 6334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ive been doing some pretty advanced stuff in my game(collision detection, fullscreen, model loading, ect...), but i get an idea for a terrain engine and i want to test it out, but now i cant even get a damn poly to draw when i start from scratch. Ive been working backwards removeing stuff thats not needed at the moment, and i still cant get a single poly to draw, tell me if you see the problem. #include #include #include #include #include #include #include void init ( void ) { glClearColor(0.0, 0.0, 0.0, 0.0); } void display ( void ) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // ------- DRAW FRAME ------- glTranslatef(0,0,-5); glColor3f(1,1,1); glBegin(GL_QUADS); glVertex2f(1,1); glVertex2f(1,-1); glVertex2f(-1,-1); glVertex2f(-1,1); glEnd(); // ------- DRAW FRAME ------- glutSwapBuffers(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if ( h==0 ) h = 0; gluPerspective ( 45, ( GLdouble ) w / ( GLdouble ) h, 1.0, 2000.0 ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void idle_func ( void ) { glutPostRedisplay(); } #pragma argsused void keyboard ( unsigned char key, int x, int y ) { switch (key) { case 27: /* Escape key */ exit(0); break; default: break; } } int main ( int argc, char** argv ) { srand((unsigned)time(NULL)); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(640, 480); glutInitWindowPosition(0, 0); glutCreateWindow(""); init(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutIdleFunc(idle_func); glutMainLoop(); return 0; } It dosent draw anything for me, and i know it used to. I recently changed dll''s so i could use the glutGameMode(which allows fullscreen hardware mode), is that the problem? home.earthlink.net/~eberkain/

Share this post


Link to post
Share on other sites
Advertisement
3 suggestions off the top, but I''m not sure.

Make sure you load the identity matrix at the beginning of the display funtion.

Call glFlush() at right before you swap buffers.

Make sure that your reshape function is called; I havn''t used glut in a while, but to make sure, I would put an explicit call in the init function.


Mike

Share this post


Link to post
Share on other sites
I cant believe i didnt have a glLoadIdentity(); in there, but that still didnt fix it, the call to glutSwapBuffers also calls glFlush from inside the function. And the display is starting correctly, all i get is black screen though.

I changed back to all my old .dll's and headers, but it still didnt help.

Edited by - Eber Kain on July 18, 2001 1:57:01 AM

Share this post


Link to post
Share on other sites
Try enclosing the quad rendering in push/pop matrix calls, like this:

glPushMatrix();
glTranslatef(0,0,-5);
glColor3f(1,1,1);
glBegin(GL_QUADS);
glVertex2f(1,1);
glVertex2f(1,-1);
glVertex2f(-1,-1);
glVertex2f(-1,1);
glEnd();
glPopMatrix();

Share this post


Link to post
Share on other sites
hey,

in your reshape function, try puting...

gluLookAt( 10, 10, 0, 0, 0, 0, 0, 1, 0 );

this would be the last line in your function.
this function places the "camera" and tells it where to look and which direction should be pointing up.

first 3 numbers are x,y,z of the camera placement.
next 3 numbers are x,y,z of where the camera is looking, so it''s looking at the orgin.
and the last 3 numbers are telling which direction is up. so i have it as the positive y direction is up.

i hope this helps.

DarkMonkey

Share this post


Link to post
Share on other sites
I already tried that, I know how to use the gluLookAt function cause i wrote a camera class for my spaceship game.

I cant figure this out.

Share this post


Link to post
Share on other sites
Well, I plugged it in mine and it worked just fine. The only thing I changed was to take out the srand call and the #pragma. Must be your pc.

And wtf is this line for:
if(h == 0) h = 0;


Mike

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!