1 / 8

OpenGL: Introduction

OpenGL: Introduction. #include <SomeWindowLib.h> 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);

cohend
Download Presentation

OpenGL: Introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OpenGL: Introduction #include <SomeWindowLib.h> 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); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, -0.5); 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. glClearColor(GLcampf r, GLcampf g, GLcampf b, GLcampf a);Sets the current clearing color. Colors0.0, 0.0, 0.0 black1.0, 1.0, 0.0 yellow0.0, 1.0, 1.0 cyan1.0, 1.0, 1.0 white glClear(Glbitfield mask)Clears the specified buffer Buffers Color Buffer GL_COLOR_BUFFER_BITDepth Buffer GL_DEPTH_BUFFER_BITAccum Buffer GL_ACCUM_BUFFER_BITStencil Buffer GL_STENCIL_BUFFER_BIT Color

  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(Glenummode) … 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() ;

More Related