Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenGL Programming Guide (Red Book) State Management and Drawing Geometric Objects 고려대학교 그래픽스 연구실 강 신 진.

Similar presentations


Presentation on theme: "OpenGL Programming Guide (Red Book) State Management and Drawing Geometric Objects 고려대학교 그래픽스 연구실 강 신 진."— Presentation transcript:

1 OpenGL Programming Guide (Red Book) State Management and Drawing Geometric Objects 고려대학교 그래픽스 연구실 강 신 진

2 Goal  Clear the window to an arbitrary color  Force any pending drawing to complete  Draw with any geometric primitive  Turn states on and off any query states variables  Control the display of geometric primitives  Specify normal vectors at appropriate points

3 Contents  A Drawing Survival Kit  Describing Points, Lines, and Polygons  Basic State Management  Display Points, Lines, and Polygons  Normal Vectors

4 A Drawing Survival Kit

5 Clearing Window BufferName Color bufferGL_COLOR_BUFFER_BIT Depth bufferGL_DEPTH_BUFFER_BIT Accumulation bufferGL_ACCUM_BUFFER_BIT Stencil bufferGL_STENCIL_BUFFER_BIT glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_CLEAR_BUFFER_BIT); Lesson27\Lesson 27.exe

6 Specifying a Color  Description of the shape of an object Independent of the description of its color  Order of Programming Setting the color or coloring scheme Drawing the objects  To set a color glColor3f(1.0f, 1.0f, 1.0f); //black glColor3f(0.0f, 1.0f, 1.0f); //cyan

7 Forcing Completion of Drawing Void glFlush(void); Forces previously issued OpenGL commands to begin execution, thus guaranteeing that they complete in finite time Void glFinish(void); Forces all previously issued OpenGL commands to complete. The command doesn’t return until all effects from previous commands are fully realized.

8 Coordinate System Survival Kit glutReshapeFunc(reshape) Void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)w/(GLfloat)h,0.1f,100.0f); }

9 Describing Points, Lines, and Polygons 점선폴리곤 \lesson1.exe

10 What are Points, Lines and Polygons?  Differences between mathematician and OpenGL 1.Difference from the limitations of computer-based calculations.  Floating-point calculations are of finite precision, and they have round-off errors 2. Difference from the limitations of a graphics display  The smallest displayable unit is a pixel, and pixel is not infinitely small

11 Specifying Vertices glVertex2s(2, 3); glVertex3d(0.0, 0.0, 3.141592653898); glVertex4f(2.3, 1.0, -2.2, 2.0); glDouble dvect[3] = {5.0, 9.0, 1992.0}; glVertex3dv(dvect); glVertex() type glVertex*() type Between glBegin() and glEnd()

12 OpenGL Geometric Drawing Primitives Void glBegin(GLenum mode); glBegin 모드 \Debug\lesson1.exe

13 Restriction on Using glBegin() and glEnd() glVertex*()Set vertex coordinates glColor*()Set current color glIndex*()Set current color index glNormal*()Set normal vector coordinates glTexCoord*()Set texture coordinates glMultiTexCoord*ARB()Set texture coordinates for multitexturing glEdgeFlag*()Control drawing of edges glMaterial*()Set material properties glArrayElement()Extract vertex array data glEvalCoord*(), ~Point*()Generate coordinates glCallList(), glCallLists()Execute display list(s)

14 Basic State Management

15 Method Void glEnable(GLenum cap); Void glDisable(GLenum cap); Checking & Debugging method GLboolean glIsEnabled(GLenum capability); Capability Example GL_BLEND, GL_DEPTH_TEST, GL_LINE_STIPPLE, GL_LIGHTING etc.

16 Display Points, Lines, and Polygons

17 Point Detail Controlling size of a rendered point Void glPointSize(GLfloat size); Whether antialiasing is enabled or disabled Disabledwidths are rounded to integer widths Enablednoninteger widths aren ’ t rounded, variation of intensity Antilaliasing\Debug\Antilaliasing.exe

18 Line Details Controlling width of a rendered line Void glLineWidth(GLfloat size); Stippled Lines glLineStipple(1, 0x3F07); glEnable(GL_LINE_STIPPLE);

19 Polygon Details - 1 Polygons as Points, Outlines or Solids Void glPolygonMode(GLenum face, GLenum mode); glPolygonMode(GL_FRONT, GL_FILL); glPolygonMode(GL_BACK, GL_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); Reserving and Culling Polygon Faces Void glFrontFace(GLenum mode); //GL_CW, GL_CCW glBegin 모드 \Debug\lesson1.exe

20 Polygon Details - 2 Void glCullFace(GLenum mode); modeGL_FRONT, GL_BACK, GL_FRONT_AND_BACK Stippling Polygons glEnable(GL_POLYGON_STIPPLE); Void glPolygonStipple(const GLubyte *mask); Boundary Edges Void glEdgeFlags(GLboolean flag); Void glEdgeFlagv(const GLboolean *flag);

21 Normal Vectors

22 Normal Vector A normal vector is a vector that points in a direction that ’ s perpendicular to surface OpenGL Method Void glNormal3{bsidf}(TYPE nx, TYPE ny, TYPE nz); Void glNormal3{bsidf}v(const TYPE *v); Normalization glEnable(GL_NORMALIZE);


Download ppt "OpenGL Programming Guide (Red Book) State Management and Drawing Geometric Objects 고려대학교 그래픽스 연구실 강 신 진."

Similar presentations


Ads by Google