OpenGL State Machine A common misconception imitive drawing functions are state changes o They are the output functions telling the system to draw something to the screen with the certain specified current state The options of the current state the current color gcor3f00.0.0.0.0); the current point size glPointSize(1.5) the depth function-enabled or not
OpenGL State Machine A common misconception The primitive drawing functions are state changes They are the output functions telling the system to draw something to the screen with the certain specified currentstate. The options of the current state the currentcolor the current point size the depth function - enabled or not … glColor3f(0.0, 0.0, 0.0); glPointSize(1.5); 6
OpenGL State Machine e what do you do to maintain states and state variables b Opengl? To set states for drawing geometric primitives E. g: glPoint Size(size ) glLine Stipple(repeat, pattern g Shade Model(GL_SMOOtH) o or change(enable) states of how Open gl draws them o by default, most of these states are initially inactive Such states include: objects rendered with lighting, texturing, or undergo different processes, such as hidden surface removal, fog, and other states which affect the app Dearance Toturn on/off states glEnable(GL- lighting) diSable(gl ⊥ BLEND)
OpenGL State Machine What do you do to maintain states and state variables by OpenGL? To set states for drawing geometric primitives E.g: glPointSize ( size ); glLineStipple ( repeat, pattern ); glShadeModel ( GL_ SMOOTH); or change (enable) states of how OpenGL draws them By default, most of these states are initially inactive. Such states include: objects rendered with lighting, texturing, or undergo different processes, such as hidden surface removal, fog, and other states, which affect the appearance. To turn on/off states glEnable ( GL_ LIGHTING ); glDisable ( GL_BLEND); 7
Basic State Management void glEnable glenum capability void glDisable(GLenum capability) More than 60 enumerated values can be passed as parameters to them E.g: GL BLEND (controls blending of RGBa values) GL DEPTH TEST (controls depth comparisons and updates to the depth buffer) GL FOG (controls fo GL LINE STIPPLE atterned lines) GL LIGHTING ht effect
Basic State Management E.g: GL_BLEND (controls blending of RGBA values) GL_DEPTH_TEST (controls depth comparisons and updates to the depth buffer) GL_FOG (controls fog) GL_LINE_STIPPLE (patterned lines) GL_LIGHTING (light effect) void glEnable (GLenum capability); void glDisable (GLenum capability); More than 60 enumerated values can be passed as parameters to them. 8
Basic State Management Tocheck whether a state is currently enabled or disabled GLboolean glls Enabled(GLenum capability) o Returns gl true or gL false, depending on whether or not it is currently activated e For more complicated state variables, such as glColor 3f() set three values, which are part of the gl CUrrent color state Query routines: glGet*O
Basic State Management To check whether a state is currently enabled or disabled by GLboolean glIsEnabled (GLenum capability) Returns GL_TRUE or GL_FALSE, depending on whether or not it is currently activated. For more complicated state variables, such as glColor3f ( ) set three values, which are part of the GL_CURRENT_COLOR state. Query routines: glGet* (); 9
Basic State Management o Five querying routines void glGetBooleanv( GLenumpname, GLboolean*params void glGetIntegerv(GLenum pname, GLint*params); void glgetFloatv(GLenum pname, GLfloat *params void glGetDoublev(GLenumpname, GLdouble *params void glGetPointerv(GLenum pname, GLvoid**params pname: a symbolic constant indicating the state variable to return; E. g: GL_ CURRENT_ COLOR GL CURRENT NORMAL arms: a pointer to an array of the returned value
Basic State Management Five querying routines void glGetBooleanv (GLenum pname, GLboolean *params); void glGetIntegerv (GLenum pname, GLint *params); void glGetFloatv (GLenum pname, GLfloat *params); void glGetDoublev (GLenum pname, GLdouble *params); void glGetPointerv (GLenum pname, GLvoid **params); pname: a symbolic constant indicating the state variable to return; E.g.: GL_CURRENT_COLOR, GL_CURRENT_NORMAL params: a pointer to an array of the returned value. 10