diff options
Diffstat (limited to 'source/modules/asura-core/graphics')
-rw-r--r-- | source/modules/asura-core/graphics/binding/_shader.cpp | 105 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/color.cpp | 8 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/color.h | 2 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/gl.cpp | 18 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/gl.h | 20 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/mesh2d.h | 10 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/render_state.h | 2 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/shader.cpp | 151 | ||||
-rw-r--r-- | source/modules/asura-core/graphics/shader.h | 98 |
9 files changed, 54 insertions, 360 deletions
diff --git a/source/modules/asura-core/graphics/binding/_shader.cpp b/source/modules/asura-core/graphics/binding/_shader.cpp index 0484997..71f4e28 100644 --- a/source/modules/asura-core/graphics/binding/_shader.cpp +++ b/source/modules/asura-core/graphics/binding/_shader.cpp @@ -23,14 +23,6 @@ namespace AsuraEngine { "SetUniformVector3", _SetUniformVector3 }, { "SetUniformVector4", _SetUniformVector4 }, { "SetUniformColor", _SetUniformColor }, - { "SetAttribPosition", _SetAttribPosition }, - { "SetAttribTangent", _SetAttribTangent }, - { "SetAttribNormal", _SetAttribNormal }, - { "SetAttribColor", _SetAttribColor }, - { "SetAttribTexcoord0", _SetAttribTexcoord0 }, - { "SetAttribTexcoord1", _SetAttribTexcoord1 }, - { "SetAttribTexcoord2", _SetAttribTexcoord2 }, - { "SetAttribTexcoord3", _SetAttribTexcoord3 }, { "SetBuiltInUniforms", _SetBuiltInUniforms } ); } @@ -136,102 +128,5 @@ namespace AsuraEngine return 0; } - // shader:SetAttribPosition(vbo, offseti, stridei, normalized) - LUAX_IMPL_METHOD(Shader, _SetAttribPosition) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - bool normalized = state.GetValue<bool>(5, false); - self->SetAttribPosition(vbo, offseti, stridei, normalized); - return 0; - } - - // shader:SetAttribTangent() - LUAX_IMPL_METHOD(Shader, _SetAttribTangent) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribTangent(vbo, offseti, stridei); - return 0; - } - - // shader:SetAttribNormal() - LUAX_IMPL_METHOD(Shader, _SetAttribNormal) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribNormal(vbo, offseti, stridei); - return 0; - } - - // shader:SetAttribColor() - LUAX_IMPL_METHOD(Shader, _SetAttribColor) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribColor(vbo, offseti, stridei); - return 0; - } - - // shader:SetAttribTexcoord0() - LUAX_IMPL_METHOD(Shader, _SetAttribTexcoord0) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribPosition(vbo, offseti, stridei); - return 0; - } - - // shader:SetAttribTexcoord1() - LUAX_IMPL_METHOD(Shader, _SetAttribTexcoord1) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribPosition(vbo, offseti, stridei); - return 0; - } - - // shader:SetAttribTexcoord2() - LUAX_IMPL_METHOD(Shader, _SetAttribTexcoord2) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribPosition(vbo, offseti, stridei); - return 0; - } - - // shader:SetAttribTexcoord3() - LUAX_IMPL_METHOD(Shader, _SetAttribTexcoord3) - { - LUAX_PREPARE(L, Shader); - - VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2); - uint offseti = state.GetValue<uint>(3, 0); - uint stridei = state.GetValue<uint>(4, 0); - self->SetAttribPosition(vbo, offseti, stridei); - return 0; - } - } } diff --git a/source/modules/asura-core/graphics/color.cpp b/source/modules/asura-core/graphics/color.cpp index 9343939..76e0942 100644 --- a/source/modules/asura-core/graphics/color.cpp +++ b/source/modules/asura-core/graphics/color.cpp @@ -39,6 +39,14 @@ namespace AsuraEngine { } + void Color::Set(float r, float g, float b, float a) + { + this->r = r; + this->g = g; + this->b = b; + this->a = a; + } + //Color Color::operator *(const Color& c) //{ // r *= c.r; diff --git a/source/modules/asura-core/graphics/color.h b/source/modules/asura-core/graphics/color.h index 197921f..ababcf7 100644 --- a/source/modules/asura-core/graphics/color.h +++ b/source/modules/asura-core/graphics/color.h @@ -38,6 +38,8 @@ namespace AsuraEngine Color operator *(const Color& c); + void Set(float r, float g, float b, float a); + float r, g, b, a; //----------------------------------------------------------------------------// diff --git a/source/modules/asura-core/graphics/gl.cpp b/source/modules/asura-core/graphics/gl.cpp index 13c623f..08c50c3 100644 --- a/source/modules/asura-core/graphics/gl.cpp +++ b/source/modules/asura-core/graphics/gl.cpp @@ -5,6 +5,7 @@ #include "gl.h" #include "shader.h" #include "matrix_stack.h" +#include "color.h" using namespace AEMath; @@ -70,13 +71,10 @@ namespace AsuraEngine void OpenGL::SetDrawColor(float r, float g, float b, float a) { - state.drawColor.x = r; - state.drawColor.y = g; - state.drawColor.z = b; - state.drawColor.w = a; + state.drawColor.Set(r, g, b, a); } - AEMath::Vector4f& OpenGL::GetDrawColor() + Color& OpenGL::GetDrawColor() { return state.drawColor; } @@ -119,9 +117,6 @@ namespace AsuraEngine void OpenGL::DrawArrays(GLenum mode, GLint first, GLsizei count) { glDrawArrays(mode, first, count); - // shader disableAttributeArray - if (state.shader) - state.shader->DisableAttribArraies(); #if ASURA_GL_PROFILE ++stats.drawCall; #endif @@ -179,6 +174,13 @@ namespace AsuraEngine return state.matrix[mode].GetTop(); } + AEMath::Matrix44 OpenGL::GetMVPMatrix() + { + return state.matrix[MATRIX_MODE_MODEL].GetTop() + * state.matrix[MATRIX_MODE_MODEL].GetTop() + * state.matrix[MATRIX_MODE_MODEL].GetTop(); + } + uint OpenGL::GetMatrixDepth() { return state.matrix[state.matrixMode].GetCapacity(); diff --git a/source/modules/asura-core/graphics/gl.h b/source/modules/asura-core/graphics/gl.h index 6bb1ee0..a4d9de2 100644 --- a/source/modules/asura-core/graphics/gl.h +++ b/source/modules/asura-core/graphics/gl.h @@ -10,6 +10,7 @@ #include <asura-utils/math/matrix44.h> #include <asura-utils/math/vector4.h> +#include "color.h" #include "matrix_stack.h" namespace AsuraEngine @@ -23,8 +24,8 @@ namespace AsuraEngine enum MatrixMode { MATRIX_MODE_PROJECTION = 0, - MATRIX_MODE_MODEL = 1, - MATRIX_MODE_VIEW = 2, + MATRIX_MODE_MODEL = 1, + MATRIX_MODE_VIEW = 2, }; enum GLParams @@ -62,7 +63,7 @@ namespace AsuraEngine void UseShader(Shader* shader); void UnuseShader(); Shader* GetShader(); - + /// /// ͳdrawcall /// @@ -81,11 +82,12 @@ namespace AsuraEngine void Scale(float x, float y); void Ortho(float l, float r, float b, float t, float n, float f); AEMath::Matrix44& GetMatrix(MatrixMode mode); + AEMath::Matrix44 GetMVPMatrix(); uint GetMatrixDepth(); uint GetMatrixIndex(); void SetDrawColor(float r, float g, float b, float a); - AEMath::Vector4f& GetDrawColor(); + Color& GetDrawColor(); /// /// ʾ @@ -103,11 +105,11 @@ namespace AsuraEngine /// struct { - Shader* shader; ///< ǰʹõshader - AEMath::Recti viewport; ///< ǰлHDC߱ڴСı߲ˢʱ䶯 - MatrixStack matrix[3]; ///< model, view, projection - MatrixMode matrixMode; ///< ǰľ - AEMath::Vector4f drawColor; ///< Ƶɫ + Shader* shader; ///< ǰʹõshader + AEMath::Recti viewport; ///< ǰлHDC߱ڴСı߲ˢʱ䶯 + MatrixStack matrix[3]; ///< model, view, projection + MatrixMode matrixMode; ///< ǰľ + Color drawColor; ///< Ƶɫ } state; #if ASURA_GL_PROFILE diff --git a/source/modules/asura-core/graphics/mesh2d.h b/source/modules/asura-core/graphics/mesh2d.h index 0c3627f..f2770e1 100644 --- a/source/modules/asura-core/graphics/mesh2d.h +++ b/source/modules/asura-core/graphics/mesh2d.h @@ -37,17 +37,15 @@ namespace AsuraEngine private: - //----------------------------------------------------------------------------// - LUAX_DECL_FACTORY(Mesh2D); - - //----------------------------------------------------------------------------// + + LUAX_DECL_METHOD(_SetVertex); /// - /// mesh2d dataйvboebo + /// mesh2d dataйvertex bufferindex buffer /// VertexBuffer* mVBO; - IndexBuffer* mEBO; + IndexBuffer* mIBO; }; diff --git a/source/modules/asura-core/graphics/render_state.h b/source/modules/asura-core/graphics/render_state.h index 4817dfa..b5814d3 100644 --- a/source/modules/asura-core/graphics/render_state.h +++ b/source/modules/asura-core/graphics/render_state.h @@ -1,11 +1,9 @@ #ifndef __ASURA_ENGINE_RENDER_STATE_H__ #define __ASURA_ENGINE_RENDER_STATE_H__ -// asura modules #include <asura-utils/math/vector2.hpp> #include <asura-utils/math/transform.h> -// folder #include "blend_mode.h" namespace AsuraEngine diff --git a/source/modules/asura-core/graphics/shader.cpp b/source/modules/asura-core/graphics/shader.cpp index a2e230a..a0c14b4 100644 --- a/source/modules/asura-core/graphics/shader.cpp +++ b/source/modules/asura-core/graphics/shader.cpp @@ -15,25 +15,7 @@ namespace AsuraEngine /// static int _texture_unit; - const char* Shader::SemanticsName[] = { - // uniforms - "asura_model_matrix", // mat4 - "asura_view_matrix", // mat4 - "asura_projection_matrix", // mat4 - "asura_draw_color", // vec4 - // attributes - "asura_position", // vec2 - "asura_tangent", // vec2 - "asura_normal", // vec2 - "asura_texcoord0", // vec2 - "asura_texcoord1", // vec2 - "asura_texcoord2", // vec2 - "asura_texcoord3", // vec2 - "asura_color" // vec4 - }; - Shader::Shader() - : mEnabledAttributes(0) { } @@ -109,9 +91,6 @@ namespace AsuraEngine throw Exception("Link shader program failed:\n%s", warnning.c_str()); } - // linklocations - UpdateSemanticsLocations(); - return true; } @@ -125,26 +104,6 @@ namespace AsuraEngine _texture_unit; } - void Shader::DisableAttribArraies() - { - if(mEnabledAttributes & ATTRIBUTE_POSITION) - glDisableVertexAttribArray(mPosition); - if (mEnabledAttributes & ATTRIBUTE_TANGENT) - glDisableVertexAttribArray(mTangent); - if (mEnabledAttributes & ATTRIBUTE_NORMAL) - glDisableVertexAttribArray(mNormal); - if (mEnabledAttributes & ATTRIBUTE_COLOR) - glDisableVertexAttribArray(mColor); - if (mEnabledAttributes & ATTRIBUTE_TEXCOORD0) - glDisableVertexAttribArray(mTexcoord0); - if (mEnabledAttributes & ATTRIBUTE_TEXCOORD1) - glDisableVertexAttribArray(mTexcoord1); - if (mEnabledAttributes & ATTRIBUTE_TEXCOORD2) - glDisableVertexAttribArray(mTexcoord2); - if (mEnabledAttributes & ATTRIBUTE_TEXCOORD3) - glDisableVertexAttribArray(mTexcoord3); - } - uint Shader::GetUniformLocation(const std::string& uniform) { GLint loc = glGetUniformLocation(mProgram, uniform.c_str()); @@ -211,14 +170,10 @@ namespace AsuraEngine glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements()); } - void Shader::SetBuiltInUniforms() + void Shader::SetUniformColor(uint loc, const Color& color) { - // model\view\projection matrix - SetUniformMatrix44(mMVP[MATRIX_MODE_MODEL], gl.GetMatrix(MATRIX_MODE_MODEL)); - SetUniformMatrix44(mMVP[MATRIX_MODE_VIEW], gl.GetMatrix(MATRIX_MODE_VIEW)); - SetUniformMatrix44(mMVP[MATRIX_MODE_PROJECTION], gl.GetMatrix(MATRIX_MODE_PROJECTION)); - // draw color - SetUniformVector4(mDrawColor, gl.GetDrawColor()); + if (gl.state.shader == this) + glUniform4f(loc, color.r, color.g, color.b, color.a); } //void Shader::GetUniform() @@ -274,109 +229,25 @@ namespace AsuraEngine return warnings; } - void Shader::UpdateSemanticsLocations() - { - // mvplocation - mMVP[MATRIX_MODE_MODEL] = glGetUniformLocation(mProgram, SemanticsName[SEMANTICS_UNIFORM_MODEL_MATRIX]); - mMVP[MATRIX_MODE_VIEW] = glGetUniformLocation(mProgram, SemanticsName[SEMANTICS_UNIFORM_VIEW_MATRIX]); - mMVP[MATRIX_MODE_PROJECTION] = glGetUniformLocation(mProgram, SemanticsName[SEMANTICS_UNIFORM_PROJECTION_MATRIX]); - - mPosition = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_POSITION]); - mTangent = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_TANGENT]); - mNormal = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_NORMAL]); - mColor = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_COLOR]); - mTexcoord0 = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_TEXCOORD0]); - mTexcoord1 = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_TEXCOORD1]); - mTexcoord2 = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_TEXCOORD2]); - mTexcoord3 = glGetAttribLocation(mProgram, SemanticsName[SEMANTICS_ATTRIBUTE_TEXCOORD3]); - } - - void Shader::SetAttribPosition(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) + void Shader::SetAttribute(int loc, VertexBuffer* vbo, uint offseti, uint stridei, bool normalized) { GLsizei offset = offseti * vbo->GetDataTypeSize(); GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mPosition); + glEnableVertexAttribArray(loc); vbo->Bind(); - glVertexAttribPointer(mPosition, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); + glVertexAttribPointer(loc, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_POSITION; } - void Shader::SetAttribTangent(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) + int Shader::GetAttributeLocation(const std::string& attribute) { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mTangent); - vbo->Bind(); - glVertexAttribPointer(mTangent, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_TANGENT; - } - - void Shader::SetAttribNormal(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) - { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mNormal); - vbo->Bind(); - glVertexAttribPointer(mNormal, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_NORMAL; - } - - void Shader::SetAttribColor(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) - { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mColor); - vbo->Bind(); - glVertexAttribPointer(mColor, 4, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_COLOR; - } - - void Shader::SetAttribTexcoord0(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) - { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mTexcoord0); - vbo->Bind(); - glVertexAttribPointer(mTexcoord0, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_TEXCOORD0; - } - - void Shader::SetAttribTexcoord1(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) - { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mTexcoord1); - vbo->Bind(); - glVertexAttribPointer(mTexcoord1, 2, vbo->GetDataType(), normalized, stride, (GLvoid*) offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_TEXCOORD1; - } - - void Shader::SetAttribTexcoord2(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) - { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mTexcoord2); - vbo->Bind(); - glVertexAttribPointer(mTexcoord2, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_TEXCOORD2; + int loc = glGetAttribLocation(mProgram, attribute.c_str()); + return loc; } - void Shader::SetAttribTexcoord3(VertexBuffer* vbo, uint offseti, uint stridei,bool normalized) + void Shader::DisableAttribute(int loc) { - GLsizei offset = offseti * vbo->GetDataTypeSize(); - GLsizei stride = stridei * vbo->GetDataTypeSize(); - glEnableVertexAttribArray(mTexcoord3); - vbo->Bind(); - glVertexAttribPointer(mTexcoord3, 2, vbo->GetDataType(), normalized, stride, (GLvoid*)offset); - vbo->UnBind(); - mEnabledAttributes |= ATTRIBUTE_TEXCOORD3; + glDisableVertexAttribArray(loc); } } diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h index 9bb745e..b7bc70d 100644 --- a/source/modules/asura-core/graphics/shader.h +++ b/source/modules/asura-core/graphics/shader.h @@ -44,25 +44,15 @@ namespace AsuraEngine void OnUse(); void OnUnuse(); - - /// - /// Disable֮ǰSetAttribXXXattributesÿdrawcallʱᱻglá - /// - void DisableAttribArraies(); - + /// /// öԣЩֵframeworkrenderer汻ãImageMesh2DЩԴ /// normalizedΪtrueݻڸbuffer¹һ255ɫһ /// 0~1 /// - void SetAttribPosition(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribTangent(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribNormal(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribColor(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribTexcoord0(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribTexcoord1(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribTexcoord2(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); - void SetAttribTexcoord3(VertexBuffer* vbo, uint offseti = 0, uint stridei = 0,bool normalized = false); + void SetAttribute(int loc, VertexBuffer* vbo, uint offseti = 0, uint stridei = 0, bool normalized = false); + int GetAttributeLocation(const std::string& attribute); + void DisableAttribute(int loc); /// /// uniform @@ -77,11 +67,6 @@ namespace AsuraEngine void SetUniformMatrix44(uint loc, const Math::Matrix44& mat44); bool SetUniformTexture(uint loc, const Texture& texture); - /// - /// \uniform - /// - void SetBuiltInUniforms(); - float GetUniformFloat(uint loc); AEMath::Vector2f GetUniformVector2(uint loc); AEMath::Vector3f GetUniformVector3(uint loc); @@ -110,14 +95,9 @@ namespace AsuraEngine LUAX_DECL_METHOD(_SetUniformVector4); LUAX_DECL_METHOD(_SetUniformColor); // vertex attributes - LUAX_DECL_METHOD(_SetAttribPosition); - LUAX_DECL_METHOD(_SetAttribTangent); - LUAX_DECL_METHOD(_SetAttribNormal); - LUAX_DECL_METHOD(_SetAttribColor); - LUAX_DECL_METHOD(_SetAttribTexcoord0); - LUAX_DECL_METHOD(_SetAttribTexcoord1); - LUAX_DECL_METHOD(_SetAttribTexcoord2); - LUAX_DECL_METHOD(_SetAttribTexcoord3); + LUAX_DECL_METHOD(_GetAttributeLocation); + LUAX_DECL_METHOD(_SetAttribute); + LUAX_DECL_METHOD(_DisableAttribute); // uniform LUAX_DECL_METHOD(_SetBuiltInUniforms); @@ -125,73 +105,11 @@ namespace AsuraEngine std::string GetProgramWarnings(); std::string GetShaderWarnings(GLuint shader); - void UpdateSemanticsLocations(); - - /// - /// AsuraShader壬Ժuniformframeworkлshaderٴηװ - /// ν壬ָshaderԶıⲿʱҪṩЩֵ - /// ĻҪ - /// - enum Semantics - { - // MVP - SEMANTICS_UNIFORM_MODEL_MATRIX = 0, - SEMANTICS_UNIFORM_VIEW_MATRIX, - SEMANTICS_UNIFORM_PROJECTION_MATRIX, - // ʱɫ - SEMANTICS_UNIFORM_DRAW_COLOR, - // - SEMANTICS_ATTRIBUTE_POSITION, - // - SEMANTICS_ATTRIBUTE_TANGENT, - // - SEMANTICS_ATTRIBUTE_NORMAL, - // UV - SEMANTICS_ATTRIBUTE_TEXCOORD0, - SEMANTICS_ATTRIBUTE_TEXCOORD1, - SEMANTICS_ATTRIBUTE_TEXCOORD2, - SEMANTICS_ATTRIBUTE_TEXCOORD3, - // ɫ - SEMANTICS_ATTRIBUTE_COLOR, - - SEMANTICS_COUNT - }; - - enum Attribute - { - ATTRIBUTE_POSITION = 1, - ATTRIBUTE_TANGENT = 1 << 1, - ATTRIBUTE_NORMAL = 1 << 2, - ATTRIBUTE_COLOR = 1 << 3, - ATTRIBUTE_TEXCOORD0 = 1 << 4, - ATTRIBUTE_TEXCOORD1 = 1 << 5, - ATTRIBUTE_TEXCOORD2 = 1 << 6, - ATTRIBUTE_TEXCOORD3 = 1 << 7, - }; - - /// - /// Asura shader ַͳһ - /// - static const char* SemanticsName[SEMANTICS_COUNT]; GLuint mProgram; GLuint mVertShader; GLuint mFragShader; - GLuint mDrawColor; - - // - GLint mMVP[3]; - GLint mPosition; - GLint mTangent; - GLint mNormal; - GLint mColor; - GLint mTexcoord0; - GLint mTexcoord1; - GLint mTexcoord2; - GLint mTexcoord3; - - int mEnabledAttributes; - + }; } |