Opengl

580 palavras 3 páginas
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 Testing glutInitDisplayMode (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

Relacionados

  • OpenGL
    12160 palavras | 49 páginas
  • Opengl
    16056 palavras | 65 páginas
  • OpenGL
    1939 palavras | 8 páginas
  • opengl casa
    308 palavras | 2 páginas
  • Animação opengl
    698 palavras | 3 páginas
  • Resumo opengl
    1037 palavras | 5 páginas
  • Edição de imagem com OpenGL
    496 palavras | 2 páginas
  • Opengl, cubos e movimentos
    642 palavras | 3 páginas
  • CG Aula3 1 Introdu O Ao OpenGL
    911 palavras | 4 páginas
  • Computação gráfica
    741 palavras | 3 páginas