From 51a715ffe0b138960846e9f407a1290037931b33 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 30 Jul 2019 22:08:14 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=88=90=E5=91=98=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/modules/asura-core/graphics/canvas.cpp | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source/modules/asura-core/graphics/canvas.cpp') diff --git a/source/modules/asura-core/graphics/canvas.cpp b/source/modules/asura-core/graphics/canvas.cpp index 0a17085..e922a51 100644 --- a/source/modules/asura-core/graphics/canvas.cpp +++ b/source/modules/asura-core/graphics/canvas.cpp @@ -6,42 +6,42 @@ namespace AsuraEngine { Canvas::Canvas() - : mWidth(0) - , mHeight(0) - , mFBO(0) + : m_Width(0) + , m_Height(0) + , m_FBO(0) { // Fix: 等设置大小初始化时再申请framebuffer资源。 - //glGenFramebuffers(1, &mFBO); + //glGenFramebuffers(1, &m_FBO); //GLint current_fbo; //glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); - //glBindFramebuffer(GL_FRAMEBUFFER, mFBO); - //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexID, 0); + //glBindFramebuffer(GL_FRAMEBUFFER, m_FBO); + //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TexID, 0); //glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); } void Canvas::SetSize(uint w, uint h) { - if (mFBO == 0) + if (m_FBO == 0) { - glGenFramebuffers(1, &mFBO); - if (mFBO == 0) + glGenFramebuffers(1, &m_FBO); + if (m_FBO == 0) throw Exception("OpenGL glGenFramebuffers cannot generate frame buffer object."); // 申请纹理 - if (mTexID == 0) + if (m_TexID == 0) { - glGenTextures(1, &mTexID); - if (mTexID == 0) + glGenTextures(1, &m_TexID); + if (m_TexID == 0) throw Exception("OpenGL glGenTextures cannot generate texture."); } GLint current_fbo; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); - glBindFramebuffer(GL_FRAMEBUFFER, mFBO); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexID, 0); + glBindFramebuffer(GL_FRAMEBUFFER, m_FBO); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TexID, 0); glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); } GLint current_tex; glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_tex); - glBindTexture(GL_TEXTURE_2D, mTexID); + glBindTexture(GL_TEXTURE_2D, m_TexID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, current_tex); } -- cgit v1.1-26-g67d0