tuto1
tuto1
Computer Graphics
Tutorial 1
Yang Rong
2003/01/15-16
Outline
Tutorial information
Assignment 1 Overview
What is OpenGL ?
Why OpenGL ?
How to program with openGL ?
OpenGL Demo !
Explanation more on B-spline
TA Information
Luo Guo ([email protected])
Office: SHB1026 (26098438)
Albert Wang Jianqing (
[email protected])
Office: SHB1026 (26098438)
Yang Rong ([email protected])
Office: SHB1026 (26098438)
Wang Guangyu ([email protected])
Office: SHB1010 (26098427)
Tutorial schedule
Torso
Shoulders Hips
As a user…
OpenGL is the 3D power
behind all of the incredible
3D graphics & effects you
see on TV, at the movies
and games…
compelling 2D and 3D
graphics in broadcasting,
CAD/CAM/CAE,
entertainment, medical
imaging, virtual reality.
What is OpenGL?
As a developer…
A software interface to graphics hardware
API for developing portable, interactive 2D and
3D graphics applications
Application
Application Program
Program
OpenGL
OpenGL API
API
Graphics
Graphics Hardware
Hardware
Why OpenGL?
delivers fast and complete 3D Voodoo
hardware acceleration
makes real-time 3D effects TNT
possible
is on every platform
GeForce
Unix
Unix
Mac
Mac
IRIX
IRIX
Linux
Linux Window
Window
OpenGL Visualization
Pipeline
Geometry 2D/3D shapes
Translation, Rotation,
Transformation Projection…etc
y
(4,4,4)
y
x x
(4,0,4)
z
OpenGL is a state machine
glBegin(mode);
glBegin(mode);
glVertex3*(x0,
glVertex3*(x0,y0,
y0,z0);
z0);
glVertex3*(x1,
glVertex3*(x1,y1,
y1,z1);
z1);
……
glEnd();
glEnd();
mode can be
GL_POINTS, GL_LINES, GL_POLYGON, GL_TRINGLES,
GL_LINE_STRIP, GL_LINE_LOOP, GL_QUADS,
GL_QUADS_STRIP, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN
Sample OpenGL commands
DrawLines(){
DrawLines(){
glColor3f(1.0,0.0,0.0);
glColor3f(1.0,0.0,0.0);
glBegin(GL_LINE_STRIP)
glBegin(GL_LINE_STRIP)
(0.0,100.0) (100.0,100.0)
glVertex2f(0.0,
glVertex2f(0.0, 0.0);
0.0);
glVertex2f(100.0,
glVertex2f(100.0, 0.0);
0.0);
glVertex2f(100.0,
glVertex2f(100.0,
100.0);
100.0);
glVertex2f(0.0,
glVertex2f(0.0, 100.0);
100.0);
glEnd();
glEnd(); (0.0,0.0) (100.0,0.0)
}}
Using GLUT !
init();
init(); Initialize environment settings
Radiu
s Stacks
(latitude)
glutSolidSphere(2, 10, 10);
Slices
GLUT GLUT (longitude)
flavors object
More on B-spline
Qi(u): i-th segment in a B-spline. Control Points : Pi, Pi+1, Pi+2, Pi+3
Qi+1(u): i+1-th segment in a B-spline. Control Points : Pi+1, Pi+2, Pi+3, Pi+4
Pi
Qi(0) Qi(1) Qi+1(0) Qi+1(1) Qi1(u) Pi1k Bk (u).
Pi+3 i0
Seek the set of basis function Bk(u) such that C0, C1, and C2 continuity