diff options
Diffstat (limited to 'src/libjin/graphics/opengl.cpp')
-rw-r--r-- | src/libjin/graphics/opengl.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/libjin/graphics/opengl.cpp b/src/libjin/graphics/opengl.cpp index da3659d..c1696f4 100644 --- a/src/libjin/graphics/opengl.cpp +++ b/src/libjin/graphics/opengl.cpp @@ -52,11 +52,12 @@ namespace JinEngine void OpenGL::init() { enable(GL_BLEND); + + unbindCanvas(); + unuseShader(); setClearColor(0, 0, 0, 0xff); setColor(0xff, 0xff, 0xff, 0xff); setBlendMode(OpenGL::BlendMode::ALPHA); - unbindCanvas(); - unuseShader(); } void OpenGL::enable(GLenum cap) @@ -337,18 +338,15 @@ namespace JinEngine if (mCanvas != canvas && canvas) { GLuint fbo = canvas->getGLFrameBuffer(); - gl.bindFrameBuffer(fbo); + bindFrameBuffer(fbo); int w = canvas->getWidth(); int h = canvas->getHeight(); glViewport(0, 0, w, h); - gl.setProjectionMatrix(0, w, 0, h, -1, 1); + setProjectionMatrix(0, w, 0, h, -1, 1); mCanvas = canvas; - gl.enable(GL_BLEND); - gl.enable(GL_TEXTURE_2D); - - gl.setBlendMode(OpenGL::BlendMode::ALPHA); + setBlendMode(OpenGL::BlendMode::ALPHA); ++mStats.canvasSwitches; } @@ -367,11 +365,12 @@ namespace JinEngine return; // Get window size as viewport. Window* wnd = Window::get(); - int w = wnd->getW(); - int h = wnd->getH(); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + int w = wnd->getW(), h = wnd->getH(); glViewport(0, 0, w, h); - gl.setProjectionMatrix(0, w, h, 0, -1, 1); + setProjectionMatrix(0, w, h, 0, -1, 1); + + setBlendMode(OpenGL::BlendMode::ALPHA); mCanvas = SCREEN; } |