Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,

Similar presentations


Presentation on theme: "OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,"— Presentation transcript:

1 OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); glColor3f(1.0, 1.0, 1.0); glBegin(); glVertex2f(-0.5, -0.5); glEnd(); glFlush(); WaitForAWhille() ; }

2 OpenGL Data Types Suffix Data Type C-Language Type OpenGL Type b 8-bit int signed char GLbyte s 16-bit int short GLshort i 32-bit int long GLint, GLsizei f 32-bit float float GLfloat, GLclampf d 64-bit float double GLdouble, Glclampd ub 8-bit uns int unsigned char Glubyte, GLboolean us 16-bit uns int unsigned short GLushort ui 32-bit usn int unsigned long GLuint, GLenum uns: unsigned

3 Color glClearColor( GLcampf r, GLcampf g, GLcampf b, GLcampf a ); Sets the current clearing color. Colors 0.0, 0.0, 0.0 black 1.0, 1.0, 0.0 yellow 0.0, 1.0, 1.0 cyan 1.0, 1.0, 1.0 white glClear( Glbitfield mask) Clears the specified buffer Buffers Color Buffer GL_COLOR_BUFFER_BIT Depth Buffer GL_DEPTH_BUFFER_BIT Accum Buffer GL_ACCUM_BUFFER_BIT Stencil Buffer GL_STENCIL_BUFFER_BIT

4 glVertex glVertex{234}{sifd}[v]{TYPE coords); Specifies a vertex for use in geometric objects glVertex2s(2,3); glVertex3d(5.2, 4.1, 4.0); GLint vert[3] = {3,7,11}; glVertex3iv(vert); glVertex2f(2.5, 7.0);

5 glBegin( Glenum mode) … glEnd() Marks a beginning of a vertex list that describes a geometric object Mode Meaning GL_POINT individual points GL_LINES pairs of vertices as individual line segments GL_POLYGON boundary of simple polygon GL_TRIANGLES triples of vertices interpreted as triangles GL_QUADS quadruples of vertices, as quads GL_LINE_STRIP series of connected line segment GL_LINE_LOOP closed polyline

6 Examples glBegin(GL_POLYGON); glVertex2i(0,0); glVertex2i(0,1); glVertex2i(1,1); glVertex2i(1,0); glEnd() ; glBegin(GL_POINTS); glVertex2i(0,0); glVertex2i(0,1); glVertex2i(1,1); glVertex2i(1,0); glEnd() ;

7 Examples GLfloat list[6][2] ; glBegin(GL_LINES) for (int i = 0 ; i < 6 ;i++) glVertex2v(list[i]); glEnd() ; glBegin(GL_LINE_STRIP) for (int i = 0 ; i < 6 ;i++) glVertex2v(list[i]); glEnd() ; glBegin(GL_LINE_LOOP) for (int i = 0 ; i < 6 ;i++) glVertex2v(list[i]); glEnd() ;

8 Examples GLfloat list[6][2] ; glColor3f(0.0, 1.0, 0.0); glBegin(GL_TRIANGLES) for (int i = 0 ; i < 6 ;i++) glVertex2v(list[i]); glEnd() ; glBegin(GL_TRIANGLES) glColor3f(1.0, 0.0, 0.0); for ( i = 0 ; i < 3 ;i++) glVertex2v(list[i]); glColor3f(1.0, 1.0, 1.0); for ( i = 3 ; i < 6 ;i++) glVertex2v(list[i]); glEnd() ;


Download ppt "OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,"

Similar presentations


Ads by Google