Archived

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

please help i'm a newbie

This topic is 5870 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

Guest Anonymous Poster

to use glut functions u need to include GLUT library

eg: #include

u can get more info at http://nehe.gamedev.net

(always anonymous)

Share this post


Link to post
Share on other sites
Sample GLUT code... It''s late so I may make mistakes, but you should get the gist of it.

  
// Normally, you should have put glut.h with the other GL headers.

#include <GL/glut.h>

int gWndID; // Stores the ID of the GLUT window


void
display()
{
// your graphics code here


glFinish(); // Wait until GL is completely done.

glutSwapBuffers(); // Double buffering command.

}

void
reshape( int width, int height )
{
glViewport( 0, 0, width, height ); // resizes the GL display area within the window;


// You should put your MODELVIEW projection code here

// ex:


glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluOrtho2D( -1, 1, -1, 1 );
}

void
idle()
{
// animations, AI ...


glutSetWindow( gWndID ); // If you have several windows, tell GLUT which one to activate.

glutPostRedisplay(); // Tell GLUT to call display() ASAP on the active window.


}

int
main( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); // enables double buffering


glutInitWindowPosition(0,0); // places the

glutInitWindowSize(840,680);

gWndID = glutCreateWindow("Title"); // you should save the return value if you plan on using several windows.


glutDisplayFunc( display ); // you MUST have a display callback

glutReshapeFunc( reshape ); // called when the window is created & whenever it is reshaped.

glutIdleFunc( idle );

glutMainLoop(); // gets the ball rolling

}

Share this post


Link to post
Share on other sites
Hmmm, forgot to answer the question

glutInitWindowPosition(x,y) will set the top left corner of the next window GLUT creates.

glutInitWindowSize(w,h) does the same thing with the size.

glutCreateWindow(title) tells GLUT to create a window, and return the window's ID.

Nothing happens graphically until glutMainLoop().
Don't forget to call glutInit() as the very first thing you do.
If you register callbacks before creating a window, you're in for a segfault.


Edited by - Fruny on November 17, 2001 12:53:18 AM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

i did told him to check nehe (since they got alot opengl links)
hmmm..

(always anonymous)

Share this post


Link to post
Share on other sites