Texture is internal state;

This commit is contained in:
bjorn 2017-08-08 02:14:50 -07:00
parent fe570e19f1
commit c89301c284
2 changed files with 18 additions and 18 deletions

View File

@ -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;

View File

@ -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);