opengl: the open graphics language introduction by ricardo veguilla

13
OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla

Upload: miles-stewart

Post on 21-Jan-2016

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla

OpenGL: The Open Graphics Language Introduction

By Ricardo Veguilla

Page 2: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla

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

OpenGL - Primitive types

Page 4: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla

Defining OpenGL primitivesglBegin( GL_PRIMITIVE_TYPE)glVertex(…)glVertex(…)…glEnd() Block.

Page 5: OpenGL: The Open Graphics Language Introduction By Ricardo Veguilla

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

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

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

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

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

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

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

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

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