summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_draw.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-11-02 09:48:30 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-11-02 09:48:30 +0000
commit9827dc8bea422b940f1efcfbd1c0d76f8bbca844 (patch)
tree9d77a4b6a3e81f3e9db5d8879e564c1455a3b10c /src/mesa/tnl/t_draw.c
parentc22f8a7787bd5260135a20a0c2ae8b743228497b (diff)
Respect array->Normalized flag.
Import edgeflag attribute to array of GLbooleans as expected by downstream code.
Diffstat (limited to 'src/mesa/tnl/t_draw.c')
-rw-r--r--src/mesa/tnl/t_draw.c70
1 files changed, 55 insertions, 15 deletions
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index be811ef628..c84a10856e 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -39,17 +39,6 @@
#include "t_vertex.h"
#include "tnl.h"
-#define CONVERT( TYPE, MACRO ) do { \
- GLuint i, j; \
- for (i = 0; i < count; i++) { \
- const TYPE *in = (TYPE *)ptr; \
- for (j = 0; j < sz; j++) { \
- *fptr++ = MACRO(*in); \
- in++; \
- } \
- ptr += input->StrideB; \
- } \
-} while (0)
static GLfloat *get_space(GLcontext *ctx, GLuint bytes)
@@ -72,6 +61,34 @@ static void free_space(GLcontext *ctx)
}
+/* Convert the incoming array to GLfloats. Understands the
+ * array->Normalized flag and selects the correct conversion method.
+ */
+#define CONVERT( TYPE, MACRO ) do { \
+ GLuint i, j; \
+ if (input->Normalized) { \
+ for (i = 0; i < count; i++) { \
+ const TYPE *in = (TYPE *)ptr; \
+ for (j = 0; j < sz; j++) { \
+ *fptr++ = MACRO(*in); \
+ in++; \
+ } \
+ ptr += input->StrideB; \
+ } \
+ } else { \
+ for (i = 0; i < count; i++) { \
+ const TYPE *in = (TYPE *)ptr; \
+ for (j = 0; j < sz; j++) { \
+ *fptr++ = (GLfloat)(*in); \
+ in++; \
+ } \
+ ptr += input->StrideB; \
+ } \
+ } \
+} while (0)
+
+
+
/* Adjust pointer to point at first requested element, convert to
* floating point, populate VB->AttribPtr[].
*/
@@ -140,6 +157,27 @@ static void _tnl_import_array( GLcontext *ctx,
VB->AttribPtr[attrib]->storage = NULL;
}
+#define CLIPVERTS ((6 + MAX_CLIP_PLANES) * 2)
+
+
+static GLboolean *_tnl_import_edgeflag( GLcontext *ctx,
+ const GLvector4f *input,
+ GLuint count)
+{
+ const GLubyte *ptr = (const GLubyte *)input->data;
+ const GLuint stride = input->stride;
+ GLboolean *space = (GLboolean *)get_space(ctx, count + CLIPVERTS);
+ GLboolean *bptr = space;
+ GLuint i;
+
+ for (i = 0; i < count; i++) {
+ *bptr++ = ((GLfloat *)ptr)[0] == 1.0;
+ ptr += stride;
+ }
+
+ return space;
+}
+
static void bind_inputs( GLcontext *ctx,
const struct gl_client_array *inputs[],
@@ -200,15 +238,17 @@ static void bind_inputs( GLcontext *ctx,
VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
}
-#if 0
- /* odd-ball vertex attribute
+ /* Clipping and drawing code still requires this to be a packed
+ * array of ubytes which can be written into. TODO: Fix and
+ * remove.
*/
if (ctx->Polygon.FrontMode != GL_FILL ||
ctx->Polygon.BackMode != GL_FILL)
{
- VB->EdgeFlag = _tnl_import_edgeflag( ctx, VB->AttribPtr[_TNL_ATTRIB_EDGEFLAG]);
+ VB->EdgeFlag = _tnl_import_edgeflag( ctx,
+ VB->AttribPtr[_TNL_ATTRIB_EDGEFLAG],
+ VB->Count );
}
-#endif
}