Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygent_vb_points.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.0 00004 * 00005 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 * 00024 * Authors: 00025 * Brian Paul 00026 */ 00027 00028 #include "main/mtypes.h" 00029 #include "main/imports.h" 00030 #include "t_context.h" 00031 #include "t_pipeline.h" 00032 00033 00034 struct point_stage_data { 00035 GLvector4f PointSize; 00036 }; 00037 00038 #define POINT_STAGE_DATA(stage) ((struct point_stage_data *)stage->privatePtr) 00039 00040 00047 static GLboolean 00048 run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) 00049 { 00050 if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) { 00051 struct point_stage_data *store = POINT_STAGE_DATA(stage); 00052 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 00053 const GLfloat *eyeCoord = (GLfloat *) VB->EyePtr->data + 2; 00054 const GLint eyeCoordStride = VB->EyePtr->stride / sizeof(GLfloat); 00055 const GLfloat p0 = ctx->Point.Params[0]; 00056 const GLfloat p1 = ctx->Point.Params[1]; 00057 const GLfloat p2 = ctx->Point.Params[2]; 00058 const GLfloat pointSize = ctx->Point.Size; 00059 GLfloat (*size)[4] = store->PointSize.data; 00060 GLuint i; 00061 00062 for (i = 0; i < VB->Count; i++) { 00063 const GLfloat dist = FABSF(*eyeCoord); 00064 const GLfloat q = p0 + dist * (p1 + dist * p2); 00065 const GLfloat atten = (q != 0.0) ? SQRTF(1.0 / q) : 1.0; 00066 size[i][0] = pointSize * atten; /* clamping done in rasterization */ 00067 eyeCoord += eyeCoordStride; 00068 } 00069 00070 VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->PointSize; 00071 } 00072 00073 return GL_TRUE; 00074 } 00075 00076 00077 static GLboolean 00078 alloc_point_data(GLcontext *ctx, struct tnl_pipeline_stage *stage) 00079 { 00080 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; 00081 struct point_stage_data *store; 00082 stage->privatePtr = _mesa_malloc(sizeof(*store)); 00083 store = POINT_STAGE_DATA(stage); 00084 if (!store) 00085 return GL_FALSE; 00086 00087 _mesa_vector4f_alloc( &store->PointSize, 0, VB->Size, 32 ); 00088 return GL_TRUE; 00089 } 00090 00091 00092 static void 00093 free_point_data(struct tnl_pipeline_stage *stage) 00094 { 00095 struct point_stage_data *store = POINT_STAGE_DATA(stage); 00096 if (store) { 00097 _mesa_vector4f_free( &store->PointSize ); 00098 _mesa_free( store ); 00099 stage->privatePtr = NULL; 00100 } 00101 } 00102 00103 00104 const struct tnl_pipeline_stage _tnl_point_attenuation_stage = 00105 { 00106 "point size attenuation", /* name */ 00107 NULL, /* stage private data */ 00108 alloc_point_data, /* alloc data */ 00109 free_point_data, /* destructor */ 00110 NULL, 00111 run_point_stage /* run */ 00112 }; Generated on Sat May 26 2012 04:19:35 for ReactOS by
1.7.6.1
|