Opengl

Disponível somente no TrabalhosFeitos
  • Páginas : 3 (580 palavras )
  • Download(s) : 0
  • Publicado : 6 de janeiro de 2011
Ler documento completo
Amostra do texto
CSCI 420 Computer Graphics OpenGL Cheat Sheet
Create a Window glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA); glutInitWindowSize(500, 500); glutInitWindowPosition (0, 0);glutCreateWindow (win_name); Clear a Window glClearColor (0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); Establish a Viewport and a Clipping Region glViewport (0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity( ); glOrtho (-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); Callback and Related Functions glutReshapeFunc (myReshape); glutDisplayFunc (myDisplay); glutIdleFunc(spinDisplay); glutMouseFunc (mouse); glutKeyboardFunc (keyboard); glutMainLoop ( ); glutPostRedisplay ( ); Move Around glPushMatrix( ); glPopMatrix( ); glLoadIdentity ( ); glRotatef(spin, 0.0, 0.0,1.0); glTranslatef(3.0, 2.0, 0.0); glScalef(1.0, 2.0, 1.0); Menus void color_menu(int id) { if(id == 1) {r = 1.0; g = 0.0; b = 0.0;}. . . c_menu = glutCreateMenu(color_menu); glutAddMenuEntry("Red",1);glutAttachMenu(GLUT_RIGHT_BUTTON); glutAddSubMenu("Colors", c_menu); Text glRasterPos2i(textX, textY); glutBitmapCharacter (GLUT_BITMAP_8_BY_13, ch); Functions to Draw glColor3f (red, green, blue);glBegin (GL_TRIANGLES); glVertex3f(3.0, 4.0, 0.0); glEnd(); // Alternatively glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer (3, GL_FLOAT, 0, vertices);glColorPointer (3, GL_FLOAT, 0, carray); glDrawElements (GL_QUADS, 24, GL_UNSIGNED_BYTE, cubeIndex); Double Buffering glutInitDisplayMode (GLUT_DOUBLE | . . .); glutSwapBuffers( );

Depth TestingglutInitDisplayMode (GLUT_DEPTH | . . .); glEnable (GL_DEPTH_TEST); glClear (GL_DEPTH_BUFFER_BIT | . . .);

Projections and Locating the Camera glOrtho (-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); glFrustum (left, right, bottom, top, near, far); gluPerspective(fovy, (GLfloat) w/(GLfloat) h, near, far); gluLookAt (eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz); Lighting and Materials glLightf...
tracking img