1OpenGLBasics - Copy (1)
1OpenGLBasics - Copy (1)
CSE 472 1
What Is OpenGL?
[imgur.com]
CSE 472 6
(Not) About OpenGL
Do not:
Think you don’t need to know underlying fundamentals
Think we will only do OpenGL (it’s already very old)
Vulkan (Linux/Windows) also by Khronos Group
OpenGL on Vulkan (Zink)
Metal by Apple
Vulkan on Apple
MoltenVK
DirectX (DXR)
CSE 472 8
Basic Rendering Models
[Slusallek’05]
Rasterization: Ray Tracing:
Project geometry forward Project image samples backwards
(object space order) (screen space order)
[RTX’19]
CSE 472 9
Background
Rendering pipeline
CSE 472 10
Rendering
Conversion of 3D model to 2D image
project
determine pixel
determine color
CSE 472 11
Rendering Parameters (Next Lecture)
Camera parameters
Location
Orientation
Focal length
12
CSE 472
3D coordinate systems
Y Y
Z
X X
Z
Right-Hand Left-Hand
Coordinate System Coordinate System
CSE 472 13
Visualizing in 3D
Y
H y=1.0 G
Counter- D C
clockwise
E F
X
x=1.0
1.0
A B
z=1.0
Z CSE 472 14
Rendering a Box in OpenGL
We render the 6 faces as polygons
Polygon specified as a list of vertices
CCW order looking at the surface
H G
C
D
E F
A B
CSE 472 15
OpenGL Polygon Rendering
CSE 472 16
OpenGL Conventions
C library
All function names start with gl
CSE 472 18
Function suffixes
Many functions have alternatives
Alternatives are specified by the suffix
glVertex2d
• 2 double parameters
• void glVertex2d(GLdouble x, GLdouble y);
glVertex3f
• 3 float parameters
• void glVertex3f(GLfloat x, GLfloat y, GLfloat z);
glVertex3fv
• void glVertex3fv(const GLfloat *v);
CSE 472 19
Defined
glVertex3fv
CSE 472 21
Vector parameters
GLdouble a[ ] = {0, 0, 1};
GLdouble b[ ] = {1, 0, 1};
GLdouble c[ ] = {1, 1, 1};
GLdouble d[ ] = {0, 1, 1};
CSE 472 A B 22
Specifying a color (no lighting)
CSE 472 25
GUI Crash Course by Carrie Anne Philbin
CSE 472 26
Window (in a Windowing System)
CSE 472 27
Linux GUI
[Wikipedia]
CSE 472 28
Windows Message Handling
[Sneha Latha]
CSE 472 30
Homework
Step 1
Introduction to Visual Studio/OpenGL
Using OpenGLWnd superclass
Basic immediate-mode OpenGL
CSE 472 31
The Basic Idea
CSE 472 32
Convex
CSE 472 33
Convex
Not Convex
CSE 472 34
3.00
Top View
d c
X
1.00
h g
e f
1.00
a
b
Z
Y Y
e f b f g
a
1.00
X Z o
i m n CSE
j 472 n 35
Front View Side View
How to model this?
CSE 472 36
3.00
Top View
d c
X
1.00
h g
e f
1.00
a
b
Z
Y Y
e f b f g
a
1.00
X Z o
i m n j n
Front View Side View
CSE 472 37
Labels
Top View Bottom labels
d c l k
h g p o
e f m n
a b i j
a e f b f g
i m n j n o
Front View Side View
CSE 472 38