Open GL Introduction include Some Window Lib h
Open. GL: Introduction #include <Some. Window. Lib. h< main} () Open. Window; () gl. Clear. Color(0. 0, 0. 0; ( gl. Clear(GL_COLOR_BUFFER_BIT; ( gl. Ortho(-1. 0, -1. 0, 1. 0; ( gl. Color 3 f(1. 0, 1. 0; ( gl. Begin; () gl. Vertex 2 f(-0. 5, -0. 5; ( gl. End; () gl. Flush; () Wait. For. AWhille; () {
Open. GL Data Types Suffix b s i f d ub us ui Data Type C-Language Type 8 -bit int signed char 16 -bit int short 32 -bit int long 32 -bit float 64 -bit float double 8 -bit uns int unsigned char 16 -bit uns int unsigned short 32 -bit usn int unsigned long uns: unsigned Open. GL Type GLbyte GLshort GLint, GLsizei GLfloat, GLclampf GLdouble, Glclampd Glubyte, GLboolean GLushort GLuint, GLenum
Color • gl. Clear. Color(GLcampf r, GLcampf g, GLcampf b, GLcampf a); Sets the current clearing color. • Colors 0. 0, 0. 0 1. 0, 0. 0, 1. 0 black yellow cyan white • gl. Clear(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
gl. Vertex{234}{sifd}[v]{TYPE coords); Specifies a vertex for use in geometric objects gl. Vertex 2 s(2, 3; ( gl. Vertex 3 d(5. 2, 4. 1, 4. 0; ( GLint vert[3] = {3, 7, 11; { gl. Vertex 3 iv(vert; ( gl. Vertex 2 f(2. 5, 7. 0; (
gl. Begin(Glenum mode) … gl. End() Marks a beginning of a vertex list that describes a geometric object Mode GL_POINT GL_LINES GL_POLYGON GL_TRIANGLES GL_QUADS GL_LINE_STRIP GL_LINE_LOOP Meaning individual points pairs of vertices as individual line segments boundary of simple polygon triples of vertices interpreted as triangles quadruples of vertices, as quads series of connected line segment closed polyline
Examples gl. Begin(GL_POLYGON; ( gl. Vertex 2 i(0, 0; ( gl. Vertex 2 i(0, 1; ( gl. Vertex 2 i(1, 0; ( gl. End; () gl. Begin(GL_POINTS; ( gl. Vertex 2 i(0, 0; ( gl. Vertex 2 i(0, 1; ( gl. Vertex 2 i(1, 0; ( gl. End; ()
Examples GLfloat list[6][2; [ gl. Begin(GL_LINES( for (int i = 0 ; i < 6 ; i(++ gl. Vertex 2 v(list[i; ([ gl. End; () gl. Begin(GL_LINE_STRIP( for (int i = 0 ; i < 6 ; i(++ gl. Vertex 2 v(list[i; ([ gl. End; () gl. Begin(GL_LINE_LOOP( for (int i = 0 ; i < 6 ; i(++ gl. Vertex 2 v(list[i; ([ gl. End; ()
Examples GLfloat list[6][2; [ gl. Color 3 f(0. 0, 1. 0, 0. 0; ( gl. Begin(GL_TRIANGLES( for (int i = 0 ; i < 6 ; i(++ gl. Vertex 2 v(list[i; ([ gl. End; () gl. Begin(GL_TRIANGLES( gl. Color 3 f(1. 0, 0. 0; ( for ( i = 0 ; i < 3 ; i(++ gl. Vertex 2 v(list[i; ([ gl. Color 3 f(1. 0, 1. 0; ( for ( i = 3 ; i < 6 ; i(++ gl. Vertex 2 v(list[i; ([ gl. End; ()
- Slides: 8