Merge branch 'mesa_7_5_branch'
[mesa.git] / src / mesa / state_tracker / st_cb_rasterpos.c
index 3b30c2a61b582d7f3658d3655a893d9dbd0fc76b..3bcccd0df46dc16da818a28e55f2317e04d2cbf2 100644 (file)
@@ -102,7 +102,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim )
 static void
 rastpos_destroy(struct draw_stage *stage)
 {
-   free(stage);
+   _mesa_free(stage);
 }
 
 
@@ -146,7 +146,10 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
    /* update raster pos */
    pos = prim->v[0]->data[0];
    ctx->Current.RasterPos[0] = pos[0];
-   ctx->Current.RasterPos[1] = height - pos[1]; /* invert Y */
+   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];
 
@@ -159,7 +162,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
                  ctx->Current.RasterSecondaryColor,
                  VERT_RESULT_COL1, VERT_ATTRIB_COLOR1);
 
-   for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
       update_attrib(ctx, outputMapping, prim->v[0],
                     ctx->Current.RasterTexCoords[i],
                     VERT_RESULT_TEX0 + i, VERT_ATTRIB_TEX0 + i);
@@ -177,7 +180,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
 static struct rastpos_stage *
 new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
 {
-   struct rastpos_stage *rs = CALLOC_STRUCT(rastpos_stage);
+   struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
    GLuint i;
 
    rs->stage.draw = draw;
@@ -191,9 +194,10 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
    rs->stage.destroy = rastpos_destroy;
    rs->ctx = ctx;
 
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+   for (i = 0; i < Elements(rs->array); i++) {
       rs->array[i].Size = 4;
       rs->array[i].Type = GL_FLOAT;
+      rs->array[i].Format = GL_RGBA;
       rs->array[i].Stride = 0;
       rs->array[i].StrideB = 0;
       rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];