summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/modules/asura-core/graphics/shader.h')
-rw-r--r--source/modules/asura-core/graphics/shader.h65
1 files changed, 51 insertions, 14 deletions
diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h
index 9cf9653..12d2f59 100644
--- a/source/modules/asura-core/graphics/shader.h
+++ b/source/modules/asura-core/graphics/shader.h
@@ -14,15 +14,25 @@
#include <asura-utils/stringmap.hpp>
#include <asura-utils/manager.hpp>
+#include "gl.h"
#include "color.h"
#include "texture.h"
-#include "gl.h"
+#include "gpu_buffer.h"
namespace AsuraEngine
{
namespace Graphics
{
+ enum BuiltInUniforms
+ {
+ BUILTIN_UNIFORM_MODEL_MATRIX = 0,
+ BUILTIN_UNIFORM_VIEW_MATRIX,
+ BUILTIN_UNIFORM_PROJECTION_MATRIX,
+
+ BUILTIN_UNIFORM_COUNT
+ };
+
///
/// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩ
/// uniformsuseɫķ༭ÿshaderͨshaderҵuniforms
@@ -40,15 +50,33 @@ namespace AsuraEngine
bool Load(const std::string& vert, const std::string& frag);
- uint GetAttributeLocation(const std::string& name);
+ void OnUse();
+ void OnUnuse();
+
+ ///
+ /// öԣAsuraֻ֧2ά
+ ///
+ int GetAttributeLocation(const std::string& name);
+ void SetAttribute(int loc, void* data, uint offset = 0, uint stride = 0);
+ void SetAttribute(int loc, GPUBuffer* vbo, uint offset = 0, uint stride = 0);
+ ///
+ /// uniform
+ ///
+ bool HasUniform(const std::string& uniform);
+ uint GetUniformLocation(const std::string& uniform);
void SetUniformFloat(uint loc, float value);
- void SetUniformTexture(uint loc, const Texture& texture);
void SetUniformVector2(uint loc, const Math::Vector2f& vec2);
void SetUniformVector3(uint loc, const Math::Vector3f& vec3);
void SetUniformVector4(uint loc, const Math::Vector4f& vec4);
void SetUniformColor(uint loc, const Color& color);
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);
@@ -56,22 +84,12 @@ namespace AsuraEngine
AEMath::Vector4f GetUniformVector4s(uint loc);
AEMath::Matrix44 GetUniformMatrix44(uint loc);
- uint GetUniformLocation(const std::string& uniform);
-
- bool HasUniform(const std::string& uniform);
-
- GLuint GetGLProgramHandle();
+ GLuint GetGLProgram();
static uint GetGLTextureUnitCount();
private:
- GLuint mProgram;
- GLuint mVertShader;
- GLuint mFragShader;
-
- private:
-
//----------------------------------------------------------------------------//
LUAX_DECL_FACTORY(Shader);
@@ -95,6 +113,25 @@ namespace AsuraEngine
std::string GetProgramWarnings();
std::string GetShaderWarnings(GLuint shader);
+
+ ///
+ /// Asura shader ַͳһ
+ ///
+ static const char* ASLSemantics[BUILTIN_UNIFORM_COUNT];
+
+ GLuint mProgram;
+ GLuint mVertShader;
+ GLuint mFragShader;
+
+ ///
+ /// Model\View\Projection matrix uniformlocationAsuraҪshader
+ /// 壺
+ /// 1: asura_model_matrix ģ;
+ /// 2: asura_view_matrix ۲߾
+ /// 3: asura_projection_matrix ͶӰ
+ /// frameworkø壬ֵϷͱ༭еġ
+ ///
+ GLint mMVP[3];
};