diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 4bfbc176..f19a0394 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -349,21 +349,6 @@ void lovrGraphicsSetWireframe(int wireframe) { #endif } -Texture* lovrGraphicsGetTexture() { - return state.activeTexture; -} - -void lovrGraphicsBindTexture(Texture* texture) { - if (!texture) { - texture = state.defaultTexture; - } - - if (texture != state.activeTexture) { - state.activeTexture = texture; - glBindTexture(GL_TEXTURE_2D, texture->id); - } -} - int lovrGraphicsGetWidth() { int width, height; glfwGetFramebufferSize(state.window, &width, &height); @@ -983,6 +968,21 @@ void lovrGraphicsPrint(const char* str, mat4 transform, float wrap, HorizontalAl } // Internal State +Texture* lovrGraphicsGetTexture() { + return state.texture; +} + +void lovrGraphicsBindTexture(Texture* texture) { + if (!texture) { + texture = state.defaultTexture; + } + + if (texture != state.texture) { + state.texture = texture; + glBindTexture(GL_TEXTURE_2D, texture->id); + } +} + void lovrGraphicsBindVertexArray(uint32_t vertexArray) { if (state.vertexArray != vertexArray) { state.vertexArray = vertexArray; diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index 40ba9198..8372093d 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -70,7 +70,6 @@ typedef struct { Shader* fontShader; Shader* fullscreenShader; Font* defaultFont; - Texture* activeTexture; Texture* defaultTexture; float transforms[MAX_TRANSFORMS + INTERNAL_TRANSFORMS][16]; CanvasState canvases[MAX_CANVASES]; @@ -100,6 +99,7 @@ typedef struct { vec_uint_t indices; } buffer; + Texture* texture; uint32_t vertexArray; uint32_t vertexBuffer; uint32_t indexBuffer; @@ -139,8 +139,6 @@ Winding lovrGraphicsGetWinding(); void lovrGraphicsSetWinding(Winding winding); int lovrGraphicsIsWireframe(); void lovrGraphicsSetWireframe(int wireframe); -Texture* lovrGraphicsGetTexture(); -void lovrGraphicsBindTexture(Texture* texture); int lovrGraphicsGetWidth(); int lovrGraphicsGetHeight(); void lovrGraphicsPushCanvas(); @@ -172,6 +170,8 @@ void lovrGraphicsSkybox(Skybox* skybox, float angle, float ax, float ay, float a void lovrGraphicsPrint(const char* str, mat4 transform, float wrap, HorizontalAlign halign, VerticalAlign valign); // Internal State +Texture* lovrGraphicsGetTexture(); +void lovrGraphicsBindTexture(Texture* texture); void lovrGraphicsBindVertexArray(uint32_t vao); void lovrGraphicsBindVertexBuffer(uint32_t vbo); void lovrGraphicsBindIndexBuffer(uint32_t ibo);