-/* $Id: varray.c,v 1.16 1999/11/18 23:56:04 brianp Exp $ */
+/* $Id: varray.c,v 1.21 2000/02/25 03:55:40 keithw Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.1
*
- * 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"),
#include "macros.h"
#include "mmath.h"
#include "pipeline.h"
+#include "state.h"
#include "texstate.h"
#include "translate.h"
#include "types.h"
}
+#if 0
/* Called only from gl_DrawElements
*/
-void gl_CVAEltPointer( GLcontext *ctx, GLenum type, const GLvoid *ptr )
+static void gl_CVAEltPointer( GLcontext *ctx, GLenum type, const GLvoid *ptr )
{
switch (type) {
case GL_UNSIGNED_BYTE:
ctx->CVA.EltFunc = gl_trans_1ui_tab[TYPE_IDX(type)];
ctx->Array.NewArrayState |= VERT_ELT; /* ??? */
}
-
+#endif
/* KW: Batch function to exec all the array elements in the input
}
-void gl_ArrayElement( GLcontext *CC, GLint i )
+static void
+gl_ArrayElement( GLcontext *CC, GLint i )
{
struct immediate *im = CC->input;
ARRAY_ELT( im, i );
* rendering to keep it turned on.
*/
relock = ctx->CompileCVAFlag;
- ctx->CompileCVAFlag = 0;
- if (!elt->pipeline_valid || relock)
+ if (relock) {
+ ctx->CompileCVAFlag = 0;
+ elt->pipeline_valid = 0;
+ }
+
+ if (!elt->pipeline_valid)
gl_build_immediate_pipeline( ctx );
required = elt->inputs;
fallback = (elt->inputs & ~ctx->Array.Summary);
+ /* The translate function doesn't do anything about size. It
+ * just ensures that type and stride come out right.
+ */
+ IM->v.Obj.size = ctx->Array.Vertex.Size;
+
if (required & VERT_RGBA)
{
Color = &ctx->Array.Color;
VB->Material = IM->Material;
VB->BoundsPtr = 0;
- IM->v.Obj.size = ctx->Array.Vertex.Size; /* added by Andree Borrmann */
-
while (remaining > 0) {
GLint vbspace = VB_MAX - VB_START;
GLuint count, n;
VB->NextPrimitive[VB->CopyStart] = VB->Count;
VB->Primitive[VB->CopyStart] = mode;
+ ctx->Array.Flag[count] |= VERT_END_VB;
/* Transform and render.
*/
gl_run_pipeline( VB );
- gl_flush_vb( ctx, "DrawArrays" ); /* added by Andree Borrmann */
gl_reset_vb( VB );
ctx->Array.Flag[count] = ctx->Array.Flags;
remaining -= n;
}
- ctx->CompileCVAFlag = relock;
+ gl_reset_input( ctx );
+
+ if (relock) {
+ ctx->CompileCVAFlag = relock;
+ elt->pipeline_valid = 0;
+ }
}
else if (ctx->Array.Vertex.Enabled)
{
return;
}
- if (mode > GL_POLYGON) {
+ if (mode < 0 || mode > GL_POLYGON) {
gl_error( ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return;
}
return;
}
+#if 0
+ /*
+ * XXX something in locked arrays is broken! If start = 0,
+ * end = 1 and count = 2 we'll take the LockArrays path and
+ * get incorrect results. See Scott McMillan's bug of 3 Jan 2000.
+ * For now, don't use locked arrays.
+ */
if (!ctx->Array.LockCount && 2*count > (GLint) 3*(end-start)) {
glLockArraysEXT( start, end );
glDrawElements( mode, count, type, indices );
} else {
glDrawElements( mode, count, type, indices );
}
+#else
+ glDrawElements( mode, count, type, indices );
+#endif
}