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 --- 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/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/Mesh2D.cpp | 0 Source/Asura.Engine/Graphics/Mesh2D.h | 30 ----- Source/Asura.Engine/Graphics/Quad.cpp | 0 Source/Asura.Engine/Graphics/Quad.h | 1 - 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/Texture.cpp | 26 ---- Source/Asura.Engine/Graphics/Texture.h | 66 ----------- Source/Asura.Engine/Graphics/Window.cpp | 56 --------- Source/Asura.Engine/Graphics/Window.h | 85 ------------- 21 files changed, 974 deletions(-) delete mode 100644 Source/Asura.Engine/Graphics/Application.Graphics.cpp 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/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/Mesh2D.cpp delete mode 100644 Source/Asura.Engine/Graphics/Mesh2D.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/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/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/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/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/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/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/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/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