Top Banner
With OpenGL ES [email protected]
21

Introduction to accelerated graphics

Jan 13, 2015

Download

Software

Ruslan Novikov

My adaptation of Stanford lecture on OpenGL ES
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to accelerated graphics

With OpenGL ES

[email protected]

Page 2: Introduction to accelerated graphics

IRIS GL

1992

Page 3: Introduction to accelerated graphics

1996 3Dfx creates Voodoo Graphics

First successful consumer 3D accelerator

1997 id Software releases Quake II game

This game uses Open GL out of the box

1999 Nvidia releases GeForce 256

first consumer-level PC graphics chip with hardware transform, lighting, and shading

Page 4: Introduction to accelerated graphics

What is OpenGL?

OpenGL stands for Open Graphics Library. It is a specification of an API for rendering 3D graphics

What is NOT OpenGL?

The OpenGL API only deals with rendering graphics. OpenGL does not provide functions for animations, timing, image file format processing, GUI etc.

Is OpenGL Open Source?

No, OpenGL doesn't have any source code. GL is a specification

Page 5: Introduction to accelerated graphics
Page 6: Introduction to accelerated graphics

Change Machine State glEnable(); glDisable(); glMatrixMode(); glBindFramebufferOES();

glViewport(); glVertexPointer(); glColorPointer(); glTranslatef() ...

Issue Drawing Commands glDrawArrays(); glDrawElements(); ...

Read Back State, Drawing Results glGetBooleanv(); glGetFloatv(); glReadPixels(); ...

Page 7: Introduction to accelerated graphics

Window Coordinates Normalized Device Coordinates Clip and Eye Coordinates World Coordinates Object Coordinates

Page 8: Introduction to accelerated graphics
Page 9: Introduction to accelerated graphics
Page 10: Introduction to accelerated graphics
Page 11: Introduction to accelerated graphics
Page 12: Introduction to accelerated graphics
Page 13: Introduction to accelerated graphics

glMatrixMode(GL_PROJECTION); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glOrthof(left, right, bottom, top, zNear, zFar); glFrustumf(left, right, bottom, top, zNear, zFar); glRotatef(degrees, x, y, z); glTranslatef(x, y, z); glScalef(x, y, z); glMultMatrixf(matrix); glPushMatrix(); glPopMatrix();

Page 14: Introduction to accelerated graphics

OpenGL ES draws triangles, lines, and points Object space vertices mapped into window

space Rasterize the shapes to get pixels

Page 15: Introduction to accelerated graphics

Each vertex can have a color associated RGBA

Alpha usually means opacity

Lines and triangles interpolate colors

Page 16: Introduction to accelerated graphics

Vertices are passed to OpenGL ES in arrays Drawing modes determine how vertices are

interpreted to produce shapes Vertex order matters

Page 17: Introduction to accelerated graphics

Use a triangle strip

Page 18: Introduction to accelerated graphics
Page 19: Introduction to accelerated graphics

Color pixels according to an image in memory Almost always 2D Vertices are given texture coordinates (u,v)

u

v

Page 20: Introduction to accelerated graphics

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture.name); GLFloat textureCoordArray[] = { u1,v1, u2,v2, u3,v3, ... }; glTexCoordPointer(2, GL_FLOAT, arrayOffset, textureCoordArray); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glDrawArrays(GL_TRIANGLE_STRIP, arrayOffset, numberOfVertices); glDisableClientState(GL_TEXTURE_COORD_ARRAY);