Académique Documents
Professionnel Documents
Culture Documents
Lecture Plan
1. Introduction to Display Hardware
2. Colour Models
3. Representing and Using Colour in OpenGL 4. Controlling OpenGL with State Variables
VGA is an analogue standard. DVI (Digital Video Interface) provides a digital solution for newer digital monitors
4
Standard created by the Digital Display Working Group (DDWG) to accommodate analogue and digital display signals 3 variations of the interface exist
DVI-A: Carry analogue only signals DVI-D: Carry digital signals DVI-I: Integrated version carry both analogue and digital signals
Additional ports - Dual-Link DVI (support resolutions 2560 x 1600) - Mini-DisplayPort (VGA and Dual-Link DVI compatible) but 2/3 size of USB
5
Pixels are arranged on a grid of horizontal and vertical wires Advantage - Simple Architecture
Pixels are activated by sending signals along the appropriate horizontal and vertical wires
Disadvantages - Slow response time (moving the mouse leaves a ghost trail) Also, pixels being updated effect its neighbours leaving a fuzzy image
Each transistor lies on a grid of wires and allows precise control over the voltage that can be passed through, allowing us to create a grey scale image (today around 256 levels)
To create a colour image, three sets of TFTs are required one for red, one for green and one for blue colour.
-TFT displays overcome the problems of passive matrix displays but can suffer from Dead Pixels eg. transistors always on or off. -Historically problems with colour reproduction and brightness existed, but less so today. -Response time & view angle important issues.
8
2. Colour Models
2. Colour Models
10
2. Colour Models
RGB Colour - Visible Gamut
Computer monitors are only capable of generating certain frequencies within the chromaticity space. As such colour models used in computer graphics do not cover the range of colours perceivable by humans.
y 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 x
11
2. Colour Models
RGB Colour Model
Colours in the visible spectrum can be created from combinations of the three primary colours Red Green Blue This is the primary colour model in computer graphics and OpenGL. RGB is an additive model ie. we combine colours to create new ones
12
2. Colour Models
CMYK Colour Model
CMYK = (Cyan, Mgenta, Yellow, Key i.e. Black)
There are many other colour models CcMmYK 6 colour model used in inkjet printers Hexachrome (CMYKOG where Orange and Green are added)
13
14
Pixel
Red
Green
Blue
Alpha
24 pixels correspond to the colour which means we can represent 16,777,216 colours!!!
15
Image
0 0 31 0 2 2 1 2 2 8 1 31 31 8
Colour Lookup Table Index 0 1 2 254 255 RGB 0,0,0 2,2,2 0,1,1 56,3,2 81,4,76
31 31
This means images are more compact, but the OpenGL ARB recommend using direct mode for more predictable results.
16
To use the colour indexing model we must set the iPixelType flag of the Pixel Format Descriptor to PFD_TYPE_COLORINDEX
Note: For the remainder of this course well be using the RGBA direct colour model.
17
Colours can be set on a per-vertex basis. To set the current colour in OpenGL use the glColor() command. Like the glVertex() commands, there are different versions depending on the type of data youre working with
glColor3f(1.0, 0.0, 0.0); - specify RGB as floating point numbers in the range [0, 1].
glColor3ub(255, 0, 0); - specify RGB as unsigned byte values in the range [0, 255].
18
19
OpenGL is an example of a state-based rendering API. The internal state (stored in the rendering context) affects how the shapes / geometry are rendered on-screen.
OpenGLs state is a collection of variable and flags that describe all aspects of the rendering pipeline. For example
Control the colour and transparency (as described above) Control the position of objects and camera in a scene How a 3D environment is mapped into a 2D window Which textures are to be used Switch on and off different features (depth testing for example)
20
Set the point size to control the size of points when rendering in GL_POINTS mode glPointSize( 2.0 );
Set the width of lines when using GL_LINES or GL_LINE_LOOP for example glLineWidth( 5.0 ); Set the pattern for lines (dotted lines, dashed lines etc.) glLineStipple( 1.0, 0xF0F0 ); The above sets the pattern of the line, but for this to be applied to lines drawn in OpenGL we need to turn the line stipple feature on. This is done with the glEnable function glEnable(GL_LINE_STIPPLE); To turn off the line stipple feature we use the glDisable function glDisable(GL_LINE_STIPPLE);
21
In the examples considered so far weve been rendering objects with (x, y) coordinates between -1 and +1. This is because the viewplane has been set to these extents. The viewplane size is just another state variable in OpenGL and this can be changed using the glOrtho function (for 2D graphics well look at 3D later in the course). The default in the tutorial example file main.cpp is glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
To give ourselves a bigger canvas we can change this to glOrtho( -10.0, 10.0, -10.0, 10.0, -1.0, 1.0 );
Now all our coordinates between -10 and +10 will be visible.
22
When we draw triangles or polygons by default they are filled in. But how they are drawn and filled in is controlled by OpenGL state variables To force OpenGL to render all polygons with lines (instead of filling in) use glPolygonMode(GL_FRONT, GL_LINE); This is useful for drawing an outline (wireframe) version of the model.
23
When triangles and polygons are filled in, OpenGL controls how they are filled in with the shade model state variable. This can take one of two values
To use flat shading (where the entire polygon is coloured using only the last colour specified with glColor) use glShadeModel(GL_FLAT);