st_cb_feedback.c File Reference

Include dependency graph for st_cb_feedback.c:

Go to the source code of this file.

Data Structures

struct  feedback_stage
 GL_SELECT and GL_FEEDBACK render modes. More...

Functions

static struct feedback_stagefeedback_stage (struct draw_stage *stage)
static void feedback_vertex (GLcontext *ctx, const struct draw_context *draw, const struct vertex_header *v)
static void feedback_tri (struct draw_stage *stage, struct prim_header *prim)
static void feedback_line (struct draw_stage *stage, struct prim_header *prim)
static void feedback_point (struct draw_stage *stage, struct prim_header *prim)
static void feedback_flush (struct draw_stage *stage, unsigned flags)
static void feedback_reset_stipple_counter (struct draw_stage *stage)
static void feedback_destroy (struct draw_stage *stage)
static struct draw_stagedraw_glfeedback_stage (GLcontext *ctx, struct draw_context *draw)
 Create GL feedback drawing stage.
static void select_tri (struct draw_stage *stage, struct prim_header *prim)
static void select_line (struct draw_stage *stage, struct prim_header *prim)
static void select_point (struct draw_stage *stage, struct prim_header *prim)
static void select_flush (struct draw_stage *stage, unsigned flags)
static void select_reset_stipple_counter (struct draw_stage *stage)
static void select_destroy (struct draw_stage *stage)
static struct draw_stagedraw_glselect_stage (GLcontext *ctx, struct draw_context *draw)
 Create GL selection mode drawing stage.
static void st_RenderMode (GLcontext *ctx, GLenum newMode)
void st_init_feedback_functions (struct dd_function_table *functions)


Function Documentation

static struct draw_stage* draw_glfeedback_stage ( GLcontext *  ctx,
struct draw_context draw 
) [static, read]

Create GL feedback drawing stage.

Definition at line 186 of file st_cb_feedback.c.

References CALLOC_STRUCT, feedback_stage::ctx, draw_stage::destroy, draw_stage::draw, feedback_destroy(), feedback_flush(), feedback_line(), feedback_point(), feedback_reset_stipple_counter(), feedback_tri(), draw_stage::flush, draw_stage::line, draw_stage::next, draw_stage::point, draw_stage::reset_stipple_counter, feedback_stage::stage, and draw_stage::tri.

00187 {
00188    struct feedback_stage *fs = CALLOC_STRUCT(feedback_stage);
00189 
00190    fs->stage.draw = draw;
00191    fs->stage.next = NULL;
00192    fs->stage.point = feedback_point;
00193    fs->stage.line = feedback_line;
00194    fs->stage.tri = feedback_tri;
00195    fs->stage.flush = feedback_flush;
00196    fs->stage.reset_stipple_counter = feedback_reset_stipple_counter;
00197    fs->stage.destroy = feedback_destroy;
00198    fs->ctx = ctx;
00199 
00200    return &fs->stage;
00201 }

static struct draw_stage* draw_glselect_stage ( GLcontext *  ctx,
struct draw_context draw 
) [static, read]

Create GL selection mode drawing stage.

Definition at line 259 of file st_cb_feedback.c.

References CALLOC_STRUCT, feedback_stage::ctx, draw_stage::destroy, draw_stage::draw, draw_stage::flush, draw_stage::line, draw_stage::next, draw_stage::point, draw_stage::reset_stipple_counter, select_destroy(), select_flush(), select_line(), select_point(), select_reset_stipple_counter(), select_tri(), feedback_stage::stage, and draw_stage::tri.

00260 {
00261    struct feedback_stage *fs = CALLOC_STRUCT(feedback_stage);
00262 
00263    fs->stage.draw = draw;
00264    fs->stage.next = NULL;
00265    fs->stage.point = select_point;
00266    fs->stage.line = select_line;
00267    fs->stage.tri = select_tri;
00268    fs->stage.flush = select_flush;
00269    fs->stage.reset_stipple_counter = select_reset_stipple_counter;
00270    fs->stage.destroy = select_destroy;
00271    fs->ctx = ctx;
00272 
00273    return &fs->stage;
00274 }

static void feedback_destroy ( struct draw_stage stage  )  [static]

