» Architectural » Electronic » Mechanical
[Image Courtesy: Pixar]
[Image Courtesy: humanproductivitylab.com
» Science • Geometry(E+DD)projections • Physics of light, color, appearance • Algebra of transformations » Engineering • Graphics software libraries, GUI • Graphics processor architectures » Art • Color and perception • Illustrative views
• Imaging = representing 2D images
• Imaging = representing 2D images • Modeling = representing 3D objects
• Imaging = representing 2D images • Modeling = representing 3D objects • Rendering = constructing 2D images from 3D models
• Imaging = representing 2D images • Modeling = representing 3D objects • Rendering = constructing 2D images from 3D models • Animation = simulating changes over time
• OpenGL is a software API to graphics hardware. • Designed as a streamlined, hardware-independent interface. • Intuitive, procedural interface with ‘ C/C++’ binding. • To access the system, we have to used a library called GL. • Omitted windowing and input to avoid window system dependencies .
OpenGL core library (GL) • OpenGL32 on Windows • GL on most unix/linux systems (libGL.a) OpenGL Utility Library (GLU) • Provides functionality in OpenGL core but avoids having to rewrite code Links with window system (GLUT) GLX for X window systems, WGL for Windows Cross-platform GUI libraries: GLUT, SDL, FLTK, QT, …
C++ with GDI * More than 400 LOC C++ with OpenGL * Less than 20 LOC
Per Vertex Polynomial Operations & Evaluator Primitive Assembly Display Per Fragment Frame CPU Rasterization List Operations Buffer Texture Memory Pixel Operations
int main( int argc, char ** argv){ glutInit( &argc, argv); glutCreateWindow( argv[0] ); glutDisplayFunc( display); glutMainLoop(); return 0; } void display(){ glClear( GL_COLOR_BUFFER_BIT); glBegin( GL_TRIANGLES); glVertex2f( 0, -.5); glVertex2f( -.5, .5); glVertex2f( .5, .5); glEnd(); glFlush(); }
(-1,1) (1,1) int main( int argc, char ** argv){ glutInit( &argc, argv); glutCreateWindow( argv[0] ); glutDisplayFunc( display); glutMainLoop(); return 0; (0,0) } void display(){ glClear( GL_COLOR_BUFFER_BIT); glBegin( GL_TRIANGLES); glVertex2f( 0, -.5); (-1,-1) (1,-1) glVertex2f( -.5, .5); glVertex2f( .5, .5); glEnd(); glFlush(); }
• Translate , glTranslatef( dx, dy, dz); • Rotate, glRotatef(angle, x, y, z); • Scale, glScalef( sx, sy, sz);
glColor3f(1.0f , 0.7f, 0.0f);
Recommend
More recommend