summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Asura.Engine/Graphics')
-rw-r--r--Source/Asura.Engine/Graphics/Canvas.cpp11
-rw-r--r--Source/Asura.Engine/Graphics/Canvas.h2
-rw-r--r--Source/Asura.Engine/Graphics/Color.cpp132
-rw-r--r--Source/Asura.Engine/Graphics/Color.h46
-rw-r--r--Source/Asura.Engine/Graphics/GL.cpp (renamed from Source/Asura.Engine/Graphics/OpenGL.cpp)0
-rw-r--r--Source/Asura.Engine/Graphics/GL.h (renamed from Source/Asura.Engine/Graphics/OpenGL.h)2
-rw-r--r--Source/Asura.Engine/Graphics/Image.h10
-rw-r--r--Source/Asura.Engine/Graphics/Shader.h90
-rw-r--r--Source/Asura.Engine/Graphics/Texture.h4
-rw-r--r--Source/Asura.Engine/Graphics/Window.cpp0
-rw-r--r--Source/Asura.Engine/Graphics/Window.h25
11 files changed, 264 insertions, 58 deletions
diff --git a/Source/Asura.Engine/Graphics/Canvas.cpp b/Source/Asura.Engine/Graphics/Canvas.cpp
index e69de29..8ca6fb2 100644
--- a/Source/Asura.Engine/Graphics/Canvas.cpp
+++ b/Source/Asura.Engine/Graphics/Canvas.cpp
@@ -0,0 +1,11 @@
+#include "Canvas.h"
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+
+
+ }
+} \ No newline at end of file
diff --git a/Source/Asura.Engine/Graphics/Canvas.h b/Source/Asura.Engine/Graphics/Canvas.h
index 93792a5..c9adf2d 100644
--- a/Source/Asura.Engine/Graphics/Canvas.h
+++ b/Source/Asura.Engine/Graphics/Canvas.h
@@ -12,7 +12,7 @@ namespace AsuraEngine
{
public:
-
+ Canvas();
private:
diff --git a/Source/Asura.Engine/Graphics/Color.cpp b/Source/Asura.Engine/Graphics/Color.cpp
index e69de29..a047f53 100644
--- a/Source/Asura.Engine/Graphics/Color.cpp
+++ b/Source/Asura.Engine/Graphics/Color.cpp
@@ -0,0 +1,132 @@
+#include "Color.h"
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ Color32::Color32()
+ {
+ r = g = b = a = 0;
+ }
+
+ Color32::Color32(const Color32& c)
+ {
+ r = c.r;
+ g = c.g;
+ b = c.b;
+ a = c.a;
+ }
+
+ Color32::Color32(const Color& c)
+ {
+ r = 255.f * c.r;
+ g = 255.f * c.g;
+ b = 255.f * c.b;
+ a = 255.f * c.a;
+ }
+
+ Color32::Color32(byte r, byte g, byte b, byte a)
+ {
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ this->a = a;
+ }
+
+ int Color32::l_GetRed(lua_State* L)
+ {
+
+ }
+
+ int Color32::l_GetGreen(lua_State* L)
+ {
+
+ }
+
+ int Color32::l_GetBlue(lua_State* L)
+ {
+
+ }
+
+ int Color32::l_GetAlpha(lua_State* L)
+ {
+
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ Color::Color()
+ {
+ r = g = b = a = 0;
+ }
+
+ Color::Color(const Color& c)
+ {
+ r = c.r;
+ g = c.g;
+ b = c.b;
+ a = c.a;
+ }
+
+ Color::Color(float r, float g, float b, float a)
+ {
+ this->r = r;
+ this->g = g;
+ this->b = b;
+ this->a = a;
+ }
+
+ Color::Color(const Color32& c)
+ {
+ r = c.r / 255.f;
+ g = c.g / 255.f;
+ b = c.b / 255.f;
+ a = c.a / 255.f;
+ }
+
+ Color Color::operator *(const Color& c)
+ {
+ r *= c.r;
+ g *= c.g;
+ b *= c.b;
+ a *= c.a;
+ }
+
+ int Color::l_GetRed(lua_State* L)
+ {
+
+ }
+
+ int Color::l_GetGreen(lua_State* L)
+ {
+
+ }
+
+ int Color::l_GetBlue(lua_State* L)
+ {
+
+ }
+
+ int Color::l_GetAlpha(lua_State* L)
+ {
+
+ }
+
+ int Color::l_Add(lua_State* L)
+ {
+
+ }
+
+ int Color::l_Minus(lua_State* L)
+ {
+
+ }
+
+ int Color::l_Multiply(lua_State* L)
+ {
+
+ }
+
+ }
+} \ No newline at end of file
diff --git a/Source/Asura.Engine/Graphics/Color.h b/Source/Asura.Engine/Graphics/Color.h
index f62f9b8..daf6a09 100644
--- a/Source/Asura.Engine/Graphics/Color.h
+++ b/Source/Asura.Engine/Graphics/Color.h
@@ -1,6 +1,8 @@
#ifndef __ASURA_ENGINE_COLOR_H__
#define __ASURA_ENGINE_COLOR_H__
+#include "Scripting/Luax.hpp"
+
#include "Type.h"
namespace AsuraEngine
@@ -17,7 +19,12 @@ namespace AsuraEngine
{
public:
- Color32(Color c);
+ Color32();
+
+ Color32(const Color32& c);
+
+ Color32(const Color& c);
+
Color32(byte r, byte g, byte b, byte a);
byte r, g, b, a;
@@ -26,20 +33,53 @@ namespace AsuraEngine
LUAX_DECL_FACTORY(Color32);
+ LUAX_DECL_METHOD(l_GetRed);
+ LUAX_DECL_METHOD(l_GetGreen);
+ LUAX_DECL_METHOD(l_GetBlue);
+ LUAX_DECL_METHOD(l_GetAlpha);
+
+ // meta methods
+ LUAX_DECL_METHOD(l_Multiply);
+ LUAX_DECL_METHOD(l_Index); //r,g,b,a
+ LUAX_DECL_METHOD(l_NewIndex); //޸r,g,b,a
+
};
+ ///
+ /// 淶ɫ
+ ///
class Color
{
public:
- Color(Color32 c32);
+ Color();
+ Color(const Color& c);
+
+ Color(float r, float g, float b, float a);
+
+ Color(const Color32& c);
+
+ Color operator *(const Color& c);
+
float r, g, b, a;
- private:
+ private:
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////
LUAX_DECL_FACTORY(Color);
+ LUAX_DECL_METHOD(l_GetRed); // color.r
+ LUAX_DECL_METHOD(l_GetGreen); // color.g
+ LUAX_DECL_METHOD(l_GetBlue); // color.b
+ LUAX_DECL_METHOD(l_GetAlpha); // color.a
+
+ // meta methods
+ LUAX_DECL_METHOD(l_Multiply); // ɫ˷
+ //LUAX_DECL_METHOD(l_Index); // r,g,b,a
+ LUAX_DECL_METHOD(l_NewIndex); // ޸r,g,b,a
+
};
}
diff --git a/Source/Asura.Engine/Graphics/OpenGL.cpp b/Source/Asura.Engine/Graphics/GL.cpp
index dac2ea4..dac2ea4 100644
--- a/Source/Asura.Engine/Graphics/OpenGL.cpp
+++ b/Source/Asura.Engine/Graphics/GL.cpp
diff --git a/Source/Asura.Engine/Graphics/OpenGL.h b/Source/Asura.Engine/Graphics/GL.h
index 315c09b..0661e17 100644
--- a/Source/Asura.Engine/Graphics/OpenGL.h
+++ b/Source/Asura.Engine/Graphics/GL.h
@@ -1,6 +1,8 @@
#ifndef __ASURA_ENGINE_OPENGL_H__
#define __ASURA_ENGINE_OPENGL_H__
+#include "glad/glad.h"
+
namespace AsuraEngine
{
namespace Graphics
diff --git a/Source/Asura.Engine/Graphics/Image.h b/Source/Asura.Engine/Graphics/Image.h
index 553df21..bdd7c1c 100644
--- a/Source/Asura.Engine/Graphics/Image.h
+++ b/Source/Asura.Engine/Graphics/Image.h
@@ -1,10 +1,8 @@
#ifndef __ASURA_ENGINE_IMAGE_H__
#define __ASURA_ENGINE_IMAGE_H__
-#include "StringMap.hpp"
-#include "String.h"
-#include "Map.h"
#include "Math/Vector2.h"
+#include "StringMap.hpp"
#include "Manager.hpp"
#include "Texture.h"
#include "Color.h"
@@ -19,7 +17,7 @@ namespace AsuraEngine
///
/// ImageͼƬڴ󣬶ȡϷ󱣴ĽһImageڴ桢ԴֻᱣһݣҪ
- /// imageêλãźתǶȣʹspriteһֻࡣ
+ /// imageêλãźתǶȣʹspriteһֻࡣҪǿǵeditorengineʹòͬķװ
///
class Image final : public Texture
{
@@ -53,7 +51,9 @@ namespace AsuraEngine
//----------------------------------------------------------------------------------------------------
- LUAX_DECL_FACTORY(SimImage); //AsuraEngine.SimImage
+ // ͼƬSim࣬ķװAsuraEngine.Image棬һԱAsuraEngine.SimImageAsuraEngine.Image
+ // һ档
+ LUAX_DECL_FACTORY(SimImage);
};
diff --git a/Source/Asura.Engine/Graphics/Shader.h b/Source/Asura.Engine/Graphics/Shader.h
index e22fc66..02d9f46 100644
--- a/Source/Asura.Engine/Graphics/Shader.h
+++ b/Source/Asura.Engine/Graphics/Shader.h
@@ -1,62 +1,108 @@
#ifndef __ASURA_ENGINE_SHADER_H__
#define __ASURA_ENGINE_SHADER_H__
-#include "luax/luax.h"
+#include <map>
+#include <string>
-#include "Map.h"
+#include "luax/luax.h"
#include "StringMap.hpp"
#include "Object.h"
#include "Color.h"
#include "Manager.hpp"
+#include "Texture.h"
+#include "Math/Vector2.h"
+#include "Math/Vector3.h"
+#include "Math/Vector4.h"
+#include "GL.h"
namespace AsuraEngine
{
namespace Graphics
{
- class Material;
-
///
- /// һshaderһڲʼ乲ijShaderuniformsͶݣֻuniforms location
+ /// һshaderһڲʼ乲ijShaderuniformsͶݣֻṩuniformsuseɫķ༭ÿ
+ /// shaderͨshaderҵuniforms¶frameworkmaterialá
///
- class Shader
+ class Shader : virtual public Object
{
public:
Shader();
~Shader();
+
+ ///
+ /// ӴshaderʱȼǷϴλuniforms location map
+ ///
+ void Load(const std::string& vertexShader, const std::string& fragmentShader);
- private:
+ ///
+ /// shaderΪ
+ ///
+ void Use();
- friend class Material;
+ ///
+ /// shaderΪǻ
+ ///
+ void UnUse();
///
- /// shaderuniformsIDӳ䡣
+ /// һϵuniformsķ
///
- static StringMap<int> sUniformsID;
+ void SetUniformFloat(const std::string& uniform, float value);
+ void SetUniformTexture(const std::string& uniform, const Texture& texture);
+ void SetUniformVector2(const std::string& uniform, const Math::Vector2& vec2);
+ void SetUniformVector3(const std::string& uniform, const Math::Vector3& vec3);
+ void SetUniformVector4(const std::string& uniform, const Math::Vector4& vec4);
///
- /// uniformID
+ /// Ѿ֪uniform location£ֵ
///
- static int GetUniformID(const String& name);
+ void SetUniformFloat(uint loc, float value);
+ void SetUniformTexture(uint loc, const Texture& texture);
+ void SetUniformVector2(uint loc, const Math::Vector2& vec2);
+ void SetUniformVector3(uint loc, const Math::Vector3& vec3);
+ void SetUniformVector4(uint loc, const Math::Vector4& vec4);
+/*
///
- /// ñ
- /// vec2 Asura_Time xֵΪ뵱ǰʼʱ䣬yֵΪһ֡ʱ
- /// vec2 Asura_RenderTargetSize RTĴСΪλ
- /// Texture Asura_MainTexture
+ /// עܷframeworkʵ֣㣬shadereditorҲõ
+ /// ջunifrom location±shaderµuniform location
///
- void SetBuiltInUniforms();
+ void ClearUniformLocation();
+*/
+ ///
+ /// program id
+ ///
+ GLint GetNativeHandle();
+
+ uint GetUniformLocation(const std::string& uniform);
+
+ private:
///
- /// ӳuniforms IDlocation
+ /// ñ
+ /// vec2 Asura_Time xֵΪ뵱ǰʼʱ䣬yֵΪһ֡ʱ
+ /// vec2 Asura_RenderTargetSize RTĴСΪλ
+ /// Texture Asura_MainTexture
///
- Map<int, int> mLocations;
+ void SetBuiltInUniforms();
- };
+ // OpenGLɫʶprogram id
+ GLuint mPID;
+ //// Uniformlocations
+ //StringMap<uint> mUniformLocation;
- class ShaderManager final : public Manager
- {
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ LUAX_DECL_FACTORY(SimShader);
+
+ LUAX_DECL_METHOD(l_SetBuiltInUniforms);
+ LUAX_DECL_METHOD(l_SetUniformFloat);
+ LUAX_DECL_METHOD(l_SetUniformTexture);
+ LUAX_DECL_METHOD(l_SetUniformVector2);
+ LUAX_DECL_METHOD(l_SetUniformVector3);
+ LUAX_DECL_METHOD(l_SetUniformVector4);
};
diff --git a/Source/Asura.Engine/Graphics/Texture.h b/Source/Asura.Engine/Graphics/Texture.h
index db5c72e..06461ce 100644
--- a/Source/Asura.Engine/Graphics/Texture.h
+++ b/Source/Asura.Engine/Graphics/Texture.h
@@ -10,9 +10,9 @@ namespace AsuraEngine
{
///
- /// 2Dࣩ2d meshrender targetбʹ
+ /// 2D࣬2d meshrender targetбʹ
///
- class Texture : public Object
+ class Texture : virtual public Object
{
};
diff --git a/Source/Asura.Engine/Graphics/Window.cpp b/Source/Asura.Engine/Graphics/Window.cpp
deleted file mode 100644
index e69de29..0000000
--- a/Source/Asura.Engine/Graphics/Window.cpp
+++ /dev/null
diff --git a/Source/Asura.Engine/Graphics/Window.h b/Source/Asura.Engine/Graphics/Window.h
deleted file mode 100644
index 3a09266..0000000
--- a/Source/Asura.Engine/Graphics/Window.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __ASURA_ENGINE_WINDOW_H__
-#define __ASURA_ENGINE_WINDOW_H__
-
-namespace AsuraEngine
-{
- namespace Graphics
- {
-
- ///
- /// ڣֶ֧രڡڱ༭Ҫ֧֣runnerֻҪһڡ
- ///
- class Window
- {
- public:
-
-
- private:
-
-
- };
-
- }
-}
-
-#endif \ No newline at end of file