Definition at line 177 of file st_cb_feedback.c.

00178 {
00179    /* no-op */
00180 }

static void feedback_flush ( struct draw_stage stage,
unsigned  flags 
) [static]

Definition at line 162 of file st_cb_feedback.c.

00163 {
00164    /* no-op */
00165 }

static void feedback_line ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 135 of file st_cb_feedback.c.

References feedback_stage::ctx, draw_stage::draw, draw, feedback_stage(), feedback_vertex(), feedback_stage::reset_stipple_counter, and prim_header::v.

00136 {
00137    struct feedback_stage *fs = feedback_stage(stage);
00138    struct draw_context *draw = stage->draw;
00139    if (fs->reset_stipple_counter) {
00140       FEEDBACK_TOKEN(fs->ctx, (GLfloat) GL_LINE_RESET_TOKEN);
00141       fs->reset_stipple_counter = GL_FALSE;
00142    }
00143    else {
00144       FEEDBACK_TOKEN(fs->ctx, (GLfloat) GL_LINE_TOKEN);
00145    }
00146    feedback_vertex(fs->ctx, draw, prim->v[0]);
00147    feedback_vertex(fs->ctx, draw, prim->v[1]);
00148 }

static void feedback_point ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 152 of file st_cb_feedback.c.

References feedback_stage::ctx, draw_stage::draw, draw, feedback_stage(), feedback_vertex(), and prim_header::v.

00153 {
00154    struct feedback_stage *fs = feedback_stage(stage);
00155    struct draw_context *draw = stage->draw;
00156    FEEDBACK_TOKEN(fs->ctx, (GLfloat) GL_POINT_TOKEN);
00157    feedback_vertex(fs->ctx, draw, prim->v[0]);
00158 }

static void feedback_reset_stipple_counter ( struct draw_stage stage  )  [static]

Definition at line 169 of file st_cb_feedback.c.

References feedback_stage(), and feedback_stage::reset_stipple_counter.

00170 {
00171    struct feedback_stage *fs = feedback_stage(stage);
00172    fs->reset_stipple_counter = GL_TRUE;
00173 }

static struct feedback_stage* feedback_stage ( struct draw_stage stage  )  [static, read]

Definition at line 78 of file st_cb_feedback.c.

00079 {
00080    return (struct feedback_stage *)stage;
00081 }

static void feedback_tri ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 122 of file st_cb_feedback.c.

References feedback_stage::ctx, draw_stage::draw, draw, feedback_stage(), feedback_vertex(), and prim_header::v.

00123 {
00124    struct feedback_stage *fs = feedback_stage(stage);
00125    struct draw_context *draw = stage->draw;
00126    FEEDBACK_TOKEN(fs->ctx, (GLfloat) GL_POLYGON_TOKEN);
00127    FEEDBACK_TOKEN(fs->ctx, (GLfloat) 3); /* three vertices */
00128    feedback_vertex(fs->ctx, draw, prim->v[0]);
00129    feedback_vertex(fs->ctx, draw, prim->v[1]);
00130    feedback_vertex(fs->ctx, draw, prim->v[2]);
00131 }

static void feedback_vertex ( GLcontext *  ctx,
const struct draw_context draw,
const struct vertex_header v 
) [static]

Definition at line 85 of file st_cb_feedback.c.

References vertex_header::data, and st_context::vertex_result_to_slot.

00087 {
00088    const struct st_context *st = ctx->st;
00089    GLfloat win[4];
00090    const GLfloat *color, *texcoord;
00091    const GLfloat ci = 0;
00092    GLuint slot;
00093 
00094    /* Recall that Y=0=Top of window for Gallium wincoords */
00095    win[0] = v->data[0][0];
00096    win[1] = ctx->DrawBuffer->Height - v->data[0][1];
00097    win[2] = v->data[0][2];
00098    win[3] = 1.0F / v->data[0][3];
00099 
00100    /* XXX
00101     * When we compute vertex layout, save info about position of the
00102     * color and texcoord attribs to use here.
00103     */
00104 
00105    slot = st->vertex_result_to_slot[VERT_RESULT_COL0];
00106    if (slot != ~0U)
00107       color = v->data[slot];
00108    else
00109       color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
00110 
00111    slot = st->vertex_result_to_slot[VERT_RESULT_TEX0];
00112    if (slot != ~0U)
00113       texcoord = v->data[slot];
00114    else
00115       texcoord = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
00116 
00117    _mesa_feedback_vertex(ctx, win, color, ci, texcoord);
00118 }

