diff --git a/GL/draw.c b/GL/draw.c index 93976a1..6a4441a 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -1049,7 +1049,28 @@ GL_FORCE_INLINE void push(PolyHeader* header, GLboolean multiTextureHeader, Poly #define DEBUG_CLIPPING 0 + +static AlignedVector VERTEX_EXTRAS; +static SubmissionTarget SUBMISSION_TARGET; + + +void _glInitSubmissionTarget() { + SubmissionTarget* target = &SUBMISSION_TARGET; + + target->extras = NULL; + target->count = 0; + target->output = NULL; + target->header_offset = target->start_offset = 0; + + aligned_vector_init(&VERTEX_EXTRAS, sizeof(VertexExtra)); + target->extras = &VERTEX_EXTRAS; +} + + GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type, const GLvoid* indices) { + SubmissionTarget* const target = &SUBMISSION_TARGET; + AlignedVector* const extras = target->extras; + TRACE(); /* Do nothing if vertices aren't enabled */ @@ -1062,26 +1083,6 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL return; } - if(mode == GL_LINE_STRIP || mode == GL_LINES) { - fprintf(stderr, "Line drawing is currently unsupported\n"); - return; - } - - static SubmissionTarget* target = NULL; - static AlignedVector extras; - - /* Initialization of the target and extras */ - if(!target) { - target = (SubmissionTarget*) malloc(sizeof(SubmissionTarget)); - target->extras = NULL; - target->count = 0; - target->output = NULL; - target->header_offset = target->start_offset = 0; - - aligned_vector_init(&extras, sizeof(VertexExtra)); - target->extras = &extras; - } - /* Polygons are treated as triangle fans, the only time this would be a * problem is if we supported glPolygonMode(..., GL_LINE) but we don't. * We optimise the triangle and quad cases. @@ -1096,6 +1097,11 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL } } + if(mode == GL_LINE_STRIP || mode == GL_LINES) { + fprintf(stderr, "Line drawing is currently unsupported\n"); + return; + } + // We don't handle this any further, so just make sure we never pass it down */ gl_assert(mode != GL_POLYGON); @@ -1107,7 +1113,7 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL gl_assert(target->count); /* Make sure we have enough room for all the "extra" data */ - aligned_vector_resize(&extras, target->count); + aligned_vector_resize(extras, target->count); /* Make room for the vertices and header */ aligned_vector_extend(&target->output->vector, target->count + 1); diff --git a/GL/flush.c b/GL/flush.c index d443c06..11cf3f4 100644 --- a/GL/flush.c +++ b/GL/flush.c @@ -58,6 +58,7 @@ void APIENTRY glKosInitEx(GLdcConfig* config) { AUTOSORT_ENABLED = config->autosort_enabled; + _glInitSubmissionTarget(); _glInitMatrices(); _glInitAttributePointers(); _glInitContext(); diff --git a/GL/private.h b/GL/private.h index 7363b22..b61f29f 100644 --- a/GL/private.h +++ b/GL/private.h @@ -290,6 +290,7 @@ void _glInitLights(); void _glInitImmediateMode(GLuint initial_size); void _glInitMatrices(); void _glInitFramebuffers(); +void _glInitSubmissionTarget(); void _glMatrixLoadNormal(); void _glMatrixLoadModelView();