![Page 1: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/1.jpg)
OpenGL: The Open Graphics Language Introduction
By Ricardo Veguilla
![Page 2: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/2.jpg)
OpenGL – The Open Graphics Language De facto Application
Programming Interface (API) for cross-platform development of 3D graphics applications.
Implementations available for all major Operating Systems and hardware platforms.
Support for hardware accelerated 3D rendering.
Scalable, high-level, easy to use, well documented.
![Page 3: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/3.jpg)
OpenGL - Primitive types
![Page 4: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/4.jpg)
Defining OpenGL primitivesglBegin( GL_PRIMITIVE_TYPE)glVertex(…)glVertex(…)…glEnd() Block.
![Page 5: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/5.jpg)
Transformation MatricesOpenGL provide 3 transformation matrix
stacks: Perspective Matrix – Used for viewing
transformations – equivalent to positioning and aiming a camera.
Modeling Matrix – Used for modeling transformations – equivalent to positioning and orienting the model to be drawn.
Texture Matrix – Used for texture transformations – equivalent to positioning and orienting the texture to be drawn over a polygon.
![Page 6: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/6.jpg)
Transformation functions glLoadIdentity()
glTranslate(TYPE x, TYPE y, TYPE z)
glRotate(TYPE angle, TYPE x, TYPE y, TYPE z)
glScale(TYPE x, TYPE y, TYPE z)
glPushMatrix()
glPopMatrix()
![Page 7: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/7.jpg)
glLoadIdentity
glLoadIdentity()
Loads the identity matrix into the current transformation matrix.
Used to reset the current transformation matrix before performing a transformation.
![Page 8: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/8.jpg)
Translatoin
glTranslate(TYPE x, TYPE y, TYPE z)
Multiplies the current transformation matrix by a matrix that moves an object (the local coordinate system) by the given x, y, and z values.
![Page 9: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/9.jpg)
Rotation
glRotate(TYPE angle, TYPE x, TYPE y, TYPE z)
Multiplies the current transformation matrix by a matrix that rotates an object (or the local coordinate system) in a counter clockwise direction about the ray from the origin through the point (x, y, z). The angle parameter specifies the angle of rotation in degrees.
![Page 10: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/10.jpg)
Scaling
glScale(TYPE x, TYPE y, TYPE z)
Multiplies the current transformation matrix by a matrix that stretches, shrinks, or reflects and object (or the local coordinate system) along the axes. Each x, y, and z coordinate of every point in the object is multiplied by the corresponding argument x, y, or z.
![Page 11: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/11.jpg)
Controlling the tranformation matrix stacks glPushMatrix()
Pushed the current transformation matrix into the stack.
glPopMatrix()
Loads the matrix at the top of the stack into the current transformation matrix.
![Page 12: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/12.jpg)
OpenGL - Code Example// Set the viewport sizeglViewport(0, 0, width, height); // Clear the windowglClear(GL_COLOR_BUFFER_BIT); // Set the drawing color glColor3f(1.0, 1.0, 1.0); // Start primitive type definition glBegin(GL_POLYGON); // Specify verticies glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f(0.5, 0.5); glVertex2f(0.5, -0.5); // End primitive type definition glEnd(); // Flush the buffer to force drawing of all objects thus farglFlush();
![Page 13: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla](https://reader035.vdocument.in/reader035/viewer/2022062322/5697c0031a28abf838cc3e4f/html5/thumbnails/13.jpg)
References:
OpenGL - The Industry Standard for High Performance Graphics http://www.opengl.org/
Jogl – Java OpenGL Bindings https://jogl.dev.java.net/
Wikipidia – OpenGL http://en.wikipedia.org/wiki/OpenGL