GLUT = ./glut INC_DIR = ./glut/include LIB_DIR = ./glut/lib INC += -I$(INC_DIR) LIB += -L$(LIB_DIR) |
turnin -v -c cs488 -p hw1 files |
Suffix | Data Type | Typical Corresponding C-Language Type | OpenGL Type Definition |
---|---|---|---|
b | 8-bit integer | signed char | GLbyte |
s | 16-bit integer | short | GLshort |
i | 32-bit integer | long | GLint, GLsizei |
f | 32-bit floating-point | float | GLfloat, GLclampf |
d | 64-bit floating-point | double | GLdouble, GLclampd |
ub | 8-bit unsigned integer | unsigned char | GLubyte, GLboolean |
us | 16-bit unsigned integer | unsigned short | GLushort |
ui | 32-bit unsigned integer | unsigned long | GLuint, GLenum, GLbitfield |
Select color -> select tools(operations) -> draw(describe graphics primitives) |
glGetDoublev(); glGetIntegerv(); ... glGet* *(See redboot Appendix B for state variables) |
Detecting OpenGL Functionality: ... // Check core version: strVersion = glGetString (GL_VERSION); // Verify extension support: strExt = glGetString (GL_EXTENSIONS); // Determine OpenGL limits: glGetIntegerv (GL_MAX_TEXTURE_SIZE, &maxTextureSize); (*From Apple Developer OpenGL tutorial documents) |
Buffer | Name | Reference |
---|---|---|
Color buffer | GL_COLOR_BUFFER_BIT | Chapter 5 |
Depth buffer | GL_DEPTH_BUFFER_BIT | Chapter 10 |
Accumulation buffer | GL_ACCUM_BUFFER_BIT | Chapter 10 |
Stencil buffer | GL_STENCIL_BUFFER_BIT | Chapter 10 |
Command | Purpose of Command | Reference |
---|---|---|
glVertex*() | set vertex coordinates | Chapter 2 |
glColor*() | set current color | Chapter 5 |
glIndex*() | set current color index | Chapter 5 |
glNormal*() | set normal vector coordinates | Chapter 2 |
glEvalCoord*() | generate coordinates | Chapter 11 |
glCallList(), glCallLists() | execute display list(s) | Chapter 4 |
glTexCoord*() | set texture coordinates | Chapter 9 |
glEdgeFlag*() | control drawing of edges | Chapter 2 |
glMaterial*() | set material properties | Chapter 6 |
#define PI 3.1415926535897; GLint circle_points = 100; glBegin(GL_LINE_LOOP); for (i = 0; i < circle_points; i++) { angle = 2*PI*i/circle_points; glVertex2f(cos(angle), sin(angle)); } glEnd(); |
GL_BLEND, GL_DEPTH_TEST, GL_FOG, GL_LINE_STIPPLE, GL_LIGHTING |
// Determine OpenGL limits: GLint maxTextureSize; glGetIntegerv (GL_MAX_TEXTURE_SIZE, &maxTextureSize); |
glLineStipple(1, 0x3F07); glEnable(GL_LINE_STIPPLE); (ps. 0x3F07 -> 0011111100000111) |
void glPolygonMode(GLenum face, GLenum mode); ---- face: GL_FRONT_AND_BACK, GL_FRONT, GL_BACK mode: GL_POINT, GL_LINE, GL_FILL Default: Both front and back are GL_FILL ---- glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE); |
void glFrontFace(GLenum mode); // GL_CCW, or GL_CW |
void glEnable(GL_CULL_FACE); // mode could be // GL_FRONT, GL_BACK, GL_FRONT_AND_BACK void glCullFace(GLenum mode); |
glEnable(GL_POLYGON_STIPPLE); void glPolygonStipple(const GLubyte *mask); glDisable(GL_POLYGON_STIPPLE); Mask: 32x32 bitmap -> Example code |
void glNormal3{bsidf}(TYPE nx, TYPE ny, TYPE nz); void glNormal3P{bsidf}v(const TYPE *v); ---- glBegin(GL_POLYGON); glNormal3fv(n0); glVertex3fv(v0); glNormal3fv(n1); glVertex3fv(v1); glNormal3fv(n2); glVertex3fv(v2); glEnd(); |
To get unit normal vector: length = sqrt( x^2 + y^2 + z^2 ); unit_normal = ( nx/length, ny/length, nz/length ); |
Default: both off Reason: Enable hits performance glEnable(GL_NORMALIZE); glEnable(GL_RESCALE_NORMAL); // cheaper |