diff --git a/gl-api.h b/gl-api.h index fa3c15f..a1811db 100644 --- a/gl-api.h +++ b/gl-api.h @@ -209,7 +209,8 @@ GLuint _glKosVertexColor(); GLubyte _glKosMaxTextureUnits(); GLubyte _glKosEnabledTextureMatrix(); -GL_TEXTURE_OBJECT *_glKosBoundMultiTexID(); +GL_TEXTURE_OBJECT *_glKosBoundMultiTexObject(); +GLuint _glKosActiveTextureBoundTexID(); inline void _glKosPushMultiTexObject(GL_TEXTURE_OBJECT *tex, pvr_vertex_t *src, diff --git a/gl-arrays.c b/gl-arrays.c index 5a706d4..54fa198 100644 --- a/gl-arrays.c +++ b/gl-arrays.c @@ -834,7 +834,7 @@ static GLuint _glKosArraysApplyClipping(GLfloat *uvsrc, GLuint uvstride, GLenum static inline void _glKosArraysApplyMultiTexture(GLenum mode, GLuint count) { if(GL_KOS_VERTEX_PTR_MODE & GL_KOS_USE_TEXTURE1) { - GL_TEXTURE_OBJECT* tex = _glKosBoundMultiTexID(); + GL_TEXTURE_OBJECT* tex = _glKosBoundMultiTexObject(); if(tex) { _glKosPushMultiTexObject(tex, (pvr_vertex_t *)_glKosVertexBufPointer(), diff --git a/gl-cap.c b/gl-cap.c index d479f99..33c4afb 100644 --- a/gl-cap.c +++ b/gl-cap.c @@ -200,7 +200,7 @@ void APIENTRY glGetIntegerv(GLenum pname, GLint *params) { break; case GL_TEXTURE_BINDING_2D: - *params = _glKosBoundTexID(); + *params = _glKosActiveTextureBoundTexID(); break; default: diff --git a/gl-texture.c b/gl-texture.c index 13d18cb..c8869a4 100644 --- a/gl-texture.c +++ b/gl-texture.c @@ -98,13 +98,22 @@ void _glKosCompileHdrTx() { _glKosCompileHdrT(GL_KOS_TEXTURE_UNIT[GL_TEXTURE0_ARB & 0xF]) : _glKosCompileHdr(); } -GL_TEXTURE_OBJECT *_glKosBoundMultiTexID() { +GL_TEXTURE_OBJECT *_glKosBoundMultiTexObject() { return GL_KOS_TEXTURE_UNIT[GL_TEXTURE1_ARB & 0xF]; } +GLuint _glKosBoundMultiTexID() { + return GL_KOS_TEXTURE_UNIT[GL_TEXTURE1_ARB & 0xF] ? + GL_KOS_TEXTURE_UNIT[GL_TEXTURE1_ARB & 0xF]->index : 0; +} + GLuint _glKosBoundTexID() { - return GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE] ? - GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->index : 0; + return GL_KOS_TEXTURE_UNIT[GL_TEXTURE0_ARB & 0xF] ? + GL_KOS_TEXTURE_UNIT[GL_TEXTURE0_ARB & 0xF]->index : 0; +} + +GLuint _glKosActiveTextureBoundTexID() { + return (GL_KOS_ACTIVE_TEXTURE) ? _glKosBoundMultiTexID() : _glKosBoundTexID(); } GLubyte _glKosMaxTextureUnits() {