From e47baca4f23db43ec91fbf64d5d06d7c0dbee495 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 6 Apr 2019 07:39:49 +0800 Subject: *misc --- source/modules/asura-core/graphics/shader.h | 52 ++++++++--------------------- 1 file changed, 13 insertions(+), 39 deletions(-) (limited to 'source/modules/asura-core/graphics/shader.h') diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h index f4bce25..9cf9653 100644 --- a/source/modules/asura-core/graphics/shader.h +++ b/source/modules/asura-core/graphics/shader.h @@ -14,7 +14,6 @@ #include #include -#include "shader_source.h" #include "color.h" #include "texture.h" #include "gl.h" @@ -35,31 +34,14 @@ namespace AsuraEngine { public: - LUAX_DECL_FACTORY(Shader); - - Shader() asura_throw(Exception); + Shader(); ~Shader(); - /// - /// 从代码编译shader,编译时会先检测是否有上次缓存的uniforms location map。使用 - /// glAttachShader重新编译生成着色器,不会重新申请着色器程序。 - /// - bool Update(AEIO::DecodedData* decodeData) override; - - /// - /// 将当期shader设置为活动 - /// - void Use(); - - /// - /// 将当期shader设置为非活动 - /// - void Unuse(); - - /// - /// 在已经知道uniform location的情况下,设置值。 - /// + bool Load(const std::string& vert, const std::string& frag); + + uint GetAttributeLocation(const std::string& name); + void SetUniformFloat(uint loc, float value); void SetUniformTexture(uint loc, const Texture& texture); void SetUniformVector2(uint loc, const Math::Vector2f& vec2); @@ -68,40 +50,32 @@ namespace AsuraEngine void SetUniformColor(uint loc, const Color& color); void SetUniformMatrix44(uint loc, const Math::Matrix44& mat44); + float GetUniformFloat(uint loc); + AEMath::Vector2f GetUniformVector2(uint loc); + AEMath::Vector3f GetUniformVector3(uint loc); + AEMath::Vector4f GetUniformVector4s(uint loc); + AEMath::Matrix44 GetUniformMatrix44(uint loc); + uint GetUniformLocation(const std::string& uniform); bool HasUniform(const std::string& uniform); GLuint GetGLProgramHandle(); - /// - /// 获得texture unit数量,一般为16个 - /// static uint GetGLTextureUnitCount(); private: - /// - /// 设置内置变量: - /// vec2 Asura_Time x值为进入当前场景开始的时间,y值为上一帧的时间间隔 - /// vec2 Asura_RenderTargetSize RT的大小,以像素为单位 - /// Texture Asura_MainTexture 主纹理 - /// - void SetBuiltInUniforms(); - - /// - /// OpenGL shader program handle. - /// GLuint mProgram; GLuint mVertShader; GLuint mFragShader; - Luax::LuaxMemberRef mCodeRef; - private: //----------------------------------------------------------------------------// + LUAX_DECL_FACTORY(Shader); + LUAX_DECL_METHOD(_New); LUAX_DECL_METHOD(_Use); LUAX_DECL_METHOD(_Unuse); -- cgit v1.1-26-g67d0