2015 Grafkom 02 Graphics Systems
2015 Grafkom 02 Graphics Systems
Outline
Sistem Grafika
Programmers Interface
Arsitektur Sistem Grafika
Programmable Pipeline
Karakteristik Performa
Programming in OpenGL 1: Background
Angel: Interactive Computer Graphics6E AddisonWesley 2012
Cameras
Microscopes
Telescopes
Human visual system
Angel: Interactive Computer Graphics6E AddisonWesley 2012
Objects
Viewer
Light source(s)
Attributes that govern how light interacts with the
materials in the scene
Note the independence of the objects, the viewer,
and the light source(s)
Angel: Interactive Computer Graphics6E AddisonWesley 2012
Review: Light
5
yp= -y/z/d
z p= d
The point (xp, yp, d) is called the projection of the point (x, y, z).
Angel: Interactive Computer Graphics6E AddisonWesley 2012
Angle of view
8
Kuis 1
12
13
Sistem Grafika
14
Sistem
Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Sistem
Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Sistem
Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Sistem
Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Sistem
Grafika
Programmable
Pipeline
Karakteristik
Performa
High dynamic range (HDR) systems use 12 or more bits for each
color component.
In a very simple system, the frame buffer holds only the colored
pixels.
In most systems, the frame buffer holds far more information, such
as depth information.
Programmers
Interface
Arsitektur
Sistem Grafika
In these systems, the frame buffer comprises multiple buffers, one or more
of which are color buffers that hold the colored pixels that are displayed.
For now, we can use the terms frame buffer and color buffer
synonymously.
Sistem
Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
In a simple system, there may be only one processor, the central processing
unit (CPU), which must do both the normal processing and the graphical
processing.
In early graphics systems, the frame buffer was part of the standard memory
that could be directly addressed by the CPU.
The GPU can be either on the mother board of the system or on a graphics card.
The frame buffer is accessed through the GPU and usually is on the same circuit board
as the GPU.
Sistem Grafika
Programmer
s Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Angel: Interactive Computer Graphics6E AddisonWesley 2012
API Contents
21
Sistem Grafika
Programmer
s Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Objects
Viewer
Light Source(s)
Materials
Other information
Object Specification
22
Sistem Grafika
Programmer
s Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Parametric
polynomials
glBegin(GL_POLYGON)
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 1.0, 0.0);
glVertex3f(0.0, 0.0, 1.0);
glEnd( );
end of object definition
Camera Specification
Types of lights
Material properties
Arsitektur Pipeline
27
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem
Grafika
Programmable
Pipeline
Vertex processing
Clipping and primitive assembly
Rasterization
Fragment processing
Karakteristik
Performa
Vertex Processing
28
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem
Grafika
Programmable
Pipeline
Karakteristik
Performa
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem
Grafika
Programmable
Pipeline
Karakteristik
Performa
Rasterization
30
Programmers
Interface
Arsitektur
Sistem
Grafika
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
Fragment Processing
31
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem
Grafika
Programmable
Pipeline
Karakteristik
Performa
Arsitektur pipeline
32
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmab
le Pipeline
Karakteristik
Performa
Arsitektur pipeline
33
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmab
le Pipeline
Karakteristik
Performa
Programmable pipeline
34
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmab
le Pipeline
Karakteristik
Performa
Performa
35
Sistem Grafika
Programmers
Interface
Arsitektur
Sistem Grafika
Programmable
Pipeline
Karakteristik
Performa
36
Objectives
Functions
Simple program
Core
Both
2D and 3D
PHIGS and X
X Window System
DEC/MIT effort
Client-server architecture with graphics
SGI and GL
OpenGL
Easy to use
Close enough to the hardware to get excellent performance
Focus on rendering: taking the spec of geometric objects
and their properties and forming a picture of them with a
virtual camera and lights
Omitted windowing and input to avoid window system
dependencies
OpenGL Evolution
compatible
Evolution reflected new hardware capabilities
Modern OpenGL
OpenGL 3.1
Totally shader-based
No default shaders
Each application must provide both a vertex and a
fragment shader
No immediate mode
Few state variables
Most 2.5 functions deprecated
Backward compatibility not required
Other Versions
OpenGL ES
Embedded systems
Version 1.0 simplified OpenGL 2.1
Version 2.0 simplified OpenGL 3.1
Shader
WebGL
based
Windows only
Advantages
Disadvantages
OpenGL Libraries
OpenGL32 on Windows
GL on most unix/linux systems (libGL.a)
GLUT
a window
Get input from mouse and keyboard
Menus
Event-driven
slide bars
freeglut
Added capabilities
Context checking
GLEW
Software Organization
OpenGL Architecture
OpenGL Functions
Primitives
Attributes
Transformations
Points
Line Segments
Triangles
Viewing
Modeling
Control (GLUT)
Input (GLUT)
Query
OpenGL State
Primitive generating
Can
State changing
Transformation
functions
Attribute functions
Under 3.1 most state variables are defined by the application and sent to the
shaders
glUniform3f
glUniform2i
glUniform3dv
dimensions
glUniform3f(x,y,z)
belongs to GL library
glUniform3fv(p)
p is a pointer to an array
OpenGL #defines
GLSL
It used to be easy
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUAD);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush();
}
int main(int argc, char** argv){
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
What happened
Viewing
Colors
Window parameters
simple.c
#include <GL/glut.h>
void mydisplay(){
glClear(GL_COLOR_BUFFER_BIT);
// need to fill in this part
// and add in shaders
}
int main(int argc, char** argv){
glutCreateWindow("simple");
glutDisplayFunc(mydisplay);
glutMainLoop();
}
Event Loop
Compilation on Windows
Visual C++
66
67
Example1.cpp main
74