static void st_RasterPos(struct gl_context *ctx, const GLfloat v[4]) { struct st_context *st = st_context(ctx); struct draw_context *draw = st->draw; struct rastpos_stage *rs; const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays; if (ctx->VertexProgram._Current == NULL || ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) { /* No vertex shader/program is enabled, used the simple/fast fixed- * function implementation of RasterPos. */ _mesa_RasterPos(ctx, v); return; } if (st->rastpos_stage) { /* get rastpos stage info */ rs = rastpos_stage(st->rastpos_stage); } else { /* create rastpos draw stage */ rs = new_draw_rastpos_stage(ctx, draw); st->rastpos_stage = &rs->stage; } /* plug our rastpos stage into the draw module */ draw_set_rasterize_stage(st->draw, st->rastpos_stage); /* make sure everything's up to date */ st_validate_state(st, ST_PIPELINE_RENDER); /* This will get set only if rastpos_point(), above, gets called */ ctx->Current.RasterPosValid = GL_FALSE; /* All vertex attribs but position were previously initialized above. * Just plug in position pointer now. */ rs->array[0].Ptr = (GLubyte *) v; /* Draw the point. * * Don't set DriverFlags.NewArray. * st_feedback_draw_vbo doesn't check for that flag. */ ctx->Array._DrawArrays = rs->arrays; st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1, NULL, 0, NULL); ctx->Array._DrawArrays = saved_arrays; /* restore draw's rasterization stage depending on rendermode */ if (ctx->RenderMode == GL_FEEDBACK) { draw_set_rasterize_stage(draw, st->feedback_stage); } else if (ctx->RenderMode == GL_SELECT) { draw_set_rasterize_stage(draw, st->selection_stage); } }
/** * Normally, this function would render a GL_POINT. */ static void rastpos_point(struct draw_stage *stage, struct prim_header *prim) { struct rastpos_stage *rs = rastpos_stage(stage); struct gl_context *ctx = rs->ctx; struct st_context *st = st_context(ctx); const GLfloat height = (GLfloat) ctx->DrawBuffer->Height; const GLuint *outputMapping = st->vertex_result_to_slot; const GLfloat *pos; GLuint i; /* if we get here, we didn't get clipped */ ctx->Current.RasterPosValid = GL_TRUE; /* update raster pos */ pos = prim->v[0]->data[0]; ctx->Current.RasterPos[0] = pos[0]; if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) ctx->Current.RasterPos[1] = height - pos[1]; /* invert Y */ else ctx->Current.RasterPos[1] = pos[1]; ctx->Current.RasterPos[2] = pos[2]; ctx->Current.RasterPos[3] = pos[3]; /* update other raster attribs */ update_attrib(ctx, outputMapping, prim->v[0], ctx->Current.RasterColor, VARYING_SLOT_COL0, VERT_ATTRIB_COLOR0); update_attrib(ctx, outputMapping, prim->v[0], ctx->Current.RasterSecondaryColor, VARYING_SLOT_COL1, VERT_ATTRIB_COLOR1); for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { update_attrib(ctx, outputMapping, prim->v[0], ctx->Current.RasterTexCoords[i], VARYING_SLOT_TEX0 + i, VERT_ATTRIB_TEX0 + i); } if (ctx->RenderMode == GL_SELECT) { _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] ); } }
static void st_RasterPos(struct gl_context *ctx, const GLfloat v[4]) { struct st_context *st = st_context(ctx); struct draw_context *draw = st->draw; struct rastpos_stage *rs; if (st->rastpos_stage) { /* get rastpos stage info */ rs = rastpos_stage(st->rastpos_stage); } else { /* create rastpos draw stage */ rs = new_draw_rastpos_stage(ctx, draw); st->rastpos_stage = &rs->stage; } /* plug our rastpos stage into the draw module */ draw_set_rasterize_stage(st->draw, st->rastpos_stage); /* make sure everything's up to date */ st_validate_state(st); /* This will get set only if rastpos_point(), above, gets called */ ctx->Current.RasterPosValid = GL_FALSE; /* All vertex attribs but position were previously initialized above. * Just plug in position pointer now. */ rs->array[0].Ptr = (GLubyte *) v; /* draw the point */ st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, GL_TRUE, 0, 1, NULL); /* restore draw's rasterization stage depending on rendermode */ if (ctx->RenderMode == GL_FEEDBACK) { draw_set_rasterize_stage(draw, st->feedback_stage); } else if (ctx->RenderMode == GL_SELECT) { draw_set_rasterize_stage(draw, st->selection_stage); } }