180 likes | 290 Views
CS 470 Introduction to Computer Graphics. OpenGL Concepts. Opengl – several related components. OpenGL glu glut (freeglut, glow, glutmaster(c++)…) Others glx wgl apl pgl GLUI. gl. 200 functions Primitives Geometric Discrete (bitmaps) Attribute functions Viewing functions.
E N D
CS 470 Introduction to Computer Graphics OpenGL Concepts
Opengl – several related components • OpenGL • glu • glut (freeglut, glow, glutmaster(c++)…) • Others • glx • wgl • apl • pgl • GLUI
gl • 200 functions • Primitives • Geometric • Discrete (bitmaps) • Attribute functions • Viewing functions
glu – Opengl Utility Library • GLU is the OpenGL Utility Library. This is a set of functions to create texture bitmaps from a base image, map coordinates between screen and object space, … • about 17 functions • about 4 drawing primitives
glut – Opengl Utility Toolkit • …a window system independent toolkit for writing OpenGL programs • Generic windows API – • same program/calls work across different gui/windows environments • Provides user interaction functions • mouse, keyboard, menus
Sample Drawing Primitives • gl • Pixels • Bitmaps • Vertice • glu • Cylinder • Disk • Sphere
Sample Drawing Primitives • glut • wire cube / solid cube • wire sphere / solid sphere • wire octahedron / solid octahedron • wire torus / solid torus • wire teapot / solid teapot
OpenGL • Written in C • No overloading of functions • No object oriented programming • but be used from C++
OpenGL Function syntax • glxxxx*() – all opengl functions begin with “gl” • gluxxx*() – all glu functions begin with “glu” • glutxxx*() – all glut functions begin with “glut”
Other libraries syntax • glx – opengl library for X windows • wgl – opengl library for MS Windows • agl – opengl library for Apple Macintosh OS • pgl – opengl library for OS/2 Warp glxCreateWindow() Not same across libraries
OpenGL • general function syntax • glVertex{2|3|4}{s|i|f|d}(TYPE arg1,…); • glVertex{2|3|4}{s|i|f|d}v(TYPE *arg); • glVertex*() manual notation
OpenGL • Data types • standard data types – int, float, double, char • OpenGL types • GLbyte – signed char • GLushort – unsigned short • GLint – int • GLuint – unsigned int • GLfloat – float • GLdouble – double • GLchar – char
OpenGL • Other Data Types – • GLclampf – float from 0.0 to 1.0 • GLsizei – largest nonnegative integer on system • other enumerated GL types • Also some GLU types
OpenGL • OpenGL constants • Predefined constants for setting or testing values • GL_RGB • GL_LINE • GL_POLYGON • GLUT_RGB • GLUT_SINGLE • GLUT_KEY_F1 • GLUT_LEFT_BUTTON • Hundreds of them
OpenGL • OpenGL rendering pipeline • simplified pipeline model Primitive Generation Transform-ation Clipping Projection Rasterization Display
OpenGL as a state machine • OpenGL can be viewed as a state-machine • The action of a function depends on the machines current state • Hundreds of properties (state variables) define the state of OpenGL • A state is in effect until it is changed • glColor3f(1.0,0.0,0.0) • State variables not like object properties
OpenGL Buffers • Frame Buffers • Single • Double