/* $Id: points.c,v 1.6 1997/03/08 02:04:27 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 2.2 * Copyright (C) 1995-1997 Brian Paul * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * $Log: points.c,v $ * Revision 1.6 1997/03/08 02:04:27 brianp * better implementation of feedback function * * Revision 1.5 1997/02/09 18:43:52 brianp * added GL_EXT_texture3D support * * Revision 1.4 1997/01/09 19:48:00 brianp * now call gl_texturing_enabled() * * Revision 1.3 1996/11/08 02:21:21 brianp * added null drawing function for GL_NO_RASTER * * Revision 1.2 1996/09/15 14:18:37 brianp * now use GLframebuffer and GLvisual * * Revision 1.1 1996/09/13 01:38:16 brianp * Initial revision * */ #include "context.h" #include "feedback.h" #include "dlist.h" #include "macros.h" #include "pb.h" #include "span.h" #include "texture.h" #include "types.h" #include "vb.h" /**********************************************************************/ /***** Rasterization *****/ /**********************************************************************/ /* * There are 3 pairs (RGBA, CI) of point rendering functions: * 1. simple: size=1 and no special rasterization functions (fastest) * 2. size1: size=1 and any rasterization functions * 3. general: any size and rasterization functions (slowest) * * All point rendering functions take the same two arguments: first and * last which specify that the points specified by VB[first] through * VB[last] are to be rendered. */ /* * 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 ); } } }