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

Slides:



Advertisements
Similar presentations
OpenGL: Simple Use Open a window and attach OpenGL to it Set projection parameters (e.g., field of view) Setup lighting, if any Main rendering loop –Set.
Advertisements

©Zachary Wartell, UNCC9/28/ :30 AM 1 Overview of OpenGL Revision: 1.2 Copyright Professor Zachary Wartell, University of North Carolina All Rights.
Chapter 2: Graphics Programming
O a polygon is a plane figure specified by a set of three or more coordinate positions, called vertices, that are connected in sequence by straight-Line.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
OPENGL Return of the Survival Guide. Buffers (0,0) OpenGL holds the buffers in a coordinate system such that the origin is the lower left corner.
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
OpenGL Son of the Survival Guide. Last Time on OpenGL Windowing … glut Rendering Primatives Transformations Projections State Management.
OpenGL (Graphics Library) Software Interface to graphics software Allows to create interactive programs that produce color images of moving 3D objects.
What is OpenGL The OpenGL graphics system is a software interface to graphics hardware. (The GL stands for Graphics Library.) It allows you to create interactive.
Draw a Simple Object. Example 1/4 #include “ glut.h ” void display(); void reshape(GLsizei w, GLsizei h); void main(int argc, char** argv){ glutInit(&argc,
Drawing Geometric Objects
Normals Specifying the normal –void glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); When using lighting effects, normals must be defined for each.
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
JOGL in MS Windows GDI – Graphics Device Interface (Windows-specific) OpenGL Lib JOGL Commands GDI Processor Graphics Hardware JOGL Lib.
Using OpenGL. 2 What is OpenGL? A software interface to graphics hardware It is a Graphics Rendering API (Application Programmer’s Interface) that is.
Open GL Programming Speaker: 彭任右 Date: 2005/10/3.
OpenGL - Lighting, Shading and Material Properties
Speeding Up Rendering After Deciding What to Draw.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
State Management and Drawing Geometry Objects
Introduction to OpenGL 1. 2 OpenGL A Graphics rendering API introduced in 1992 by Silicon Graphics Inc Provide the low-level functions to access graphics.
1. OpenGL/GLU/GLUT  OpenGL v4.0 (latest) is the “core” library that is platform independent  GLUT v3.7 is an auxiliary library that handles window creation,
1 10/24/ :01 UML Graphics II Shadows Session 4.
P RACTICING O PEN GL- P RIMITIVES. O PEN GL O UTPUT P RIMITIVES  Each geometric object is described by a set of vertices and the type of primitive to.
Computer Graphics Bing-Yu Chen National Taiwan University.
Lecture 2: Some definitions of terms 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 711,  ex 2271 
Introduction to OpenGL. OpenGL is a low-level graphics library specification. It makes available to the programmer  a small set of geometric primitives.
Draw a Simple Object. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture blending.
Intro to OpenGL (Version 2) Geb Thomas. Setting Up GLUT You will need GLUT for opening windows We can use the version made by Nate Robins: –
Intro to OpenGL: Vertices and Drawing
UniS CS297 Graphics with Java and OpenGL State Management and Drawing Primative Geometric Objects.
Programming With OpenGL
NoufNaief.net 1 TA: Nouf Al-Harbi.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
OpenGL Basic Drawing 2003 Spring Keng Shih-Ling
Lecture 2 Review OpenGL Libraries Graphics Overview Rendering Pipeline OpenGL command structure.
Chap 2 Write a Simple OpenGL Program. Preparing 1/2 environment : Microsoft Visual C 、 Microsoft Visual C++.Net Also need : GLUT
OpenGL Vertex Arrays OpenGL vertex arrays store vertex properties such as coordinates, normal vectors, color values and texture coordinates. These properties.
1 Programming with OpenGL Part 2: Complete Programs.
OpenGL API 2D Graphic Primitives Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Computer Graphics I, Fall 2010 Building Models.
CS559: Computer Graphics Lecture 12: OpenGL: ModelView Li Zhang Spring 2010.
OpenGL: Introduction #include main() { OpenWindow() ; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0,
OpenGL Basic Drawing Jian-Liang Lin A Smidgen of OpenGL Code #include main() { InitializeAWindowPlease(); glClearColor (0.0, 0.0, 0.0, 0.0); glClear.
2002 by Jim X. Chen: Drawing Geometric Models.1. Objectives –OpenGL drawing primitives and attributes –OpenGL polygon face.
The Framebuffer Hyun-Chul Cho. HyunChul Cho - KUCG -2 Buffer Goal of a graphics program Draw pictures on the screen Screen Rectangular array.
Introduction to Graphics Programming. Graphics API.
Graphics Graphics Korea University kucg.korea.ac.kr Graphics Programming 고려대학교 컴퓨터 그래픽스 연구실.
Introduction to OpenGL (INF 250) Veronika Solteszova et al., UiB Dept. of Informatics,
Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs.
Computer Graphics (Fall 2003) COMS 4160, Lecture 5: OpenGL 1 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Computer Graphics Lecture 34. OpenGL Programming II Taqdees A. Siddiqi
CSC Graphic Programming Lecture 2 OpenGL Lightning.
OpenGL Programming Guide Chapter 2 Korea Univ. Graphics Labs. Ji Jun Yong Korea Univ. Graphics Labs. Ji Jun Yong.
CSC Graphics Programming
Draw a Simple Object.
State Management and Drawing Geometric Objects
State Management and Drawing Geometric Objects
COIS712/ECOM708/COIS800 Chapter 5 Attributes of Graphics Primitives
Lab 3 Geometric Drawing Lab 3 Geometric Drawing.
Objectives OpenGL drawing primitives and attributes
Introduction to OpenGL
Lecture 13 Clipping & Scan Conversion
Chapter VII Rasterizer
Programming with OpenGL Part 2: Complete Programs
Presentation transcript:

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

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

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

A Drawing Survival Kit

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

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

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.

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); }

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

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

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

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

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)

Basic State Management

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.

Display Points, Lines, and Polygons

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

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

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

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);

Normal Vectors

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);