diff options
Diffstat (limited to 'Runtime/Graphics/GfxDevice.h')
-rw-r--r-- | Runtime/Graphics/GfxDevice.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/Runtime/Graphics/GfxDevice.h b/Runtime/Graphics/GfxDevice.h index 0931eae..ef7788c 100644 --- a/Runtime/Graphics/GfxDevice.h +++ b/Runtime/Graphics/GfxDevice.h @@ -4,6 +4,11 @@ #include "../Utilities/NonCopyable.h" #include "../Utilities/Type.h" #include "../Utilities/Assert.h" +#include "../Graphics/Shader.h" +#include "../Math/Vector2.h" +#include "../Math/Vector3.h" +#include "../Math/Vector4.h" +#include "../Math/Matrix44.h" #include "Texture.h" #include "DeviceDefine.h" @@ -17,6 +22,23 @@ struct GfxDeviceSetting ETextureWrapMode wrapMode; // 默认的贴图平铺模式 }; +// 当前绑定的shader +struct ShaderState +{ + LuaBind::StrongRef ref; // 在lua中的引用 + Shader* shader; + operator bool() + { + return ref && shader != NULL; + } + GLuint GetID() { + if (shader == nullptr) + return 0; + GLint id = shader->GetID(); + return id; + } +}; + // 对渲染相关API的封装 class GfxDevice : public NonCopyable { @@ -37,7 +59,14 @@ public: void SetAntiAliasing(int level = 0); - void Clear(int clearFlag); + void Clear(int clearFlag); + + void UseShader(LuaBind::State& state, Shader* shader, int idx); + void UnuseShader(); + void SetUniformVec2(const char* name, Internal::Vector2 vec2); + void SetUniformVec3(const char* name, Internal::Vector3 vec3); + void SetUniformVec4(const char* name, Internal::Vector4 vec4); + void SetUniformMat4(const char* name, Internal::Matrix44 mat4); void BeginFrame(); void EndFrame(); @@ -62,6 +91,8 @@ private: EStencilOp m_StencilOp; byte m_StencilMask; + ShaderState m_Shader; // 当前绑定的shader + // 贴图默认设置 ETextureFilterMode m_DefaultFilterMode; ETextureWrapMode m_DefaultWrapMode; |