/** * Load the top-most name of the name stack. * * \param name name. * * Verifies we are in selection mode and that the name stack is not empty. * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), * and replace the top-most name in the stack. * * sa __struct gl_contextRec::Select. */ void GLAPIENTRY _mesa_LoadName( GLuint name ) { GET_CURRENT_CONTEXT(ctx); if (ctx->RenderMode != GL_SELECT) { return; } if (ctx->Select.NameStackDepth == 0) { _mesa_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); return; } FLUSH_VERTICES(ctx, _NEW_RENDERMODE); if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) { ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name; } else { ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name; } }
void _mesa_InitNames( void ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glInitNames"); /* Record the hit before the HitFlag is wiped out again. */ if (ctx->RenderMode == GL_SELECT) { if (ctx->Select.HitFlag) { write_hit_record( ctx ); } } ctx->Select.NameStackDepth = 0; ctx->Select.HitFlag = GL_FALSE; ctx->Select.HitMinZ = 1.0; ctx->Select.HitMaxZ = 0.0; }
/** * Initialize the name stack. * * Verifies we are in select mode and resets the name stack depth and resets * the hit record data in gl_selection. Marks new render mode in * __struct gl_contextRec::NewState. */ void GLAPIENTRY _mesa_InitNames( void ) { GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); /* Record the hit before the HitFlag is wiped out again. */ if (ctx->RenderMode == GL_SELECT) { if (ctx->Select.HitFlag) { write_hit_record( ctx ); } } ctx->Select.NameStackDepth = 0; ctx->Select.HitFlag = GL_FALSE; ctx->Select.HitMinZ = 1.0; ctx->Select.HitMaxZ = 0.0; ctx->NewState |= _NEW_RENDERMODE; }
void _mesa_PopName( void ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopName"); if (ctx->RenderMode != GL_SELECT) { return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth > 0) { ctx->Select.NameStackDepth--; } else { gl_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); } }
void _mesa_PushName( GLuint name ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushName"); if (ctx->RenderMode != GL_SELECT) { return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) { ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; } else { gl_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); } }
/** * Pop a name into the name stack. * * Verifies we are in selection mode and that the name stack is not empty. * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), * and removes top-most name in the name stack. * * sa __struct gl_contextRec::Select. */ void GLAPIENTRY _mesa_PopName( void ) { GET_CURRENT_CONTEXT(ctx); if (ctx->RenderMode != GL_SELECT) { return; } FLUSH_VERTICES(ctx, _NEW_RENDERMODE); if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth == 0) { _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); } else ctx->Select.NameStackDepth--; }
/** * Push a name into the name stack. * * \param name name. * * Verifies we are in selection mode and that the name stack is not full. * Flushes vertices. If there is a hit flag writes it (via write_hit_record()), * and adds the name to the top of the name stack. * * sa __struct gl_contextRec::Select. */ void GLAPIENTRY _mesa_PushName( GLuint name ) { GET_CURRENT_CONTEXT(ctx); if (ctx->RenderMode != GL_SELECT) { return; } FLUSH_VERTICES(ctx, _NEW_RENDERMODE); if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth >= MAX_NAME_STACK_DEPTH) { _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); } else ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; }
void gl_PopName( GLcontext *ctx ) { if (INSIDE_BEGIN_END(ctx)) { gl_error( ctx, GL_INVALID_OPERATION, "glPopName" ); return; } if (ctx->RenderMode!=GL_SELECT) { return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth>0) { ctx->Select.NameStackDepth--; } else { gl_error( ctx, GL_STACK_UNDERFLOW, "glPopName" ); } }
void gl_PushName( GLcontext *ctx, GLuint name ) { if (INSIDE_BEGIN_END(ctx)) { gl_error( ctx, GL_INVALID_OPERATION, "glPushName" ); return; } if (ctx->RenderMode!=GL_SELECT) { return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth<MAX_NAME_STACK_DEPTH) { ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; } else { gl_error( ctx, GL_STACK_OVERFLOW, "glPushName" ); } }
void _mesa_LoadName( GLuint name ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLoadName"); if (ctx->RenderMode != GL_SELECT) { return; } if (ctx->Select.NameStackDepth == 0) { gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) { ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name; } else { ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name; } }
/** * Set rasterization mode. * * \param mode rasterization mode. * * \note this function can't be put in a display list. * * \sa glRenderMode(). * * Flushes the vertices and do the necessary cleanup according to the previous * rasterization mode, such as writing the hit record or resent the select * buffer index when exiting the select mode. Updates * __struct gl_contextRec::RenderMode and notifies the driver via the * dd_function_table::RenderMode callback. */ GLint GLAPIENTRY _mesa_RenderMode( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); GLint result; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode)); FLUSH_VERTICES(ctx, _NEW_RENDERMODE); switch (ctx->RenderMode) { case GL_RENDER: result = 0; break; case GL_SELECT: if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.BufferCount > ctx->Select.BufferSize) { /* overflow */ #ifdef DEBUG _mesa_warning(ctx, "Feedback buffer overflow"); #endif result = -1; } else { result = ctx->Select.Hits; } ctx->Select.BufferCount = 0; ctx->Select.Hits = 0; ctx->Select.NameStackDepth = 0; break; case GL_FEEDBACK: if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { /* overflow */ result = -1; } else { result = ctx->Feedback.Count; } ctx->Feedback.Count = 0; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); return 0; } switch (mode) { case GL_RENDER: break; case GL_SELECT: if (ctx->Select.BufferSize==0) { /* haven't called glSelectBuffer yet */ _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } break; case GL_FEEDBACK: if (ctx->Feedback.BufferSize==0) { /* haven't called glFeedbackBuffer yet */ _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); return 0; } ctx->RenderMode = mode; if (ctx->Driver.RenderMode) ctx->Driver.RenderMode( ctx, mode ); return result; }
/* * NOTE: this function can't be put in a display list. */ GLint _mesa_RenderMode( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); GLint result; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, "glRenderMode", 0); if (MESA_VERBOSE & VERBOSE_API) fprintf(stderr, "glRenderMode %s\n", gl_lookup_enum_by_nr(mode)); ctx->TriangleCaps &= ~(DD_FEEDBACK|DD_SELECT); switch (ctx->RenderMode) { case GL_RENDER: result = 0; break; case GL_SELECT: if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.BufferCount > ctx->Select.BufferSize) { /* overflow */ #ifdef DEBUG gl_warning(ctx, "Feedback buffer overflow"); #endif result = -1; } else { result = ctx->Select.Hits; } ctx->Select.BufferCount = 0; ctx->Select.Hits = 0; ctx->Select.NameStackDepth = 0; break; case GL_FEEDBACK: if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { /* overflow */ result = -1; } else { result = ctx->Feedback.Count; } ctx->Feedback.Count = 0; break; default: gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); return 0; } switch (mode) { case GL_RENDER: break; case GL_SELECT: ctx->TriangleCaps |= DD_SELECT; if (ctx->Select.BufferSize==0) { /* haven't called glSelectBuffer yet */ gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } break; case GL_FEEDBACK: ctx->TriangleCaps |= DD_FEEDBACK; if (ctx->Feedback.BufferSize==0) { /* haven't called glFeedbackBuffer yet */ gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } break; default: gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); return 0; } ctx->RenderMode = mode; ctx->NewState |= NEW_ALL; return result; }
/* * NOTE: this function can't be put in a display list. */ GLint gl_RenderMode( GLcontext *ctx, GLenum mode ) { GLint result; if (INSIDE_BEGIN_END(ctx)) { gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } switch (ctx->RenderMode) { case GL_RENDER: result = 0; break; case GL_SELECT: if (ctx->Select.HitFlag) { write_hit_record( ctx ); } if (ctx->Select.BufferCount > ctx->Select.BufferSize) { /* overflow */ #ifdef DEBUG gl_warning(ctx, "Feedback buffer overflow"); #endif result = -1; } else { result = ctx->Select.Hits; } ctx->Select.BufferCount = 0; ctx->Select.Hits = 0; ctx->Select.NameStackDepth = 0; break; case GL_FEEDBACK: if (ctx->Feedback.Count > ctx->Feedback.BufferSize) { /* overflow */ result = -1; } else { result = ctx->Feedback.Count; } ctx->Feedback.Count = 0; break; default: gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); return 0; } switch (mode) { case GL_RENDER: break; case GL_SELECT: if (ctx->Select.BufferSize==0) { /* haven't called glSelectBuffer yet */ gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } break; case GL_FEEDBACK: if (ctx->Feedback.BufferSize==0) { /* haven't called glFeedbackBuffer yet */ gl_error( ctx, GL_INVALID_OPERATION, "glRenderMode" ); } break; default: gl_error( ctx, GL_INVALID_ENUM, "glRenderMode" ); return 0; } ctx->RenderMode = mode; ctx->NewState |= NEW_ALL; return result; }