diff options
author | chai <chaifix@163.com> | 2019-07-29 09:06:09 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-07-29 09:06:09 +0800 |
commit | ecd7883521cbde02f4f1a6b23a7b3b601c32dbef (patch) | |
tree | 37d94224896ea6a27777f67d31ec8d71cbfc91f9 /source/modules/asura-core/graphics | |
parent | 7894c2971626f9560b4ec77a1ce5a9a64a4f3810 (diff) |
*misc
Diffstat (limited to 'source/modules/asura-core/graphics')
-rw-r--r-- | source/modules/asura-core/graphics/canvas.cpp | 12 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/canvas.h | 2 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/image.cpp | 10 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/texture.cpp | 14 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/texture.h | 19 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/vertex_buffer.h | 3 |
6 files changed, 23 insertions, 37 deletions
diff --git a/source/modules/asura-core/graphics/canvas.cpp b/source/modules/asura-core/graphics/canvas.cpp index 0543461..0a17085 100644 --- a/source/modules/asura-core/graphics/canvas.cpp +++ b/source/modules/asura-core/graphics/canvas.cpp @@ -15,7 +15,7 @@ namespace AsuraEngine //GLint current_fbo; //glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); //glBindFramebuffer(GL_FRAMEBUFFER, mFBO); - //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTex, 0); + //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexID, 0); //glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); } @@ -27,21 +27,21 @@ namespace AsuraEngine if (mFBO == 0) throw Exception("OpenGL glGenFramebuffers cannot generate frame buffer object."); // - if (mTex == 0) + if (mTexID == 0) { - glGenTextures(1, &mTex); - if (mTex == 0) + glGenTextures(1, &mTexID); + if (mTexID == 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, mTex, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexID, 0); glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); } GLint current_tex; glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_tex); - glBindTexture(GL_TEXTURE_2D, mTex); + glBindTexture(GL_TEXTURE_2D, mTexID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, current_tex); } diff --git a/source/modules/asura-core/graphics/canvas.h b/source/modules/asura-core/graphics/canvas.h index 03326df..e2e713c 100644 --- a/source/modules/asura-core/graphics/canvas.h +++ b/source/modules/asura-core/graphics/canvas.h @@ -49,7 +49,7 @@ namespace AsuraEngine GLuint mFBO; - GLuint mTex; + GLuint mTexID; uint mWidth, mHeight; diff --git a/source/modules/asura-core/graphics/image.cpp b/source/modules/asura-core/graphics/image.cpp index ef01730..1d74d27 100644 --- a/source/modules/asura-core/graphics/image.cpp +++ b/source/modules/asura-core/graphics/image.cpp @@ -28,14 +28,14 @@ namespace AsuraEngine { if (!imgData) return false; - if (mTex == 0) + if (mTexID == 0) { - glGenTextures(1, &mTex); - if (mTex == 0) + glGenTextures(1, &mTexID); + if (mTexID == 0) throw Exception("OpenGL glGenTextures failed."); } - glBindTexture(GL_TEXTURE_2D, mTex); + glBindTexture(GL_TEXTURE_2D, mTexID); imgData->Lock(); int width = imgData->width; int height = imgData->height; @@ -66,7 +66,7 @@ namespace AsuraEngine { if (!imgData) return false; - glBindTexture(GL_TEXTURE_2D, mTex); + glBindTexture(GL_TEXTURE_2D, mTexID); imgData->Lock(); int width = imgData->width; int height = imgData->height; diff --git a/source/modules/asura-core/graphics/texture.cpp b/source/modules/asura-core/graphics/texture.cpp index 3438334..240a5f8 100644 --- a/source/modules/asura-core/graphics/texture.cpp +++ b/source/modules/asura-core/graphics/texture.cpp @@ -8,24 +8,20 @@ namespace AsuraEngine { Texture::Texture() - : mTex(0) + : mTexID(0) { - // Fix: ҪʱԴ - //glGenTextures(1, &mTex); - //if(mTex == 0) - // throw Exception("Cannot create texture."); } Texture::~Texture() { // ͷԴ - if(mTex != 0) - glDeleteTextures(1, &mTex); + if(mTexID != 0) + glDeleteTextures(1, &mTexID); } GLuint Texture::GetGLTexture() const { - return mTex; + return mTexID; } TextureFormat Texture::ConvertColorFormat(const ColorFormat& colorformat) @@ -44,7 +40,7 @@ namespace AsuraEngine t.type = GL_FLOAT; break; default: - ASSERT(false); // cant reach here + ASSERT(false); } return t; } diff --git a/source/modules/asura-core/graphics/texture.h b/source/modules/asura-core/graphics/texture.h index 7cfddec..e16990c 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -16,6 +16,7 @@ namespace AsuraEngine class RenderTarget; + /// UVʽ enum WrapMode { WRAP_MODE_REPEAT, @@ -24,38 +25,32 @@ namespace AsuraEngine WRAP_MODE_CLAMPTOBORDER, }; + /// ˲ģʽ enum FilterMode { FILTER_MODE_NEAREST, FILTER_MODE_LINEAR, }; - /// /// ͼݵɫʽ - /// enum ColorFormat { COLOR_FORMAT_UNKNOWN, - COLOR_FORMAT_RGBA8, ///< RGBA8bits int COLOR_FORMAT_RGBA32F, ///< RGBA32bits float }; - /// /// ʽGPUڲCPUⲿʽ - /// struct TextureFormat { GLenum internalformat; ///< GPUڲʽ - GLenum externalformat; ///< CPUⲿʽ GLenum type; ///< ⲿʽÿchannelֵ }; /// - /// 2D࣬2d meshrender targetбʹáTextureȾԭϽǣϷ - /// ϲԵѿϵΪEditorҲϽΪԭ㣬Ϊ - /// 㡣 + /// 2D࣬2d meshrender targetбʹáTextureȾԭϽǣϷϲԵѿ + /// ϵΪEditorҲϽΪԭ㣬Ϊ˷㡣 /// ASURA_ABSTRACT class Texture : public AEScripting::Object { @@ -74,19 +69,15 @@ namespace AsuraEngine void GetFilterMode(); void GetWrapMode(); - /// /// UVfilterΪ - /// bool IsGenMipmap(); protected: - /// /// תcolor formatΪtexture format - /// TextureFormat ConvertColorFormat(const ColorFormat& colorformat); - GLuint mTex; + GLuint mTexID; FilterMode mMinFilter; FilterMode mMagFilter; WrapMode mWrapMode; diff --git a/source/modules/asura-core/graphics/vertex_buffer.h b/source/modules/asura-core/graphics/vertex_buffer.h index 83ca4d1..c16c6d2 100644 --- a/source/modules/asura-core/graphics/vertex_buffer.h +++ b/source/modules/asura-core/graphics/vertex_buffer.h @@ -11,8 +11,7 @@ namespace AsuraEngine { /// - /// frameworkṩ˴Դ滺Ĺܣֱû壬ܶͨ - /// ֱöݡ + /// frameworkṩ˴Դ滺Ĺܣֱû壬ֱܶͨöݡ /// class VertexBuffer ASURA_FINAL : public AEScripting::Portable<VertexBuffer> |