/* * Put points in feedback buffer. */ static void feedback_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; GLuint i; GLfloat invRedScale = ctx->Visual->InvRedScale; GLfloat invGreenScale = ctx->Visual->InvGreenScale; GLfloat invBlueScale = ctx->Visual->InvBlueScale; GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; for (i=first;i<=last;i++) { if (VB->Unclipped[i]) { GLfloat x, y, z, w, invq; GLfloat color[4], texcoord[4]; x = VB->Win[i][0]; y = VB->Win[i][1]; z = VB->Win[i][2] / DEPTH_SCALE; w = VB->Clip[i][3]; /* convert color from integer back to a float in [0,1] */ if (ctx->Light.ShadeModel==GL_SMOOTH) { /* smooth shading - colors are in fixed point */ color[0] = FixedToFloat(VB->Color[i][0]) * invRedScale; color[1] = FixedToFloat(VB->Color[i][1]) * invGreenScale; color[2] = FixedToFloat(VB->Color[i][2]) * invBlueScale; color[3] = FixedToFloat(VB->Color[i][3]) * invAlphaScale; } else { /* flat shading - colors are integers */ color[0] = VB->Color[i][0] * invRedScale; color[1] = VB->Color[i][1] * invGreenScale; color[2] = VB->Color[i][2] * invBlueScale; color[3] = VB->Color[i][3] * invAlphaScale; } invq = 1.0F / VB->TexCoord[i][3]; texcoord[0] = VB->TexCoord[i][0] * invq; texcoord[1] = VB->TexCoord[i][1] * invq; texcoord[2] = VB->TexCoord[i][2] * invq; texcoord[3] = VB->TexCoord[i][3]; FEEDBACK_TOKEN( ctx, (GLfloat) GL_POINT_TOKEN ); gl_feedback_vertex( ctx, x, y, z, w, color, (GLfloat) VB->Index[i], texcoord ); } } }
static void feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv ) { GLfloat win[4]; GLfloat color[4]; GLfloat tc[4]; GLuint texUnit = ctx->Texture.CurrentTransformUnit; const struct vertex_buffer *VB = ctx->VB; GLuint index; win[0] = VB->Win.data[v][0]; win[1] = VB->Win.data[v][1]; win[2] = VB->Win.data[v][2] / ctx->Visual->DepthMaxF; win[3] = 1.0 / VB->Win.data[v][3]; if (ctx->Light.ShadeModel == GL_SMOOTH) pv = v; UBYTE_RGBA_TO_FLOAT_RGBA( color, VB->ColorPtr->data[pv] ); if (VB->TexCoordPtr[texUnit]->size == 4 && VB->TexCoordPtr[texUnit]->data[v][3] != 0.0) { GLfloat invq = 1.0F / VB->TexCoordPtr[texUnit]->data[v][3]; tc[0] = VB->TexCoordPtr[texUnit]->data[v][0] * invq; tc[1] = VB->TexCoordPtr[texUnit]->data[v][1] * invq; tc[2] = VB->TexCoordPtr[texUnit]->data[v][2] * invq; tc[3] = VB->TexCoordPtr[texUnit]->data[v][3]; } else { ASSIGN_4V(tc, 0,0,0,1); COPY_SZ_4V(tc, VB->TexCoordPtr[texUnit]->size, VB->TexCoordPtr[texUnit]->data[v]); } if (VB->IndexPtr) index = VB->IndexPtr->data[v]; else index = 0; gl_feedback_vertex( ctx, win, color, index, tc ); }
static void feedback_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) { struct vertex_buffer *VB = ctx->VB; GLfloat x1, y1, z1, w1; GLfloat x2, y2, z2, w2; GLfloat tex1[4], tex2[4], invq; GLfloat invRedScale = ctx->Visual->InvRedScale; GLfloat invGreenScale = ctx->Visual->InvGreenScale; GLfloat invBlueScale = ctx->Visual->InvBlueScale; GLfloat invAlphaScale = ctx->Visual->InvAlphaScale; x1 = VB->Win[v1][0]; y1 = VB->Win[v1][1]; z1 = VB->Win[v1][2] / DEPTH_SCALE; w1 = VB->Clip[v1][3]; x2 = VB->Win[v2][0]; y2 = VB->Win[v2][1]; z2 = VB->Win[v2][2] / DEPTH_SCALE; w2 = VB->Clip[v2][3]; invq = 1.0F / VB->TexCoord[v1][3]; tex1[0] = VB->TexCoord[v1][0] * invq; tex1[1] = VB->TexCoord[v1][1] * invq; tex1[2] = VB->TexCoord[v1][2] * invq; tex1[3] = VB->TexCoord[v1][3]; invq = 1.0F / VB->TexCoord[v2][3]; tex2[0] = VB->TexCoord[v2][0] * invq; tex2[1] = VB->TexCoord[v2][1] * invq; tex2[2] = VB->TexCoord[v2][2] * invq; tex2[3] = VB->TexCoord[v2][3]; if (ctx->StippleCounter==0) { FEEDBACK_TOKEN( ctx, (GLfloat) GL_LINE_RESET_TOKEN ); } else { FEEDBACK_TOKEN( ctx, (GLfloat) GL_LINE_TOKEN ); } if (ctx->Light.ShadeModel==GL_FLAT) { GLfloat color[4]; /* convert color from integer to a float in [0,1] */ color[0] = (GLfloat) VB->Color[pv][0] * invRedScale; color[1] = (GLfloat) VB->Color[pv][1] * invGreenScale; color[2] = (GLfloat) VB->Color[pv][2] * invBlueScale; color[3] = (GLfloat) VB->Color[pv][3] * invAlphaScale; gl_feedback_vertex( ctx, x1,y1,z1,w1, color, (GLfloat) VB->Index[pv], tex1 ); gl_feedback_vertex( ctx, x2,y2,z2,w2, color, (GLfloat) VB->Index[pv], tex2 ); } else { GLfloat color[4]; /* convert color from fixed point to a float in [0,1] */ color[0] = FixedToFloat(VB->Color[v1][0]) * invRedScale; color[1] = FixedToFloat(VB->Color[v1][1]) * invGreenScale; color[2] = FixedToFloat(VB->Color[v1][2]) * invBlueScale; color[3] = FixedToFloat(VB->Color[v1][3]) * invAlphaScale; gl_feedback_vertex( ctx, x1,y1,z1,w1, color, (GLfloat) VB->Index[v1], tex1 ); /* convert color from fixed point to a float in [0,1] */ color[0] = FixedToFloat(VB->Color[v2][0]) * invRedScale; color[1] = FixedToFloat(VB->Color[v2][1]) * invGreenScale; color[2] = FixedToFloat(VB->Color[v2][2]) * invBlueScale; color[3] = FixedToFloat(VB->Color[v2][3]) * invAlphaScale; gl_feedback_vertex( ctx, x2,y2,z2,w2, color, (GLfloat) VB->Index[v2], tex2 ); } ctx->StippleCounter++; }