Download presentation
Presentation is loading. Please wait.
Published byLouise Thomas Modified over 9 years ago
2
“OpenGL (Open Graphics Library) is a standard specification defining a cross- language cross-platform API for writing applications that produce 2D and 3D computer graphics.” – from Wikipediacross-platformAPI2D3D computer graphics State machine For example, set the color, all subsequent drawing will be in this color until you change the color.
3
The OpenGL Utility Library (GLU) Routines that accomplishes some tasks by calling low-level OpenGL commands Provided as part of OpenGL implementation Prefix: glu The OpenGL Utility Toolkit (GLUT) window system-independent toolkit Prefix: glut
4
The Red book http://www.glprogramming.com/red/ http://www.glprogramming.com/red/ The website http://www.opengl.org/ http://www.opengl.org/
5
http://csf11.acs.uwosh.edu/cs371/visualstudio/ http://csf11.acs.uwosh.edu/cs371/visualstudio/
6
#include Put it before stdlib.h
7
glutInit(int *argc, char **argv) initializes. glutInit() should be called before any other GLUT routine. glutInitDisplayMode(unsigned int mode) specifies whether to use an RGBA or color-index color model. For example, a window with double buffering, the RGBA color model, and a depth buffer: glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH). glutInitWindowPosition(int x, int y) specifies the screen location for the upper-left corner of your window. glutInitWindowSize(int width, int size) specifies the size, in pixels, of your window. int glutCreateWindow(char *string) creates a window with an OpenGL context.
8
glutDisplayFunc(void (*func)(void)).Whenever GLUT determines the contents of the window need to be redisplayed, the callback function registered by glutDisplayFunc() is executed. Therefore, you should put all the routines you need to redraw the scene in the display callback function. If your program changes the contents of the window, sometimes you will have to call glutPostRedisplay(void), which gives glutMainLoop() a nudge to call the registered display callback at its next opportunity.
9
glutMainLoop() is the last to be called, and it is never exited once entered. Things that only need to be done once should be called only once in init(). More on GLUT http://www.glprogramming.com/red/appendixd.h tml http://www.glprogramming.com/red/appendixd.h tml
10
Mouse input Button clicking ▪ void glutMouseFunc(void (*func)(int button, int state, int x, int y)) Motion ▪ glutMotionFunc( void (*func)(int x, int y)) Keyboard input Key pressing ▪ void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y)) Window resizing void glutReshapeFunc(void (*func)(int w, int h))
12
Rotate void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); Translate void glTranslatef (GLfloat x, GLfloat y, GLfloat z); Scale void glScalef(GLfloat x, GLfloat y, GLfloat z);
14
Backface Culling void glCullFace(GLenum mode); glEnable(GL_CULL_FACE); Cull faces that are facing back based on vertex normals View frustum culling http://www.lighthouse3d.com/opengl/viewfrustum/ http://www.lighthouse3d.com/opengl/viewfrustum/ Big models (PLY)
15
User input Backface culling View-frustum culling
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.