Properly restore state after glEnd

This commit is contained in:
Luke Benstead 2018-08-21 16:15:43 +01:00
parent 9b0322ce8a
commit 21f8f9d855
3 changed files with 43 additions and 10 deletions

View File

@ -8,13 +8,6 @@
#include "private.h"
#include "profiler.h"
typedef struct {
const void* ptr;
GLenum type;
GLsizei stride;
GLint size;
} AttribPointer;
static AttribPointer VERTEX_POINTER;
static AttribPointer UV_POINTER;
@ -76,6 +69,26 @@ GLuint _glGetEnabledAttributes() {
return ENABLED_VERTEX_ATTRIBUTES;
}
AttribPointer* _glGetVertexAttribPointer() {
return &VERTEX_POINTER;
}
AttribPointer* _glGetDiffuseAttribPointer() {
return &DIFFUSE_POINTER;
}
AttribPointer* _glGetNormalAttribPointer() {
return &NORMAL_POINTER;
}
AttribPointer* _glGetUVAttribPointer() {
return &UV_POINTER;
}
AttribPointer* _glGetSTAttribPointer() {
return &ST_POINTER;
}
static inline void _parseVec3FromShort3(GLfloat* out, const GLubyte* in) {
GLshort* ptr = (GLshort*) in;

View File

@ -161,7 +161,11 @@ void APIENTRY glEnd() {
glGetBooleanv(GL_COLOR_ARRAY, &colorArrayEnabled);
glGetBooleanv(GL_NORMAL_ARRAY, &normalArrayEnabled);
/* FIXME: Push pointer state */
AttribPointer vptr = *_glGetVertexAttribPointer();
AttribPointer dptr = *_glGetDiffuseAttribPointer();
AttribPointer nptr = *_glGetNormalAttribPointer();
AttribPointer uvptr = *_glGetUVAttribPointer();
AttribPointer stptr = *_glGetSTAttribPointer();
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
@ -192,6 +196,12 @@ void APIENTRY glEnd() {
aligned_vector_clear(&ST_COORDS);
aligned_vector_clear(&NORMALS);
*_glGetVertexAttribPointer() = vptr;
*_glGetDiffuseAttribPointer() = dptr;
*_glGetNormalAttribPointer() = nptr;
*_glGetUVAttribPointer() = uvptr;
*_glGetSTAttribPointer() = stptr;
if(!vertexArrayEnabled) {
glDisableClientState(GL_VERTEX_ARRAY);
}
@ -216,8 +226,6 @@ void APIENTRY glEnd() {
glClientActiveTextureARB((GLuint) activeTexture);
/* FIXME: Pop pointers */
}
void APIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) {

View File

@ -105,7 +105,19 @@ GLubyte _glKosInitTextures();
void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit);
typedef struct {
const void* ptr;
GLenum type;
GLsizei stride;
GLint size;
} AttribPointer;
GLuint _glGetEnabledAttributes();
AttribPointer* _glGetVertexAttribPointer();
AttribPointer* _glGetDiffuseAttribPointer();
AttribPointer* _glGetNormalAttribPointer();
AttribPointer* _glGetUVAttribPointer();
AttribPointer* _glGetSTAttribPointer();
TextureObject* getTexture0();
TextureObject* getTexture1();