From 3be135f0000515f677c3ca927034caa2fc669e2e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 17 Jan 2000 15:40:43 +0000 Subject: Z values were wrong in selection mode (Holger Waechtler), misc clean-up --- src/mesa/main/feedback.c | 54 ++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'src/mesa/main/feedback.c') diff --git a/src/mesa/main/feedback.c b/src/mesa/main/feedback.c index c2a52aaa53..2b6ff083b8 100644 --- a/src/mesa/main/feedback.c +++ b/src/mesa/main/feedback.c @@ -1,10 +1,10 @@ -/* $Id: feedback.c,v 1.6 1999/11/11 01:22:26 brianp Exp $ */ +/* $Id: feedback.c,v 1.7 2000/01/17 15:40:43 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -170,19 +170,20 @@ static void gl_do_feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv ) win[2] = VB->Win.data[v][2] / DEPTH_SCALE; win[3] = 1.0 / VB->Win.data[v][3]; - if (ctx->Light.ShadeModel==GL_SMOOTH) pv = v; + 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) - { + 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 { + } + else { ASSIGN_4V(tc, 0,0,0,1); COPY_SZ_4V(tc, VB->TexCoordPtr[texUnit]->size, @@ -232,11 +233,12 @@ void gl_feedback_points( GLcontext *ctx, GLuint first, GLuint last ) struct vertex_buffer *VB = ctx->VB; GLuint i; - for (i=first;i<=last;i++) + for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POINT_TOKEN ); gl_do_feedback_vertex( ctx, i, i ); } + } } @@ -294,9 +296,9 @@ void gl_select_triangle( GLcontext *ctx, struct vertex_buffer *VB = ctx->VB; if (gl_cull_triangle( ctx, v0, v1, v2, 0 )) { - gl_update_hitflag( ctx, VB->Win.data[v0][3] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v1][3] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v2][3] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win.data[v2][2] / DEPTH_SCALE ); } } @@ -306,18 +308,21 @@ void gl_select_line( GLcontext *ctx, { struct vertex_buffer *VB = ctx->VB; - gl_update_hitflag( ctx, VB->Win.data[v0][3] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v1][3] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE ); + gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE ); } + void gl_select_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; GLuint i; - for (i=first;i<=last;i++) - if (VB->ClipMask[i]==0) - gl_update_hitflag( ctx, VB->Win.data[i][3] / DEPTH_SCALE); + for (i=first;i<=last;i++) { + if (VB->ClipMask[i]==0) { + gl_update_hitflag( ctx, VB->Win.data[i][2] / DEPTH_SCALE); + } + } } @@ -336,7 +341,7 @@ static void write_hit_record( GLcontext *ctx ) WRITE_RECORD( ctx, ctx->Select.NameStackDepth ); WRITE_RECORD( ctx, zmin ); WRITE_RECORD( ctx, zmax ); - for (i=0;iSelect.NameStackDepth;i++) { + for (i = 0; i < ctx->Select.NameStackDepth; i++) { WRITE_RECORD( ctx, ctx->Select.NameStack[i] ); } @@ -354,7 +359,7 @@ _mesa_InitNames( void ) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glInitNames"); /* Record the hit before the HitFlag is wiped out again. */ - if (ctx->RenderMode==GL_SELECT) { + if (ctx->RenderMode == GL_SELECT) { if (ctx->Select.HitFlag) { write_hit_record( ctx ); } @@ -372,17 +377,17 @@ _mesa_LoadName( GLuint name ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLoadName"); - if (ctx->RenderMode!=GL_SELECT) { + if (ctx->RenderMode != GL_SELECT) { return; } - if (ctx->Select.NameStackDepth==0) { + if (ctx->Select.NameStackDepth == 0) { gl_error( ctx, GL_INVALID_OPERATION, "glLoadName" ); return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } - if (ctx->Select.NameStackDepthSelect.NameStackDepth < MAX_NAME_STACK_DEPTH) { ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name; } else { @@ -396,13 +401,13 @@ _mesa_PushName( GLuint name ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushName"); - if (ctx->RenderMode!=GL_SELECT) { + if (ctx->RenderMode != GL_SELECT) { return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } - if (ctx->Select.NameStackDepthSelect.NameStackDepth < MAX_NAME_STACK_DEPTH) { ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name; } else { @@ -417,13 +422,13 @@ _mesa_PopName( void ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopName"); - if (ctx->RenderMode!=GL_SELECT) { + if (ctx->RenderMode != GL_SELECT) { return; } if (ctx->Select.HitFlag) { write_hit_record( ctx ); } - if (ctx->Select.NameStackDepth>0) { + if (ctx->Select.NameStackDepth > 0) { ctx->Select.NameStackDepth--; } else { @@ -514,7 +519,6 @@ _mesa_RenderMode( GLenum mode ) return 0; } - ctx->RenderMode = mode; ctx->NewState |= NEW_ALL; -- cgit v1.2.3