static void select_destroy ( struct draw_stage stage  )  [static]

Definition at line 249 of file st_cb_feedback.c.

00250 {
00251    /* no-op */
00252 }

static void select_flush ( struct draw_stage stage,
unsigned  flags 
) [static]

Definition at line 236 of file st_cb_feedback.c.

00237 {
00238    /* no-op */
00239 }

static void select_line ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 219 of file st_cb_feedback.c.

References feedback_stage::ctx, vertex_header::data, feedback_stage(), and prim_header::v.

00220 {
00221    struct feedback_stage *fs = feedback_stage(stage);
00222    _mesa_update_hitflag( fs->ctx, prim->v[0]->data[0][2] );
00223    _mesa_update_hitflag( fs->ctx, prim->v[1]->data[0][2] );
00224 }

static void select_point ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 228 of file st_cb_feedback.c.

References feedback_stage::ctx, vertex_header::data, feedback_stage(), and prim_header::v.

00229 {
00230    struct feedback_stage *fs = feedback_stage(stage);
00231    _mesa_update_hitflag( fs->ctx, prim->v[0]->data[0][2] );
00232 }

static void select_reset_stipple_counter ( struct draw_stage stage  )  [static]

Definition at line 243 of file st_cb_feedback.c.

00244 {
00245    /* no-op */
00246 }

static void select_tri ( struct draw_stage stage,
struct prim_header prim 
) [static]

Definition at line 210 of file st_cb_feedback.c.

References feedback_stage::ctx, vertex_header::data, feedback_stage(), and prim_header::v.

00211 {
00212    struct feedback_stage *fs = feedback_stage(stage);
00213    _mesa_update_hitflag( fs->ctx, prim->v[0]->data[0][2] );
00214    _mesa_update_hitflag( fs->ctx, prim->v[1]->data[0][2] );
00215    _mesa_update_hitflag( fs->ctx, prim->v[2]->data[0][2] );
00216 }

void st_init_feedback_functions ( struct dd_function_table *  functions  ) 

Definition at line 307 of file st_cb_feedback.c.

References st_RenderMode().

00308 {
00309    functions->RenderMode = st_RenderMode;
00310 }

static void st_RenderMode ( GLcontext *  ctx,
GLenum  newMode 
) [static]

Definition at line 278 of file st_cb_feedback.c.

References st_context::dirty, st_context::draw, draw, draw_glfeedback_stage(), draw_glselect_stage(), draw_set_rasterize_stage(), st_context::feedback_stage, st_context::selection_stage, st_state_flags::st, st_draw_vbo(), st_feedback_draw_vbo(), and ST_NEW_VERTEX_PROGRAM.

00279 {
00280    struct st_context *st = ctx->st;
00281    struct draw_context *draw = st->draw;
00282 
00283    if (newMode == GL_RENDER) {
00284       /* restore normal VBO draw function */
00285       vbo_set_draw_func(ctx, st_draw_vbo);
00286    }
00287    else if (newMode == GL_SELECT) {
00288       if (!st->selection_stage)
00289          st->selection_stage = draw_glselect_stage(ctx, draw);
00290       draw_set_rasterize_stage(draw, st->selection_stage);
00291       /* Plug in new vbo draw function */
00292       vbo_set_draw_func(ctx, st_feedback_draw_vbo);
00293    }
00294    else {
00295       if (!st->feedback_stage)
00296          st->feedback_stage = draw_glfeedback_stage(ctx, draw);
00297       draw_set_rasterize_stage(draw, st->feedback_stage);
00298       /* Plug in new vbo draw function */
00299       vbo_set_draw_func(ctx, st_feedback_draw_vbo);
00300       /* need to generate/use a vertex program that emits pos/color/tex */
00301       st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
00302    }
00303 }


Generated on Tue Sep 29 06:25:53 2009 for Gallium3D by  doxygen 1.5.4