From 1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 19 Mar 2019 23:06:27 +0800 Subject: *rename --- .../Asura.Engine/graphics/application.graphics.cpp | 19 --- .../graphics/binding/canvas.binding.cpp | 0 .../graphics/binding/color.binding.cpp | 0 .../graphics/binding/image.binding.cpp | 0 .../graphics/binding/image_data.binding.cpp | 35 ------ .../graphics/binding/mesh2d.binding.cpp | 0 .../graphics/binding/mesh2d_data.binding.cpp | 9 -- .../graphics/binding/shader.binding.cpp | 119 ------------------- .../graphics/binding/sprite_batch.binding.cpp | 0 .../graphics/binding/window.binding.cpp | 11 -- Source/Asura.Engine/graphics/blend_mode.h | 17 --- Source/Asura.Engine/graphics/canvas.cpp | 41 ------- Source/Asura.Engine/graphics/canvas.h | 81 ------------- Source/Asura.Engine/graphics/color.cpp | 132 --------------------- Source/Asura.Engine/graphics/color.h | 94 --------------- Source/Asura.Engine/graphics/color_palette.h | 0 Source/Asura.Engine/graphics/gif.cpp | 0 Source/Asura.Engine/graphics/gif.h | 4 - Source/Asura.Engine/graphics/gl.cpp | 11 -- Source/Asura.Engine/graphics/gl.h | 19 --- Source/Asura.Engine/graphics/image.cpp | 32 ----- Source/Asura.Engine/graphics/image.h | 75 ------------ Source/Asura.Engine/graphics/image_data.cpp | 50 -------- Source/Asura.Engine/graphics/image_data.h | 62 ---------- Source/Asura.Engine/graphics/image_decoder.h | 35 ------ Source/Asura.Engine/graphics/mesh2d.cpp | 0 Source/Asura.Engine/graphics/mesh2d.h | 30 ----- Source/Asura.Engine/graphics/mesh2d_data.cpp | 0 Source/Asura.Engine/graphics/mesh2d_data.h | 0 Source/Asura.Engine/graphics/pixel_format.h | 91 -------------- Source/Asura.Engine/graphics/png_decoder.cpp | 19 --- Source/Asura.Engine/graphics/png_decoder.h | 27 ----- Source/Asura.Engine/graphics/quad.cpp | 0 Source/Asura.Engine/graphics/quad.h | 1 - Source/Asura.Engine/graphics/render_state.h | 50 -------- Source/Asura.Engine/graphics/render_target.cpp | 0 Source/Asura.Engine/graphics/render_target.h | 54 --------- Source/Asura.Engine/graphics/shader.cpp | 81 ------------- Source/Asura.Engine/graphics/shader.h | 125 ------------------- Source/Asura.Engine/graphics/shape.cpp | 0 Source/Asura.Engine/graphics/shape.h | 0 Source/Asura.Engine/graphics/sprite_batch.cpp | 0 Source/Asura.Engine/graphics/sprite_batch.h | 28 ----- Source/Asura.Engine/graphics/stb_decoder.cpp | 65 ---------- Source/Asura.Engine/graphics/stb_decoder.h | 28 ----- Source/Asura.Engine/graphics/texture.cpp | 26 ---- Source/Asura.Engine/graphics/texture.h | 66 ----------- Source/Asura.Engine/graphics/window.cpp | 56 --------- Source/Asura.Engine/graphics/window.h | 85 ------------- 49 files changed, 1678 deletions(-) delete mode 100644 Source/Asura.Engine/graphics/application.graphics.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/canvas.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/color.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/image.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/image_data.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/mesh2d.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/mesh2d_data.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/shader.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/sprite_batch.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/binding/window.binding.cpp delete mode 100644 Source/Asura.Engine/graphics/blend_mode.h delete mode 100644 Source/Asura.Engine/graphics/canvas.cpp delete mode 100644 Source/Asura.Engine/graphics/canvas.h delete mode 100644 Source/Asura.Engine/graphics/color.cpp delete mode 100644 Source/Asura.Engine/graphics/color.h delete mode 100644 Source/Asura.Engine/graphics/color_palette.h delete mode 100644 Source/Asura.Engine/graphics/gif.cpp delete mode 100644 Source/Asura.Engine/graphics/gif.h delete mode 100644 Source/Asura.Engine/graphics/gl.cpp delete mode 100644 Source/Asura.Engine/graphics/gl.h delete mode 100644 Source/Asura.Engine/graphics/image.cpp delete mode 100644 Source/Asura.Engine/graphics/image.h delete mode 100644 Source/Asura.Engine/graphics/image_data.cpp delete mode 100644 Source/Asura.Engine/graphics/image_data.h delete mode 100644 Source/Asura.Engine/graphics/image_decoder.h delete mode 100644 Source/Asura.Engine/graphics/mesh2d.cpp delete mode 100644 Source/Asura.Engine/graphics/mesh2d.h delete mode 100644 Source/Asura.Engine/graphics/mesh2d_data.cpp delete mode 100644 Source/Asura.Engine/graphics/mesh2d_data.h delete mode 100644 Source/Asura.Engine/graphics/pixel_format.h delete mode 100644 Source/Asura.Engine/graphics/png_decoder.cpp delete mode 100644 Source/Asura.Engine/graphics/png_decoder.h delete mode 100644 Source/Asura.Engine/graphics/quad.cpp delete mode 100644 Source/Asura.Engine/graphics/quad.h delete mode 100644 Source/Asura.Engine/graphics/render_state.h delete mode 100644 Source/Asura.Engine/graphics/render_target.cpp delete mode 100644 Source/Asura.Engine/graphics/render_target.h delete mode 100644 Source/Asura.Engine/graphics/shader.cpp delete mode 100644 Source/Asura.Engine/graphics/shader.h delete mode 100644 Source/Asura.Engine/graphics/shape.cpp delete mode 100644 Source/Asura.Engine/graphics/shape.h delete mode 100644 Source/Asura.Engine/graphics/sprite_batch.cpp delete mode 100644 Source/Asura.Engine/graphics/sprite_batch.h delete mode 100644 Source/Asura.Engine/graphics/stb_decoder.cpp delete mode 100644 Source/Asura.Engine/graphics/stb_decoder.h delete mode 100644 Source/Asura.Engine/graphics/texture.cpp delete mode 100644 Source/Asura.Engine/graphics/texture.h delete mode 100644 Source/Asura.Engine/graphics/window.cpp delete mode 100644 Source/Asura.Engine/graphics/window.h (limited to 'Source/Asura.Engine/graphics') diff --git a/Source/Asura.Engine/graphics/application.graphics.cpp b/Source/Asura.Engine/graphics/application.graphics.cpp deleted file mode 100644 index 4d3102f..0000000 --- a/Source/Asura.Engine/graphics/application.graphics.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Application.h" -#include "Sdl2/SDL.h" -#include "Exceptions/Exception.h" - -namespace AsuraEngine -{ - - /// - /// 初始化graphics模块 - /// - bool Application::InitGraphics() - { - - if (SDL_Init(SDL_INIT_VIDEO) < 0) - return false; - - } - -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/binding/canvas.binding.cpp b/Source/Asura.Engine/graphics/binding/canvas.binding.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/binding/color.binding.cpp b/Source/Asura.Engine/graphics/binding/color.binding.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/binding/image.binding.cpp b/Source/Asura.Engine/graphics/binding/image.binding.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/binding/image_data.binding.cpp b/Source/Asura.Engine/graphics/binding/image_data.binding.cpp deleted file mode 100644 index d576718..0000000 --- a/Source/Asura.Engine/graphics/binding/image_data.binding.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "../image.h" - -using namespace Luax; - -namespace AsuraEngine -{ - namespace Graphics - { - - void Image::RegisterLuaxInterface(LuaxState& state) - { - - } - - void Image::RegisterLuaxClass(LuaxState& state) - { - - } - - void Image::RegisterLuaxPostprocess(LuaxState& state) - { - // blend方法枚举,AsuraEngine.EBlendMode - LuaxEnum EBlendMode[] = { - { "Additive", 1 }, - { "PreBlend", 2 }, - { "Substruction", 3 }, - { "Multiplied", 4 }, - {0, 0} - }; - - state.RegisterEnum("EBlendMode", EBlendMode); - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/binding/mesh2d.binding.cpp b/Source/Asura.Engine/graphics/binding/mesh2d.binding.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/binding/mesh2d_data.binding.cpp b/Source/Asura.Engine/graphics/binding/mesh2d_data.binding.cpp deleted file mode 100644 index 6e15052..0000000 --- a/Source/Asura.Engine/graphics/binding/mesh2d_data.binding.cpp +++ /dev/null @@ -1,9 +0,0 @@ -namespace AsuraEngine -{ - namespace Graphics - { - - - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/binding/shader.binding.cpp b/Source/Asura.Engine/graphics/binding/shader.binding.cpp deleted file mode 100644 index 1190997..0000000 --- a/Source/Asura.Engine/graphics/binding/shader.binding.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "../shader.h" - -using namespace Luax; - -namespace AsuraEngine -{ - namespace Graphics - { - - void Shader::RegisterLuaxInterface(LuaxState& state) - { - - } - - void Shader::RegisterLuaxClass(LuaxState& state) - { - - LuaxEnum EBuiltIn[] = { - {0, 0} - }; - - state.RegisterEnum("EBuiltIn", EBuiltIn); - - } - - void Shader::RegisterLuaxPostprocess(LuaxState& state) - { - - } - - /// - /// 将此shader设置为活动。 - /// - int Shader::l_Use(lua_State* L) - { - LUAX_STATE(L); - - } - - /// - /// 将此shader设置为非活动。 - /// - int Shader::l_Unuse(lua_State* L) - { - LUAX_STATE(L); - - } - - /// - /// 从着色器代码中构建shader程序。如果成功返回true,失败返回false。 - /// - int Shader::l_Load(lua_State* L) - { - LUAX_STATE(L); - - } - - /// - /// 判断shader是否有这个uniform,如果有返回true,否则返回false - /// - int Shader::l_HasUniform(lua_State* L) - { - LUAX_STATE(L); - - } - - /// - /// 后的uniforms的location,如果没有这个uniform,返回nil,否则返回对应的loc - /// - int Shader::l_GetUniformLocation(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetBuiltInUniforms(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetUniformFloat(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetUniformTexture(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetUniformVector2(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetUniformVector3(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetUniformVector4(lua_State* L) - { - LUAX_STATE(L); - - } - - int Shader::l_SetUniformColor(lua_State* L) - { - LUAX_STATE(L); - - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/binding/sprite_batch.binding.cpp b/Source/Asura.Engine/graphics/binding/sprite_batch.binding.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/binding/window.binding.cpp b/Source/Asura.Engine/graphics/binding/window.binding.cpp deleted file mode 100644 index 3befc8c..0000000 --- a/Source/Asura.Engine/graphics/binding/window.binding.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "../Window.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - - - } -} diff --git a/Source/Asura.Engine/graphics/blend_mode.h b/Source/Asura.Engine/graphics/blend_mode.h deleted file mode 100644 index 775cc45..0000000 --- a/Source/Asura.Engine/graphics/blend_mode.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __ASURA_ENGINE_BLEND_MODE_H__ -#define __ASURA_ENGINE_BLEND_MODE_H__ - -namespace AsuraEngine -{ - namespace Graphics - { - - enum BlendMode - { - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/canvas.cpp b/Source/Asura.Engine/graphics/canvas.cpp deleted file mode 100644 index 61787b6..0000000 --- a/Source/Asura.Engine/graphics/canvas.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "Canvas.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - Canvas::Canvas() - : Texture() - , mWidth(0) - , mHeight(0) - { - glGenFramebuffers(1, &mFBO); - GLint current_fbo; - glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); - glBindFramebuffer(GL_FRAMEBUFFER, mFBO); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextureHandle, 0); - glBindFramebuffer(GL_FRAMEBUFFER, current_fbo); - } - - void Canvas::SetSize(uint w, uint h) - { - GLint current_tex; - glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_tex); - glBindTexture(GL_TEXTURE_2D, mTextureHandle); - - glBindTexture(GL_TEXTURE_2D, current_tex); - } - - void Canvas::Bind() - { - - } - - void Canvas::Unbind() - { - - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/canvas.h b/Source/Asura.Engine/graphics/canvas.h deleted file mode 100644 index c4e0f65..0000000 --- a/Source/Asura.Engine/graphics/canvas.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef __ASURA_ENGINE_CANVAS_H__ -#define __ASURA_ENGINE_CANVAS_H__ - -#include - -#include "Math/Rect.hpp" -#include "GL.h" -#include "Texture.h" -#include "RenderTarget.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// Canvas也可以称为render texture,自身也可以作为texture渲染。 - /// - class Canvas ASURA_FINAL - : public Drawable - , public RenderTarget - , public Scripting::Portable - { - public: - - Canvas(); - - ~Canvas(); - - /// - /// 设置render texture的大小 - /// - void SetSize(uint w, uint h); - - void Clear(const Color& col = Color::Black) override; - - void Clear(const Math::Recti& quad, const Color& col = Color::Black) override; - - void Render(const RenderTarget* rt, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); - - void Render(const RenderTarget* rt, const Math::Rectf& quad, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); - - void Draw(const Drawable* texture, const RenderState& state); - - void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state); - - private: - - /// - /// Frame buffer object id. - /// - GLuint mFBO; - - /// - /// canvas的大小 - /// - uint mWidth, mHeight; - - public: - - //---------------------------------------------------------------------------------------------------------- - - LUAX_DECL_FACTORY(SimCanvas); - - LUAX_DECL_METHOD(l_SetSize); - LUAX_DECL_METHOD(l_Bind); - LUAX_DECL_METHOD(l_Unbind); - - //---------------------------------------------------------------------------------------------------------- - - }; - - /// - /// Canvas别名为RenderTexture - /// - using RenderTexture = Canvas; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/color.cpp b/Source/Asura.Engine/graphics/color.cpp deleted file mode 100644 index 106493d..0000000 --- a/Source/Asura.Engine/graphics/color.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#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 deleted file mode 100644 index 0d65cb1..0000000 --- a/Source/Asura.Engine/graphics/color.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef __ASURA_ENGINE_COLOR_H__ -#define __ASURA_ENGINE_COLOR_H__ - -#include "Scripting/Luax.hpp" -#include "Scripting/Portable.h" -#include "Config.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class Color; - - /// - /// 32bits颜色 - /// - class Color32 ASURA_FINAL: public Scripting::Portable - { - public: - - Color32(); - - ~Color32(); - - Color32(const Color32& c); - - Color32(const Color& c); - - Color32(byte r, byte g, byte b, byte a); - - byte r, g, b, a; - - //---------------------------------------------------------------------------------------------------------- - - LUAX_DECL_FACTORY(Color32); - - LUAX_DECL_METHOD(l_ToColor); - LUAX_DECL_METHOD(l_GetRed); - LUAX_DECL_METHOD(l_GetGreen); - LUAX_DECL_METHOD(l_GetBlue); - LUAX_DECL_METHOD(l_GetAlpha); - 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 ASURA_FINAL: public Scripting::Portable - { - public: - - static Color Black; - static Color White; - static Color Red; - static Color Green; - static Color Blue; - - Color(); - - Color(const Color& c); - - Color(float r, float g, float b, float a); - - Color(const Color32& c); - - ~Color(); - - Color operator *(const Color& c); - - float r, g, b, a; - - //---------------------------------------------------------------------------------------------------------- - - LUAX_DECL_FACTORY(Color); - - LUAX_DECL_METHOD(l_ToColor32); - LUAX_DECL_METHOD(l_SetColor); - LUAX_DECL_METHOD(l_GetColor); - LUAX_DECL_METHOD(l_Multiply); // 颜色乘法 - - //---------------------------------------------------------------------------------------------------------- - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/color_palette.h b/Source/Asura.Engine/graphics/color_palette.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/gif.cpp b/Source/Asura.Engine/graphics/gif.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/gif.h b/Source/Asura.Engine/graphics/gif.h deleted file mode 100644 index 36a3259..0000000 --- a/Source/Asura.Engine/graphics/gif.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __ASURA_GIF_H__ -#define __ASURA_GIF_H__ - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/gl.cpp b/Source/Asura.Engine/graphics/gl.cpp deleted file mode 100644 index dac2ea4..0000000 --- a/Source/Asura.Engine/graphics/gl.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "OpenGL.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/gl.h b/Source/Asura.Engine/graphics/gl.h deleted file mode 100644 index 0661e17..0000000 --- a/Source/Asura.Engine/graphics/gl.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __ASURA_ENGINE_OPENGL_H__ -#define __ASURA_ENGINE_OPENGL_H__ - -#include "glad/glad.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class OpenGL - { - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/image.cpp b/Source/Asura.Engine/graphics/image.cpp deleted file mode 100644 index e704945..0000000 --- a/Source/Asura.Engine/graphics/image.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Config.h" -#include "Image.h" -#include "GL.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - Image::Image() - { - } - - Image::~Image() - { - } - - //创建\更新纹理像素信息 - bool Image::Load(ImageData* data) - { - ASSERT(data); - - glBindTexture(GL_TEXTURE_2D, mTextureHandle); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, data->width, data->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data->pixels); - glBindTexture(GL_TEXTURE_2D, 0); - return true; - - RRA(data, mImageData); - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/image.h b/Source/Asura.Engine/graphics/image.h deleted file mode 100644 index 916c365..0000000 --- a/Source/Asura.Engine/graphics/image.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __ASURA_ENGINE_IMAGE_H__ -#define __ASURA_ENGINE_IMAGE_H__ - -#include "math/vector2.hpp" -#include "scripting/portable.hpp" -#include "fileSystem/reloadable.h" -#include "stringmap.hpp" -#include "manager.hpp" -#include "texture.h" -#include "color.h" -#include "image_data.h" -#include "render_state.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class ImageFactory; - - /// - /// Image是图片从内存中载入后,读取进游戏后保存的结果。一个Image在内存、显存中只会保存一份,不会产生副本。需要特征 - /// 化的区别image,如锚点位置,缩放和旋转角度,使用sprite。是一个只读类。主要是考虑到editor和engine使用不同的封装。 - /// - class Image ASURA_FINAL - : public Drawable - , public Scripting::Portable - , public Filesystem::Reloadable - { - public: - - Image(); - - ~Image(); - - /// - /// 从数据buffer构建image像素信息,如果mPixels不为空,先清空数据。用来重新构建image,使用glTexImage2D重新提交image - /// 的像素数据。 - /// - bool Load(ImageData* data); - - uint GetWidth(); - uint GetHeight(); - Math::Vector2u GetSize(); - - /// - /// 获得某一个位置的像素 - /// - Color32 GetPixel(uint x, uint y); - - void Render(const RenderTarget* rt, const RenderState& state) override; - - void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) override; - - private: - - ImageData* mImageData; - - Math::Vector2u mSize; - - public: - - LUAX_DECL_FACTORY(SimImage); - - LUAX_DECL_METHOD(l_Load); - LUAX_DECL_METHOD(l_GetWidth); - LUAX_DECL_METHOD(l_GetHeight); - LUAX_DECL_METHOD(l_GetSize); - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/image_data.cpp b/Source/Asura.Engine/graphics/image_data.cpp deleted file mode 100644 index 821bfd6..0000000 --- a/Source/Asura.Engine/graphics/image_data.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "image_data.h" -#include "png_decoder.h" -#include "stb_decoder.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - using namespace std; - - // 解析image的decoder,用来作为解析策略。 - list ImageData::ImageDecoders = { - new PNGDecoder(), // png - new STBDecoder() // jpeg, tga, bmp - }; - - ImageData::ImageData(const Filesystem::DataBuffer& buffer) - : DecodedData(buffer) - { - } - - ImageData::~ImageData() - { - if (pixels) - delete[] pixels; - } - - /// - /// 解析,如果无法成功,抛出异常 - /// - void ImageData::Decode(const Filesystem::DataBuffer& buffer) - { - for (ImageDecoder* decoder : ImageDecoders) - { - if (decoder->CanDecode(buffer)) - { - decoder->Decode(buffer, this); - return; - } - } - } - - Color ImageData::GetPixel(uint x, uint y) - { - - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/image_data.h b/Source/Asura.Engine/graphics/image_data.h deleted file mode 100644 index 1e711a8..0000000 --- a/Source/Asura.Engine/graphics/image_data.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __ASURA_ENGINE_IMAGEDATA_H__ -#define __ASURA_ENGINE_IMAGEDATA_H__ - -#include - -#include "scripting/luax.hpp" -#include "filesystem/decoded_data.h" -#include "image_decoder.h" -#include "pixel_format.h" -#include "color.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class ImageData ASURA_FINAL - : public Filesystem::DecodedData - , public Scripting::Portable - { - public: - - /// - /// 解析图片数据文件,并构建像素信息,如果解析失败,抛出异常 - /// - ImageData(const Filesystem::DataBuffer& buffer); - - ~ImageData(); - - Color GetPixel(uint x, uint y); - - uint width, height; - PixelFormat format; - std::size_t size; - byte* pixels; - - private: - - void Decode(const Filesystem::DataBuffer& buffer) override; - - /// - /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 - /// - static std::list ImageDecoders; - - public: - - //---------------------------------------------------------------------------------------------------------- - - LUAX_DECL_FACTORY(ImageData); - - LUAX_DECL_METHOD(l_GetPixel); - LUAX_DECL_METHOD(l_GetSize); - - //---------------------------------------------------------------------------------------------------------- - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/image_decoder.h b/Source/Asura.Engine/graphics/image_decoder.h deleted file mode 100644 index 2c73fd1..0000000 --- a/Source/Asura.Engine/graphics/image_decoder.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __ASURA_ENGINE_IMAGE_DECODER_H__ -#define __ASURA_ENGINE_IMAGE_DECODER_H__ - -#include "FileSystem/DataBuffer.h" - -#include "ImageData.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class ImageDecoder - { - public: - - ImageDecoder(); - virtual ~ImageDecoder(); - - /// - /// 判断内存是否能用本decoder解压 - /// - virtual bool CanDecode(const Filesystem::DataBuffer& buffer) = 0; - - /// - /// 输入一个编码后的内存,输出一个解压后的Image data,如果解压失败返回nullptr - /// - virtual void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) = 0; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/mesh2d.cpp b/Source/Asura.Engine/graphics/mesh2d.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/mesh2d.h b/Source/Asura.Engine/graphics/mesh2d.h deleted file mode 100644 index 2c58f00..0000000 --- a/Source/Asura.Engine/graphics/mesh2d.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __ASURA_ENGINE_MESH2D_H__ -#define __ASURA_ENGINE_MESH2D_H__ - -#include "Scripting/Luax.hpp" - -#include "scripting/portable.hpp" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// 2D mesh,用于做一些顶点动画。 - /// - class Mesh2D ASURA_FINAL - : public Scripting::Portable - { - public: - - Mesh2D(); - - ~Mesh2D(); - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/mesh2d_data.cpp b/Source/Asura.Engine/graphics/mesh2d_data.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/mesh2d_data.h b/Source/Asura.Engine/graphics/mesh2d_data.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/pixel_format.h b/Source/Asura.Engine/graphics/pixel_format.h deleted file mode 100644 index 8df07d5..0000000 --- a/Source/Asura.Engine/graphics/pixel_format.h +++ /dev/null @@ -1,91 +0,0 @@ -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// 像素格式 - /// - enum PixelFormat - { - PIXELFORMAT_UNKNOWN, - - // these are converted to an actual format by love - PIXELFORMAT_NORMAL, - PIXELFORMAT_HDR, - - // "regular" formats - PIXELFORMAT_R8, - PIXELFORMAT_RG8, - PIXELFORMAT_RGBA8, - PIXELFORMAT_sRGBA8, - PIXELFORMAT_R16, - PIXELFORMAT_RG16, - PIXELFORMAT_RGBA16, - PIXELFORMAT_R16F, - PIXELFORMAT_RG16F, - PIXELFORMAT_RGBA16F, - PIXELFORMAT_R32F, - PIXELFORMAT_RG32F, - PIXELFORMAT_RGBA32F, - - PIXELFORMAT_LA8, // Same as RG8, but accessed as (L, L, L, A) - - // packed formats - PIXELFORMAT_RGBA4, - PIXELFORMAT_RGB5A1, - PIXELFORMAT_RGB565, - PIXELFORMAT_RGB10A2, - PIXELFORMAT_RG11B10F, - - // depth/stencil formats - PIXELFORMAT_STENCIL8, - PIXELFORMAT_DEPTH16, - PIXELFORMAT_DEPTH24, - PIXELFORMAT_DEPTH32F, - PIXELFORMAT_DEPTH24_STENCIL8, - PIXELFORMAT_DEPTH32F_STENCIL8, - - // compressed formats - PIXELFORMAT_DXT1, - PIXELFORMAT_DXT3, - PIXELFORMAT_DXT5, - PIXELFORMAT_BC4, - PIXELFORMAT_BC4s, - PIXELFORMAT_BC5, - PIXELFORMAT_BC5s, - PIXELFORMAT_BC6H, - PIXELFORMAT_BC6Hs, - PIXELFORMAT_BC7, - PIXELFORMAT_PVR1_RGB2, - PIXELFORMAT_PVR1_RGB4, - PIXELFORMAT_PVR1_RGBA2, - PIXELFORMAT_PVR1_RGBA4, - PIXELFORMAT_ETC1, - PIXELFORMAT_ETC2_RGB, - PIXELFORMAT_ETC2_RGBA, - PIXELFORMAT_ETC2_RGBA1, - PIXELFORMAT_EAC_R, - PIXELFORMAT_EAC_Rs, - PIXELFORMAT_EAC_RG, - PIXELFORMAT_EAC_RGs, - PIXELFORMAT_ASTC_4x4, - PIXELFORMAT_ASTC_5x4, - PIXELFORMAT_ASTC_5x5, - PIXELFORMAT_ASTC_6x5, - PIXELFORMAT_ASTC_6x6, - PIXELFORMAT_ASTC_8x5, - PIXELFORMAT_ASTC_8x6, - PIXELFORMAT_ASTC_8x8, - PIXELFORMAT_ASTC_10x5, - PIXELFORMAT_ASTC_10x6, - PIXELFORMAT_ASTC_10x8, - PIXELFORMAT_ASTC_10x10, - PIXELFORMAT_ASTC_12x10, - PIXELFORMAT_ASTC_12x12, - - PIXELFORMAT_MAX_ENUM - }; - - } -} diff --git a/Source/Asura.Engine/graphics/png_decoder.cpp b/Source/Asura.Engine/graphics/png_decoder.cpp deleted file mode 100644 index f919090..0000000 --- a/Source/Asura.Engine/graphics/png_decoder.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "PNGDecoder.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - bool PNGDecoder::CanDecode(const Filesystem::DataBuffer& buffer) - { - return false; - } - - void PNGDecoder::Decode(const Filesystem::DataBuffer& buffer, ImageData& data) - { - - } - - } -} diff --git a/Source/Asura.Engine/graphics/png_decoder.h b/Source/Asura.Engine/graphics/png_decoder.h deleted file mode 100644 index 980753f..0000000 --- a/Source/Asura.Engine/graphics/png_decoder.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __ASURA_ENGINE_PNGDECODER_H__ -#define __ASURA_ENGINE_PNGDECODER_H__ - -#include "ImageDecoder.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// 使用lodepng解压png文件 - /// - class PNGDecoder ASURA_FINAL: public ImageDecoder - { - public: - - bool CanDecode(const Filesystem::DataBuffer& buffer) override; - - void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) override; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/quad.cpp b/Source/Asura.Engine/graphics/quad.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/quad.h b/Source/Asura.Engine/graphics/quad.h deleted file mode 100644 index b7dd3d9..0000000 --- a/Source/Asura.Engine/graphics/quad.h +++ /dev/null @@ -1 +0,0 @@ -// Quad和rect的区别在于,rect是的边偏向于轴,quad不一定。 diff --git a/Source/Asura.Engine/graphics/render_state.h b/Source/Asura.Engine/graphics/render_state.h deleted file mode 100644 index a80efd3..0000000 --- a/Source/Asura.Engine/graphics/render_state.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __ASURA_ENGINE_RENDER_STATE_H__ -#define __ASURA_ENGINE_RENDER_STATE_H__ - -#include "Math/Vector2.hpp" -#include "Math/Rect.hpp" -#include "Math/Transform.h" - -#include "Shader.h" -#include "blend_mode.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// 渲染当前纹理的方式 - /// - struct RenderState ASURA_FINAL - { - /// - /// 默认的render state - /// - static RenderState Default; - - RenderState(); - ~RenderState(); - - /// - /// 位置、缩放、中心位置和旋转 - /// - - Math::Transform transform; - - /// - /// 着色器 - /// - Shader* shader; - - /// - /// 混合方式 - /// - BlendMode blendMode; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/render_target.cpp b/Source/Asura.Engine/graphics/render_target.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/render_target.h b/Source/Asura.Engine/graphics/render_target.h deleted file mode 100644 index d6de164..0000000 --- a/Source/Asura.Engine/graphics/render_target.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __ASURA_ENGINE_RENDERTARGET_H__ -#define __ASURA_ENGINE_RENDERTARGET_H__ - -#include "Math/Rect.hpp" -#include "Texture.h" -#include "Scripting/Portable.h" -#include "Color.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class Drawable; - - /// - /// 可被作为渲染目标的类,派生类有 - /// Canvas(RenderTexture) - /// Window(RenderWindow) - /// - class RenderTarget - { - public: - - RenderTarget() {}; - - virtual ~RenderTarget() {}; - - /// - /// 用颜色col清空整个RT - /// - virtual void Clear(const Color& col = Color::Black) = 0; - - /// - /// 用颜色col清空部分RT - /// - virtual void Clear(const Math::Recti& quad, const Color& col = Color::Black) = 0; - - /// - /// 绘制texture到本RT上 - /// - virtual void Draw(const Drawable* texture, const RenderState& state) = 0; - - /// - /// 绘制一部分texture到本RT上 - /// - virtual void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state) = 0; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/shader.cpp b/Source/Asura.Engine/graphics/shader.cpp deleted file mode 100644 index 1a85866..0000000 --- a/Source/Asura.Engine/graphics/shader.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "Shader.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - Shader::Shader() - { - - } - - Shader::~Shader() - { - - } - - bool Shader::Load(const std::string& vertexShader, const std::string& fragmentShader) - { - - } - - uint Shader::GetUniformLocation(const std::string& uniform) - { - - } - - GLuint Shader::GetGLProgramHandle() - { - return mProgramHandle; - } - - void Shader::Use() - { - - } - - void Shader::Unuse() - { - - } - - void Shader::SetUniformFloat(uint loc, float value) - { - - } - - void Shader::SetUniformFloat(uint loc, float value) - { - - } - - void Shader::SetUniformTexture(uint loc, const Texture& texture) - { - - } - - void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) - { - - } - - void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) - { - - } - - void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) - { - - } - - uint Shader::GetGLTextureUnitCount() - { - GLint maxTextureUnits = 0; - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - return (uint)maxTextureUnits; - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/shader.h b/Source/Asura.Engine/graphics/shader.h deleted file mode 100644 index 65f214e..0000000 --- a/Source/Asura.Engine/graphics/shader.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef __ASURA_ENGINE_SHADER_H__ -#define __ASURA_ENGINE_SHADER_H__ - -#include -#include - -#include "FileSystem/Reloadable.h" -#include "Scripting/Luax.hpp" -#include "Math/Vector2.hpp" -#include "Math/Vector3.hpp" -#include "Math/Vector4.h" -#include "Math/Matrix44.h" -#include "StringMap.hpp" -#include "scripting/portable.hpp" -#include "Color.h" -#include "Manager.hpp" -#include "Texture.h" -#include "GL.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// 一个shader是一个在材质间共享的程序。Shader本身不保存uniforms和顶点数据,只提供设置uniforms和use着色器的方法。编辑 - /// 器针对每个shader,会通过shader代码找到声明的uniforms变量,并暴露给framework的material设置。 - /// - class Shader ASURA_FINAL - : public Scripting::Portable - , public Filesystem::Reloadable - { - public: - - Shader(); - - ~Shader(); - - /// - /// 从代码编译shader,编译时会先检测是否有上次缓存的uniforms location map。使用glAttachShader重新编译生成着色器, - /// 不会重新申请着色器程序。 - /// - bool Load(const std::string& vertexShader, const std::string& fragmentShader); - - /// - /// 将当期shader设置为活动 - /// - void Use(); - - /// - /// 将当期shader设置为非活动 - /// - void Unuse(); - - /// - /// 在已经知道uniform location的情况下,设置值。 - /// - 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); - - uint GetUniformLocation(const std::string& uniform); - - bool HasUniform(const std::string& uniform); - - GLuint GetGLProgramHandle(); - - /// - /// 获得texture unit数量,一般为16个 - /// - static uint GetGLTextureUnitCount(); - - private: - - /// - /// 当前活动的shader - /// - static Shader* mCurrentShader; - - /// - /// 设置内置变量: - /// vec2 Asura_Time x值为进入当前场景开始的时间,y值为上一帧的时间间隔 - /// vec2 Asura_RenderTargetSize RT的大小,以像素为单位 - /// Texture Asura_MainTexture 主纹理 - /// - void SetBuiltInUniforms(); - - /// - /// OpenGL shader program handle. - /// - GLuint mProgramHandle; - - //------------------------------------------------------------------------------------------------------------ - - public: - - LUAX_DECL_FACTORY(SimShader); - - LUAX_DECL_METHOD(l_Use); - LUAX_DECL_METHOD(l_Unuse); - LUAX_DECL_METHOD(l_Load); - LUAX_DECL_METHOD(l_HasUniform); - LUAX_DECL_METHOD(l_GetUniformLocation); - 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); - LUAX_DECL_METHOD(l_SetUniformColor); - - private: - - Luax::LuaxMemberRef mCodeLuaRef; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/shape.cpp b/Source/Asura.Engine/graphics/shape.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/shape.h b/Source/Asura.Engine/graphics/shape.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/sprite_batch.cpp b/Source/Asura.Engine/graphics/sprite_batch.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Engine/graphics/sprite_batch.h b/Source/Asura.Engine/graphics/sprite_batch.h deleted file mode 100644 index 7909519..0000000 --- a/Source/Asura.Engine/graphics/sprite_batch.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __ASURA_ENGINE_SPRITE_BATCH_H__ -#define __ASURA_ENGINE_SPRITE_BATCH_H__ - -#include "Scripting/Portable.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// Sprite batch用在批量渲染单个图片的地方,比如粒子系统。 - /// - class SpriteBatch ASURA_FINAL - : public Scripting::Portable - { - public: - - SpriteBatch(); - - ~SpriteBatch(); - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/stb_decoder.cpp b/Source/Asura.Engine/graphics/stb_decoder.cpp deleted file mode 100644 index b14d0f3..0000000 --- a/Source/Asura.Engine/graphics/stb_decoder.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "STBDecoder.h" - -#include "Exceptions/Exception.h" -#include "stb/stb_image.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - bool STBDecoder::CanDecode(const Filesystem::DataBuffer& buffer) - { - int w = 0; - int h = 0; - int comp = 0; - - int status = stbi_info_from_memory((const stbi_uc*)buffer.data, buffer.size, &w, &h, &comp); - - return status == 1 && w > 0 && h > 0; - } - - void STBDecoder::Decode(const Filesystem::DataBuffer& db, ImageData& imageData) - { - const stbi_uc *buffer = (const stbi_uc *)db.data; - int bufferlen = db.size; - int width, height; - int comp = 0; - byte* data = nullptr; - PixelFormat format = PIXELFORMAT_UNKNOWN; - std::size_t size = 0; - - if (stbi_is_hdr_from_memory(buffer, bufferlen)) - { - // 4个channel都是float - data = (byte*)stbi_loadf_from_memory(buffer, bufferlen, &width, &height, &comp, STBI_rgb_alpha); - format = PIXELFORMAT_RGBA32F; - size = width * height * 4 * sizeof(float); - } - else - { - data = (byte*)stbi_load_from_memory(buffer, bufferlen, &width, &height, &comp, STBI_rgb_alpha); - format = PIXELFORMAT_ASTC_8x5; - size = width * height * 4; - } - if (data) - { - // 保证内存被释放,做一个防护,理论上不会出现没有释放的情况,因为image data是一次性的,image才是多次的。 - if (imageData.pixels) - delete[] imageData.pixels; - imageData.pixels = (byte*)data; - imageData.format = format; - imageData.width = width; - imageData.height = height; - } - else - { - const char *err = stbi_failure_reason(); - if (err == nullptr) - err = "unknown error"; - throw Exception("Could not decode image with stb_image (%s).", err); - } - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/stb_decoder.h b/Source/Asura.Engine/graphics/stb_decoder.h deleted file mode 100644 index 57b247c..0000000 --- a/Source/Asura.Engine/graphics/stb_decoder.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __ASURA_ENGINE_STBDECODER_H__ -#define __ASURA_ENGINE_STBDECODER_H__ - -#include "image_decoder.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - /// - /// 使用stb_image解压JPEG、TGA、BMP文件 - /// - class STBDecoder ASURA_FINAL - : public ImageDecoder - { - public: - - bool CanDecode(const Filesystem::DataBuffer& buffer) override; - - void Decode(const Filesystem::DataBuffer& buffer, ImageData& data) override; - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/texture.cpp b/Source/Asura.Engine/graphics/texture.cpp deleted file mode 100644 index 6cb6497..0000000 --- a/Source/Asura.Engine/graphics/texture.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Texture.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - Texture::Texture() - : mTextureHandle(0) - { - // 申请GL texture - glGenTextures(1, &mTextureHandle); - } - - Texture::~Texture() - { - glDeleteTextures(1, &mTextureHandle); - } - - GLuint Texture::GetGLTextureHandle() const - { - return mTextureHandle; - } - - } -} \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/texture.h b/Source/Asura.Engine/graphics/texture.h deleted file mode 100644 index 81aa469..0000000 --- a/Source/Asura.Engine/graphics/texture.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef __ASURA_ENGINE_TEXTURE_H__ -#define __ASURA_ENGINE_TEXTURE_H__ - -#include "Config.h" -#include "Math/Rect.hpp" -#include "Math/Vector2.hpp" -#include "Scripting/Luax.hpp" -#include "RenderState.h" -#include "GL.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - class RenderTarget; - - /// - /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔坐标系为标准。 - /// 在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 - /// - ASURA_ABSTRACT class Texture - { - public: - - Texture(); - - virtual ~Texture(); - - GLuint GetGLTextureHandle() const; - - /// - /// 渲染整个texture到rt上,原点在左上角,向右,向下延伸 - /// - virtual void Render(const RenderTarget* rt, const RenderState& state) = 0; - - /// - /// 渲染texture的一部分到rt上,原点在左上角,向右,向下延伸。 - /// - virtual void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) = 0; - - /// - /// 设置过滤方式 - /// - void SetSmooth(bool smooth); - - /// - /// 设置重复方式 - /// - void SetRepeated(); - - protected: - - /// - /// OpenGL texture handle。 - /// - GLuint mTextureHandle; - - }; - - using Drawable = Texture; - - } -} - -#endif \ No newline at end of file diff --git a/Source/Asura.Engine/graphics/window.cpp b/Source/Asura.Engine/graphics/window.cpp deleted file mode 100644 index bb941e1..0000000 --- a/Source/Asura.Engine/graphics/window.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "Config.h" -#include "Window.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - Window::Window(WindowStyle style) - { - //mWindowHandle = SDL_CreateWindow(); - } - - Window::~Window() - { - - } - - SDL_Window* Window::GetSDLWindowHandle() - { - return mWindowHandle; - } - - void Window::SetPosition(int x, int y) - { - ASSERT(mWindowHandle); - SDL_SetWindowPosition(mWindowHandle, x, y); - } - - void Window::SetTitle(const std::string& title) - { - - } - - void Window::Show() - { - - } - - void Window::Hide() - { - - } - - void Window::SetWindowStyle(WindowStyle style) - { - - } - - void Window::SwapRenderBuffer() - { - - } - - } -} diff --git a/Source/Asura.Engine/graphics/window.h b/Source/Asura.Engine/graphics/window.h deleted file mode 100644 index 973fd98..0000000 --- a/Source/Asura.Engine/graphics/window.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef __ASURA_ENGINE_WINDOW_H__ -#define __ASURA_ENGINE_WINDOW_H__ - -#include "SDL2/Sdl.h" -#include "Graphics/RenderTarget.h" -#include "Math/Vector2.hpp" -#include "Scripting/Portable.h" - -namespace AsuraEngine -{ - namespace Graphics - { - - enum WindowStyle - { - WINDOW_STYLE_FULLSCREEN = 1 << 1, - }; - - /// - /// 窗口,支持多窗口。在编辑器下需要多个窗口支持,runner只需要一个窗口。 - /// - class Window ASURA_FINAL - : public RenderTarget - , public Scripting::Portable - { - public: - - Window(WindowStyle style); - - ~Window(); - - SDL_Window* GetSDLWindowHandle(); - - void SetSize(uint width, uint height); - - void SetPosition(int x, int y); - - void SetTitle(const std::string& title); - - void SetWindowStyle(WindowStyle style); - - void Show(); - - void Hide(); - - /// - /// 如果是开启双缓冲的窗口,需要交换缓冲区来展示到前台 - /// - void SwapRenderBuffer(); - - void Clear(const Color& col = Color::Black) override; - - void Clear(const Math::Recti& quad, const Color& col = Color::Black) override; - - void Draw(const Drawable* texture, const RenderState& state) override; - - void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state) override; - - private: - - /// - /// SDL window handle. - /// - SDL_Window* mWindowHandle; - - Math::Vector2i mPosition; - - Math::Vector2i mSize; - - public: - - //---------------------------------------------------------------------------------------------------------- - - LUAX_DECL_FACTORY(Window); - - //---------------------------------------------------------------------------------------------------------- - - }; - - using RenderWindow = Window; - - } -} - -#endif \ No newline at end of file -- cgit v1.1-26-g67d0