st/mesa: Include mfeatures.h in files that perform feature tests.
[mesa.git] / src / mesa / state_tracker / st_cb_rasterpos.c
index d82b2a2035f4a62f4c4dfbe4935f4ee9157c8977..32d465c5cceee5399c67054120409493337855c6 100644 (file)
 
 #include "main/imports.h"
 #include "main/macros.h"
+#include "main/mfeatures.h"
 #include "main/feedback.h"
 
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_draw.h"
 #include "st_cb_rasterpos.h"
-#include "st_draw.h"
 #include "draw/draw_context.h"
 #include "draw/draw_pipe.h"
-#include "shader/prog_instruction.h"
 #include "vbo/vbo.h"
 
 
+#if FEATURE_rastpos
 
 /**
  * Our special drawing pipeline stage (replaces rasterization).
@@ -58,7 +58,7 @@
 struct rastpos_stage
 {
    struct draw_stage stage;   /**< Base class */
-   GLcontext *ctx;            /**< Rendering context */
+   struct gl_context *ctx;            /**< Rendering context */
 
    /* vertex attrib info we can setup once and re-use */
    struct gl_client_array array[VERT_ATTRIB_MAX];
@@ -102,7 +102,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim )
 static void
 rastpos_destroy(struct draw_stage *stage)
 {
-   _mesa_free(stage);
+   free(stage);
 }
 
 
@@ -111,7 +111,7 @@ rastpos_destroy(struct draw_stage *stage)
  * else copy the current attrib.
  */
 static void
-update_attrib(GLcontext *ctx, const GLuint *outputMapping,
+update_attrib(struct gl_context *ctx, const GLuint *outputMapping,
               const struct vertex_header *vert,
               GLfloat *dest,
               GLuint result, GLuint defaultAttrib)
@@ -133,8 +133,8 @@ static void
 rastpos_point(struct draw_stage *stage, struct prim_header *prim)
 {
    struct rastpos_stage *rs = rastpos_stage(stage);
-   GLcontext *ctx = rs->ctx;
-   struct st_context *st = ctx->st;
+   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;
@@ -178,7 +178,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
  * Create rasterpos "drawing" stage.
  */
 static struct rastpos_stage *
-new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
+new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
 {
    struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
    GLuint i;
@@ -220,9 +220,9 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
 
 
 static void
-st_RasterPos(GLcontext *ctx, const GLfloat v[4])
+st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
 {
-   struct st_context *st = ctx->st;
+   struct st_context *st = st_context(ctx);
    struct draw_context *draw = st->draw;
    struct rastpos_stage *rs;
 
@@ -240,7 +240,7 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4])
    draw_set_rasterize_stage(st->draw, st->rastpos_stage);
 
    /* make sure everything's up to date */
-   st_validate_state(ctx->st);
+   st_validate_state(st);
 
    /* This will get set only if rastpos_point(), above, gets called */
    ctx->Current.RasterPosValid = GL_FALSE;
@@ -252,6 +252,14 @@ st_RasterPos(GLcontext *ctx, const GLfloat v[4])
 
    /* draw the point */
    st_feedback_draw_vbo(ctx, rs->arrays, &rs->prim, 1, NULL, GL_TRUE, 0, 1);
+
+   /* 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);
+   }
 }
 
 
@@ -260,3 +268,5 @@ void st_init_rasterpos_functions(struct dd_function_table *functions)
 {
    functions->RasterPos = st_RasterPos;
 }
+
+#endif /* FEATURE_rastpos */