From a077eb38b01292611f4f6031b75e3e2c1c20f06e Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 16 Aug 2019 08:54:08 +0800 Subject: *misc --- Bin/win64/01-window.exe | Bin 1462272 -> 1462272 bytes Bin/win64/SDL2.dll | Bin 2491904 -> 2491904 bytes Build/.vs/Asura/v15/Server/sqlite3/storage.ide-shm | Bin 32768 -> 32768 bytes Build/.vs/Asura/v15/Server/sqlite3/storage.ide-wal | Bin 539752 -> 552112 bytes Build/Asura.Editor/Asura.Editor.vcxproj | 21 +- Build/Asura.Editor/Asura.Editor.vcxproj.filters | 69 +- Build/Asura.sln | 13 + Build/external/Json/Json.vcxproj | 122 ++++ Build/external/Json/Json.vcxproj.filters | 2 + Build/external/Json/Json.vcxproj.user | 4 + Build/modules/asura-base/asura-base.vcxproj | 6 +- .../modules/asura-base/asura-base.vcxproj.filters | 21 +- Build/modules/asura-box2d/asura-box2d.vcxproj | 48 +- .../asura-box2d/asura-box2d.vcxproj.filters | 104 +-- Build/modules/asura-core/asura-core.vcxproj | 44 +- .../modules/asura-core/asura-core.vcxproj.filters | 128 ++-- Build/modules/asura-json/asura-json.vcxproj | 4 +- .../modules/asura-json/asura-json.vcxproj.filters | 8 +- .../bindingGen.csproj.CoreCompileInputs.cache | 2 +- Samples/Hello/entities.folder.asset | 6 +- Samples/Hello/gfx.folder.asset | 4 +- Source/Asura.Editor/Controls/GUIPanel.cpp | 6 - Source/Asura.Editor/Controls/GUIPanel.h | 10 +- Source/Asura.Editor/Graphics/GUIMaterial.cpp | 5 + Source/Asura.Editor/Graphics/GUIMaterial.h | 22 + Source/Asura.Editor/Graphics/GUIStyle.cpp | 4 + Source/Asura.Editor/Graphics/GUIStyle.h | 34 + Source/Asura.Editor/Graphics/Pen.cpp | 0 Source/Asura.Editor/Graphics/Pen.h | 7 - Source/Asura.Editor/Graphics/Shader.h | 13 +- .../Asura.Editor/Graphics/Shaders/GUIClip.shader.h | 35 + .../Asura.Editor/Graphics/Shaders/GUIText.shader.h | 29 + .../Graphics/Shaders/GUITexture.shader.h | 35 + Source/Asura.Editor/Graphics/Style.cpp | 0 Source/Asura.Editor/Graphics/Style.h | 15 - .../Asura.Editor/Graphics/shaders/image.shader.h | 35 - .../Asura.Editor/Graphics/shaders/polygon.shader.h | 29 - Source/Asura.Editor/System/ContainerFrame.cpp | 6 + Source/Asura.Editor/System/ContainerFrame.h | 63 ++ Source/Asura.Editor/System/ContainerWindow.h | 14 +- Source/Asura.Editor/System/GUIWindow.cpp | 0 Source/Asura.Editor/System/GUIWindow.h | 36 + Source/Asura.Editor/System/Input.cpp | 2 +- Source/modules/asura-base/Classes.h | 11 +- Source/modules/asura-base/Math/Matrix44.h | 8 +- Source/modules/asura-base/Math/Quaternion.h | 4 +- Source/modules/asura-base/Math/Random.h | 4 +- Source/modules/asura-base/Math/Rect.hpp | 8 +- Source/modules/asura-base/Math/Transform.h | 6 +- Source/modules/asura-base/Math/Vector2.hpp | 6 +- Source/modules/asura-base/Math/Vector3.hpp | 8 +- Source/modules/asura-base/Math/Vector4.h | 8 +- Source/modules/asura-base/Misc/GUID.cpp | 0 Source/modules/asura-base/Misc/GUID.h | 0 Source/modules/asura-base/Misc/UTF8.cpp | 395 +++++++++++ Source/modules/asura-base/Misc/UTF8.h | 20 + Source/modules/asura-base/Utilities/LinkedList.cpp | 0 Source/modules/asura-base/Utilities/LinkedList.h | 388 +++++++++++ .../modules/asura-base/Utilities/dynamic_array.h | 337 +++++++++ Source/modules/asura-box2d/Physics/Body.h | 64 -- Source/modules/asura-box2d/Physics/ChainShape.h | 29 - Source/modules/asura-box2d/Physics/CircleShape.h | 0 Source/modules/asura-box2d/Physics/Contact.h | 0 Source/modules/asura-box2d/Physics/DebugDraw.h | 9 - Source/modules/asura-box2d/Physics/DistanceJoint.h | 0 Source/modules/asura-box2d/Physics/EdgeShape.h | 0 Source/modules/asura-box2d/Physics/Fixture.h | 17 - Source/modules/asura-box2d/Physics/FrictionJoint.h | 0 Source/modules/asura-box2d/Physics/GearJoint.h | 0 Source/modules/asura-box2d/Physics/Joint.h | 0 Source/modules/asura-box2d/Physics/MotorJoint.h | 0 Source/modules/asura-box2d/Physics/MouseJoint.h | 0 Source/modules/asura-box2d/Physics/PolygonShape.h | 0 .../modules/asura-box2d/Physics/PrismaticJoint.h | 0 Source/modules/asura-box2d/Physics/PulleyJoint.h | 0 Source/modules/asura-box2d/Physics/RevoluteJoint.h | 0 Source/modules/asura-box2d/Physics/RopeJoint.h | 0 Source/modules/asura-box2d/Physics/Shape.h | 0 Source/modules/asura-box2d/Physics/WeldJoint.h | 0 Source/modules/asura-box2d/Physics/WheelJoint.h | 0 Source/modules/asura-box2d/Physics/World.h | 18 - .../modules/asura-box2d/Physics/binding/_body.cpp | 171 ----- .../modules/asura-box2d/Physics/binding/_world.cpp | 21 - Source/modules/asura-box2d/Physics2D/Body.h | 64 ++ Source/modules/asura-box2d/Physics2D/ChainShape.h | 29 + Source/modules/asura-box2d/Physics2D/CircleShape.h | 0 Source/modules/asura-box2d/Physics2D/Contact.h | 0 Source/modules/asura-box2d/Physics2D/DebugDraw.h | 9 + .../modules/asura-box2d/Physics2D/DistanceJoint.h | 0 Source/modules/asura-box2d/Physics2D/EdgeShape.h | 0 Source/modules/asura-box2d/Physics2D/Fixture.h | 17 + .../modules/asura-box2d/Physics2D/FrictionJoint.h | 0 Source/modules/asura-box2d/Physics2D/GearJoint.h | 0 Source/modules/asura-box2d/Physics2D/Joint.h | 0 Source/modules/asura-box2d/Physics2D/MotorJoint.h | 0 Source/modules/asura-box2d/Physics2D/MouseJoint.h | 0 .../modules/asura-box2d/Physics2D/PolygonShape.h | 0 .../modules/asura-box2d/Physics2D/PrismaticJoint.h | 0 Source/modules/asura-box2d/Physics2D/PulleyJoint.h | 0 .../modules/asura-box2d/Physics2D/RevoluteJoint.h | 0 Source/modules/asura-box2d/Physics2D/RopeJoint.h | 0 Source/modules/asura-box2d/Physics2D/Shape.h | 0 Source/modules/asura-box2d/Physics2D/WeldJoint.h | 0 Source/modules/asura-box2d/Physics2D/WheelJoint.h | 0 Source/modules/asura-box2d/Physics2D/World.h | 18 + .../asura-box2d/Physics2D/binding/_body.cpp | 171 +++++ .../asura-box2d/Physics2D/binding/_world.cpp | 21 + Source/modules/asura-core/Font/TTF.cpp | 0 Source/modules/asura-core/Font/TTF.h | 17 - Source/modules/asura-core/Font/TTFImporter.cpp | 0 Source/modules/asura-core/Font/TTFImporter.h | 0 Source/modules/asura-core/Font/Utf.hpp | 720 -------------------- Source/modules/asura-core/Font/Utf.inc | 752 --------------------- Source/modules/asura-core/Graphics/DrawInfo.h | 8 + Source/modules/asura-core/Graphics/GPUBuffer.cpp | 13 +- Source/modules/asura-core/Graphics/GfxDevice.cpp | 76 +-- Source/modules/asura-core/Graphics/GfxDevice.h | 110 ++- Source/modules/asura-core/Graphics/Image.cpp | 103 --- Source/modules/asura-core/Graphics/Image.h | 63 -- Source/modules/asura-core/Graphics/MatrixStack.cpp | 2 +- Source/modules/asura-core/Graphics/MatrixStack.h | 26 +- Source/modules/asura-core/Graphics/Mesh.cpp | 0 Source/modules/asura-core/Graphics/Mesh.h | 0 Source/modules/asura-core/Graphics/Mesh2D.cpp | 0 Source/modules/asura-core/Graphics/Mesh2D.h | 52 -- .../modules/asura-core/Graphics/RenderTarget.cpp | 0 Source/modules/asura-core/Graphics/RenderTarget.h | 52 -- .../modules/asura-core/Graphics/RenderTexture.cpp | 0 Source/modules/asura-core/Graphics/RenderTexture.h | 22 + Source/modules/asura-core/Graphics/Shader.cpp | 26 +- Source/modules/asura-core/Graphics/Shader.h | 27 +- Source/modules/asura-core/Graphics/Texture.h | 38 +- Source/modules/asura-core/Graphics/VBO.cpp | 0 Source/modules/asura-core/Graphics/VBO.h | 27 - Source/modules/asura-core/Graphics/VBOs.cpp | 0 Source/modules/asura-core/Graphics/VBOs.h | 56 ++ .../asura-core/Graphics/binding/Canvas.binding.cpp | 48 ++ .../asura-core/Graphics/binding/Color.binding.cpp | 130 ++++ .../Graphics/binding/Color32.binding.cpp | 66 ++ .../Graphics/binding/GPUBuffer.binding.cpp | 118 ++++ .../Graphics/binding/GfxDevice.binding.cpp | 151 +++++ .../asura-core/Graphics/binding/Image.binding.cpp | 71 ++ .../Graphics/binding/IndexBuffer.binding.cpp | 31 + .../asura-core/Graphics/binding/Mesh.binding.cpp | 20 + .../asura-core/Graphics/binding/Shader.binding.cpp | 131 ++++ .../Graphics/binding/SpriteBatch.binding.cpp | 20 + .../Graphics/binding/Texture.binding.cpp | 85 +++ .../Graphics/binding/VertexBuffer.binding.cpp | 38 ++ .../asura-core/Graphics/binding/_canvas.cpp | 48 -- .../modules/asura-core/Graphics/binding/_color.cpp | 130 ---- .../asura-core/Graphics/binding/_color32.cpp | 66 -- .../asura-core/Graphics/binding/_gfx_device.cpp | 151 ----- .../asura-core/Graphics/binding/_gpu_buffer.cpp | 118 ---- .../modules/asura-core/Graphics/binding/_image.cpp | 71 -- .../asura-core/Graphics/binding/_index_buffer.cpp | 31 - .../asura-core/Graphics/binding/_mesh2d.cpp | 20 - .../asura-core/Graphics/binding/_shader.cpp | 131 ---- .../asura-core/Graphics/binding/_sprite_batch.cpp | 20 - .../asura-core/Graphics/binding/_texture.cpp | 85 --- .../asura-core/Graphics/binding/_vertex_buffer.cpp | 38 -- Source/modules/asura-core/Input/InputDevice.h | 5 +- Source/modules/asura-core/Input/InputEvent.h | 2 +- Source/modules/asura-core/Input/InputManager.cpp | 8 +- Source/modules/asura-core/Input/InputManager.h | 14 +- Source/modules/asura-core/Mesh/Mesh2DData.h | 4 +- Source/modules/asura-json/Json/JsonData.cpp | 9 + Source/modules/asura-json/Json/JsonData.h | 17 + Source/tests/win32/01-window/03_sub_menu.cpp | 42 +- bin/win64/01-window.exe | Bin 1462272 -> 1462272 bytes bin/win64/SDL2.dll | Bin 2491904 -> 2491904 bytes build/Asura.Editor/Asura.Editor.vcxproj | 21 +- build/Asura.Editor/Asura.Editor.vcxproj.filters | 69 +- build/Asura.sln | 13 + build/modules/asura-base/asura-base.vcxproj | 6 +- .../modules/asura-base/asura-base.vcxproj.filters | 21 +- build/modules/asura-box2d/asura-box2d.vcxproj | 48 +- .../asura-box2d/asura-box2d.vcxproj.filters | 104 +-- build/modules/asura-core/asura-core.vcxproj | 44 +- .../modules/asura-core/asura-core.vcxproj.filters | 128 ++-- build/modules/asura-json/asura-json.vcxproj | 4 +- .../modules/asura-json/asura-json.vcxproj.filters | 8 +- samples/Hello/entities.folder.asset | 6 +- samples/Hello/gfx.folder.asset | 4 +- source/Asura.Editor/Controls/GUIPanel.cpp | 6 - source/Asura.Editor/Controls/GUIPanel.h | 10 +- source/Asura.Editor/Graphics/Pen.cpp | 0 source/Asura.Editor/Graphics/Pen.h | 7 - source/Asura.Editor/Graphics/Shader.h | 13 +- source/Asura.Editor/Graphics/Style.cpp | 0 source/Asura.Editor/Graphics/Style.h | 15 - .../Asura.Editor/Graphics/shaders/image.shader.h | 35 - .../Asura.Editor/Graphics/shaders/polygon.shader.h | 29 - source/Asura.Editor/System/ContainerWindow.h | 14 +- source/Asura.Editor/System/Input.cpp | 2 +- source/Asura.Editor/graphics/pen.cpp | 0 source/Asura.Editor/graphics/pen.h | 7 - source/Asura.Editor/graphics/shader.h | 13 +- .../Asura.Editor/graphics/shaders/image.shader.h | 35 - .../Asura.Editor/graphics/shaders/polygon.shader.h | 29 - source/Asura.Editor/graphics/style.cpp | 0 source/Asura.Editor/graphics/style.h | 15 - source/modules/asura-box2d/Physics/Body.h | 64 -- source/modules/asura-box2d/Physics/ChainShape.h | 29 - source/modules/asura-box2d/Physics/CircleShape.h | 0 source/modules/asura-box2d/Physics/Contact.h | 0 source/modules/asura-box2d/Physics/DebugDraw.h | 9 - source/modules/asura-box2d/Physics/DistanceJoint.h | 0 source/modules/asura-box2d/Physics/EdgeShape.h | 0 source/modules/asura-box2d/Physics/Fixture.h | 17 - source/modules/asura-box2d/Physics/FrictionJoint.h | 0 source/modules/asura-box2d/Physics/GearJoint.h | 0 source/modules/asura-box2d/Physics/Joint.h | 0 source/modules/asura-box2d/Physics/MotorJoint.h | 0 source/modules/asura-box2d/Physics/MouseJoint.h | 0 source/modules/asura-box2d/Physics/PolygonShape.h | 0 .../modules/asura-box2d/Physics/PrismaticJoint.h | 0 source/modules/asura-box2d/Physics/PulleyJoint.h | 0 source/modules/asura-box2d/Physics/RevoluteJoint.h | 0 source/modules/asura-box2d/Physics/RopeJoint.h | 0 source/modules/asura-box2d/Physics/Shape.h | 0 source/modules/asura-box2d/Physics/WeldJoint.h | 0 source/modules/asura-box2d/Physics/WheelJoint.h | 0 source/modules/asura-box2d/Physics/World.h | 18 - .../modules/asura-box2d/Physics/binding/_body.cpp | 171 ----- .../modules/asura-box2d/Physics/binding/_world.cpp | 21 - .../modules/asura-box2d/physics/binding/_body.cpp | 171 ----- .../modules/asura-box2d/physics/binding/_world.cpp | 21 - source/modules/asura-box2d/physics/body.h | 64 -- source/modules/asura-box2d/physics/contact.h | 0 source/modules/asura-box2d/physics/fixture.h | 17 - source/modules/asura-box2d/physics/joint.h | 0 source/modules/asura-box2d/physics/shape.h | 0 source/modules/asura-box2d/physics/world.h | 18 - source/modules/asura-core/Font/TTF.cpp | 0 source/modules/asura-core/Font/TTF.h | 17 - source/modules/asura-core/Font/Utf.hpp | 720 -------------------- source/modules/asura-core/Font/Utf.inc | 752 --------------------- source/modules/asura-core/Graphics/DrawInfo.h | 8 + source/modules/asura-core/Graphics/GPUBuffer.cpp | 13 +- source/modules/asura-core/Graphics/GfxDevice.cpp | 76 +-- source/modules/asura-core/Graphics/GfxDevice.h | 110 ++- source/modules/asura-core/Graphics/Image.cpp | 103 --- source/modules/asura-core/Graphics/Image.h | 63 -- source/modules/asura-core/Graphics/MatrixStack.cpp | 2 +- source/modules/asura-core/Graphics/MatrixStack.h | 26 +- source/modules/asura-core/Graphics/Mesh2D.cpp | 0 source/modules/asura-core/Graphics/Mesh2D.h | 52 -- .../modules/asura-core/Graphics/RenderTarget.cpp | 0 source/modules/asura-core/Graphics/RenderTarget.h | 52 -- source/modules/asura-core/Graphics/Shader.cpp | 26 +- source/modules/asura-core/Graphics/Shader.h | 27 +- source/modules/asura-core/Graphics/Texture.h | 38 +- source/modules/asura-core/Graphics/VBO.cpp | 0 source/modules/asura-core/Graphics/VBO.h | 27 - .../asura-core/Graphics/binding/_canvas.cpp | 48 -- .../modules/asura-core/Graphics/binding/_color.cpp | 130 ---- .../asura-core/Graphics/binding/_color32.cpp | 66 -- .../asura-core/Graphics/binding/_gfx_device.cpp | 151 ----- .../asura-core/Graphics/binding/_gpu_buffer.cpp | 118 ---- .../modules/asura-core/Graphics/binding/_image.cpp | 71 -- .../asura-core/Graphics/binding/_index_buffer.cpp | 31 - .../asura-core/Graphics/binding/_mesh2d.cpp | 20 - .../asura-core/Graphics/binding/_shader.cpp | 131 ---- .../asura-core/Graphics/binding/_sprite_batch.cpp | 20 - .../asura-core/Graphics/binding/_texture.cpp | 85 --- .../asura-core/Graphics/binding/_vertex_buffer.cpp | 38 -- source/modules/asura-core/Input/InputDevice.h | 5 +- source/modules/asura-core/Input/InputEvent.h | 2 +- source/modules/asura-core/Input/InputManager.cpp | 8 +- source/modules/asura-core/Input/InputManager.h | 14 +- source/modules/asura-core/Mesh/Mesh2DData.h | 4 +- source/modules/asura-core/font/ttf.cpp | 0 source/modules/asura-core/font/ttf.h | 17 - source/modules/asura-core/font/utf.hpp | 720 -------------------- .../asura-core/graphics/binding/_canvas.cpp | 48 -- .../modules/asura-core/graphics/binding/_color.cpp | 130 ---- .../asura-core/graphics/binding/_color32.cpp | 66 -- .../asura-core/graphics/binding/_gfx_device.cpp | 151 ----- .../asura-core/graphics/binding/_gpu_buffer.cpp | 118 ---- .../modules/asura-core/graphics/binding/_image.cpp | 71 -- .../asura-core/graphics/binding/_index_buffer.cpp | 31 - .../asura-core/graphics/binding/_mesh2d.cpp | 20 - .../asura-core/graphics/binding/_shader.cpp | 131 ---- .../asura-core/graphics/binding/_sprite_batch.cpp | 20 - .../asura-core/graphics/binding/_texture.cpp | 85 --- .../asura-core/graphics/binding/_vertex_buffer.cpp | 38 -- source/modules/asura-core/graphics/image.cpp | 103 --- source/modules/asura-core/graphics/image.h | 63 -- source/modules/asura-core/graphics/mesh2d.cpp | 0 source/modules/asura-core/graphics/mesh2d.h | 52 -- source/modules/asura-core/graphics/shader.cpp | 26 +- source/modules/asura-core/graphics/shader.h | 27 +- source/modules/asura-core/graphics/texture.h | 38 +- source/tests/win32/01-window/03_sub_menu.cpp | 42 +- 294 files changed, 4011 insertions(+), 9342 deletions(-) create mode 100644 Build/external/Json/Json.vcxproj create mode 100644 Build/external/Json/Json.vcxproj.filters create mode 100644 Build/external/Json/Json.vcxproj.user create mode 100644 Source/Asura.Editor/Graphics/GUIMaterial.cpp create mode 100644 Source/Asura.Editor/Graphics/GUIMaterial.h create mode 100644 Source/Asura.Editor/Graphics/GUIStyle.cpp create mode 100644 Source/Asura.Editor/Graphics/GUIStyle.h delete mode 100644 Source/Asura.Editor/Graphics/Pen.cpp delete mode 100644 Source/Asura.Editor/Graphics/Pen.h create mode 100644 Source/Asura.Editor/Graphics/Shaders/GUIClip.shader.h create mode 100644 Source/Asura.Editor/Graphics/Shaders/GUIText.shader.h create mode 100644 Source/Asura.Editor/Graphics/Shaders/GUITexture.shader.h delete mode 100644 Source/Asura.Editor/Graphics/Style.cpp delete mode 100644 Source/Asura.Editor/Graphics/Style.h delete mode 100644 Source/Asura.Editor/Graphics/shaders/image.shader.h delete mode 100644 Source/Asura.Editor/Graphics/shaders/polygon.shader.h create mode 100644 Source/Asura.Editor/System/ContainerFrame.cpp create mode 100644 Source/Asura.Editor/System/ContainerFrame.h create mode 100644 Source/Asura.Editor/System/GUIWindow.cpp create mode 100644 Source/Asura.Editor/System/GUIWindow.h create mode 100644 Source/modules/asura-base/Misc/GUID.cpp create mode 100644 Source/modules/asura-base/Misc/GUID.h create mode 100644 Source/modules/asura-base/Misc/UTF8.cpp create mode 100644 Source/modules/asura-base/Misc/UTF8.h delete mode 100644 Source/modules/asura-base/Utilities/LinkedList.cpp create mode 100644 Source/modules/asura-base/Utilities/dynamic_array.h delete mode 100644 Source/modules/asura-box2d/Physics/Body.h delete mode 100644 Source/modules/asura-box2d/Physics/ChainShape.h delete mode 100644 Source/modules/asura-box2d/Physics/CircleShape.h delete mode 100644 Source/modules/asura-box2d/Physics/Contact.h delete mode 100644 Source/modules/asura-box2d/Physics/DebugDraw.h delete mode 100644 Source/modules/asura-box2d/Physics/DistanceJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/EdgeShape.h delete mode 100644 Source/modules/asura-box2d/Physics/Fixture.h delete mode 100644 Source/modules/asura-box2d/Physics/FrictionJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/GearJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/Joint.h delete mode 100644 Source/modules/asura-box2d/Physics/MotorJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/MouseJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/PolygonShape.h delete mode 100644 Source/modules/asura-box2d/Physics/PrismaticJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/PulleyJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/RevoluteJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/RopeJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/Shape.h delete mode 100644 Source/modules/asura-box2d/Physics/WeldJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/WheelJoint.h delete mode 100644 Source/modules/asura-box2d/Physics/World.h delete mode 100644 Source/modules/asura-box2d/Physics/binding/_body.cpp delete mode 100644 Source/modules/asura-box2d/Physics/binding/_world.cpp create mode 100644 Source/modules/asura-box2d/Physics2D/Body.h create mode 100644 Source/modules/asura-box2d/Physics2D/ChainShape.h create mode 100644 Source/modules/asura-box2d/Physics2D/CircleShape.h create mode 100644 Source/modules/asura-box2d/Physics2D/Contact.h create mode 100644 Source/modules/asura-box2d/Physics2D/DebugDraw.h create mode 100644 Source/modules/asura-box2d/Physics2D/DistanceJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/EdgeShape.h create mode 100644 Source/modules/asura-box2d/Physics2D/Fixture.h create mode 100644 Source/modules/asura-box2d/Physics2D/FrictionJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/GearJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/Joint.h create mode 100644 Source/modules/asura-box2d/Physics2D/MotorJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/MouseJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/PolygonShape.h create mode 100644 Source/modules/asura-box2d/Physics2D/PrismaticJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/PulleyJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/RevoluteJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/RopeJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/Shape.h create mode 100644 Source/modules/asura-box2d/Physics2D/WeldJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/WheelJoint.h create mode 100644 Source/modules/asura-box2d/Physics2D/World.h create mode 100644 Source/modules/asura-box2d/Physics2D/binding/_body.cpp create mode 100644 Source/modules/asura-box2d/Physics2D/binding/_world.cpp delete mode 100644 Source/modules/asura-core/Font/TTF.cpp delete mode 100644 Source/modules/asura-core/Font/TTF.h create mode 100644 Source/modules/asura-core/Font/TTFImporter.cpp create mode 100644 Source/modules/asura-core/Font/TTFImporter.h delete mode 100644 Source/modules/asura-core/Font/Utf.hpp delete mode 100644 Source/modules/asura-core/Font/Utf.inc delete mode 100644 Source/modules/asura-core/Graphics/Image.cpp delete mode 100644 Source/modules/asura-core/Graphics/Image.h create mode 100644 Source/modules/asura-core/Graphics/Mesh.cpp create mode 100644 Source/modules/asura-core/Graphics/Mesh.h delete mode 100644 Source/modules/asura-core/Graphics/Mesh2D.cpp delete mode 100644 Source/modules/asura-core/Graphics/Mesh2D.h delete mode 100644 Source/modules/asura-core/Graphics/RenderTarget.cpp delete mode 100644 Source/modules/asura-core/Graphics/RenderTarget.h create mode 100644 Source/modules/asura-core/Graphics/RenderTexture.cpp create mode 100644 Source/modules/asura-core/Graphics/RenderTexture.h delete mode 100644 Source/modules/asura-core/Graphics/VBO.cpp delete mode 100644 Source/modules/asura-core/Graphics/VBO.h create mode 100644 Source/modules/asura-core/Graphics/VBOs.cpp create mode 100644 Source/modules/asura-core/Graphics/VBOs.h create mode 100644 Source/modules/asura-core/Graphics/binding/Canvas.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/Color.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/Color32.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/GPUBuffer.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/GfxDevice.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/Image.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/IndexBuffer.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/Mesh.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/Shader.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/SpriteBatch.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/Texture.binding.cpp create mode 100644 Source/modules/asura-core/Graphics/binding/VertexBuffer.binding.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_canvas.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_color.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_color32.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_gfx_device.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_image.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_index_buffer.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_mesh2d.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_shader.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_texture.cpp delete mode 100644 Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp create mode 100644 Source/modules/asura-json/Json/JsonData.cpp create mode 100644 Source/modules/asura-json/Json/JsonData.h delete mode 100644 source/Asura.Editor/Graphics/Pen.cpp delete mode 100644 source/Asura.Editor/Graphics/Pen.h delete mode 100644 source/Asura.Editor/Graphics/Style.cpp delete mode 100644 source/Asura.Editor/Graphics/Style.h delete mode 100644 source/Asura.Editor/Graphics/shaders/image.shader.h delete mode 100644 source/Asura.Editor/Graphics/shaders/polygon.shader.h delete mode 100644 source/Asura.Editor/graphics/pen.cpp delete mode 100644 source/Asura.Editor/graphics/pen.h delete mode 100644 source/Asura.Editor/graphics/shaders/image.shader.h delete mode 100644 source/Asura.Editor/graphics/shaders/polygon.shader.h delete mode 100644 source/Asura.Editor/graphics/style.cpp delete mode 100644 source/Asura.Editor/graphics/style.h delete mode 100644 source/modules/asura-box2d/Physics/Body.h delete mode 100644 source/modules/asura-box2d/Physics/ChainShape.h delete mode 100644 source/modules/asura-box2d/Physics/CircleShape.h delete mode 100644 source/modules/asura-box2d/Physics/Contact.h delete mode 100644 source/modules/asura-box2d/Physics/DebugDraw.h delete mode 100644 source/modules/asura-box2d/Physics/DistanceJoint.h delete mode 100644 source/modules/asura-box2d/Physics/EdgeShape.h delete mode 100644 source/modules/asura-box2d/Physics/Fixture.h delete mode 100644 source/modules/asura-box2d/Physics/FrictionJoint.h delete mode 100644 source/modules/asura-box2d/Physics/GearJoint.h delete mode 100644 source/modules/asura-box2d/Physics/Joint.h delete mode 100644 source/modules/asura-box2d/Physics/MotorJoint.h delete mode 100644 source/modules/asura-box2d/Physics/MouseJoint.h delete mode 100644 source/modules/asura-box2d/Physics/PolygonShape.h delete mode 100644 source/modules/asura-box2d/Physics/PrismaticJoint.h delete mode 100644 source/modules/asura-box2d/Physics/PulleyJoint.h delete mode 100644 source/modules/asura-box2d/Physics/RevoluteJoint.h delete mode 100644 source/modules/asura-box2d/Physics/RopeJoint.h delete mode 100644 source/modules/asura-box2d/Physics/Shape.h delete mode 100644 source/modules/asura-box2d/Physics/WeldJoint.h delete mode 100644 source/modules/asura-box2d/Physics/WheelJoint.h delete mode 100644 source/modules/asura-box2d/Physics/World.h delete mode 100644 source/modules/asura-box2d/Physics/binding/_body.cpp delete mode 100644 source/modules/asura-box2d/Physics/binding/_world.cpp delete mode 100644 source/modules/asura-box2d/physics/binding/_body.cpp delete mode 100644 source/modules/asura-box2d/physics/binding/_world.cpp delete mode 100644 source/modules/asura-box2d/physics/body.h delete mode 100644 source/modules/asura-box2d/physics/contact.h delete mode 100644 source/modules/asura-box2d/physics/fixture.h delete mode 100644 source/modules/asura-box2d/physics/joint.h delete mode 100644 source/modules/asura-box2d/physics/shape.h delete mode 100644 source/modules/asura-box2d/physics/world.h delete mode 100644 source/modules/asura-core/Font/TTF.cpp delete mode 100644 source/modules/asura-core/Font/TTF.h delete mode 100644 source/modules/asura-core/Font/Utf.hpp delete mode 100644 source/modules/asura-core/Font/Utf.inc delete mode 100644 source/modules/asura-core/Graphics/Image.cpp delete mode 100644 source/modules/asura-core/Graphics/Image.h delete mode 100644 source/modules/asura-core/Graphics/Mesh2D.cpp delete mode 100644 source/modules/asura-core/Graphics/Mesh2D.h delete mode 100644 source/modules/asura-core/Graphics/RenderTarget.cpp delete mode 100644 source/modules/asura-core/Graphics/RenderTarget.h delete mode 100644 source/modules/asura-core/Graphics/VBO.cpp delete mode 100644 source/modules/asura-core/Graphics/VBO.h delete mode 100644 source/modules/asura-core/Graphics/binding/_canvas.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_color.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_color32.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_gfx_device.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_image.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_index_buffer.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_mesh2d.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_shader.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_sprite_batch.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_texture.cpp delete mode 100644 source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp delete mode 100644 source/modules/asura-core/font/ttf.cpp delete mode 100644 source/modules/asura-core/font/ttf.h delete mode 100644 source/modules/asura-core/font/utf.hpp delete mode 100644 source/modules/asura-core/graphics/binding/_canvas.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_color.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_color32.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_gfx_device.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_gpu_buffer.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_image.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_index_buffer.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_mesh2d.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_shader.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_sprite_batch.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_texture.cpp delete mode 100644 source/modules/asura-core/graphics/binding/_vertex_buffer.cpp delete mode 100644 source/modules/asura-core/graphics/image.cpp delete mode 100644 source/modules/asura-core/graphics/image.h delete mode 100644 source/modules/asura-core/graphics/mesh2d.cpp delete mode 100644 source/modules/asura-core/graphics/mesh2d.h diff --git a/Bin/win64/01-window.exe b/Bin/win64/01-window.exe index 70db8e5..e812b2e 100644 Binary files a/Bin/win64/01-window.exe and b/Bin/win64/01-window.exe differ diff --git a/Bin/win64/SDL2.dll b/Bin/win64/SDL2.dll index 8f849cd..8778af5 100644 Binary files a/Bin/win64/SDL2.dll and b/Bin/win64/SDL2.dll differ diff --git a/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-shm b/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-shm index baa828a..4522c57 100644 Binary files a/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-shm and b/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-shm differ diff --git a/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-wal b/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-wal index a2c8fca..2561822 100644 Binary files a/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-wal and b/Build/.vs/Asura/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Build/Asura.Editor/Asura.Editor.vcxproj b/Build/Asura.Editor/Asura.Editor.vcxproj index d214c2e..542fcf2 100644 --- a/Build/Asura.Editor/Asura.Editor.vcxproj +++ b/Build/Asura.Editor/Asura.Editor.vcxproj @@ -129,7 +129,7 @@ - + @@ -137,13 +137,14 @@ - - + + + @@ -153,7 +154,7 @@ - + @@ -162,15 +163,17 @@ - - - - - + + + + + + + diff --git a/Build/Asura.Editor/Asura.Editor.vcxproj.filters b/Build/Asura.Editor/Asura.Editor.vcxproj.filters index bc89328..27c5a7e 100644 --- a/Build/Asura.Editor/Asura.Editor.vcxproj.filters +++ b/Build/Asura.Editor/Asura.Editor.vcxproj.filters @@ -10,9 +10,6 @@ {4be8ce5c-0921-4341-a976-92d31aa84c8c} - - {b4c26f9c-9f4e-4332-a6e2-33456b4abecb} - {7654ef3d-54c4-490f-bb24-e6a67bd63e1e} @@ -25,6 +22,9 @@ {799e7ea2-8870-4d1e-b278-b3a0dd912632} + + {b4c26f9c-9f4e-4332-a6e2-33456b4abecb} + @@ -36,9 +36,6 @@ Controls - - Controls - Controls @@ -51,12 +48,6 @@ Graphics - - Graphics - - - Graphics - Layout @@ -86,14 +77,20 @@ Controls + + System + + + Controls + + + Graphics + + + Graphics + - - Graphics\shaders - - - Graphics\shaders - Controls @@ -103,9 +100,6 @@ Controls - - Controls - Controls @@ -118,15 +112,6 @@ Graphics - - Graphics - - - Graphics - - - Graphics - Layout @@ -162,5 +147,29 @@ Controls + + System + + + Controls + + + Graphics + + + Graphics + + + Graphics\Shaders + + + Graphics\Shaders + + + Graphics\Shaders + + + Graphics + \ No newline at end of file diff --git a/Build/Asura.sln b/Build/Asura.sln index 5332a4a..938b621 100644 --- a/Build/Asura.sln +++ b/Build/Asura.sln @@ -119,6 +119,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RunnerConfigure", "configur EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asura-base", "modules\asura-base\asura-base.vcxproj", "{7D41093F-E356-4C5B-A25F-41779BF86E54}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Json", "external\Json\Json.vcxproj", "{01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -651,6 +653,16 @@ Global {7D41093F-E356-4C5B-A25F-41779BF86E54}.Release|x64.Build.0 = Release|x64 {7D41093F-E356-4C5B-A25F-41779BF86E54}.Release|x86.ActiveCfg = Release|Win32 {7D41093F-E356-4C5B-A25F-41779BF86E54}.Release|x86.Build.0 = Release|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x64.ActiveCfg = Debug|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x64.Build.0 = Debug|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x86.ActiveCfg = Debug|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x86.Build.0 = Debug|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|Any CPU.ActiveCfg = Release|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x64.ActiveCfg = Release|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x64.Build.0 = Release|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x86.ActiveCfg = Release|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -703,6 +715,7 @@ Global {93CFEFAB-3922-4D81-91FD-8A80E9785FC6} = {1C5D0C23-C0A9-4200-BD67-B5B8F6DDE41C} {9DD2D23B-BE70-4453-88C7-D904E024CB68} = {1C5D0C23-C0A9-4200-BD67-B5B8F6DDE41C} {7D41093F-E356-4C5B-A25F-41779BF86E54} = {CD115016-E377-4AC1-8595-DB2836CEFE7E} + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C} = {64D4E4B2-4A60-46F4-A500-370EFED4524F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {331032D8-F7CC-43E3-A03B-67108767F96B} diff --git a/Build/external/Json/Json.vcxproj b/Build/external/Json/Json.vcxproj new file mode 100644 index 0000000..dcb86ec --- /dev/null +++ b/Build/external/Json/Json.vcxproj @@ -0,0 +1,122 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C} + Json + 10.0.17134.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + + + Level3 + Disabled + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + + \ No newline at end of file diff --git a/Build/external/Json/Json.vcxproj.filters b/Build/external/Json/Json.vcxproj.filters new file mode 100644 index 0000000..9cd8510 --- /dev/null +++ b/Build/external/Json/Json.vcxproj.filters @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/Build/external/Json/Json.vcxproj.user b/Build/external/Json/Json.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/Build/external/Json/Json.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Build/modules/asura-base/asura-base.vcxproj b/Build/modules/asura-base/asura-base.vcxproj index 89ba183..e8ecc4a 100644 --- a/Build/modules/asura-base/asura-base.vcxproj +++ b/Build/modules/asura-base/asura-base.vcxproj @@ -142,6 +142,8 @@ + + @@ -155,7 +157,6 @@ - @@ -185,6 +186,8 @@ + + @@ -200,6 +203,7 @@ + diff --git a/Build/modules/asura-base/asura-base.vcxproj.filters b/Build/modules/asura-base/asura-base.vcxproj.filters index 5f639bc..2aa1840 100644 --- a/Build/modules/asura-base/asura-base.vcxproj.filters +++ b/Build/modules/asura-base/asura-base.vcxproj.filters @@ -22,6 +22,9 @@ {b4b078e1-bb8d-4cb3-84b9-963e851be123} + + {9bfbea59-2b66-4aad-add2-ac9c737a1dc1} + @@ -82,9 +85,6 @@ Utilities - - Utilities - Utilities @@ -128,6 +128,12 @@ FileSystem\Binding + + Misc + + + Misc + @@ -249,6 +255,15 @@ Math + + Misc + + + Utilities + + + Misc + diff --git a/Build/modules/asura-box2d/asura-box2d.vcxproj b/Build/modules/asura-box2d/asura-box2d.vcxproj index b41df12..2a3c00b 100644 --- a/Build/modules/asura-box2d/asura-box2d.vcxproj +++ b/Build/modules/asura-box2d/asura-box2d.vcxproj @@ -118,33 +118,33 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Build/modules/asura-box2d/asura-box2d.vcxproj.filters b/Build/modules/asura-box2d/asura-box2d.vcxproj.filters index 5415a04..b169c1a 100644 --- a/Build/modules/asura-box2d/asura-box2d.vcxproj.filters +++ b/Build/modules/asura-box2d/asura-box2d.vcxproj.filters @@ -2,88 +2,88 @@ - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - + {c01b5c57-f3a7-445f-aed3-e0a27dbe74c2} - - {3fb6587c-0c9d-4f6e-9e72-653032d9b238} + + {76f8cfef-3ffe-47a2-9e7c-b90f1d252bce} - - Physics\binding + + + Physics2D\Binding - - Physics\binding + + Physics2D\Binding - \ No newline at end of file diff --git a/Build/modules/asura-core/asura-core.vcxproj b/Build/modules/asura-core/asura-core.vcxproj index f548922..5b2dd32 100644 --- a/Build/modules/asura-core/asura-core.vcxproj +++ b/Build/modules/asura-core/asura-core.vcxproj @@ -128,19 +128,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -149,18 +149,17 @@ - - + - + - + @@ -194,8 +193,7 @@ - - + @@ -206,19 +204,18 @@ - - + - + - + @@ -264,7 +261,6 @@ - diff --git a/Build/modules/asura-core/asura-core.vcxproj.filters b/Build/modules/asura-core/asura-core.vcxproj.filters index cf39389..5ffc385 100644 --- a/Build/modules/asura-core/asura-core.vcxproj.filters +++ b/Build/modules/asura-core/asura-core.vcxproj.filters @@ -42,27 +42,6 @@ - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - Window\binding @@ -72,27 +51,12 @@ Image\binding - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - Font Font - - Font - Graphics @@ -108,24 +72,15 @@ Graphics - - Graphics - Graphics Graphics - - Graphics - Graphics - - Graphics - Graphics @@ -215,18 +170,60 @@ Graphics - - Graphics - Input Input - + + Graphics + + + Font + + + Graphics + + + Graphics\Binding + + + Graphics\Binding + + Graphics\Binding + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics + @@ -235,9 +232,6 @@ Font - - Font - Graphics @@ -259,27 +253,18 @@ Graphics - - Graphics - Graphics Graphics - - Graphics - Graphics Graphics - - Graphics - Graphics @@ -373,9 +358,6 @@ Threads - - Font - Graphics @@ -388,22 +370,28 @@ Graphics - - Graphics - Input Input + + Graphics + + + Font + + + Graphics + + + Graphics + Font - - Font - \ No newline at end of file diff --git a/Build/modules/asura-json/asura-json.vcxproj b/Build/modules/asura-json/asura-json.vcxproj index 64af220..bde2695 100644 --- a/Build/modules/asura-json/asura-json.vcxproj +++ b/Build/modules/asura-json/asura-json.vcxproj @@ -20,11 +20,11 @@ - + - + 15.0 diff --git a/Build/modules/asura-json/asura-json.vcxproj.filters b/Build/modules/asura-json/asura-json.vcxproj.filters index 7f255cb..86218ef 100644 --- a/Build/modules/asura-json/asura-json.vcxproj.filters +++ b/Build/modules/asura-json/asura-json.vcxproj.filters @@ -6,15 +6,15 @@ - + + Json - - + + Json - \ No newline at end of file diff --git a/Build/tools/bindingGen/obj/Debug/bindingGen.csproj.CoreCompileInputs.cache b/Build/tools/bindingGen/obj/Debug/bindingGen.csproj.CoreCompileInputs.cache index 93b7e43..c1e0407 100644 --- a/Build/tools/bindingGen/obj/Debug/bindingGen.csproj.CoreCompileInputs.cache +++ b/Build/tools/bindingGen/obj/Debug/bindingGen.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -76869cb9eeaafde93fc35e764d87dc7f1f272b2f +534362588ad2d4462c430a54eb5dee7ab94c0164 diff --git a/Samples/Hello/entities.folder.asset b/Samples/Hello/entities.folder.asset index 1d8fd23..5d0e1a5 100644 --- a/Samples/Hello/entities.folder.asset +++ b/Samples/Hello/entities.folder.asset @@ -1,4 +1,4 @@ { - type="folder", - extern="entities" -} \ No newline at end of file + "frameGrid" : "folder", + "extern" : "entities" +} diff --git a/Samples/Hello/gfx.folder.asset b/Samples/Hello/gfx.folder.asset index 2ad12da..f9eefa7 100644 --- a/Samples/Hello/gfx.folder.asset +++ b/Samples/Hello/gfx.folder.asset @@ -1,4 +1,4 @@ { - type="folder", - extern="gfx" + "type" : "folder", + "extern" : "gfx" } \ No newline at end of file diff --git a/Source/Asura.Editor/Controls/GUIPanel.cpp b/Source/Asura.Editor/Controls/GUIPanel.cpp index 3a78af7..e69de29 100644 --- a/Source/Asura.Editor/Controls/GUIPanel.cpp +++ b/Source/Asura.Editor/Controls/GUIPanel.cpp @@ -1,6 +0,0 @@ -#include "GUIPanel.h" - -namespace_begin(AsuraEditor) - - -namespace_end diff --git a/Source/Asura.Editor/Controls/GUIPanel.h b/Source/Asura.Editor/Controls/GUIPanel.h index 0f98eaa..9ff6eed 100644 --- a/Source/Asura.Editor/Controls/GUIPanel.h +++ b/Source/Asura.Editor/Controls/GUIPanel.h @@ -1,11 +1,13 @@ -#ifndef _ASURA_EDITOR_GUI_PANEL_H_ -#define _ASURA_EDITOR_GUI_PANEL_H_ +#ifndef _ASURA_EDITOR_GUIPANEL_H_ +#define _ASURA_EDITOR_GUIPANEL_H_ #include +#include "../System/GUIWindow.h" + namespace_begin(AsuraEditor) -/// IMGUI panel +// GUIWindowµÄµ¥¸öÃæ°å class GUIPanel { public: @@ -15,10 +17,12 @@ public: private: + GUIWindow* m_GUIWindow; // ËùÊôµÄ»æÖÆ´°¿Ú }; + namespace_end #endif \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/GUIMaterial.cpp b/Source/Asura.Editor/Graphics/GUIMaterial.cpp new file mode 100644 index 0000000..b82afaa --- /dev/null +++ b/Source/Asura.Editor/Graphics/GUIMaterial.cpp @@ -0,0 +1,5 @@ +#include "GUIMaterial.h" + +namespace_begin(AsuraEditor) + +namespace_end diff --git a/Source/Asura.Editor/Graphics/GUIMaterial.h b/Source/Asura.Editor/Graphics/GUIMaterial.h new file mode 100644 index 0000000..bccfc7e --- /dev/null +++ b/Source/Asura.Editor/Graphics/GUIMaterial.h @@ -0,0 +1,22 @@ +#ifndef _ASURA_EDITOR_GUI_MATERIAL_H_ +#define _ASURA_EDITOR_GUI_MATERIAL_H_ + +#include + +namespace_begin(AsuraEditor) + +// GUIÄÚ½¨²ÄÖÊ +class GUIMaterial +{ +public: + +private: + + + +}; + + +namespace_end + +#endif diff --git a/Source/Asura.Editor/Graphics/GUIStyle.cpp b/Source/Asura.Editor/Graphics/GUIStyle.cpp new file mode 100644 index 0000000..4da2847 --- /dev/null +++ b/Source/Asura.Editor/Graphics/GUIStyle.cpp @@ -0,0 +1,4 @@ +#include "GUIStyle.h" + + + diff --git a/Source/Asura.Editor/Graphics/GUIStyle.h b/Source/Asura.Editor/Graphics/GUIStyle.h new file mode 100644 index 0000000..8556397 --- /dev/null +++ b/Source/Asura.Editor/Graphics/GUIStyle.h @@ -0,0 +1,34 @@ +#ifndef _ASURA_EDITOR_GUI_STYLE_H_ +#define _ASURA_EDITOR_GUI_STYLE_H_ + +#include + +#include "GUIMaterial.h" + +namespace_begin(AsuraEditor) + +/// ±à¼­Æ÷Ñùʽ +class GUIStyle +{ +public: + + GUIStyle(); + ~GUIStyle(); + + void DrawContent(); + +private: + + GUIMaterial* GetGUITextMaterial(); + GUIMaterial* GetGUIBlendMaterial(); + GUIMaterial* GetGUIBlitMaterial(); + + GUIMaterial* m_GUITextMaterial; + GUIMaterial* m_GUIBlendMaterial; + GUIMaterial* m_GUIBlitMaterial; + +}; + +namespace_end + +#endif \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/Pen.cpp b/Source/Asura.Editor/Graphics/Pen.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Editor/Graphics/Pen.h b/Source/Asura.Editor/Graphics/Pen.h deleted file mode 100644 index b949d14..0000000 --- a/Source/Asura.Editor/Graphics/Pen.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ASURA_EDITOR_PEN_H_ -#define _ASURA_EDITOR_PEN_H_ - - - - -#endif \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/Shader.h b/Source/Asura.Editor/Graphics/Shader.h index a3abec1..af291a5 100644 --- a/Source/Asura.Editor/Graphics/Shader.h +++ b/Source/Asura.Editor/Graphics/Shader.h @@ -3,16 +3,13 @@ namespace AsuraEditor { - namespace Graphics - { - struct ShaderProgram - { - const char* vert; - const char* frag; - }; +struct ShaderProgram +{ + const char* vert; + const char* frag; +}; - } } #endif \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/Shaders/GUIClip.shader.h b/Source/Asura.Editor/Graphics/Shaders/GUIClip.shader.h new file mode 100644 index 0000000..cbdd542 --- /dev/null +++ b/Source/Asura.Editor/Graphics/Shaders/GUIClip.shader.h @@ -0,0 +1,35 @@ +#ifndef _ASURA_EDITOR_SHADER_H_ +#include "../shader.h" +#endif + +// »æÖÆ +static AsuraEditor::Graphics::ShaderProgram image_shader = +{ +R"( +in vec2 asura_position; +in vec2 asura_texcoord0; + +uniform mat4 asura_model_matrix; +uniform mat4 asura_view_matrix; +uniform mat4 asura_projection_matrix; + +void main() +{ + gl_Position = asura_projection_matrix * asura_view_matrix * asura_model_matrix * vec4(asura_position, 0, 1); + uv = asura_texcoord0; +} + +)", + +R"( +in vec2 uv; + +uniform sampler2D asura_maintex; + +void main() +{ + +} + +)" +}; \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/Shaders/GUIText.shader.h b/Source/Asura.Editor/Graphics/Shaders/GUIText.shader.h new file mode 100644 index 0000000..a92e9a6 --- /dev/null +++ b/Source/Asura.Editor/Graphics/Shaders/GUIText.shader.h @@ -0,0 +1,29 @@ +#ifndef _ASURA_EDITOR_SHADER_H_ +#include "../shader.h" +#endif + +// »æÖÆ +static AsuraEditor::Graphics::ShaderProgram polygon_shader = +{ + R"( +in vec2 position; + +uniform mat4 mvp_matrix; + +void main() +{ + gl_Position = mvp_matrix * vec4(position, 0, 1); +} + +)", + +R"( +uniform vec4 color; + +void main() +{ + gl_FragColor = color; +} + +)" +}; \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/Shaders/GUITexture.shader.h b/Source/Asura.Editor/Graphics/Shaders/GUITexture.shader.h new file mode 100644 index 0000000..cbdd542 --- /dev/null +++ b/Source/Asura.Editor/Graphics/Shaders/GUITexture.shader.h @@ -0,0 +1,35 @@ +#ifndef _ASURA_EDITOR_SHADER_H_ +#include "../shader.h" +#endif + +// »æÖÆ +static AsuraEditor::Graphics::ShaderProgram image_shader = +{ +R"( +in vec2 asura_position; +in vec2 asura_texcoord0; + +uniform mat4 asura_model_matrix; +uniform mat4 asura_view_matrix; +uniform mat4 asura_projection_matrix; + +void main() +{ + gl_Position = asura_projection_matrix * asura_view_matrix * asura_model_matrix * vec4(asura_position, 0, 1); + uv = asura_texcoord0; +} + +)", + +R"( +in vec2 uv; + +uniform sampler2D asura_maintex; + +void main() +{ + +} + +)" +}; \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/Style.cpp b/Source/Asura.Editor/Graphics/Style.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/Asura.Editor/Graphics/Style.h b/Source/Asura.Editor/Graphics/Style.h deleted file mode 100644 index 2676c68..0000000 --- a/Source/Asura.Editor/Graphics/Style.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _ASURA_EDITOR_GUI_STYLE_H_ -#define _ASURA_EDITOR_GUI_STYLE_H_ - -#include - -namespace_begin(AsuraEditor) - -class GUIStyle -{ - -}; - -namespace_end - -#endif \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/shaders/image.shader.h b/Source/Asura.Editor/Graphics/shaders/image.shader.h deleted file mode 100644 index cbdd542..0000000 --- a/Source/Asura.Editor/Graphics/shaders/image.shader.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _ASURA_EDITOR_SHADER_H_ -#include "../shader.h" -#endif - -// »æÖÆ -static AsuraEditor::Graphics::ShaderProgram image_shader = -{ -R"( -in vec2 asura_position; -in vec2 asura_texcoord0; - -uniform mat4 asura_model_matrix; -uniform mat4 asura_view_matrix; -uniform mat4 asura_projection_matrix; - -void main() -{ - gl_Position = asura_projection_matrix * asura_view_matrix * asura_model_matrix * vec4(asura_position, 0, 1); - uv = asura_texcoord0; -} - -)", - -R"( -in vec2 uv; - -uniform sampler2D asura_maintex; - -void main() -{ - -} - -)" -}; \ No newline at end of file diff --git a/Source/Asura.Editor/Graphics/shaders/polygon.shader.h b/Source/Asura.Editor/Graphics/shaders/polygon.shader.h deleted file mode 100644 index a92e9a6..0000000 --- a/Source/Asura.Editor/Graphics/shaders/polygon.shader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _ASURA_EDITOR_SHADER_H_ -#include "../shader.h" -#endif - -// »æÖÆ -static AsuraEditor::Graphics::ShaderProgram polygon_shader = -{ - R"( -in vec2 position; - -uniform mat4 mvp_matrix; - -void main() -{ - gl_Position = mvp_matrix * vec4(position, 0, 1); -} - -)", - -R"( -uniform vec4 color; - -void main() -{ - gl_FragColor = color; -} - -)" -}; \ No newline at end of file diff --git a/Source/Asura.Editor/System/ContainerFrame.cpp b/Source/Asura.Editor/System/ContainerFrame.cpp new file mode 100644 index 0000000..9626317 --- /dev/null +++ b/Source/Asura.Editor/System/ContainerFrame.cpp @@ -0,0 +1,6 @@ +#include "ContainerFrame.h" + +namespace_begin(AsuraEditor) + + +namespace_end diff --git a/Source/Asura.Editor/System/ContainerFrame.h b/Source/Asura.Editor/System/ContainerFrame.h new file mode 100644 index 0000000..51a08d4 --- /dev/null +++ b/Source/Asura.Editor/System/ContainerFrame.h @@ -0,0 +1,63 @@ +#ifndef _ASURA_CONTAINER_FRAME_H_ +#define _ASURA_CONTAINER_FRAME_H_ + +#include +#include + +#include +#include + +#include "../Type.h" + +namespace_begin(AsuraEditor) + +/// °üº¬±à¼­Æ÷´°¿ÚµÄnative´°¿Ú£¬·ÖΪÓÐmenuºÍûÓÐmenuµÄ£¬ÓÃÀ´ÈÝÄÉGUIWindow¡£ +class ContainerFrame : public AEScripting::Portable +{ +public: + + enum WindowStyle + { + WINDOW_STYLE_MAIN, ///< Ö÷´°¿Ú + WINDOW_STYLE_NORMAL, ///< »ù´¡·ç¸ñ + WINDOW_STYLE_TOOL, ///< ¹¤¾ßÀ¸·ç¸ñ + WINDOW_STYLE_POPUP, ///< µ¯³ö´°¿Ú + }; + + struct WindowConfig + { + std::string title; ///< ±êÌâ + uint x, y; ///< ×ø±ê + uint width, height; ///< ´óС + WindowStyle style; ///< ·ç¸ñ + }; + + ContainerFrame(); + ~ContainerFrame(); + + bool Init(WindowConfig& config); + +private: + + WindowStyle m_Style; + HWND m_HWND; + HDC m_HDC; + +luaxport: + + LUAX_DECL_FACTORY(ContainerFrame); + + LUAX_DECL_ENUM(WindowStyle); + + LUAX_DECL_METHOD(_New); + LUAX_DECL_METHOD(_Init); + LUAX_DECL_METHOD(_SetPosition); + +}; + +// ÈÝÄÉGUIWindowµÄ¿ò¼Ü +using ContainerWindow = ContainerFrame; + +namespace_end + +#endif \ No newline at end of file diff --git a/Source/Asura.Editor/System/ContainerWindow.h b/Source/Asura.Editor/System/ContainerWindow.h index 5893aff..06a7b82 100644 --- a/Source/Asura.Editor/System/ContainerWindow.h +++ b/Source/Asura.Editor/System/ContainerWindow.h @@ -11,9 +11,7 @@ namespace_begin(AsuraEditor) -/// -/// °üº¬±à¼­Æ÷´°¿ÚµÄnative´°¿Ú -/// +/// °üº¬±à¼­Æ÷´°¿ÚµÄnative´°¿Ú£¬·ÖΪÓÐmenuºÍûÓÐmenuµÄ£¬ÓÃÀ´ÈÝÄÉGUIWindow¡£ class ContainerWindow : public AEScripting::Portable { public: @@ -40,10 +38,9 @@ public: private: - ContainerWindow* mParent; - WindowStyle mStyle; - HWND mHWND; - HDC mHDC; + WindowStyle m_Style; + HWND m_HWND; + HDC m_HDC; luaxport: @@ -57,6 +54,9 @@ luaxport: }; +// ÈÝÄÉGUIWindowµÄ¿ò¼Ü +using ContainerFrame = ContainerWindow; + namespace_end #endif \ No newline at end of file diff --git a/Source/Asura.Editor/System/GUIWindow.cpp b/Source/Asura.Editor/System/GUIWindow.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/Asura.Editor/System/GUIWindow.h b/Source/Asura.Editor/System/GUIWindow.h new file mode 100644 index 0000000..228aa74 --- /dev/null +++ b/Source/Asura.Editor/System/GUIWindow.h @@ -0,0 +1,36 @@ +#ifndef _ASURA_GUI_WINDOW_H_ +#define _ASURA_GUI_WINDOW_H_ + +#include + +#include + +#include "ContainerWindow.h" + +namespace_begin(AsuraEditor) + +typedef std::vector GUIPanelVector; + +/// Ò»¸öGUIWindow°üº¬¶à¸ö³éÏóµÄGUI panel£¬ÓÃtab¿ÉÒÔÔÚpanel¼äÇл»¡£»æÖÆGUIÔªËØµÄ´°¿Ú¡£ +class GUIWindow +{ +public: + + GUIWindow(); + ~GUIWindow(); + + void DoRepint(); + +private: + + ContainerWindow* m_ParentWindow; + GUIPanelVector m_GUIPanels; + + bool m_IsRepaint; + +}; + + +namespace_end + +#endif \ No newline at end of file diff --git a/Source/Asura.Editor/System/Input.cpp b/Source/Asura.Editor/System/Input.cpp index c10eb3b..80086d3 100644 --- a/Source/Asura.Editor/System/Input.cpp +++ b/Source/Asura.Editor/System/Input.cpp @@ -49,7 +49,7 @@ LRESULT Input::OnDeviceChange(LPCWSTR name, bool add) { } -bool Input::ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos) +bool Input::ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos) { } diff --git a/Source/modules/asura-base/Classes.h b/Source/modules/asura-base/Classes.h index b2700f0..515762b 100644 --- a/Source/modules/asura-base/Classes.h +++ b/Source/modules/asura-base/Classes.h @@ -1,7 +1,16 @@ #ifndef _ASURAENGINE_CLASSES_H_ #define _ASURAENGINE_CLASSES_H_ -#define GET_SET(TYPE,PROP_NAME,VAR_NAME) void Set##PROP_NAME (TYPE val) { VAR_NAME = val; } TYPE Get##PROP_NAME () {return VAR_NAME; } +#define GET_SET(TYPE,PROP_NAME,VAR_NAME) \ +inline void Set##PROP_NAME (TYPE val) { VAR_NAME = val; } \ +inline TYPE Get##PROP_NAME () {return VAR_NAME; } + +#define PROPERTY(TYPE,PROP_NAME,VAR_NAME) \ +private: \ + TYPE VAR_NAME; \ +public: \ + inline void Set##PROP_NAME (TYPE val) { VAR_NAME = val; } \ + inline TYPE Get##PROP_NAME () {return VAR_NAME; } #define namespace_begin(NAMESPACE) namespace NAMESPACE { #define namespace_end } diff --git a/Source/modules/asura-base/Math/Matrix44.h b/Source/modules/asura-base/Math/Matrix44.h index e987dd4..6babde1 100644 --- a/Source/modules/asura-base/Math/Matrix44.h +++ b/Source/modules/asura-base/Math/Matrix44.h @@ -6,7 +6,7 @@ #include "../Scripting/Scripting.h" namespace_begin(AsuraEngine) -namespace_begin(Math) +//namespace_begin(Math) /// ²»ÐèҪתÖõÄOpenGL¾ØÕó£¬ÀàËÆglm::mat4¡£ /// https://blog.csdn.net/candycat1992/article/details/8830894 @@ -71,9 +71,7 @@ public: ///// //void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const; - /// /// ¼ÆËãÐÐÁÐʽ - /// float Calculate(); private: @@ -88,9 +86,7 @@ private: }; +//namespace_end namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Quaternion.h b/Source/modules/asura-base/Math/Quaternion.h index c1e19be..53b63c9 100644 --- a/Source/modules/asura-base/Math/Quaternion.h +++ b/Source/modules/asura-base/Math/Quaternion.h @@ -4,7 +4,7 @@ #include namespace_begin(AsruaEngine) -namespace_begin(Math) +//namespace_begin(Math) class Quaternion { @@ -12,7 +12,7 @@ class Quaternion }; -namespace_end +//namespace_end namespace_end #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Random.h b/Source/modules/asura-base/Math/Random.h index 7d3b976..914a607 100644 --- a/Source/modules/asura-base/Math/Random.h +++ b/Source/modules/asura-base/Math/Random.h @@ -5,7 +5,7 @@ #include "../Classes.h" namespace_begin(AsuraEngine) -namespace_begin(Math) +//namespace_begin(Math) /* Some random generator timings: @@ -82,7 +82,7 @@ private: uint32 x, y, z, w; }; -namespace_end +//namespace_end namespace_end #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Rect.hpp b/Source/modules/asura-base/Math/Rect.hpp index af4fa78..3b9039b 100644 --- a/Source/modules/asura-base/Math/Rect.hpp +++ b/Source/modules/asura-base/Math/Rect.hpp @@ -3,8 +3,8 @@ namespace AsuraEngine { -namespace Math -{ +//namespace Math +//{ template struct Rect @@ -42,9 +42,7 @@ typedef Rect Rectu; typedef Rect Rectf; typedef Rect Reftl; +//} } -} - -namespace AEMath = AsuraEngine::Math; #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Transform.h b/Source/modules/asura-base/Math/Transform.h index 5dcfdcf..02f3c1c 100644 --- a/Source/modules/asura-base/Math/Transform.h +++ b/Source/modules/asura-base/Math/Transform.h @@ -5,8 +5,8 @@ namespace AsuraEngine { - namespace Math - { + //namespace Math + //{ class Transform { @@ -24,7 +24,7 @@ namespace AsuraEngine }; - } +// } } #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Vector2.hpp b/Source/modules/asura-base/Math/Vector2.hpp index e141017..09fd299 100644 --- a/Source/modules/asura-base/Math/Vector2.hpp +++ b/Source/modules/asura-base/Math/Vector2.hpp @@ -4,7 +4,7 @@ #include namespace_begin(AsuraEngine) -namespace_begin(Math) +//namespace_begin(Math) template class Vector2 @@ -64,9 +64,7 @@ typedef Vector2 Vector2i; typedef Vector2 Vector2u; typedef Vector2 Vector2f; +//namespace_end namespace_end -namespace_end - -namespace AEMath = AsuraEngine::Math; #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Vector3.hpp b/Source/modules/asura-base/Math/Vector3.hpp index c526ace..b50c363 100644 --- a/Source/modules/asura-base/Math/Vector3.hpp +++ b/Source/modules/asura-base/Math/Vector3.hpp @@ -3,8 +3,8 @@ namespace AsuraEngine { - namespace Math - { + //namespace Math + //{ template class Vector3 { @@ -227,9 +227,7 @@ namespace AsuraEngine typedef Vector3 Vector3i; typedef Vector3 Vector3f; - } +// } } -namespace AEMath = AsuraEngine::Math; - #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Math/Vector4.h b/Source/modules/asura-base/Math/Vector4.h index a5bf549..c39d9a6 100644 --- a/Source/modules/asura-base/Math/Vector4.h +++ b/Source/modules/asura-base/Math/Vector4.h @@ -3,8 +3,8 @@ namespace AsuraEngine { - namespace Math - { + //namespace Math + //{ template class Vector4 { @@ -228,7 +228,9 @@ namespace AsuraEngine typedef Vector4 Vector4i; typedef Vector4 Vector4f; - } +// } } + + #endif \ No newline at end of file diff --git a/Source/modules/asura-base/Misc/GUID.cpp b/Source/modules/asura-base/Misc/GUID.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-base/Misc/GUID.h b/Source/modules/asura-base/Misc/GUID.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-base/Misc/UTF8.cpp b/Source/modules/asura-base/Misc/UTF8.cpp new file mode 100644 index 0000000..8cfb3ab --- /dev/null +++ b/Source/modules/asura-base/Misc/UTF8.cpp @@ -0,0 +1,395 @@ +#include "UTF8.h" + +namespace_begin(AsuraEngine) + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +ConversionResult ConvertUTF8toUTF16( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + + +/* +* Copyright 2001-2004 Unicode, Inc. +* +* Disclaimer +* +* This source code is provided as is by Unicode, Inc. No claims are +* made as to fitness for any particular purpose. No warranties of any +* kind are expressed or implied. The recipient agrees to determine +* applicability of information provided. If this file has been +* purchased on magnetic or optical media from Unicode, Inc., the +* sole remedy for any claim will be exchange of defective media +* within 90 days of receipt. +* +* Limitations on Rights to Redistribute This Code +* +* Unicode, Inc. hereby grants the right to freely use the information +* supplied in this file in the creation of products supporting the +* Unicode Standard, and to make copies of this file in any form +* for internal or external distribution as long as this notice +* remains attached. +*/ + +/* --------------------------------------------------------------------- + +Conversions between UTF32, UTF-16, and UTF-8. Source code file. +Author: Mark E. Davis, 1994. +Rev History: Rick McGowan, fixes & updates May 2001. +Sept 2001: fixed const & error conditions per +mods suggested by S. Parent & A. Lillich. +June 2002: Tim Dodd added detection and handling of incomplete +source sequences, enhanced error detection, added casts +to eliminate compiler warnings. +July 2003: slight mods to back out aggressive FFFE detection. +Jan 2004: updated switches in from-UTF8 conversions. +Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions. + +See the header file "ConvertUTF.h" for complete documentation. + +------------------------------------------------------------------------ */ + + +#include "UTF8.h" +#ifdef CVTUTF_DEBUG +#include +#endif + +static const int halfShift = 10; /* used for shifting by 10 bits */ + +static const UTF32 halfBase = 0x0010000UL; +static const UTF32 halfMask = 0x3FFUL; + +#define UNI_SUR_HIGH_START (UTF32)0xD800 +#define UNI_SUR_HIGH_END (UTF32)0xDBFF +#define UNI_SUR_LOW_START (UTF32)0xDC00 +#define UNI_SUR_LOW_END (UTF32)0xDFFF + + +/* --------------------------------------------------------------------- */ + +/* +* Index into the table below with the first byte of a UTF-8 sequence to +* get the number of trailing bytes that are supposed to follow it. +* Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is +* left as-is for anyone who may want to do such conversion, which was +* allowed in earlier algorithms. +*/ +static const char trailingBytesForUTF8[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 +}; + +/* +* Magic values subtracted from a buffer value during UTF8 conversion. +* This table contains as many values as there might be trailing bytes +* in a UTF-8 sequence. +*/ +static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, +0x03C82080UL, 0xFA082080UL, 0x82082080UL }; + +/* +* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed +* into the first byte, depending on how many bytes follow. There are +* as many entries in this table as there are UTF-8 sequence types. +* (I.e., one byte sequence, two byte... etc.). Remember that sequencs +* for *legal* UTF-8 will be 4 or fewer bytes total. +*/ +static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + +/* --------------------------------------------------------------------- */ + +/* +* Utility routine to tell whether a sequence of bytes is legal UTF-8. +* This must be called with the length pre-determined by the first byte. +* If not calling this from ConvertUTF8to*, then the length can be set by: +* length = trailingBytesForUTF8[*source]+1; +* and the sequence is illegal right away if there aren't that many bytes +* available. +* If presented with a length > 4, this returns false. The Unicode +* definition of UTF-8 goes up to 4-byte sequences. +*/ + +static Boolean isLegalUTF8(const UTF8 *source, int length) { + UTF8 a; + const UTF8 *srcptr = source + length; + switch (length) { + default: return false; + /* Everything else falls through when "true"... */ + case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; + case 2: if ((a = (*--srcptr)) > 0xBF) return false; + + switch (*source) { + /* no fall-through in this inner switch */ + case 0xE0: if (a < 0xA0) return false; break; + case 0xED: if (a > 0x9F) return false; break; + case 0xF0: if (a < 0x90) return false; break; + case 0xF4: if (a > 0x8F) return false; break; + default: if (a < 0x80) return false; + } + + case 1: if (*source >= 0x80 && *source < 0xC2) return false; + } + if (*source > 0xF4) return false; + return true; +} + + +/* --------------------------------------------------------------------- */ + +ConversionResult ConvertUTF8toUTF16( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF8* source = *sourceStart; + UTF16* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch = 0; + unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + if (source + extraBytesToRead >= sourceEnd) { + result = sourceExhausted; break; + } + /* Do this check whether lenient or strict */ + if (!isLegalUTF8(source, extraBytesToRead + 1)) { + result = sourceIllegal; + break; + } + /* + * The cases all fall through. See "Note A" below. + */ + switch (extraBytesToRead) { + case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */ + case 3: ch += *source++; ch <<= 6; + case 2: ch += *source++; ch <<= 6; + case 1: ch += *source++; ch <<= 6; + case 0: ch += *source++; + } + ch -= offsetsFromUTF8[extraBytesToRead]; + + //DebugAssertIf(target >= targetEnd); + + if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */ + /* UTF-16 surrogate values are illegal in UTF-32 */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) { + if (flags == strictConversion) { + source -= (extraBytesToRead + 1); /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } + else { + *target++ = (UTF16)ch; /* normal case */ + } + } + else if (ch > UNI_MAX_UTF16) { + if (flags == strictConversion) { + result = sourceIllegal; + source -= (extraBytesToRead + 1); /* return to the start */ + break; /* Bail out; shouldn't continue */ + } + else { + *target++ = UNI_REPLACEMENT_CHAR; + } + } + else { + /* target is a character in range 0xFFFF - 0x10FFFF. */ + if (target + 1 >= targetEnd) { + source -= (extraBytesToRead + 1); /* Back up source pointer! */ + result = targetExhausted; break; + } + ch -= halfBase; + *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START); + *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START); + } + } + *sourceStart = source; + *targetStart = target; + return result; +} + +/* --------------------------------------------------------------------- + +Note A. +The fall-through switches in UTF-8 reading code save a +temp variable, some decrements & conditionals. The switches +are equivalent to the following loop: +{ +int tmpBytesToRead = extraBytesToRead+1; +do { +ch += *source++; +--tmpBytesToRead; +if (tmpBytesToRead) ch <<= 6; +} while (tmpBytesToRead > 0); +} +In UTF-8 writing code, the switches on "bytesToWrite" are +similarly unrolled loops. + +--------------------------------------------------------------------- */ + +ConversionResult ConvertUTF16toUTF8( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) { + ConversionResult result = conversionOK; + const UTF16* source = *sourceStart; + UTF8* target = *targetStart; + while (source < sourceEnd) { + UTF32 ch; + unsigned short bytesToWrite = 0; + const UTF32 byteMask = 0xBF; + const UTF32 byteMark = 0x80; + const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */ + ch = *source++; + /* If we have a surrogate pair, convert to UTF32 first. */ + if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END && source < sourceEnd) { + UTF32 ch2 = *source; + if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { + ch = ((ch - UNI_SUR_HIGH_START) << halfShift) + + (ch2 - UNI_SUR_LOW_START) + halfBase; + ++source; + } + else if (flags == strictConversion) { /* it's an unpaired high surrogate */ + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + } + else if ((flags == strictConversion) && (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END)) { + --source; /* return to the illegal value itself */ + result = sourceIllegal; + break; + } + /* Figure out how many bytes the result will require */ + if (ch < (UTF32)0x80) { + bytesToWrite = 1; + } + else if (ch < (UTF32)0x800) { + bytesToWrite = 2; + } + else if (ch < (UTF32)0x10000) { + bytesToWrite = 3; + } + else if (ch < (UTF32)0x200000) { + bytesToWrite = 4; + } + else { + bytesToWrite = 2; + ch = UNI_REPLACEMENT_CHAR; + } + + target += bytesToWrite; + if (target > targetEnd) { + source = oldSource; /* Back up source pointer! */ + target -= bytesToWrite; result = targetExhausted; break; + } + switch (bytesToWrite) { /* note: everything falls through. */ + case 4: *--target = (ch | byteMark) & byteMask; ch >>= 6; + case 3: *--target = (ch | byteMark) & byteMask; ch >>= 6; + case 2: *--target = (ch | byteMark) & byteMask; ch >>= 6; + case 1: *--target = ch | firstByteMark[bytesToWrite]; + } + target += bytesToWrite; + } + *sourceStart = source; + *targetStart = target; + return result; +} + + +bool ConvertUTF8toUTF16(const char* source, int srcLength, uint16* output, int& outlength) +{ + uint16* newoutput = output; + const UTF8* src = (UTF8*)source; + if (ConvertUTF8toUTF16(&src, src + srcLength, &newoutput, newoutput + srcLength, lenientConversion) != sourceIllegal) + { + outlength = newoutput - output; + return true; + } + else + { + outlength = 0; + return false; + } +} + +bool ConvertUTF8toUTF16(const std::string& source, dynamic_array& utf16) +{ + utf16.resize_uninitialized(source.size()); + int length = 0; + bool success = ConvertUTF8toUTF16(source.data(), (int)source.size(), utf16.begin(), length); + utf16.resize_uninitialized(length); + return success; +} + +bool ConvertUTF16toUTF8(const uint16* source, int srcLength, char* output, int& outlength) +{ + UTF8* newoutput = (UTF8*)output; + const UTF16* src = (UTF16*)source; + if (ConvertUTF16toUTF8(&src, src + srcLength, &newoutput, newoutput + (srcLength * 4), lenientConversion) != sourceIllegal) + { + outlength = newoutput - (UTF8*)output; + return true; + } + else + { + outlength = 0; + return false; + } +} + + +bool ConvertUTF16toUTF8(const dynamic_array& source, std::string& utf8) +{ + utf8.resize(source.size() * 4); + int length = 0; + bool success = ConvertUTF16toUTF8(source.data(), (int)source.size(), &utf8[0], length); + utf8.resize(length); + return success; +} + +bool ConvertUTF16toUTF8(const uint16 utf16character, std::string& utf8) +{ + int len; + char character[5]; + if (!ConvertUTF16toUTF8(&utf16character, 1, character, len)) + return false; + character[len] = 0; + utf8 = std::string(character); + return true; +} + + +namespace_end \ No newline at end of file diff --git a/Source/modules/asura-base/Misc/UTF8.h b/Source/modules/asura-base/Misc/UTF8.h new file mode 100644 index 0000000..269ad36 --- /dev/null +++ b/Source/modules/asura-base/Misc/UTF8.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +#include "../Type.h" +#include "../Classes.h" +#include "../Utilities/dynamic_array.h" + +namespace_begin(AsuraEngine) + +typedef uint16 UnicodeChar; + +bool ConvertUTF8toUTF16(const char* source, int srcLength, UnicodeChar* output, int& outlength); +bool ConvertUTF8toUTF16(const std::string& source, dynamic_array& utf16); +bool ConvertUTF16toUTF8(const uint16* source, int srcLength, char* output, int& outlength); +bool ConvertUTF16toUTF8(const dynamic_array& source, std::string& utf8); +bool ConvertUTF16toUTF8(const uint16* source, int srcLength, char* output, int& outlength); +bool ConvertUTF16toUTF8(const uint16 utf16character, std::string& utf8); + +namespace_end \ No newline at end of file diff --git a/Source/modules/asura-base/Utilities/LinkedList.cpp b/Source/modules/asura-base/Utilities/LinkedList.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-base/Utilities/LinkedList.h b/Source/modules/asura-base/Utilities/LinkedList.h index e69de29..5a7dc74 100644 --- a/Source/modules/asura-base/Utilities/LinkedList.h +++ b/Source/modules/asura-base/Utilities/LinkedList.h @@ -0,0 +1,388 @@ +#ifndef _ASURA_LINKED_LIST_H_ +#define _ASURA_LINKED_LIST_H_ + +#include "../Type.h" +#include + +#if !ASURA_RELEASE +#define LINKED_LIST_ASSERT(x) Assert(x) +#else +#define LINKED_LIST_ASSERT(x) +#endif + +class ListElement +{ +public: + inline ListElement(); + inline ~ListElement() { RemoveFromList(); } + + inline bool IsInList() const; + inline bool RemoveFromList(); + inline void InsertInList(ListElement* pos); + + // Check against List::end(), not NULL + ListElement* GetPrev() const { return m_Prev; } + ListElement* GetNext() const { return m_Next; } + +private: + // Non copyable + ListElement(const ListElement&); + ListElement& operator=(const ListElement&); + + ListElement* m_Prev; + ListElement* m_Next; + + template friend class List; + inline void ValidateLinks() const; + +#if !ASURA_RELEASE + // Iterator debugging only + template friend class ListIterator; + template friend class ListConstIterator; + void SetList(void* l) { m_List = l; } + void* m_List; +#else + void SetList(void*) {} +#endif +}; + +template +class ListNode : public ListElement +{ +public: + ListNode(T* data = NULL) : m_Data(data) {} + T& operator*() const { return *m_Data; } + T* operator->() const { return m_Data; } + T* GetData() const { return m_Data; } + void SetData(T* data) { m_Data = data; } + + // We know the type of prev and next element + ListNode* GetPrev() const { return static_cast(ListElement::GetPrev()); } + ListNode* GetNext() const { return static_cast(ListElement::GetNext()); } + +private: + T * m_Data; +}; + +template +class ListIterator +{ +public: + ListIterator(T* node = NULL) : m_Node(node) {} + + // Pre- and post-increment operator + ListIterator& operator++() { m_Node = m_Node->GetNext(); return *this; } + ListIterator operator++(int) { ListIterator ret(*this); ++(*this); return ret; } + + // Pre- and post-decrement operator + ListIterator& operator--() { m_Node = m_Node->GetPrev(); return *this; } + ListIterator operator--(int) { ListIterator ret(*this); --(*this); return ret; } + + T& operator*() const { return static_cast(*m_Node); } + T* operator->() const { return static_cast(m_Node); } + + friend bool operator !=(const ListIterator& x, const ListIterator& y) { return x.m_Node != y.m_Node; } + friend bool operator ==(const ListIterator& x, const ListIterator& y) { return x.m_Node == y.m_Node; } + +private: + template friend class List; + ListIterator(ListElement* node) : m_Node(node) {} + ListElement* m_Node; +}; + + +template +class ListConstIterator +{ +public: + ListConstIterator(const T* node = NULL) : m_Node(node) {} + + // Pre- and post-increment operator + ListConstIterator& operator++() { m_Node = m_Node->GetNext(); return *this; } + ListConstIterator operator++(int) { ListConstIterator ret(*this); ++(*this); return ret; } + + // Pre- and post-decrement operator + ListConstIterator& operator--() { m_Node = m_Node->GetPrev(); return *this; } + ListConstIterator operator--(int) { ListConstIterator ret(*this); --(*this); return ret; } + + const T& operator*() const { return static_cast(*m_Node); } + const T* operator->() const { return static_cast(m_Node); } + + friend bool operator !=(const ListConstIterator& x, const ListConstIterator& y) { return x.m_Node != y.m_Node; } + friend bool operator ==(const ListConstIterator& x, const ListConstIterator& y) { return x.m_Node == y.m_Node; } + +private: + template friend class List; + ListConstIterator(const ListElement* node) : m_Node(node) {} + const ListElement* m_Node; +}; + +template +class List +{ +public: + typedef ListConstIterator const_iterator; + typedef ListIterator iterator; + typedef T value_type; + + inline List(); + inline ~List(); + + void push_back(T& node) { node.InsertInList(&m_Root); } + void push_front(T& node) { node.InsertInList(m_Root.m_Next); } + void insert(iterator pos, T& node) { node.InsertInList(&(*pos)); } + void erase(iterator pos) { pos->RemoveFromList(); } + + void pop_back() { if (m_Root.m_Prev != &m_Root) m_Root.m_Prev->RemoveFromList(); } + void pop_front() { if (m_Root.m_Next != &m_Root) m_Root.m_Next->RemoveFromList(); } + + iterator begin() { return iterator(m_Root.m_Next); } + iterator end() { return iterator(&m_Root); } + + const_iterator begin() const { return const_iterator(m_Root.m_Next); } + const_iterator end() const { return const_iterator(&m_Root); } + + T& front() { LINKED_LIST_ASSERT(!empty()); return static_cast(*m_Root.m_Next); } + T& back() { LINKED_LIST_ASSERT(!empty()); return static_cast(*m_Root.m_Prev); } + + const T& front() const { LINKED_LIST_ASSERT(!empty()); return static_cast(*m_Root.m_Next); } + const T& back() const { LINKED_LIST_ASSERT(!empty()); return static_cast(*m_Root.m_Prev); } + + bool empty() const { return begin() == end(); } + + size_t size_slow() const; + inline void clear(); + inline void swap(List& other); + + // Insert list into list (removes elements from source) + inline void insert(iterator pos, List& src); + inline void append(List& src); + +private: + ListElement m_Root; +}; + + +template +List::List() +{ + m_Root.m_Prev = &m_Root; + m_Root.m_Next = &m_Root; + m_Root.SetList(this); +} + +template +List::~List() +{ + clear(); +} + +template +size_t List::size_slow() const +{ + size_t size = 0; + ListElement* node = m_Root.m_Next; + while (node != &m_Root) + { + node = node->m_Next; + size++; + } + return size; +} + +template +void List::clear() +{ + ListElement* node = m_Root.m_Next; + while (node != &m_Root) + { + ListElement* next = node->m_Next; + node->m_Prev = NULL; + node->m_Next = NULL; + node->SetList(NULL); + node = next; + } + m_Root.m_Next = &m_Root; + m_Root.m_Prev = &m_Root; +} + +template +void List::swap(List& other) +{ + LINKED_LIST_ASSERT(this != &other); + + std::swap(other.m_Root.m_Prev, m_Root.m_Prev); + std::swap(other.m_Root.m_Next, m_Root.m_Next); + + if (other.m_Root.m_Prev == &m_Root) + other.m_Root.m_Prev = &other.m_Root; + if (m_Root.m_Prev == &other.m_Root) + m_Root.m_Prev = &m_Root; + if (other.m_Root.m_Next == &m_Root) + other.m_Root.m_Next = &other.m_Root; + if (m_Root.m_Next == &other.m_Root) + m_Root.m_Next = &m_Root; + + other.m_Root.m_Prev->m_Next = &other.m_Root; + other.m_Root.m_Next->m_Prev = &other.m_Root; + + m_Root.m_Prev->m_Next = &m_Root; + m_Root.m_Next->m_Prev = &m_Root; + +#if !ASURA_RELEASE + iterator my_it, my_end = end(); + for (my_it = begin(); my_it != my_end; ++my_it) + my_it->m_List = this; + iterator other_it, other_end = other.end(); + for (other_it = other.begin(); other_it != other_end; ++other_it) + other_it->m_List = &other; +#endif +} + +template +void List::insert(iterator pos, List& src) +{ + LINKED_LIST_ASSERT(this != &src); + if (src.empty()) + return; + +#if !ASURA_RELEASE + iterator src_it, src_end = src.end(); + for (src_it = src.begin(); src_it != src_end; ++src_it) + src_it->m_List = this; +#endif + // Insert source before pos + ListElement* a = pos.m_Node->m_Prev; + ListElement* b = pos.m_Node; + a->m_Next = src.m_Root.m_Next; + b->m_Prev = src.m_Root.m_Prev; + a->m_Next->m_Prev = a; + b->m_Prev->m_Next = b; + // Clear source list + src.m_Root.m_Next = &src.m_Root; + src.m_Root.m_Prev = &src.m_Root; +} + +template +void List::append(List& src) +{ + insert(end(), src); +} + +ListElement::ListElement() +{ + m_Prev = NULL; + m_Next = NULL; + SetList(NULL); +} + +bool ListElement::IsInList() const +{ + return m_Prev != NULL; +} + +bool ListElement::RemoveFromList() +{ + if (!IsInList()) + return false; + +#if !ASURA_RELEASE + ValidateLinks(); +#endif + m_Prev->m_Next = m_Next; + m_Next->m_Prev = m_Prev; + m_Prev = NULL; + m_Next = NULL; + return true; +} + +void ListElement::InsertInList(ListElement* pos) +{ + if (this == pos) + return; + + if (IsInList()) + RemoveFromList(); + +#if !ASURA_RELEASE + m_List = pos->m_List; + pos->m_Prev->ValidateLinks(); + pos->ValidateLinks(); +#endif + m_Prev = pos->m_Prev; + m_Next = pos; + m_Prev->m_Next = this; + m_Next->m_Prev = this; +#if !ASURA_RELEASE + ValidateLinks(); +#endif + return; +} + +void ListElement::ValidateLinks() const +{ +#if !ASURA_RELEASE + LINKED_LIST_ASSERT(m_Prev != NULL && m_Next != NULL); + LINKED_LIST_ASSERT(m_Prev->m_Next == this && m_Next->m_Prev == this); + LINKED_LIST_ASSERT(m_Prev->m_List == m_List && m_Next->m_List == m_List); +#endif +} + +/// Allows for iterating a linked list, even if you add / remove any node during traversal. +template +class SafeIterator +{ +public: + SafeIterator(T& list) + : m_SourceList(list) + { + m_CurrentNode = NULL; + m_ExecuteList.swap(m_SourceList); + } + + ~SafeIterator() + { + // Call Complete if you abort the iteration! + LINKED_LIST_ASSERT(m_ExecuteList.empty()); + } + + // You must call complete if you are in some way aborting list iteration. + // If you dont call Complete, the source list will lose nodes that have not yet been iterated permanently. + // + /// SafeIterator i(myList); + /// i =0; + /// while(i.GetNext() && ++i != 3) + /// (**i).Update(); + /// i.Complete(); + void Complete() + { + m_SourceList.append(m_ExecuteList); + } + + typename T::value_type* Next() + { + if (!m_ExecuteList.empty()) + { + typename T::iterator it = m_ExecuteList.begin(); + m_CurrentNode = &*it; + m_ExecuteList.erase(it); + m_SourceList.push_back(*m_CurrentNode); + } + else + { + m_CurrentNode = NULL; + } + return m_CurrentNode; + } + + typename T::value_type& operator *() const { return *m_CurrentNode; } + typename T::value_type* operator ->() const { return m_CurrentNode; } + +private: + T m_ExecuteList; + T& m_SourceList; + typename T::value_type* m_CurrentNode; +}; + + +#endif diff --git a/Source/modules/asura-base/Utilities/dynamic_array.h b/Source/modules/asura-base/Utilities/dynamic_array.h new file mode 100644 index 0000000..36885f0 --- /dev/null +++ b/Source/modules/asura-base/Utilities/dynamic_array.h @@ -0,0 +1,337 @@ +#pragma once + +#include // std::uninitialized_fill + +// dynamic_array - simplified version of std::vector +// +// features: +// . always uses memcpy for copying elements. Your data structures must be simple and can't have internal pointers / rely on copy constructor. +// . EASTL like push_back(void) implementation +// Existing std STL implementations implement insertion operations by copying from an element. +// For example, resize(size() + 1) creates a throw-away temporary object. +// There is no way in existing std STL implementations to add an element to a container without implicitly or +// explicitly providing one to copy from (aside from some existing POD optimizations). +// For expensive-to-construct objects this creates a potentially serious performance problem. +// . grows X2 on reallocation +// . small code footprint +// . clear actually deallocates memory +// . resize does NOT initialize members! +// +// Changelog: +// Added pop_back() +// Added assign() +// Added clear() - frees the data, use resize(0) to clear w/o freeing +// zero allocation for empty array +// +// +template +struct AlignOfType +{ + enum { align = ALIGN_OF(T) }; +}; + + +template ::align, MemLabelIdentifier defaultLabel = kMemDynamicArrayId> +struct dynamic_array +{ +public: + typedef T* iterator; + typedef const T* const_iterator; + typedef T value_type; + typedef size_t size_type; + typedef size_t difference_type; + typedef T& reference; + typedef const T& const_reference; + +public: + + dynamic_array() : m_data(NULL), m_label(defaultLabel, NULL), m_size(0), m_capacity(0) + { + m_label = MemLabelId(defaultLabel, GET_CURRENT_ALLOC_ROOT_HEADER()); + } + + dynamic_array(MemLabelRef label) : m_data(NULL), m_label(label), m_size(0), m_capacity(0) + { + } + + explicit dynamic_array(size_t size, MemLabelRef label) + : m_label(label), m_size(size), m_capacity(size) + { + m_data = allocate(size); + } + + dynamic_array(size_t size, T const& init_value, MemLabelRef label) + : m_label(label), m_size(size), m_capacity(size) + { + m_data = allocate(size); + std::uninitialized_fill(m_data, m_data + size, init_value); + } + + ~dynamic_array() + { + if (owns_data()) + m_data = deallocate(m_data); + } + + dynamic_array(const dynamic_array& other) : m_capacity(0), m_size(0), m_label(other.m_label) + { + //m_label.SetRootHeader(GET_CURRENT_ALLOC_ROOT_HEADER()); + m_data = NULL; + assign(other.begin(), other.end()); + } + + dynamic_array& operator=(const dynamic_array& other) + { + // should not allocate memory unless we have to + assign(other.begin(), other.end()); + return *this; + } + + void clear() + { + if (owns_data()) + m_data = deallocate(m_data); + m_size = 0; + m_capacity = 0; + } + + void assign(const_iterator begin, const_iterator end) + { + Assert(begin <= end); + + resize_uninitialized(end - begin); + memcpy(m_data, begin, m_size * sizeof(T)); + } + + void erase(iterator input_begin, iterator input_end) + { + Assert(input_begin <= input_end); + Assert(input_begin >= begin()); + Assert(input_end <= end()); + + size_t leftOverSize = end() - input_end; + memmove(input_begin, input_end, leftOverSize * sizeof(T)); + m_size -= input_end - input_begin; + } + + iterator erase(iterator position) + { + Assert(position >= begin()); + Assert(position < end()); + + size_t leftOverSize = end() - position - 1; + memmove(position, position + 1, leftOverSize * sizeof(T)); + m_size -= 1; + + return position; + } + + iterator insert(iterator insert_before, const_iterator input_begin, const_iterator input_end) + { + Assert(input_begin <= input_end); + Assert(insert_before >= begin()); + Assert(insert_before <= end()); + + // resize (make sure that insertBefore does not get invalid in the meantime because of a reallocation) + size_t insert_before_index = insert_before - begin(); + size_t elements_to_be_moved = size() - insert_before_index; + resize_uninitialized((input_end - input_begin) + size()); + insert_before = begin() + insert_before_index; + + size_t insertsize = input_end - input_begin; + // move to the end of where the inserted data will be + memmove(insert_before + insertsize, insert_before, elements_to_be_moved * sizeof(T)); + // inject input data in the hole we just created + memcpy(insert_before, input_begin, insertsize * sizeof(T)); + + return insert_before; + } + + iterator insert(iterator insertBefore, const T& t) { return insert(insertBefore, &t, &t + 1); } + + void swap(dynamic_array& other) throw() + { + if (m_data) UNITY_TRANSFER_OWNERSHIP_TO_HEADER(m_data, m_label, other.m_label.GetRootHeader()); + if (other.m_data) UNITY_TRANSFER_OWNERSHIP_TO_HEADER(other.m_data, other.m_label, m_label.GetRootHeader()); + std::swap(m_data, other.m_data); + std::swap(m_size, other.m_size); + std::swap(m_capacity, other.m_capacity); + std::swap(m_label, other.m_label); + } + + T& push_back() + { + if (++m_size > capacity()) + reserve(std::max(capacity() * 2, 1)); + return back(); + } + + void push_back(const T& t) + { + push_back() = t; + } + + void pop_back() + { + Assert(m_size >= 1); + m_size--; + } + + void resize_uninitialized(size_t size, bool double_on_resize = false) + { + m_size = size; + if (m_size <= capacity()) + return; + + if (double_on_resize && size < capacity() * 2) + size = capacity() * 2; + reserve(size); + } + + void resize_initialized(size_t size, const T& t = T(), bool double_on_resize = false) + { + if (size > capacity()) + { + size_t requested_size = size; + if (double_on_resize && size < capacity() * 2) + requested_size = capacity() * 2; + reserve(requested_size); + } + + if (size > m_size) + std::uninitialized_fill(m_data + m_size, m_data + size, t); + m_size = size; + } + + void reserve(size_t inCapacity) + { + if (capacity() >= inCapacity) + return; + + if (owns_data()) + { + m_capacity = inCapacity; + m_data = reallocate(m_data, inCapacity); + } + else + { + T* newData = allocate(inCapacity); + memcpy(newData, m_data, m_size * sizeof(T)); + + // Invalidate old non-owned data, since using the data from two places is most likely a really really bad idea. +#if DEBUGMODE + memset(m_data, 0xCD, capacity() * sizeof(T)); +#endif + + m_capacity = inCapacity; // and clear reference bit + m_data = newData; + } + } + + void assign_external(T* begin, T* end) + { + if (owns_data()) + m_data = deallocate(m_data); + m_size = m_capacity = reinterpret_cast (end) - reinterpret_cast (begin); + Assert(m_size < k_reference_bit); + m_capacity |= k_reference_bit; + m_data = begin; + } + + void set_owns_data(bool ownsData) + { + if (ownsData) + m_capacity &= ~k_reference_bit; + else + m_capacity |= k_reference_bit; + } + + void shrink_to_fit() + { + if (owns_data()) + { + m_capacity = m_size; + m_data = reallocate(m_data, m_size); + } + } + + const T& back() const { Assert(m_size != 0); return m_data[m_size - 1]; } + const T& front() const { Assert(m_size != 0); return m_data[0]; } + + T& back() { Assert(m_size != 0); return m_data[m_size - 1]; } + T& front() { Assert(m_size != 0); return m_data[0]; } + + T* data() { return m_data; } + T const* data() const { return m_data; } + + bool empty() const { return m_size == 0; } + size_t size() const { return m_size; } + size_t capacity() const { return m_capacity & ~k_reference_bit; } + + T const& operator[] (size_t index) const { DebugAssert(index < m_size); return m_data[index]; } + T& operator[] (size_t index) { DebugAssert(index < m_size); return m_data[index]; } + + T const* begin() const { return m_data; } + T* begin() { return m_data; } + + T const* end() const { return m_data + m_size; } + T* end() { return m_data + m_size; } + + bool owns_data() { return (m_capacity & k_reference_bit) == 0; } + + bool equals(const dynamic_array& other) + { + if (m_size != other.m_size) + return false; + + for (int i = 0; i < m_size; i++) + { + if (m_data[i] != other.m_data[i]) + return false; + } + + return true; + } + + void set_memory_label(MemLabelRef label) + { + Assert(m_data == NULL); + m_label = label; + } + +private: + + static const size_t k_reference_bit = (size_t)1 << (sizeof(size_t) * 8 - 1); + + T* allocate(size_t size) + { + // If you are getting this error then you are trying to allocate memory for an incomplete type + CompileTimeAssert(sizeof(T) != 0, "incomplete type"); + CompileTimeAssert(align != 0, "incomplete type"); + + return static_cast (UNITY_MALLOC_ALIGNED(m_label, size * sizeof(T), align)); + } + + T* deallocate(T* data) + { + Assert(owns_data()); + UNITY_FREE(m_label, data); + return NULL; + } + + T* reallocate(T* data, size_t size) + { + // If you are getting this error then you are trying to allocate memory for an incomplete type + CompileTimeAssert(sizeof(T) != 0, "incomplete type"); + CompileTimeAssert(align != 0, "incomplete type"); + + Assert(owns_data()); + int alignof = static_cast(align); + return static_cast (UNITY_REALLOC_ALIGNED(m_label, data, size * sizeof(T), alignof)); + } + + T* m_data; + MemLabelId m_label; + size_t m_size; + size_t m_capacity; +}; diff --git a/Source/modules/asura-box2d/Physics/Body.h b/Source/modules/asura-box2d/Physics/Body.h deleted file mode 100644 index d7e79d5..0000000 --- a/Source/modules/asura-box2d/Physics/Body.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __ASURA_BOX2D_BODY_H__ -#define __ASURA_BOX2D_BODY_H__ - -#include - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class World; -class Joint; - -enum BodyType -{ - BODY_TYPE_INVALID, - BODY_TYPE_STATIC, - BODY_TYPE_DYNAMIC, - BODY_TYPE_KINEMATIC -}; - -class Body : public AEScripting::Portable -{ -public: - -private: - - friend class Joint; - - //----------------------------------------------------------------------------// - - LUAX_DECL_FACTORY(Body); - - LUAX_DECL_ENUM(BodyType, 1); - - LUAX_DECL_METHOD(_GetType); - LUAX_DECL_METHOD(_GetX); - LUAX_DECL_METHOD(_GetY); - LUAX_DECL_METHOD(_GetAngle); - LUAX_DECL_METHOD(_GetPosition); - LUAX_DECL_METHOD(_GetLinearVelocity); - LUAX_DECL_METHOD(_GetWorldCenter); - LUAX_DECL_METHOD(_GetLocalCenter); - LUAX_DECL_METHOD(_GetAngularVelocity); - LUAX_DECL_METHOD(_GetMass); - LUAX_DECL_METHOD(_GetInertia); - LUAX_DECL_METHOD(_GetMassData); - LUAX_DECL_METHOD(_GetAngularDamping); - LUAX_DECL_METHOD(_GetLinearDamping); - LUAX_DECL_METHOD(_GetGravityScale); - LUAX_DECL_METHOD(_GetGravityScale); - - //----------------------------------------------------------------------------// - - b2Body* m_Body; - World* m_World; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics/ChainShape.h b/Source/modules/asura-box2d/Physics/ChainShape.h deleted file mode 100644 index 2403587..0000000 --- a/Source/modules/asura-box2d/Physics/ChainShape.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __ASURA_CHAIN_SHAPE_H__ -#define __ASURA_CHAIN_SHAPE_H__ - -#include - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class ChainShape - : AEScripting::Portable -{ -public: - - ChainShape(); - ~ChainShape(); - -private: - - b2ChainShape* m_Shape; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics/CircleShape.h b/Source/modules/asura-box2d/Physics/CircleShape.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/Contact.h b/Source/modules/asura-box2d/Physics/Contact.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/DebugDraw.h b/Source/modules/asura-box2d/Physics/DebugDraw.h deleted file mode 100644 index a92be43..0000000 --- a/Source/modules/asura-box2d/Physics/DebugDraw.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _ASURA_BOX2D_DEBUG_DRAW_H_ -#define _ASURA_BOX2D_DEBUG_DRAW_H_ - -namespace AsuraEngine -{ - -} - -#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics/DistanceJoint.h b/Source/modules/asura-box2d/Physics/DistanceJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/EdgeShape.h b/Source/modules/asura-box2d/Physics/EdgeShape.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/Fixture.h b/Source/modules/asura-box2d/Physics/Fixture.h deleted file mode 100644 index 69f0153..0000000 --- a/Source/modules/asura-box2d/Physics/Fixture.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ASRUA_ENGINE_FIXTURE_H_ -#define _ASRUA_ENGINE_FIXTURE_H_ - -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class Fixture -{ - -}; - -namespace_end -namespace_end - -#endif diff --git a/Source/modules/asura-box2d/Physics/FrictionJoint.h b/Source/modules/asura-box2d/Physics/FrictionJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/GearJoint.h b/Source/modules/asura-box2d/Physics/GearJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/Joint.h b/Source/modules/asura-box2d/Physics/Joint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/MotorJoint.h b/Source/modules/asura-box2d/Physics/MotorJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/MouseJoint.h b/Source/modules/asura-box2d/Physics/MouseJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/PolygonShape.h b/Source/modules/asura-box2d/Physics/PolygonShape.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/PrismaticJoint.h b/Source/modules/asura-box2d/Physics/PrismaticJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/PulleyJoint.h b/Source/modules/asura-box2d/Physics/PulleyJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/RevoluteJoint.h b/Source/modules/asura-box2d/Physics/RevoluteJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/RopeJoint.h b/Source/modules/asura-box2d/Physics/RopeJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/Shape.h b/Source/modules/asura-box2d/Physics/Shape.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/WeldJoint.h b/Source/modules/asura-box2d/Physics/WeldJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/WheelJoint.h b/Source/modules/asura-box2d/Physics/WheelJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-box2d/Physics/World.h b/Source/modules/asura-box2d/Physics/World.h deleted file mode 100644 index a156c79..0000000 --- a/Source/modules/asura-box2d/Physics/World.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASURA_BOX2D_WORLD_H__ -#define __ASURA_BOX2D_WORLD_H__ - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class World : public AEScripting::Portable -{ - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics/binding/_body.cpp b/Source/modules/asura-box2d/Physics/binding/_body.cpp deleted file mode 100644 index 0c9e3e8..0000000 --- a/Source/modules/asura-box2d/Physics/binding/_body.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "../Body.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace Physics - { - - LUAX_REGISTRY(Body) - { - LUAX_REGISTER_METHODS(state, - { "GetType", _GetType }, - { "GetX", _GetX }, - { "GetY", _GetY }, - { "GetAngle", _GetAngle }, - { "GetPosition", _GetPosition }, - { "GetLinearVelocity", _GetLinearVelocity }, - { "GetWorldCenter", _GetWorldCenter }, - { "GetLocalCenter", _GetLocalCenter }, - { "GetAngularVelocity", _GetAngularVelocity }, - { "GetMass", _GetMass }, - { "GetInertia", _GetInertia }, - { "GetMassData", _GetMassData }, - { "GetAngularDamping", _GetAngularDamping }, - { "GetLinearDamping", _GetLinearDamping }, - { "GetGravityScale", _GetGravityScale }, - { "GetGravityScale", _GetGravityScale } - ); - } - - LUAX_POSTPROCESS(Body) - { - LUAX_REGISTER_ENUM(state, "EBodyType", - { "INVALID", BODY_TYPE_INVALID }, - { "STATIC", BODY_TYPE_STATIC }, - { "DYNAMIC", BODY_TYPE_DYNAMIC }, - { "KINEMATIC", BODY_TYPE_KINEMATIC } - ); - - } - - // body:GetType() - LUAX_IMPL_METHOD(Body, _GetType) - { - LUAX_PREPARE(L, Body); - return 0; - } - - // body:GetX() - LUAX_IMPL_METHOD(Body, _GetX) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetY() - LUAX_IMPL_METHOD(Body, _GetY) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngle() - LUAX_IMPL_METHOD(Body, _GetAngle) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetPosition() - LUAX_IMPL_METHOD(Body, _GetPosition) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLinearVelocity() - LUAX_IMPL_METHOD(Body, _GetLinearVelocity) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetWorldCenter() - LUAX_IMPL_METHOD(Body, _GetWorldCenter) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLocalCenter() - LUAX_IMPL_METHOD(Body, _GetLocalCenter) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngularVelocity() - LUAX_IMPL_METHOD(Body, _GetAngularVelocity) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetMass() - LUAX_IMPL_METHOD(Body, _GetMass) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetInertia() - LUAX_IMPL_METHOD(Body, _GetInertia) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetMassData() - LUAX_IMPL_METHOD(Body, _GetMassData) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngularDamping() - LUAX_IMPL_METHOD(Body, _GetAngularDamping) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLinearDamping() - LUAX_IMPL_METHOD(Body, _GetLinearDamping) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetGravityScale() - LUAX_IMPL_METHOD(Body, _GetGravityScale) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetGravityScale() - LUAX_IMPL_METHOD(Body, _GetGravityScale) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - } -} diff --git a/Source/modules/asura-box2d/Physics/binding/_world.cpp b/Source/modules/asura-box2d/Physics/binding/_world.cpp deleted file mode 100644 index 0940959..0000000 --- a/Source/modules/asura-box2d/Physics/binding/_world.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "../World.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace Physics - { - /* - LUAX_REGISTRY(World) - { - - } - - LUAX_POSTPROCESS(World) - { - - } -*/ - } -} diff --git a/Source/modules/asura-box2d/Physics2D/Body.h b/Source/modules/asura-box2d/Physics2D/Body.h new file mode 100644 index 0000000..d7e79d5 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/Body.h @@ -0,0 +1,64 @@ +#ifndef __ASURA_BOX2D_BODY_H__ +#define __ASURA_BOX2D_BODY_H__ + +#include + +#include +#include + +namespace_begin(AsuraEngine) +namespace_begin(Physics) + +class World; +class Joint; + +enum BodyType +{ + BODY_TYPE_INVALID, + BODY_TYPE_STATIC, + BODY_TYPE_DYNAMIC, + BODY_TYPE_KINEMATIC +}; + +class Body : public AEScripting::Portable +{ +public: + +private: + + friend class Joint; + + //----------------------------------------------------------------------------// + + LUAX_DECL_FACTORY(Body); + + LUAX_DECL_ENUM(BodyType, 1); + + LUAX_DECL_METHOD(_GetType); + LUAX_DECL_METHOD(_GetX); + LUAX_DECL_METHOD(_GetY); + LUAX_DECL_METHOD(_GetAngle); + LUAX_DECL_METHOD(_GetPosition); + LUAX_DECL_METHOD(_GetLinearVelocity); + LUAX_DECL_METHOD(_GetWorldCenter); + LUAX_DECL_METHOD(_GetLocalCenter); + LUAX_DECL_METHOD(_GetAngularVelocity); + LUAX_DECL_METHOD(_GetMass); + LUAX_DECL_METHOD(_GetInertia); + LUAX_DECL_METHOD(_GetMassData); + LUAX_DECL_METHOD(_GetAngularDamping); + LUAX_DECL_METHOD(_GetLinearDamping); + LUAX_DECL_METHOD(_GetGravityScale); + LUAX_DECL_METHOD(_GetGravityScale); + + //----------------------------------------------------------------------------// + + b2Body* m_Body; + World* m_World; + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics2D/ChainShape.h b/Source/modules/asura-box2d/Physics2D/ChainShape.h new file mode 100644 index 0000000..2403587 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/ChainShape.h @@ -0,0 +1,29 @@ +#ifndef __ASURA_CHAIN_SHAPE_H__ +#define __ASURA_CHAIN_SHAPE_H__ + +#include + +#include +#include + +namespace_begin(AsuraEngine) +namespace_begin(Physics) + +class ChainShape + : AEScripting::Portable +{ +public: + + ChainShape(); + ~ChainShape(); + +private: + + b2ChainShape* m_Shape; + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics2D/CircleShape.h b/Source/modules/asura-box2d/Physics2D/CircleShape.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/Contact.h b/Source/modules/asura-box2d/Physics2D/Contact.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/DebugDraw.h b/Source/modules/asura-box2d/Physics2D/DebugDraw.h new file mode 100644 index 0000000..a92be43 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/DebugDraw.h @@ -0,0 +1,9 @@ +#ifndef _ASURA_BOX2D_DEBUG_DRAW_H_ +#define _ASURA_BOX2D_DEBUG_DRAW_H_ + +namespace AsuraEngine +{ + +} + +#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics2D/DistanceJoint.h b/Source/modules/asura-box2d/Physics2D/DistanceJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/EdgeShape.h b/Source/modules/asura-box2d/Physics2D/EdgeShape.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/Fixture.h b/Source/modules/asura-box2d/Physics2D/Fixture.h new file mode 100644 index 0000000..69f0153 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/Fixture.h @@ -0,0 +1,17 @@ +#ifndef _ASRUA_ENGINE_FIXTURE_H_ +#define _ASRUA_ENGINE_FIXTURE_H_ + +#include + +namespace_begin(AsuraEngine) +namespace_begin(Physics) + +class Fixture +{ + +}; + +namespace_end +namespace_end + +#endif diff --git a/Source/modules/asura-box2d/Physics2D/FrictionJoint.h b/Source/modules/asura-box2d/Physics2D/FrictionJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/GearJoint.h b/Source/modules/asura-box2d/Physics2D/GearJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/Joint.h b/Source/modules/asura-box2d/Physics2D/Joint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/MotorJoint.h b/Source/modules/asura-box2d/Physics2D/MotorJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/MouseJoint.h b/Source/modules/asura-box2d/Physics2D/MouseJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/PolygonShape.h b/Source/modules/asura-box2d/Physics2D/PolygonShape.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/PrismaticJoint.h b/Source/modules/asura-box2d/Physics2D/PrismaticJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/PulleyJoint.h b/Source/modules/asura-box2d/Physics2D/PulleyJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/RevoluteJoint.h b/Source/modules/asura-box2d/Physics2D/RevoluteJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/RopeJoint.h b/Source/modules/asura-box2d/Physics2D/RopeJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/Shape.h b/Source/modules/asura-box2d/Physics2D/Shape.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/WeldJoint.h b/Source/modules/asura-box2d/Physics2D/WeldJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/WheelJoint.h b/Source/modules/asura-box2d/Physics2D/WheelJoint.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-box2d/Physics2D/World.h b/Source/modules/asura-box2d/Physics2D/World.h new file mode 100644 index 0000000..a156c79 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/World.h @@ -0,0 +1,18 @@ +#ifndef __ASURA_BOX2D_WORLD_H__ +#define __ASURA_BOX2D_WORLD_H__ + +#include +#include + +namespace_begin(AsuraEngine) +namespace_begin(Physics) + +class World : public AEScripting::Portable +{ + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file diff --git a/Source/modules/asura-box2d/Physics2D/binding/_body.cpp b/Source/modules/asura-box2d/Physics2D/binding/_body.cpp new file mode 100644 index 0000000..0c9e3e8 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/binding/_body.cpp @@ -0,0 +1,171 @@ +#include "../Body.h" + +using namespace std; + +namespace AsuraEngine +{ + namespace Physics + { + + LUAX_REGISTRY(Body) + { + LUAX_REGISTER_METHODS(state, + { "GetType", _GetType }, + { "GetX", _GetX }, + { "GetY", _GetY }, + { "GetAngle", _GetAngle }, + { "GetPosition", _GetPosition }, + { "GetLinearVelocity", _GetLinearVelocity }, + { "GetWorldCenter", _GetWorldCenter }, + { "GetLocalCenter", _GetLocalCenter }, + { "GetAngularVelocity", _GetAngularVelocity }, + { "GetMass", _GetMass }, + { "GetInertia", _GetInertia }, + { "GetMassData", _GetMassData }, + { "GetAngularDamping", _GetAngularDamping }, + { "GetLinearDamping", _GetLinearDamping }, + { "GetGravityScale", _GetGravityScale }, + { "GetGravityScale", _GetGravityScale } + ); + } + + LUAX_POSTPROCESS(Body) + { + LUAX_REGISTER_ENUM(state, "EBodyType", + { "INVALID", BODY_TYPE_INVALID }, + { "STATIC", BODY_TYPE_STATIC }, + { "DYNAMIC", BODY_TYPE_DYNAMIC }, + { "KINEMATIC", BODY_TYPE_KINEMATIC } + ); + + } + + // body:GetType() + LUAX_IMPL_METHOD(Body, _GetType) + { + LUAX_PREPARE(L, Body); + return 0; + } + + // body:GetX() + LUAX_IMPL_METHOD(Body, _GetX) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetY() + LUAX_IMPL_METHOD(Body, _GetY) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetAngle() + LUAX_IMPL_METHOD(Body, _GetAngle) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetPosition() + LUAX_IMPL_METHOD(Body, _GetPosition) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetLinearVelocity() + LUAX_IMPL_METHOD(Body, _GetLinearVelocity) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetWorldCenter() + LUAX_IMPL_METHOD(Body, _GetWorldCenter) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetLocalCenter() + LUAX_IMPL_METHOD(Body, _GetLocalCenter) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetAngularVelocity() + LUAX_IMPL_METHOD(Body, _GetAngularVelocity) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetMass() + LUAX_IMPL_METHOD(Body, _GetMass) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetInertia() + LUAX_IMPL_METHOD(Body, _GetInertia) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetMassData() + LUAX_IMPL_METHOD(Body, _GetMassData) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetAngularDamping() + LUAX_IMPL_METHOD(Body, _GetAngularDamping) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetLinearDamping() + LUAX_IMPL_METHOD(Body, _GetLinearDamping) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetGravityScale() + LUAX_IMPL_METHOD(Body, _GetGravityScale) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + // body:GetGravityScale() + LUAX_IMPL_METHOD(Body, _GetGravityScale) + { + LUAX_PREPARE(L, Body); + + return 0; + } + + } +} diff --git a/Source/modules/asura-box2d/Physics2D/binding/_world.cpp b/Source/modules/asura-box2d/Physics2D/binding/_world.cpp new file mode 100644 index 0000000..0940959 --- /dev/null +++ b/Source/modules/asura-box2d/Physics2D/binding/_world.cpp @@ -0,0 +1,21 @@ +#include "../World.h" + +using namespace std; + +namespace AsuraEngine +{ + namespace Physics + { + /* + LUAX_REGISTRY(World) + { + + } + + LUAX_POSTPROCESS(World) + { + + } +*/ + } +} diff --git a/Source/modules/asura-core/Font/TTF.cpp b/Source/modules/asura-core/Font/TTF.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-core/Font/TTF.h b/Source/modules/asura-core/Font/TTF.h deleted file mode 100644 index b83cf76..0000000 --- a/Source/modules/asura-core/Font/TTF.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ASURA_TTF_H_ -#define _ASURA_TTF_H_ - -namespace AsuraEngine -{ - namespace Text - { - - class TTF - { - - }; - - } -} - -#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Font/TTFImporter.cpp b/Source/modules/asura-core/Font/TTFImporter.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-core/Font/TTFImporter.h b/Source/modules/asura-core/Font/TTFImporter.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-core/Font/Utf.hpp b/Source/modules/asura-core/Font/Utf.hpp deleted file mode 100644 index 59f62ed..0000000 --- a/Source/modules/asura-core/Font/Utf.hpp +++ /dev/null @@ -1,720 +0,0 @@ -#ifndef _ASURA_UTF_HPP_ -#define _ASURA_UTF_HPP_ - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include -#include -#include - -namespace AsuraEngine -{ - namespace Text - { - - template - class Utf; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-8 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<8> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-8 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-8 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-8 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-8. - /// - /// \param input Codepoint to encode as UTF-8 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-8 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint8 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-8 character - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-8 sequence - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element, thus the - /// total size can be different from (begin - end). - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-8 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-8 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - }; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-16 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<16> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-16 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-16 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-16 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-16. - /// - /// \param input Codepoint to encode as UTF-16 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-16 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint16 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-16 character - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-16 sequence - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element, thus the - /// total size can be different from (begin - end). - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-16 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-16 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - }; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-32 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<32> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-32 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// For UTF-32, the character value is the same as the codepoint. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-32 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-32. - /// For UTF-32, the codepoint is the same as the character value. - /// - /// \param input Codepoint to encode as UTF-32 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-32 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-32 character - /// - /// This function is trivial for UTF-32, which can store - /// every character in a single storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-32 sequence - /// - /// This function is trivial for UTF-32, which can store - /// every character in a single storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-32 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-32 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-32 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-32 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Decode a single ANSI character to UTF-32 - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param input Input ANSI character - /// \param locale Locale to use for conversion - /// - /// \return Converted character - /// - //////////////////////////////////////////////////////////// - template - static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Decode a single wide character to UTF-32 - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param input Input wide character - /// - /// \return Converted character - /// - //////////////////////////////////////////////////////////// - template - static Uint32 DecodeWide(In input); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character to ANSI - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param codepoint Iterator pointing to the beginning of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement if the input character is not convertible to ANSI (use 0 to skip it) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character to wide - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param codepoint Iterator pointing to the beginning of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement if the input character is not convertible to wide (use 0 to skip it) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0); - }; - -#include "Utf.inc" - - // Make typedefs to get rid of the template syntax - typedef Utf<8> Utf8; - typedef Utf<16> Utf16; - typedef Utf<32> Utf32; - - } // namespace sf - -} - - -#endif // SFML_UTF_HPP diff --git a/Source/modules/asura-core/Font/Utf.inc b/Source/modules/asura-core/Font/Utf.inc deleted file mode 100644 index 69a523b..0000000 --- a/Source/modules/asura-core/Font/Utf.inc +++ /dev/null @@ -1,752 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -// References: -// -// https://www.unicode.org/ -// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c -// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h -// https://people.w3.org/rishida/scripts/uniview/conversion -// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -template -In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement) -{ - // Some useful precomputed data - static const int trailing[256] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 - }; - static const Uint32 offsets[6] = - { - 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080 - }; - - // decode the character - int trailingBytes = trailing[static_cast(*begin)]; - if (begin + trailingBytes < end) - { - output = 0; - switch (trailingBytes) - { - case 5: output += static_cast(*begin++); output <<= 6; - case 4: output += static_cast(*begin++); output <<= 6; - case 3: output += static_cast(*begin++); output <<= 6; - case 2: output += static_cast(*begin++); output <<= 6; - case 1: output += static_cast(*begin++); output <<= 6; - case 0: output += static_cast(*begin++); - } - output -= offsets[trailingBytes]; - } - else - { - // Incomplete character - begin = end; - output = replacement; - } - - return begin; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement) -{ - // Some useful precomputed data - static const Uint8 firstBytes[7] = - { - 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC - }; - - // encode the character - if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF))) - { - // Invalid character - if (replacement) - *output++ = replacement; - } - else - { - // Valid character - - // Get the number of bytes to write - std::size_t bytestoWrite = 1; - if (input < 0x80) bytestoWrite = 1; - else if (input < 0x800) bytestoWrite = 2; - else if (input < 0x10000) bytestoWrite = 3; - else if (input <= 0x0010FFFF) bytestoWrite = 4; - - // Extract the bytes to write - Uint8 bytes[4]; - switch (bytestoWrite) - { - case 4: bytes[3] = static_cast((input | 0x80) & 0xBF); input >>= 6; - case 3: bytes[2] = static_cast((input | 0x80) & 0xBF); input >>= 6; - case 2: bytes[1] = static_cast((input | 0x80) & 0xBF); input >>= 6; - case 1: bytes[0] = static_cast (input | firstBytes[bytestoWrite]); - } - - // Add them to the output - output = std::copy(bytes, bytes + bytestoWrite, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<8>::Next(In begin, In end) -{ - Uint32 codepoint; - return Decode(begin, end, codepoint); -} - - -//////////////////////////////////////////////////////////// -template -std::size_t Utf<8>::Count(In begin, In end) -{ - std::size_t length = 0; - while (begin < end) - { - begin = Next(begin, end); - ++length; - } - - return length; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::FromAnsi(In begin, In end, Out output, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::FromWide(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeWide(*begin++); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::FromLatin1(In begin, In end, Out output) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - output = Encode(*begin++, output); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeWide(codepoint, output, replacement); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToLatin1(In begin, In end, Out output, char replacement) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - *output++ = codepoint < 256 ? static_cast(codepoint) : replacement; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToUtf8(In begin, In end, Out output) -{ - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToUtf16(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<16>::Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToUtf32(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - *output++ = codepoint; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<16>::Decode(In begin, In end, Uint32& output, Uint32 replacement) -{ - Uint16 first = *begin++; - - // If it's a surrogate pair, first convert to a single UTF-32 character - if ((first >= 0xD800) && (first <= 0xDBFF)) - { - if (begin < end) - { - Uint32 second = *begin++; - if ((second >= 0xDC00) && (second <= 0xDFFF)) - { - // The second element is valid: convert the two elements to a UTF-32 character - output = ((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000; - } - else - { - // Invalid character - output = replacement; - } - } - else - { - // Invalid character - begin = end; - output = replacement; - } - } - else - { - // We can make a direct copy - output = first; - } - - return begin; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::Encode(Uint32 input, Out output, Uint16 replacement) -{ - if (input <= 0xFFFF) - { - // The character can be copied directly, we just need to check if it's in the valid range - if ((input >= 0xD800) && (input <= 0xDFFF)) - { - // Invalid character (this range is reserved) - if (replacement) - *output++ = replacement; - } - else - { - // Valid character directly convertible to a single UTF-16 character - *output++ = static_cast(input); - } - } - else if (input > 0x0010FFFF) - { - // Invalid character (greater than the maximum Unicode value) - if (replacement) - *output++ = replacement; - } - else - { - // The input character will be converted to two UTF-16 elements - input -= 0x0010000; - *output++ = static_cast((input >> 10) + 0xD800); - *output++ = static_cast((input & 0x3FFUL) + 0xDC00); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<16>::Next(In begin, In end) -{ - Uint32 codepoint; - return Decode(begin, end, codepoint); -} - - -//////////////////////////////////////////////////////////// -template -std::size_t Utf<16>::Count(In begin, In end) -{ - std::size_t length = 0; - while (begin < end) - { - begin = Next(begin, end); - ++length; - } - - return length; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::FromAnsi(In begin, In end, Out output, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::FromWide(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeWide(*begin++); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::FromLatin1(In begin, In end, Out output) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeWide(codepoint, output, replacement); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToLatin1(In begin, In end, Out output, char replacement) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - { - *output++ = *begin < 256 ? static_cast(*begin) : replacement; - begin++; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToUtf8(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<8>::Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToUtf16(In begin, In end, Out output) -{ - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToUtf32(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - *output++ = codepoint; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<32>::Decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/) -{ - output = *begin++; - return begin; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::Encode(Uint32 input, Out output, Uint32 /*replacement*/) -{ - *output++ = input; - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<32>::Next(In begin, In /*end*/) -{ - return ++begin; -} - - -//////////////////////////////////////////////////////////// -template -std::size_t Utf<32>::Count(In begin, In end) -{ - return begin - end; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::FromAnsi(In begin, In end, Out output, const std::locale& locale) -{ - while (begin < end) - *output++ = DecodeAnsi(*begin++, locale); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::FromWide(In begin, In end, Out output) -{ - while (begin < end) - *output++ = DecodeWide(*begin++); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::FromLatin1(In begin, In end, Out output) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) -{ - while (begin < end) - output = EncodeAnsi(*begin++, output, replacement, locale); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement) -{ - while (begin < end) - output = EncodeWide(*begin++, output, replacement); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToLatin1(In begin, In end, Out output, char replacement) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - { - *output++ = *begin < 256 ? static_cast(*begin) : replacement; - begin++; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToUtf8(In begin, In end, Out output) -{ - while (begin < end) - output = Utf<8>::Encode(*begin++, output); - - return output; -} - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToUtf16(In begin, In end, Out output) -{ - while (begin < end) - output = Utf<16>::Encode(*begin++, output); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToUtf32(In begin, In end, Out output) -{ - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale) -{ - // On Windows, GCC's standard library (glibc++) has almost - // no support for Unicode stuff. As a consequence, in this - // context we can only use the default locale and ignore - // the one passed as parameter. - - #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \ - (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \ - !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */ - - (void)locale; // to avoid warnings - - wchar_t character = 0; - mbtowc(&character, &input, 1); - return static_cast(character); - - #else - - // Get the facet of the locale which deals with character conversion - const std::ctype& facet = std::use_facet< std::ctype >(locale); - - // Use the facet to convert each character of the input string - return static_cast(facet.widen(input)); - - #endif -} - - -//////////////////////////////////////////////////////////// -template -Uint32 Utf<32>::DecodeWide(In input) -{ - // The encoding of wide characters is not well defined and is left to the system; - // however we can safely assume that it is UCS-2 on Windows and - // UCS-4 on Unix systems. - // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4, - // and UCS-4 *is* UTF-32). - - return input; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale) -{ - // On Windows, gcc's standard library (glibc++) has almost - // no support for Unicode stuff. As a consequence, in this - // context we can only use the default locale and ignore - // the one passed as parameter. - - #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \ - (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \ - !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */ - - (void)locale; // to avoid warnings - - char character = 0; - if (wctomb(&character, static_cast(codepoint)) >= 0) - *output++ = character; - else if (replacement) - *output++ = replacement; - - return output; - - #else - - // Get the facet of the locale which deals with character conversion - const std::ctype& facet = std::use_facet< std::ctype >(locale); - - // Use the facet to convert each character of the input string - *output++ = facet.narrow(static_cast(codepoint), replacement); - - return output; - - #endif -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::EncodeWide(Uint32 codepoint, Out output, wchar_t replacement) -{ - // The encoding of wide characters is not well defined and is left to the system; - // however we can safely assume that it is UCS-2 on Windows and - // UCS-4 on Unix systems. - // For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4). - // For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32). - - switch (sizeof(wchar_t)) - { - case 4: - { - *output++ = static_cast(codepoint); - break; - } - - default: - { - if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF))) - { - *output++ = static_cast(codepoint); - } - else if (replacement) - { - *output++ = replacement; - } - break; - } - } - - return output; -} diff --git a/Source/modules/asura-core/Graphics/DrawInfo.h b/Source/modules/asura-core/Graphics/DrawInfo.h index 0082102..6167359 100644 --- a/Source/modules/asura-core/Graphics/DrawInfo.h +++ b/Source/modules/asura-core/Graphics/DrawInfo.h @@ -6,6 +6,14 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +struct ShaderUniform; + +struct ShaderUniformSheet +{ + + +}; + /// struct DrawInfo { diff --git a/Source/modules/asura-core/Graphics/GPUBuffer.cpp b/Source/modules/asura-core/Graphics/GPUBuffer.cpp index f28b914..ded4708 100644 --- a/Source/modules/asura-core/Graphics/GPUBuffer.cpp +++ b/Source/modules/asura-core/Graphics/GPUBuffer.cpp @@ -69,16 +69,16 @@ bool GPUBuffer::Fill(const void * data, size_t size, uint offset) return false; if (m_Buffer == 0) { - g_Device.WipeError(); + g_GfxDevice.WipeError(); glGenBuffers(1, &m_Buffer); if (m_Buffer == 0) throw Exception("OpenGL glGenBuffers failed."); glBindBuffer(m_Target, m_Buffer); glBufferData(m_Target, m_Size, NULL, m_Usage); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) { glBindBuffer(m_Target, 0); - throw Exception("OpenGL glBufferData failed. Errorcode=%d.", g_Device.GetError()); + throw Exception("OpenGL glBufferData failed. Errorcode=%d.", g_GfxDevice.GetError()); } #if ASURA_DEBUG m_Data = (byte*)malloc(size); @@ -87,11 +87,12 @@ bool GPUBuffer::Fill(const void * data, size_t size, uint offset) } else glBindBuffer(m_Target, m_Buffer); - glBufferSubData(m_Target, offset, size, data); - if (g_Device.HasError()) + //glBufferSubData(m_Target, offset, size, data); + GL_CALL(glBufferSubData, m_Target, offset, size, data); + if (g_GfxDevice.HasError()) { glBindBuffer(m_Target, 0); - throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", g_Device.GetError()); + throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", g_GfxDevice.GetError()); } glBindBuffer(m_Target, 0); #if ASURA_DEBUG diff --git a/Source/modules/asura-core/Graphics/GfxDevice.cpp b/Source/modules/asura-core/Graphics/GfxDevice.cpp index 529a76c..ab5e281 100644 --- a/Source/modules/asura-core/Graphics/GfxDevice.cpp +++ b/Source/modules/asura-core/Graphics/GfxDevice.cpp @@ -7,7 +7,7 @@ #include "MatrixStack.h" #include "Color.h" -using namespace AEMath; + namespace_begin(AsuraEngine) namespace_begin(Graphics) @@ -16,7 +16,13 @@ namespace_begin(Graphics) static bool instantiated = false; #endif -GfxDevice g_Device; +#if ASURA_GL_PROFILE +#define Stats(f) m_Stats.f +#else +#define Stats(f) +#endif + +GfxDevice g_GfxDevice; GfxDevice::GfxDevice() { @@ -32,12 +38,12 @@ GfxDevice::~GfxDevice() GfxDevice& GfxDevice::Get() { - return g_Device; + return g_GfxDevice; } static bool inited = false; -bool GfxDevice::Init(const AEMath::Recti& view) +bool GfxDevice::Init(const Recti& view) { bool loaded = false; #if ASURA_OPENGL_LOADER & ASURA_OPENGL_GLAD @@ -74,113 +80,101 @@ GLenum GfxDevice::GetError() void GfxDevice::SetDrawColor(float r, float g, float b, float a) { - state.drawColor.Set(r, g, b, a); + m_State.drawColor.Set(r, g, b, a); } Color& GfxDevice::GetDrawColor() { - return state.drawColor; + return m_State.drawColor; } void GfxDevice::SetViewport(const Recti v) { - state.viewport = v; + m_State.viewport = v; glViewport(v.x, v.y, v.w, v.h); } const Recti& GfxDevice::GetViewport() { - return state.viewport; + return m_State.viewport; } void GfxDevice::SetActiveShader(Shader* shader) { - if (state.shader == shader) + if (m_State.activeShader == shader) return; - if (state.shader) - state.shader->OnDisable(); - state.shader = shader; + if (m_State.activeShader) + m_State.activeShader->OnDisable(); + m_State.activeShader = shader; if (shader) { GLint program = shader->GetGLProgram(); glUseProgram(program); -#if ASURA_GL_PROFILE - ++stats.shaderSwitch; -#endif shader->OnEnable(); + Stats(AddShaderSwitch()); } } Shader* GfxDevice::GetActiveShader() const { - return state.shader; -} - -void GfxDevice::DrawArrays(GLenum mode, GLint first, GLsizei count) -{ - glDrawArrays(mode, first, count); -#if ASURA_GL_PROFILE - ++stats.drawCall; -#endif - if (state.shader) - state.shader->OnUsed(); + return m_State.activeShader; } void GfxDevice::PushMatrix () { - state.matrix[state.matrixMode].Push (); + m_State.matrix[m_State.matrixMode].Push (); } void GfxDevice::PopMatrix () { - state.matrix[state.matrixMode].Pop(); + m_State.matrix[m_State.matrixMode].Pop(); } void GfxDevice::LoadIdentity() { - state.matrix[state.matrixMode].LoadIdentity(); + m_State.matrix[m_State.matrixMode].LoadIdentity(); } void GfxDevice::Rotate (float angle) { - state.matrix[state.matrixMode].Rotate(angle); + m_State.matrix[m_State.matrixMode].Rotate(angle); } void GfxDevice::Translate (float x, float y) { - state.matrix[state.matrixMode].Translate(x, y); + m_State.matrix[m_State.matrixMode].Translate(x, y); } void GfxDevice::Scale (float x, float y) { - state.matrix[state.matrixMode].Scale(x, y); + m_State.matrix[m_State.matrixMode].Scale(x, y); } void GfxDevice::Ortho(float l, float r, float b, float t, float n, float f) { - state.matrix[state.matrixMode].Ortho(l, r, b, t, n, f); + m_State.matrix[m_State.matrixMode].Ortho(l, r, b, t, n, f); } -AEMath::Matrix44& GfxDevice::GetMatrix(MatrixMode mode) +Matrix44& GfxDevice::GetMatrix(MatrixMode mode) { - return state.matrix[mode].GetTop(); + return m_State.matrix[mode].GetTop(); } -AEMath::Matrix44 GfxDevice::GetMVPMatrix() +Matrix44 GfxDevice::GetMVPMatrix() { - return state.matrix[MATRIX_MODE_PROJECTION].GetTop() - * state.matrix[MATRIX_MODE_VIEW].GetTop() - * state.matrix[MATRIX_MODE_MODEL].GetTop(); + return m_State.matrix[MATRIX_MODE_PROJECTION].GetTop() + * m_State.matrix[MATRIX_MODE_VIEW].GetTop() + * m_State.matrix[MATRIX_MODE_MODEL].GetTop(); } uint GfxDevice::GetMatrixDepth() { - return state.matrix[state.matrixMode].GetCapacity(); + return m_State.matrix[m_State.matrixMode].GetCapacity(); } uint GfxDevice::GetMatrixIndex() { - return state.matrix[state.matrixMode].GetTopIndex(); + return m_State.matrix[m_State.matrixMode].GetTopIndex(); } diff --git a/Source/modules/asura-core/Graphics/GfxDevice.h b/Source/modules/asura-core/Graphics/GfxDevice.h index 2b105df..7ef03a3 100644 --- a/Source/modules/asura-core/Graphics/GfxDevice.h +++ b/Source/modules/asura-core/Graphics/GfxDevice.h @@ -16,10 +16,40 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +class Mesh; class Profiler; class Shader; class GPUBuffer; class Canvas; +class DynamicVBO; +class VBO; +class VBOList; + +#define GFX_STATS_PROPERTY(TYPE,PROP_NAME,VAR_NAME) \ +private: \ + TYPE VAR_NAME; \ +public: \ + void Set##PROP_NAME (TYPE val) { VAR_NAME = val; } \ + TYPE Get##PROP_NAME () {return VAR_NAME; } \ + void Add##PROP_NAME (TYPE v=1) { VAR_NAME+=v;}; + +struct GfxDeviceStats +{ + GFX_STATS_PROPERTY(uint, DrawCall, drawCall); ///< ͳ¼Ædrawcall + GFX_STATS_PROPERTY(uint, CanvasSwitch, canvasSwitch); ///< Çл»textureµÄ´ÎÊý + GFX_STATS_PROPERTY(uint, ShaderSwitch, shaderSwitch); ///< Çл»shaderµÄ´ÎÊý + GFX_STATS_PROPERTY(uint64, PrimsCount, primsCount); ///< ͼԪÊýÁ¿Í³¼Æ + + void Reset() + { + drawCall = 0; + canvasSwitch = 0; + shaderSwitch = 0; + primsCount = 0; + } +}; + +#undef GFX_STATS_PROPERTY enum MatrixMode { @@ -28,6 +58,20 @@ enum MatrixMode MATRIX_MODE_VIEW = 2, }; + +enum GfxPrimitiveType +{ + GFX_PRIMITIVE_TRIANGLES = 0, + GFX_PRIMITIVE_TRIANGLESTRIPDEPRECATED, + GFX_PRIMITIVE_QUADS, + GFX_PRIMITIVE_LINES, + GFX_PRIMITIVE_LINESTRIP, + GFX_PRIMITIVE_POINTS, + + GFX_PRIMITIVE_TYPECOUNT, // KEEP THIS LAST! + GFX_PRIMITIVE_FORCE32BITINT = 0X7FFFFFFF // FORCE 32 BIT ENUM SIZE +}; + enum GLParams { GL_PARAM_MAX_TEXTURE_UNIT = 1, @@ -44,12 +88,12 @@ public: int GetParam(GLParams param); - bool Init(const AEMath::Recti& viewport); + bool Init(const Recti& viewport); bool Inited(); - void SetViewport(const AEMath::Recti viewport); + void SetViewport(const Recti viewport); - const AEMath::Recti& GetViewport(); + const Recti& GetViewport(); void PushMatrix(); void PopMatrix(); @@ -63,10 +107,8 @@ public: uint GetMatrixDepth(); uint GetMatrixIndex(); - void DrawArrays(GLenum mode, GLint first, GLsizei count); - - AEMath::Matrix44& GetMatrix(MatrixMode mode); - AEMath::Matrix44 GetMVPMatrix(); + Matrix44& GetMatrix(MatrixMode mode); + Matrix44 GetMVPMatrix(); void SetDrawColor(float r, float g, float b, float a); Color& GetDrawColor(); @@ -74,36 +116,47 @@ public: void SetActiveShader(Shader* = NULL); Shader* GetActiveShader() const; + VBO* CreateVBO(); + void DeleteVBO(); + + void DrawMesh(Mesh* mesh); + void DrawVBO(VBO* vbo); + void DrawDynamicVBO(); + void DrawTexture(Texture*); + void WipeError(); bool HasError(); GLenum GetError(); - GET_SET(MatrixMode, MatrixMode, state.matrixMode); - GET_SET(Canvas*, ActiveCanvas, state.canvas); + GET_SET(MatrixMode, MatrixMode, m_State.matrixMode); + GET_SET(Canvas*, ActiveCanvas, m_State.activeCanvas); private: + void BeforeDrawCall(); + + // Callbacks + void OnCreateVBO(VBO* vbo); + void OnDeleteVBO(VBO* vbo); + friend class Profiler; - struct - { - AEMath::Recti viewport; ///< µ±Ç°µÄÊÓÇø£¬ÔÚÇл»HDC»òÕß±¾´°¿Ú´óС¸Ä±ä»òÕß²¿·ÖË¢ÐÂʱ±ä¶¯ - MatrixStack matrix[3]; ///< model, view, projection¾ØÕó - MatrixMode matrixMode; ///< µ±Ç°²Ù×÷µÄ¾ØÕó - Color drawColor; ///< »æÖƵÄÑÕÉ« - Canvas* canvas; ///< µ±Ç°canvas - Shader* shader; ///< µ±Ç°Ê¹ÓõÄshader - } state; + struct { + Recti viewport; ///< µ±Ç°µÄÊÓÇø£¬ÔÚÇл»HDC»òÕß±¾´°¿Ú´óС¸Ä±ä»òÕß²¿·ÖË¢ÐÂʱ±ä¶¯ + MatrixStack matrix[3]; ///< model, view, projection¾ØÕó + MatrixMode matrixMode; ///< µ±Ç°²Ù×÷µÄ¾ØÕó + Color drawColor; ///< »æÖƵÄÑÕÉ« + Canvas* activeCanvas; ///< µ±Ç°canvas + Shader* activeShader; ///< µ±Ç°Ê¹ÓõÄshader + } m_State; #if ASURA_GL_PROFILE - struct - { - uint drawCall; ///< ͳ¼Ædrawcall - uint canvasSwitch; ///< Çл»textureµÄ´ÎÊý - uint shaderSwitch; ///< Çл»shaderµÄ´ÎÊý - } stats; + GfxDeviceStats m_Stats; #endif + DynamicVBO* m_DynamicVBO; + VBOList* m_VBOList; + luaxport: LUAX_DECL_SINGLETON(GfxDevice); @@ -127,13 +180,12 @@ luaxport: }; -extern GfxDevice g_Device; - - -#define GL_CALL(x) do { x; /*GLAssert(); */} while(0) - +// È«¾Ögfx device£¬runnerºÍeditor¶¼ÊÊÓà +extern GfxDevice g_GfxDevice; +inline GfxDevice& GetGfxDevice() { return g_GfxDevice; }; +#define GL_CALL(f, ...) do { f(__VA_ARGS__); /*GLAssert(); */} while(0) namespace_end namespace_end diff --git a/Source/modules/asura-core/Graphics/Image.cpp b/Source/modules/asura-core/Graphics/Image.cpp deleted file mode 100644 index 36d2478..0000000 --- a/Source/modules/asura-core/Graphics/Image.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include - -#include "../CoreConfig.h" - -#include "Shader.h" -#include "Image.h" -#include "GfxDevice.h" - -using namespace AEFileSystem; -using namespace AEImage; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -Image::Image() - : m_Width(0) - , m_Height(0) -{ -} - -Image::~Image() -{ -} - -bool Image::Load(ImageData* imgData) -{ - if (!imgData) return false; - - if (m_TexID == 0) - { - glGenTextures(1, &m_TexID); - if (m_TexID == 0) - throw Exception("OpenGL glGenTextures failed."); - } - - glBindTexture(GL_TEXTURE_2D, m_TexID); - imgData->Lock(); - int width = imgData->width; - int height = imgData->height; - TextureFormat tf = ConvertColorFormat(imgData->format); - glTexImage2D( - GL_TEXTURE_2D - , 0 - , tf.internalformat - , width, height - , 0 - , tf.externalformat - , tf.type - , imgData->pixels - ); - - m_Width = imgData->width; - m_Height = imgData->height; - imgData->Unlock(); - GLenum err = glGetError(); - if (err != GL_NO_ERROR) - throw Exception("OpenGL glTexImage2D cause error, error code=%d", err); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -bool Image::Load(ImageData* imgData, const AEMath::Vector2i& pos) -{ - if (!imgData) return false; - - glBindTexture(GL_TEXTURE_2D, m_TexID); - imgData->Lock(); - int width = imgData->width; - int height = imgData->height; - TextureFormat tf = ConvertColorFormat(imgData->format); - glTexSubImage2D( - GL_TEXTURE_2D - , 0 - , pos.x - , pos.y - , imgData->width - , imgData->height - , tf.externalformat - , tf.type - , imgData->pixels - ); - imgData->Unlock(); - GLenum err = glGetError(); - if (err != GL_NO_ERROR) - throw Exception("OpenGL glTexSubImage2D cause error, error code=%d", err); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -uint32 Image::GetWidth() -{ - return m_Width; -} - -uint32 Image::GetHeight() -{ - return m_Height; -} - -namespace_end -namespace_end \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/Image.h b/Source/modules/asura-core/Graphics/Image.h deleted file mode 100644 index a76d06f..0000000 --- a/Source/modules/asura-core/Graphics/Image.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _ASURA_ENGINE_IMAGE_H_ -#define _ASURA_ENGINE_IMAGE_H_ - -// asura modules -#include -#include -#include -#include -#include -#include - -// module -#include "../Image/ImageData.h" - -// folder -#include "Color.h" -#include "Color32.h" -#include "RenderState.h" -#include "GPUBuffer.h" -#include "Texture.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -class Image ASURA_FINAL : public AEScripting::Portable -{ -public: - - Image(); - ~Image(); - - bool Load(AEImage::ImageData* decodeData); - bool Load(AEImage::ImageData* decodeData, const AEMath::Vector2i& pos); - - uint GetWidth(); - uint GetHeight(); - - GPUBuffer* GenGPUBuffer(); - -private: - - uint32 m_Width, m_Height; - -luaxport: - - LUAX_DECL_FACTORY(Image, Texture); - - LUAX_DECL_METHOD(_New); - LUAX_DECL_METHOD(_Load); - LUAX_DECL_METHOD(_GetWidth); - LUAX_DECL_METHOD(_GetHeight); - LUAX_DECL_METHOD(_GetSize); - LUAX_DECL_METHOD(_GetPixel); - LUAX_DECL_METHOD(_Render); - -}; - -namespace_end -namespace_end - -namespace AEGraphics = AsuraEngine::Graphics; - -#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/MatrixStack.cpp b/Source/modules/asura-core/Graphics/MatrixStack.cpp index 987d29c..88b9b6b 100644 --- a/Source/modules/asura-core/Graphics/MatrixStack.cpp +++ b/Source/modules/asura-core/Graphics/MatrixStack.cpp @@ -36,7 +36,7 @@ bool MatrixStack::Pop() return true; } -AEMath::Matrix44& MatrixStack::GetTop() +Matrix44& MatrixStack::GetTop() { return m_Stack[top]; } diff --git a/Source/modules/asura-core/Graphics/MatrixStack.h b/Source/modules/asura-core/Graphics/MatrixStack.h index 8dd56bf..15ae7e5 100644 --- a/Source/modules/asura-core/Graphics/MatrixStack.h +++ b/Source/modules/asura-core/Graphics/MatrixStack.h @@ -8,17 +8,9 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) -/// -/// Õ»µÄ¾ØÕóÉî¶È¡£ -/// -#define ASURA_MAX_MATRIX_STACK_DEPTH 32 // 2KB - -/// -/// ±£´æÕ»×´Ì¬£¬ÓÃÀ´»Ö¸´Ö®Ç°µÄ״̬¡£Õ»ÖеÄÒ»¸ö¾ØÕóstack[i]µÄÖµÊÇstack[0]*..*stack[i-1] -/// µÄÖµ£¬²¢¸½¼ÓһϵÁÐtransform¡£ -/// -/// TODO: template MatrixStack -/// +// ±£´æÕ»×´Ì¬£¬ÓÃÀ´»Ö¸´Ö®Ç°µÄ״̬¡£Õ»ÖеÄÒ»¸ö¾ØÕóstack[i]µÄÖµÊÇstack[0]*..*stack[i-1]µÄÖµ£¬²¢¸½¼ÓһϵÁÐtransform¡£ +// +// TODO: template MatrixStack class MatrixStack { public: @@ -30,11 +22,11 @@ public: bool Push(); bool Pop(); - AEMath::Matrix44& GetTop(); - void GetTop(ASURA_OUT AEMath::Matrix44& mat44); + Matrix44& GetTop(); + void GetTop(ASURA_OUT Matrix44& mat44); - void LoadMatrix(const AEMath::Matrix44& mat44); - void MultMatrix(const AEMath::Matrix44& mat44); + void LoadMatrix(const Matrix44& mat44); + void MultMatrix(const Matrix44& mat44); void Rotate(float angle); void Translate(float x, float y); @@ -47,8 +39,8 @@ public: private: - AEMath::Matrix44 m_Stack[ASURA_MAX_MATRIX_STACK_DEPTH]; - uint8 top; + Matrix44 m_Stack[32]; // 2kB + uint8 m_Top; }; diff --git a/Source/modules/asura-core/Graphics/Mesh.cpp b/Source/modules/asura-core/Graphics/Mesh.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-core/Graphics/Mesh.h b/Source/modules/asura-core/Graphics/Mesh.h new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-core/Graphics/Mesh2D.cpp b/Source/modules/asura-core/Graphics/Mesh2D.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-core/Graphics/Mesh2D.h b/Source/modules/asura-core/Graphics/Mesh2D.h deleted file mode 100644 index 7a0f62e..0000000 --- a/Source/modules/asura-core/Graphics/Mesh2D.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _ASURA_ENGINE_MESH2D_H__ -#define _ASURA_ENGINE_MESH2D_H__ - -// cpp -#include - -// asura modules -#include -#include - -// module -#include "../Mesh/Mesh2dData.h" - -// folder -#include "Color.h" -#include "VertexBuffer.h" -#include "IndexBuffer.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -/// -/// 2D mesh£¬ÓÃÓÚ×öһЩ¶¥µã¶¯»­¡£ -/// https://en.wikipedia.org/wiki/Polygon_mesh -/// -class Mesh2D ASURA_FINAL - : public Scripting::Portable -{ -public: - - Mesh2D(); - ~Mesh2D(); - - bool Load(AEMesh::Mesh2DData* data); - -private: - - VertexBuffer* m_VBO; ///< vertex buffer - IndexBuffer* m_IBO; ///< index buffer - -luaxport: - - LUAX_DECL_FACTORY(Mesh2D); - - LUAX_DECL_METHOD(_SetVertex); - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/RenderTarget.cpp b/Source/modules/asura-core/Graphics/RenderTarget.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-core/Graphics/RenderTarget.h b/Source/modules/asura-core/Graphics/RenderTarget.h deleted file mode 100644 index ab09e35..0000000 --- a/Source/modules/asura-core/Graphics/RenderTarget.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _ASURA_ENGINE_RENDERTARGET_H_ -#define _ASURA_ENGINE_RENDERTARGET_H_ - -#include -#include -#include - -#include "Texture.h" -#include "Color.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -/// -/// ¿É±»×÷ΪäÖȾĿ±êµÄÀ࣬ÅÉÉúÀàÓÐ -/// Canvas(RenderTexture) -/// Window(RenderWindow) -/// -class RenderTarget : public AEScripting::Object -{ -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; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/RenderTexture.cpp b/Source/modules/asura-core/Graphics/RenderTexture.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-core/Graphics/RenderTexture.h b/Source/modules/asura-core/Graphics/RenderTexture.h new file mode 100644 index 0000000..08199bf --- /dev/null +++ b/Source/modules/asura-core/Graphics/RenderTexture.h @@ -0,0 +1,22 @@ +#ifndef _ASURA_ENGINE_RENDERTARGET_H_ +#define _ASURA_ENGINE_RENDERTARGET_H_ + +#include +#include +#include + +#include "Texture.h" +#include "Color.h" + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + +class RenderTexture : public Texture +{ + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/Shader.cpp b/Source/modules/asura-core/Graphics/Shader.cpp index 329b3f1..56d638d 100644 --- a/Source/modules/asura-core/Graphics/Shader.cpp +++ b/Source/modules/asura-core/Graphics/Shader.cpp @@ -24,12 +24,12 @@ Shader::~Shader() void Shader::SetActive(Shader* shader) { - g_Device.SetActiveShader(shader); + g_GfxDevice.SetActiveShader(shader); } Shader* Shader::GetActive() { - return g_Device.GetActiveShader(); + return g_GfxDevice.GetActiveShader(); } bool Shader::Load(const string& vert, const string& frag) @@ -157,56 +157,56 @@ GLuint Shader::GetGLProgram() void Shader::SetUniformFloat(uint loc, float value) { - if(g_Device.GetActiveShader() == this) + if(g_GfxDevice.GetActiveShader() == this) glUniform1f(loc, value); } bool Shader::SetUniformTexture(uint loc, const Texture& texture) { - if (g_Device.GetActiveShader() != this) + if (g_GfxDevice.GetActiveShader() != this) return false; - g_Device.WipeError(); + g_GfxDevice.WipeError(); glActiveTexture(GL_TEXTURE0 + texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; GLint tex = texture.GetGLTexture(); glBindTexture(GL_TEXTURE_2D, tex); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; glUniform1i(loc, texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; ++texUnit; } void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform2f(loc, vec2.x, vec2.y); } void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform3f(loc, vec3.x, vec3.y, vec3.z); } void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w); } void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements()); } void Shader::SetUniformColor(uint loc, const Color& color) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, color.r, color.g, color.b, color.a); } diff --git a/Source/modules/asura-core/Graphics/Shader.h b/Source/modules/asura-core/Graphics/Shader.h index 615b028..6d7ef90 100644 --- a/Source/modules/asura-core/Graphics/Shader.h +++ b/Source/modules/asura-core/Graphics/Shader.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -23,10 +24,21 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +enum ShaderChannel +{ + SHADER_CHANNEL_NONE = -1, + SHADER_CHANNEL_VERTEX = 0, // Vertex (vector3) + SHADER_CHANNEL_NORMAL, // Normal (vector3) + SHADER_CHANNEL_COLOR, // Vertex color + SHADER_CHANNEL_TEXCOORD0, // UV set 0 (vector2) + SHADER_CHANNEL_TEXCOORD1, // UV set 1 (vector2) + SHADER_CHANNEL_TANGENT, // Tangent (vector4) + SHADER_CHANNEL_COUNT, // Keep this last! +}; + /// -/// Ò»¸öshaderÊÇÒ»¸öÔÚ²ÄÖʼ乲ÏíµÄ³ÌÐò¡£Shader±¾Éí²»±£´æuniformsºÍ¶¥µãÊý¾Ý£¬Ö»ÌṩÉèÖà uniformsºÍuse×ÅÉ« -/// Æ÷µÄ·½·¨¡£±à¼­Æ÷Õë¶Ôÿ¸öshader£¬»áͨ¹ýshader´úÂëÕÒµ½ÉùÃ÷µÄuniforms±äÁ¿£¬²¢±©Â¶¸øframeworkµÄmaterial -/// ÉèÖᣠ+/// Ò»¸öshaderÊÇÒ»¸öÔÚ²ÄÖʼ乲ÏíµÄ³ÌÐò¡£Shader±¾Éí²»±£´æuniformsºÍ¶¥µãÊý¾Ý£¬Ö»ÌṩÉèÖà uniformsºÍuse×ÅÉ«Æ÷µÄ·½·¨¡£ +/// ±à¼­Æ÷Õë¶Ôÿ¸öshader£¬»áͨ¹ýshader´úÂëÕÒµ½ÉùÃ÷µÄuniforms±äÁ¿£¬²¢±©Â¶¸øframeworkµÄmaterialÉèÖᣠ/// class Shader ASURA_FINAL : public Scripting::Portable @@ -64,10 +76,10 @@ public: bool SetUniformTexture(uint loc, const Texture& texture); float GetUniformFloat(uint loc); - AEMath::Vector2f GetUniformVector2(uint loc); - AEMath::Vector3f GetUniformVector3(uint loc); - AEMath::Vector4f GetUniformVector4s(uint loc); - AEMath::Matrix44 GetUniformMatrix44(uint loc); + Vector2f GetUniformVector2(uint loc); + Vector3f GetUniformVector3(uint loc); + Vector4f GetUniformVector4s(uint loc); + Matrix44 GetUniformMatrix44(uint loc); GLuint GetGLProgram(); @@ -109,6 +121,7 @@ luaxport: }; +// GPU program typedef Shader GpuProgram; namespace_end diff --git a/Source/modules/asura-core/Graphics/Texture.h b/Source/modules/asura-core/Graphics/Texture.h index 76b9a8f..572fad4 100644 --- a/Source/modules/asura-core/Graphics/Texture.h +++ b/Source/modules/asura-core/Graphics/Texture.h @@ -3,6 +3,7 @@ #include #include +#include #include "../CoreConfig.h" @@ -14,6 +15,17 @@ namespace_begin(Graphics) class RenderTarget; +/// ͼƬÊý¾Ý +class ImageData +{ +public: + uint8* GetData(); +private: + int m_Format; + uint8* m_ImageData; + Vector2i m_ImageSize; +}; + /// UV²ÉÑù·½Ê½ enum WrapMode { @@ -34,8 +46,8 @@ enum FilterMode enum ColorFormat { COLOR_FORMAT_UNKNOWN, - COLOR_FORMAT_RGBA8, ///< RGBA¶¼ÊÇ8bits int - COLOR_FORMAT_RGBA32F, ///< RGBA¶¼ÊÇ32bits float + COLOR_FORMAT_RGBA8, + COLOR_FORMAT_RGBA32F, }; /// ÎÆÀí¸ñʽ£¬GPUÄÚ²¿ºÍCPUÍⲿ¸ñʽ @@ -50,11 +62,14 @@ struct TextureFormat /// 2DÎÆÀí³éÏóÀ࣬ÔÚ2d meshºÍrender targetÖб»Ê¹Óá£TextureµÄäÖȾԭµãÔÚ×óÉϽǣ¬ÓÎÏ·ÀïÃæµÄÉϲã»áÒԵѿ¨¶û /// ×ø±êϵΪ±ê×¼¡£ÔÚEditorÀïÃæ½çÃæºÍ×é¼þÒ²ÊÇÒÔ×óÉϽÇΪԭµã£¬ÕâÑùÊÇΪÁË·½±ã¡£ /// -ASURA_ABSTRACT class Texture : public AEScripting::Object +class Texture : public AEScripting::Object { public: - LUAX_DECL_ABSTRACT_FACTORY(Texture); + LUAX_DECL_FACTORY(Texture); + + // Texture generator + static Texture* GenerateTexture(); Texture(); virtual ~Texture(); @@ -67,9 +82,12 @@ public: void GetFilterMode(); void GetWrapMode(); - /// Èç¹ûÉèÖÃU»òV·½ÏòfilterΪ bool IsGenMipmap(); + int GetWidth(); + int GetHeight(); + Vector2i GetSize(); + protected: /// ת»»color formatΪtexture format¡£ @@ -79,7 +97,12 @@ protected: FilterMode m_MinFilter; FilterMode m_MagFilter; WrapMode m_WrapMode; + int m_UsageMode; bool m_IsGenMipmap; + Vector2f m_TexelSize; + Vector2f m_UVScale; + +luaxport: LUAX_DECL_ENUM(ColorFormat, 1); LUAX_DECL_ENUM(FilterMode, 1); @@ -90,11 +113,12 @@ protected: LUAX_DECL_METHOD(_GetFilterMode); LUAX_DECL_METHOD(_GetWrapMode); LUAX_DECL_METHOD(_IsGenMipmap); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetSize); }; -typedef Texture Drawable; - namespace_end namespace_end diff --git a/Source/modules/asura-core/Graphics/VBO.cpp b/Source/modules/asura-core/Graphics/VBO.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Source/modules/asura-core/Graphics/VBO.h b/Source/modules/asura-core/Graphics/VBO.h deleted file mode 100644 index f80991e..0000000 --- a/Source/modules/asura-core/Graphics/VBO.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ASURA_ENGINE_VBO_H_ -#define _ASURA_ENGINE_VBO_H_ - -#include - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -struct VertexBufferData -{ - -}; - -struct IndexBufferData -{ - -}; - -class VBO -{ - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/VBOs.cpp b/Source/modules/asura-core/Graphics/VBOs.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Source/modules/asura-core/Graphics/VBOs.h b/Source/modules/asura-core/Graphics/VBOs.h new file mode 100644 index 0000000..0833534 --- /dev/null +++ b/Source/modules/asura-core/Graphics/VBOs.h @@ -0,0 +1,56 @@ +#ifndef _ASURA_ENGINE_VBO_H_ +#define _ASURA_ENGINE_VBO_H_ + +#include +#include + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + +struct VertexBufferData +{ + +}; + +struct IndexBufferData +{ + +}; + +class VBO +{ +public: + +private: + + + +}; + +class SharedVBO; + +class DynamicVBO +{ +public: + + void GetChunk(uint32 maxVertices, uint32 maxIndices, void** outVB, void** outIB); + void ReleaseChunk(uint32 actualVertices, uint32 actualIndices); + +private: + + // vertex buffer + SharedVBO* m_VB; + SharedVBO* m_LargeVB; + SharedVBO* m_ActiveVB; + + // index buffer + SharedVBO* m_IB; + SharedVBO* m_LargeIB; + SharedVBO* m_ActiveIB; + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/Canvas.binding.cpp b/Source/modules/asura-core/Graphics/binding/Canvas.binding.cpp new file mode 100644 index 0000000..a038e67 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Canvas.binding.cpp @@ -0,0 +1,48 @@ +#include "../Canvas.h" + +using namespace std; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + +LUAX_REGISTRY(Canvas) +{ + LUAX_REGISTER_METHODS(state, + { "SetSize", _SetSize }, + { "Bind", _Bind }, + { "Unbind", _Unbind } + ); +} + +LUAX_POSTPROCESS(Canvas) +{ + +} + +// canvas:SetSize() +LUAX_IMPL_METHOD(Canvas, _SetSize) +{ + LUAX_PREPARE(L, Canvas); + return 0; + +} + +// canvas:Bind() +LUAX_IMPL_METHOD(Canvas, _Bind) +{ + LUAX_PREPARE(L, Canvas); + + return 0; +} + +// canvas:Unbind() +LUAX_IMPL_METHOD(Canvas, _Unbind) +{ + LUAX_PREPARE(L, Canvas); + return 0; + +} + +namespace_end +namespace_end \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/Color.binding.cpp b/Source/modules/asura-core/Graphics/binding/Color.binding.cpp new file mode 100644 index 0000000..008d9c2 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Color.binding.cpp @@ -0,0 +1,130 @@ +#include "../Color.h" + +using namespace std; +using namespace Luax; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + +LUAX_REGISTRY(Color) +{ + LUAX_REGISTER_METHODS(state, + { "ToColor32", _ToColor32 }, + { "SetColor", _SetColor }, + { "GetColor", _GetColor }, + { "GetR", _GetR }, + { "GetG", _GetG }, + { "GetB", _GetB }, + { "GetA", _GetA }, + { "__eq", ___eq }, + { "__add", ___add }, + { "__sub", ___sub }, + { "__mul", ___mul }, + { "__div", ___div } + ); +} + +LUAX_POSTPROCESS(Color) +{ + +} + +// color:ToColor32() +LUAX_IMPL_METHOD(Color, _ToColor32) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:SetColor() +LUAX_IMPL_METHOD(Color, _SetColor) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:GetColor() +LUAX_IMPL_METHOD(Color, _GetColor) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:GetR() +LUAX_IMPL_METHOD(Color, _GetR) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:GetG() +LUAX_IMPL_METHOD(Color, _GetG) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:GetB() +LUAX_IMPL_METHOD(Color, _GetB) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:GetA() +LUAX_IMPL_METHOD(Color, _GetA) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:__eq() +LUAX_IMPL_METHOD(Color, ___eq) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:__add() +LUAX_IMPL_METHOD(Color, ___add) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:__sub() +LUAX_IMPL_METHOD(Color, ___sub) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:__mul() +LUAX_IMPL_METHOD(Color, ___mul) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +// color:__div() +LUAX_IMPL_METHOD(Color, ___div) +{ + LUAX_PREPARE(L, Color); + + return 0; +} + +} +} \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/Color32.binding.cpp b/Source/modules/asura-core/Graphics/binding/Color32.binding.cpp new file mode 100644 index 0000000..7613361 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Color32.binding.cpp @@ -0,0 +1,66 @@ +#include "../Color32.h" + +using namespace std; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(Color32) + { + LUAX_REGISTER_METHODS(state, + { "ToColor", _ToColor }, + { "GetRed", _GetRed }, + { "GetGreen", _GetGreen }, + { "GetBlue", _GetBlue }, + { "GetAlpha", _GetAlpha } + ); + } + + LUAX_POSTPROCESS(Color32) + { + + } + + // color32:ToColor() + LUAX_IMPL_METHOD(Color32, _ToColor) + { + LUAX_PREPARE(L, Color32); + return 0; + + } + + // color32:GetRed() + LUAX_IMPL_METHOD(Color32, _GetRed) + { + LUAX_PREPARE(L, Color32); + return 0; + } + + // color32:GetGreen() + LUAX_IMPL_METHOD(Color32, _GetGreen) + { + LUAX_PREPARE(L, Color32); + + return 0; + } + + // color32:GetBlue() + LUAX_IMPL_METHOD(Color32, _GetBlue) + { + LUAX_PREPARE(L, Color32); + + return 0; + } + + // color32:GetAlpha() + LUAX_IMPL_METHOD(Color32, _GetAlpha) + { + LUAX_PREPARE(L, Color32); + + return 0; + } + + } +} + \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/GPUBuffer.binding.cpp b/Source/modules/asura-core/Graphics/binding/GPUBuffer.binding.cpp new file mode 100644 index 0000000..8c39a59 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/GPUBuffer.binding.cpp @@ -0,0 +1,118 @@ +#include + +#include "../image.h" +#include "../GPUBuffer.h" + +using namespace std; +using namespace Luax; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(GPUBuffer) + { + LUAX_REGISTER_METHODS(state, + { "Fill", _Fill }, + { "GetSize", _GetSize }, + { "GetCount", _GetCount } + ); + } + + LUAX_POSTPROCESS(GPUBuffer) + { + LUAX_REGISTER_ENUM(state, "EBufferType", + { "VERTEX", BUFFER_TYPE_VERTEX }, + { "INDEX", BUFFER_TYPE_INDEX } + ); + LUAX_REGISTER_ENUM(state, "EBufferUsage", + { "STREAM", BUFFER_USAGE_STREAM }, + { "DYNAMIC", BUFFER_USAGE_DYNAMIC }, + { "STATIC", BUFFER_USAGE_STATIC } + ); + LUAX_REGISTER_ENUM(state, "EBufferDataType", + { "INT", BUFFER_DATA_TYPE_INT }, + { "FLOAT", BUFFER_DATA_TYPE_FLOAT }, + { "UNSIGNED_BYTE", BUFFER_DATA_TYPE_UNSIGNED_BYTE } + ); + + } + + // buffer = GPUBuffer.New(bufferType, bufferUsage, bufferDataType, size) + // buffer = GPUBuffer.New(image) + // buffer = GPUBuffer.New(mesh2d) + // buffer = GPUBuffer.New(canvas) + // buffer = GPUBuffer.New(shape) + //LUAX_IMPL_METHOD(GPUBuffer, _New) + //{ + // LUAX_STATE(L); + + // return 0; + //} + + // gpubuffer:Fill({data_unit_list}, offseti) + // data_unit_list £º´æ·ÅÊý¾ÝµÄtable + // offseti : ¿ªÊ¼¸²¸ÇµÄµØ·½ËùÔÚµÄË÷Òý(´Ó0¿ªÊ¼£© + LUAX_IMPL_METHOD(GPUBuffer, _Fill) + { + LUAX_PREPARE(L, GPUBuffer); + + // ʹÓÃbuffer¶ÔÓ¦µÄÀàÐÍÊý¾ÝÐÞ¸Äbuffer£¬ÔÚµÚÒ»´Îµ÷ÓÃʱ»á³õʼ»¯size´óСµÄbuffer£¬È»ºóÌî³ä¡£ + int offset = state.GetValue(3, 0); + int count = lua_objlen(L, 2); + int size = count * self->GetDataTypeSize(); + byte* data = (byte*)malloc(size); + int unit = self->GetDataTypeSize(); + int i = 1; + lua_rawgeti(L, 2, i); + while (!lua_isnil(L, -1)) + { + switch (self->m_DataType) + { + case GL_INT: + { + int n = state.CheckValue(-1); + memcpy(data + (i - 1)*unit, &n, unit); + break; + } + case GL_FLOAT: + { + float n = state.CheckValue(-1); + memcpy(data + (i - 1)*unit, &n, unit); + break; + } + case GL_UNSIGNED_BYTE: + { + unsigned char n = state.CheckValue(-1); + memcpy(data + (i - 1)*unit, &n, unit); + break; + } + } + state.Pop(1); // value + lua_rawgeti(L, 2, ++i); + } + state.Pop(); // nil + + self->Fill(data, size, offset * unit); + + free(data); + return 0; + } + + // gpubuffer:GetSize() + LUAX_IMPL_METHOD(GPUBuffer, _GetSize) + { + LUAX_PREPARE(L, GPUBuffer); + state.Push(self->m_Size); + return 0; + } + + LUAX_IMPL_METHOD(GPUBuffer, _GetCount) + { + LUAX_PREPARE(L, GPUBuffer); + state.Push(self->m_Size / self->GetDataTypeSize()); + return 0; + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/GfxDevice.binding.cpp b/Source/modules/asura-core/Graphics/binding/GfxDevice.binding.cpp new file mode 100644 index 0000000..f6c2004 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/GfxDevice.binding.cpp @@ -0,0 +1,151 @@ +#include "../GfxDevice.h" + +using namespace std; +using namespace Luax; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(GfxDevice) + { + LUAX_REGISTER_METHODS(state, + { "SetMatrixMode", _SetMatrixMode }, + { "GetMatrixMode", _GetMatrixMode }, + { "PushMatrix", _PushMatrix }, + { "PopMatrix", _PopMatrix }, + { "LoadIdentity", _LoadIdentity }, + { "Rotate", _Rotate }, + { "Translate", _Translate }, + { "Scale", _Scale }, + { "Ortho", _Ortho }, + { "GetMatrixDepth", _GetMatrixDepth }, + { "GetMatrixIndex", _GetMatrixIndex }, + { "UseShader", _UseShader }, + { "UnuseShader", _UnuseShader } + ); + } + + LUAX_POSTPROCESS(GfxDevice) + { + LUAX_REGISTER_ENUM(state, "EMatrixMode", + { "PROJECTION", MATRIX_MODE_PROJECTION }, + { "0", 0 }, + { "MODEL", MATRIX_MODE_MODEL }, + { "1", 1 }, + { "VIEW", MATRIX_MODE_VIEW }, + { "2", 2 } + ); + LUAX_REGISTER_ENUM(state, "EGLParams", + { "MAX_TEXTURE_UNIT", GL_PARAM_MAX_TEXTURE_UNIT }, + { "1", 1 } + ); + + } + + // gfxdevice:SetMatrixMode() + LUAX_IMPL_METHOD(GfxDevice, _SetMatrixMode) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:GetMatrixMode() + LUAX_IMPL_METHOD(GfxDevice, _GetMatrixMode) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:PushMatrix() + LUAX_IMPL_METHOD(GfxDevice, _PushMatrix) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:PopMatrix() + LUAX_IMPL_METHOD(GfxDevice, _PopMatrix) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:LoadIdentity() + LUAX_IMPL_METHOD(GfxDevice, _LoadIdentity) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:Rotate() + LUAX_IMPL_METHOD(GfxDevice, _Rotate) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:Translate() + LUAX_IMPL_METHOD(GfxDevice, _Translate) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:Scale() + LUAX_IMPL_METHOD(GfxDevice, _Scale) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:Ortho() + LUAX_IMPL_METHOD(GfxDevice, _Ortho) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:GetMatrixDepth() + LUAX_IMPL_METHOD(GfxDevice, _GetMatrixDepth) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:GetMatrixIndex() + LUAX_IMPL_METHOD(GfxDevice, _GetMatrixIndex) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:UseShader() + LUAX_IMPL_METHOD(GfxDevice, _UseShader) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + // gfxdevice:UnuseShader() + LUAX_IMPL_METHOD(GfxDevice, _UnuseShader) + { + LUAX_PREPARE(L, GfxDevice); + + return 0; + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/Image.binding.cpp b/Source/modules/asura-core/Graphics/binding/Image.binding.cpp new file mode 100644 index 0000000..94f88b8 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Image.binding.cpp @@ -0,0 +1,71 @@ +#include "../image.h" + +using namespace std; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + +LUAX_REGISTRY(Image) +{ + LUAX_INHERIT(state, Texture); + + LUAX_REGISTER_METHODS(state, + { "New", _New }, + { "GetWidth", _GetWidth }, + { "GetHeight", _GetHeight }, + { "GetSize", _GetSize }, + { "Render", _Render } + ); +} + +LUAX_POSTPROCESS(Image) +{ +} + +// image = Image.New() +LUAX_IMPL_METHOD(Image, _New) +{ + LUAX_STATE(L); + Image* img = new Image(); + img->PushLuaxUserdata(state); + return 1; +} + +// width = image:GetWidth() +LUAX_IMPL_METHOD(Image, _GetWidth) +{ + LUAX_PREPARE(L, Image); + state.Push(self->GetWidth()); + return 1; +} + +// height = image:GetHeight() +LUAX_IMPL_METHOD(Image, _GetHeight) +{ + LUAX_PREPARE(L, Image); + state.Push(self->GetHeight()); + return 1; +} + +// width, height = image:GetSize() +LUAX_IMPL_METHOD(Image, _GetSize) +{ + LUAX_PREPARE(L, Image); + int width = self->GetWidth(); + int height = self->GetHeight(); + state.Push(width); + state.Push(height); + return 2; +} + +// image:Render() +LUAX_IMPL_METHOD(Image, _Render) +{ + LUAX_PREPARE(L, Image); + + return 0; +} + +} +} diff --git a/Source/modules/asura-core/Graphics/binding/IndexBuffer.binding.cpp b/Source/modules/asura-core/Graphics/binding/IndexBuffer.binding.cpp new file mode 100644 index 0000000..151dc98 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/IndexBuffer.binding.cpp @@ -0,0 +1,31 @@ +#include "../IndexBuffer.h" + +using namespace std; +using namespace Luax; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(IndexBuffer) + { + LUAX_REGISTER_METHODS(state, + { "New", _New } + ); + } + + LUAX_POSTPROCESS(IndexBuffer) + { + + } + + // IndexBuffer.New() + LUAX_IMPL_METHOD(IndexBuffer, _New) + { + LUAX_STATE(L); + + return 0; + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/Mesh.binding.cpp b/Source/modules/asura-core/Graphics/binding/Mesh.binding.cpp new file mode 100644 index 0000000..4e3f426 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Mesh.binding.cpp @@ -0,0 +1,20 @@ +#include "../mesh2d.h" + +using namespace std; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(Mesh2D) + { + + } + + LUAX_POSTPROCESS(Mesh2D) + { + + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/Shader.binding.cpp b/Source/modules/asura-core/Graphics/binding/Shader.binding.cpp new file mode 100644 index 0000000..85fd388 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Shader.binding.cpp @@ -0,0 +1,131 @@ +#include "../shader.h" + +using namespace std; +using namespace Luax; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(Shader) + { + LUAX_REGISTER_METHODS(state, + { "New", _New }, + { "Load", _Load }, + { "Update", _Update }, + { "HasUniform", _HasUniform }, + { "GetUniformLocation", _GetUniformLocation }, + { "SetBuiltInUniforms", _SetBuiltInUniforms }, + { "SetUniformFloat", _SetUniformFloat }, + { "SetUniformTexture", _SetUniformTexture }, + { "SetUniformVector2", _SetUniformVector2 }, + { "SetUniformVector3", _SetUniformVector3 }, + { "SetUniformVector4", _SetUniformVector4 }, + { "SetUniformColor", _SetUniformColor }, + { "SetBuiltInUniforms", _SetBuiltInUniforms } + ); + } + + LUAX_POSTPROCESS(Shader) + { + + } + + // Shader.New() + LUAX_IMPL_METHOD(Shader, _New) + { + LUAX_STATE(L); + + return 0; + } + + // shader:Load() + LUAX_IMPL_METHOD(Shader, _Load) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:Update() + LUAX_IMPL_METHOD(Shader, _Update) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:HasUniform() + LUAX_IMPL_METHOD(Shader, _HasUniform) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:GetUniformLocation() + LUAX_IMPL_METHOD(Shader, _GetUniformLocation) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetBuiltInUniforms() + LUAX_IMPL_METHOD(Shader, _SetBuiltInUniforms) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetUniformFloat() + LUAX_IMPL_METHOD(Shader, _SetUniformFloat) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetUniformTexture() + LUAX_IMPL_METHOD(Shader, _SetUniformTexture) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetUniformVector2() + LUAX_IMPL_METHOD(Shader, _SetUniformVector2) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetUniformVector3() + LUAX_IMPL_METHOD(Shader, _SetUniformVector3) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetUniformVector4() + LUAX_IMPL_METHOD(Shader, _SetUniformVector4) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + // shader:SetUniformColor() + LUAX_IMPL_METHOD(Shader, _SetUniformColor) + { + LUAX_PREPARE(L, Shader); + + return 0; + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/SpriteBatch.binding.cpp b/Source/modules/asura-core/Graphics/binding/SpriteBatch.binding.cpp new file mode 100644 index 0000000..6b7d25c --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/SpriteBatch.binding.cpp @@ -0,0 +1,20 @@ +#include "../SpriteBatch.h" + +using namespace std; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(SpriteBatch) + { + + } + + LUAX_POSTPROCESS(SpriteBatch) + { + + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/Texture.binding.cpp b/Source/modules/asura-core/Graphics/binding/Texture.binding.cpp new file mode 100644 index 0000000..f5e5f17 --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/Texture.binding.cpp @@ -0,0 +1,85 @@ +#include "../texture.h" + +using namespace std; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(Texture) + { + LUAX_REGISTER_METHODS(state, + { "SetFilterMode", _SetFilterMode }, + { "SetWrapMode", _SetWrapMode }, + { "GetFilterMode", _GetFilterMode }, + { "GetWrapMode", _GetWrapMode }, + { "IsGenMipmap", _IsGenMipmap } + ); + } + + LUAX_POSTPROCESS(Texture) + { + LUAX_REGISTER_ENUM(state, "EColorFormat", + { "UNKNOWN", COLOR_FORMAT_UNKNOWN }, + { "RGBA8", COLOR_FORMAT_RGBA8 }, + { "RGBA32F", COLOR_FORMAT_RGBA32F } + ); + LUAX_REGISTER_ENUM(state, "EFilterMode", + { "NEAREST", FILTER_MODE_NEAREST }, + { "LINEAR", FILTER_MODE_LINEAR } + ); + LUAX_REGISTER_ENUM(state, "EWrapMode", + { "REPEAT", WRAP_MODE_REPEAT }, + { "MIRROR", WRAP_MODE_MIRROR }, + { "CLAMPTOEDGE", WRAP_MODE_CLAMPTOEDGE }, + { "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER } + ); + + } + + // texture:SetFilterMode(minFilter, magFilter) + LUAX_IMPL_METHOD(Texture, _SetFilterMode) + { + LUAX_PREPARE(L, Texture); + FilterMode min = (FilterMode)state.CheckValue(2); + FilterMode mag = (FilterMode)state.CheckValue(3); + self->SetFilterMode(min, mag); + return 0; + } + + // texture:SetWrapMode(wrap_mode) + LUAX_IMPL_METHOD(Texture, _SetWrapMode) + { + LUAX_PREPARE(L, Texture); + WrapMode wrap_mode = (WrapMode)state.CheckValue(2); + self->SetWrapMode(wrap_mode); + return 0; + } + + // min, mag = texture:GetFilterMode() + LUAX_IMPL_METHOD(Texture, _GetFilterMode) + { + LUAX_PREPARE(L, Texture); + state.Push((int)self->m_MinFilter); + state.Push((int)self->m_MagFilter); + return 2; + } + + // wrapmode= texture:GetWrapMode() + LUAX_IMPL_METHOD(Texture, _GetWrapMode) + { + LUAX_PREPARE(L, Texture); + state.Push((int)self->m_WrapMode); + return 1; + } + + // texture:IsGenMipmap() + LUAX_IMPL_METHOD(Texture, _IsGenMipmap) + { + LUAX_PREPARE(L, Texture); + state.Push(self->IsGenMipmap()); + return 1; + } + + } +} \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/VertexBuffer.binding.cpp b/Source/modules/asura-core/Graphics/binding/VertexBuffer.binding.cpp new file mode 100644 index 0000000..8ed487b --- /dev/null +++ b/Source/modules/asura-core/Graphics/binding/VertexBuffer.binding.cpp @@ -0,0 +1,38 @@ +#include "../VertexBuffer.h" + +using namespace std; +using namespace Luax; + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + + LUAX_REGISTRY(VertexBuffer) + { + LUAX_REGISTER_METHODS(state, + { "New", _New } + ); + } + + LUAX_POSTPROCESS(VertexBuffer) + { + + } + + // vbo = VertexBuffer.New(usage, data_type, count) + LUAX_IMPL_METHOD(VertexBuffer, _New) + { + LUAX_STATE(L); + + BufferUsage usage = (BufferUsage)state.CheckValue(1); + BufferDataType datatype = (BufferDataType)state.CheckValue(2); + uint count = state.CheckValue(3); + + VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype)); + vbo->PushLuaxUserdata(state); + + return 1; + } + + } +} diff --git a/Source/modules/asura-core/Graphics/binding/_canvas.cpp b/Source/modules/asura-core/Graphics/binding/_canvas.cpp deleted file mode 100644 index 44841f5..0000000 --- a/Source/modules/asura-core/Graphics/binding/_canvas.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "../Canvas.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Canvas) - { - LUAX_REGISTER_METHODS(state, - { "SetSize", _SetSize }, - { "Bind", _Bind }, - { "Unbind", _Unbind } - ); - } - - LUAX_POSTPROCESS(Canvas) - { - - } - - // canvas:SetSize() - LUAX_IMPL_METHOD(Canvas, _SetSize) - { - LUAX_PREPARE(L, Canvas); - return 0; - - } - - // canvas:Bind() - LUAX_IMPL_METHOD(Canvas, _Bind) - { - LUAX_PREPARE(L, Canvas); - - return 0; - } - - // canvas:Unbind() - LUAX_IMPL_METHOD(Canvas, _Unbind) - { - LUAX_PREPARE(L, Canvas); - return 0; - - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_color.cpp b/Source/modules/asura-core/Graphics/binding/_color.cpp deleted file mode 100644 index 008d9c2..0000000 --- a/Source/modules/asura-core/Graphics/binding/_color.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "../Color.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - -LUAX_REGISTRY(Color) -{ - LUAX_REGISTER_METHODS(state, - { "ToColor32", _ToColor32 }, - { "SetColor", _SetColor }, - { "GetColor", _GetColor }, - { "GetR", _GetR }, - { "GetG", _GetG }, - { "GetB", _GetB }, - { "GetA", _GetA }, - { "__eq", ___eq }, - { "__add", ___add }, - { "__sub", ___sub }, - { "__mul", ___mul }, - { "__div", ___div } - ); -} - -LUAX_POSTPROCESS(Color) -{ - -} - -// color:ToColor32() -LUAX_IMPL_METHOD(Color, _ToColor32) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:SetColor() -LUAX_IMPL_METHOD(Color, _SetColor) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetColor() -LUAX_IMPL_METHOD(Color, _GetColor) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetR() -LUAX_IMPL_METHOD(Color, _GetR) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetG() -LUAX_IMPL_METHOD(Color, _GetG) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetB() -LUAX_IMPL_METHOD(Color, _GetB) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetA() -LUAX_IMPL_METHOD(Color, _GetA) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__eq() -LUAX_IMPL_METHOD(Color, ___eq) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__add() -LUAX_IMPL_METHOD(Color, ___add) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__sub() -LUAX_IMPL_METHOD(Color, ___sub) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__mul() -LUAX_IMPL_METHOD(Color, ___mul) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__div() -LUAX_IMPL_METHOD(Color, ___div) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -} -} \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/_color32.cpp b/Source/modules/asura-core/Graphics/binding/_color32.cpp deleted file mode 100644 index 7613361..0000000 --- a/Source/modules/asura-core/Graphics/binding/_color32.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "../Color32.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Color32) - { - LUAX_REGISTER_METHODS(state, - { "ToColor", _ToColor }, - { "GetRed", _GetRed }, - { "GetGreen", _GetGreen }, - { "GetBlue", _GetBlue }, - { "GetAlpha", _GetAlpha } - ); - } - - LUAX_POSTPROCESS(Color32) - { - - } - - // color32:ToColor() - LUAX_IMPL_METHOD(Color32, _ToColor) - { - LUAX_PREPARE(L, Color32); - return 0; - - } - - // color32:GetRed() - LUAX_IMPL_METHOD(Color32, _GetRed) - { - LUAX_PREPARE(L, Color32); - return 0; - } - - // color32:GetGreen() - LUAX_IMPL_METHOD(Color32, _GetGreen) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - // color32:GetBlue() - LUAX_IMPL_METHOD(Color32, _GetBlue) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - // color32:GetAlpha() - LUAX_IMPL_METHOD(Color32, _GetAlpha) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - } -} - \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/_gfx_device.cpp b/Source/modules/asura-core/Graphics/binding/_gfx_device.cpp deleted file mode 100644 index f6c2004..0000000 --- a/Source/modules/asura-core/Graphics/binding/_gfx_device.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "../GfxDevice.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(GfxDevice) - { - LUAX_REGISTER_METHODS(state, - { "SetMatrixMode", _SetMatrixMode }, - { "GetMatrixMode", _GetMatrixMode }, - { "PushMatrix", _PushMatrix }, - { "PopMatrix", _PopMatrix }, - { "LoadIdentity", _LoadIdentity }, - { "Rotate", _Rotate }, - { "Translate", _Translate }, - { "Scale", _Scale }, - { "Ortho", _Ortho }, - { "GetMatrixDepth", _GetMatrixDepth }, - { "GetMatrixIndex", _GetMatrixIndex }, - { "UseShader", _UseShader }, - { "UnuseShader", _UnuseShader } - ); - } - - LUAX_POSTPROCESS(GfxDevice) - { - LUAX_REGISTER_ENUM(state, "EMatrixMode", - { "PROJECTION", MATRIX_MODE_PROJECTION }, - { "0", 0 }, - { "MODEL", MATRIX_MODE_MODEL }, - { "1", 1 }, - { "VIEW", MATRIX_MODE_VIEW }, - { "2", 2 } - ); - LUAX_REGISTER_ENUM(state, "EGLParams", - { "MAX_TEXTURE_UNIT", GL_PARAM_MAX_TEXTURE_UNIT }, - { "1", 1 } - ); - - } - - // gfxdevice:SetMatrixMode() - LUAX_IMPL_METHOD(GfxDevice, _SetMatrixMode) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixMode() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixMode) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:PushMatrix() - LUAX_IMPL_METHOD(GfxDevice, _PushMatrix) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:PopMatrix() - LUAX_IMPL_METHOD(GfxDevice, _PopMatrix) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:LoadIdentity() - LUAX_IMPL_METHOD(GfxDevice, _LoadIdentity) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Rotate() - LUAX_IMPL_METHOD(GfxDevice, _Rotate) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Translate() - LUAX_IMPL_METHOD(GfxDevice, _Translate) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Scale() - LUAX_IMPL_METHOD(GfxDevice, _Scale) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Ortho() - LUAX_IMPL_METHOD(GfxDevice, _Ortho) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixDepth() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixDepth) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixIndex() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixIndex) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:UseShader() - LUAX_IMPL_METHOD(GfxDevice, _UseShader) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:UnuseShader() - LUAX_IMPL_METHOD(GfxDevice, _UnuseShader) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp b/Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp deleted file mode 100644 index 8c39a59..0000000 --- a/Source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include - -#include "../image.h" -#include "../GPUBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(GPUBuffer) - { - LUAX_REGISTER_METHODS(state, - { "Fill", _Fill }, - { "GetSize", _GetSize }, - { "GetCount", _GetCount } - ); - } - - LUAX_POSTPROCESS(GPUBuffer) - { - LUAX_REGISTER_ENUM(state, "EBufferType", - { "VERTEX", BUFFER_TYPE_VERTEX }, - { "INDEX", BUFFER_TYPE_INDEX } - ); - LUAX_REGISTER_ENUM(state, "EBufferUsage", - { "STREAM", BUFFER_USAGE_STREAM }, - { "DYNAMIC", BUFFER_USAGE_DYNAMIC }, - { "STATIC", BUFFER_USAGE_STATIC } - ); - LUAX_REGISTER_ENUM(state, "EBufferDataType", - { "INT", BUFFER_DATA_TYPE_INT }, - { "FLOAT", BUFFER_DATA_TYPE_FLOAT }, - { "UNSIGNED_BYTE", BUFFER_DATA_TYPE_UNSIGNED_BYTE } - ); - - } - - // buffer = GPUBuffer.New(bufferType, bufferUsage, bufferDataType, size) - // buffer = GPUBuffer.New(image) - // buffer = GPUBuffer.New(mesh2d) - // buffer = GPUBuffer.New(canvas) - // buffer = GPUBuffer.New(shape) - //LUAX_IMPL_METHOD(GPUBuffer, _New) - //{ - // LUAX_STATE(L); - - // return 0; - //} - - // gpubuffer:Fill({data_unit_list}, offseti) - // data_unit_list £º´æ·ÅÊý¾ÝµÄtable - // offseti : ¿ªÊ¼¸²¸ÇµÄµØ·½ËùÔÚµÄË÷Òý(´Ó0¿ªÊ¼£© - LUAX_IMPL_METHOD(GPUBuffer, _Fill) - { - LUAX_PREPARE(L, GPUBuffer); - - // ʹÓÃbuffer¶ÔÓ¦µÄÀàÐÍÊý¾ÝÐÞ¸Äbuffer£¬ÔÚµÚÒ»´Îµ÷ÓÃʱ»á³õʼ»¯size´óСµÄbuffer£¬È»ºóÌî³ä¡£ - int offset = state.GetValue(3, 0); - int count = lua_objlen(L, 2); - int size = count * self->GetDataTypeSize(); - byte* data = (byte*)malloc(size); - int unit = self->GetDataTypeSize(); - int i = 1; - lua_rawgeti(L, 2, i); - while (!lua_isnil(L, -1)) - { - switch (self->m_DataType) - { - case GL_INT: - { - int n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - case GL_FLOAT: - { - float n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - case GL_UNSIGNED_BYTE: - { - unsigned char n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - } - state.Pop(1); // value - lua_rawgeti(L, 2, ++i); - } - state.Pop(); // nil - - self->Fill(data, size, offset * unit); - - free(data); - return 0; - } - - // gpubuffer:GetSize() - LUAX_IMPL_METHOD(GPUBuffer, _GetSize) - { - LUAX_PREPARE(L, GPUBuffer); - state.Push(self->m_Size); - return 0; - } - - LUAX_IMPL_METHOD(GPUBuffer, _GetCount) - { - LUAX_PREPARE(L, GPUBuffer); - state.Push(self->m_Size / self->GetDataTypeSize()); - return 0; - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_image.cpp b/Source/modules/asura-core/Graphics/binding/_image.cpp deleted file mode 100644 index 0e4cb16..0000000 --- a/Source/modules/asura-core/Graphics/binding/_image.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "../image.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Image) - { - LUAX_INHERIT(state, Texture); - - LUAX_REGISTER_METHODS(state, - { "New", _New }, - { "GetWidth", _GetWidth }, - { "GetHeight", _GetHeight }, - { "GetSize", _GetSize }, - { "Render", _Render } - ); - } - - LUAX_POSTPROCESS(Image) - { - } - - // image = Image.New() - LUAX_IMPL_METHOD(Image, _New) - { - LUAX_STATE(L); - Image* img = new Image(); - img->PushLuaxUserdata(state); - return 1; - } - - // width = image:GetWidth() - LUAX_IMPL_METHOD(Image, _GetWidth) - { - LUAX_PREPARE(L, Image); - state.Push(self->GetWidth()); - return 1; - } - - // height = image:GetHeight() - LUAX_IMPL_METHOD(Image, _GetHeight) - { - LUAX_PREPARE(L, Image); - state.Push(self->GetHeight()); - return 1; - } - - // width, height = image:GetSize() - LUAX_IMPL_METHOD(Image, _GetSize) - { - LUAX_PREPARE(L, Image); - int width = self->GetWidth(); - int height = self->GetHeight(); - state.Push(width); - state.Push(height); - return 2; - } - - // image:Render() - LUAX_IMPL_METHOD(Image, _Render) - { - LUAX_PREPARE(L, Image); - - return 0; - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_index_buffer.cpp b/Source/modules/asura-core/Graphics/binding/_index_buffer.cpp deleted file mode 100644 index 151dc98..0000000 --- a/Source/modules/asura-core/Graphics/binding/_index_buffer.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "../IndexBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(IndexBuffer) - { - LUAX_REGISTER_METHODS(state, - { "New", _New } - ); - } - - LUAX_POSTPROCESS(IndexBuffer) - { - - } - - // IndexBuffer.New() - LUAX_IMPL_METHOD(IndexBuffer, _New) - { - LUAX_STATE(L); - - return 0; - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_mesh2d.cpp b/Source/modules/asura-core/Graphics/binding/_mesh2d.cpp deleted file mode 100644 index 4e3f426..0000000 --- a/Source/modules/asura-core/Graphics/binding/_mesh2d.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "../mesh2d.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Mesh2D) - { - - } - - LUAX_POSTPROCESS(Mesh2D) - { - - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_shader.cpp b/Source/modules/asura-core/Graphics/binding/_shader.cpp deleted file mode 100644 index 85fd388..0000000 --- a/Source/modules/asura-core/Graphics/binding/_shader.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "../shader.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Shader) - { - LUAX_REGISTER_METHODS(state, - { "New", _New }, - { "Load", _Load }, - { "Update", _Update }, - { "HasUniform", _HasUniform }, - { "GetUniformLocation", _GetUniformLocation }, - { "SetBuiltInUniforms", _SetBuiltInUniforms }, - { "SetUniformFloat", _SetUniformFloat }, - { "SetUniformTexture", _SetUniformTexture }, - { "SetUniformVector2", _SetUniformVector2 }, - { "SetUniformVector3", _SetUniformVector3 }, - { "SetUniformVector4", _SetUniformVector4 }, - { "SetUniformColor", _SetUniformColor }, - { "SetBuiltInUniforms", _SetBuiltInUniforms } - ); - } - - LUAX_POSTPROCESS(Shader) - { - - } - - // Shader.New() - LUAX_IMPL_METHOD(Shader, _New) - { - LUAX_STATE(L); - - return 0; - } - - // shader:Load() - LUAX_IMPL_METHOD(Shader, _Load) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:Update() - LUAX_IMPL_METHOD(Shader, _Update) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:HasUniform() - LUAX_IMPL_METHOD(Shader, _HasUniform) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:GetUniformLocation() - LUAX_IMPL_METHOD(Shader, _GetUniformLocation) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetBuiltInUniforms() - LUAX_IMPL_METHOD(Shader, _SetBuiltInUniforms) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformFloat() - LUAX_IMPL_METHOD(Shader, _SetUniformFloat) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformTexture() - LUAX_IMPL_METHOD(Shader, _SetUniformTexture) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector2() - LUAX_IMPL_METHOD(Shader, _SetUniformVector2) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector3() - LUAX_IMPL_METHOD(Shader, _SetUniformVector3) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector4() - LUAX_IMPL_METHOD(Shader, _SetUniformVector4) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformColor() - LUAX_IMPL_METHOD(Shader, _SetUniformColor) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp b/Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp deleted file mode 100644 index 6b7d25c..0000000 --- a/Source/modules/asura-core/Graphics/binding/_sprite_batch.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "../SpriteBatch.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(SpriteBatch) - { - - } - - LUAX_POSTPROCESS(SpriteBatch) - { - - } - - } -} diff --git a/Source/modules/asura-core/Graphics/binding/_texture.cpp b/Source/modules/asura-core/Graphics/binding/_texture.cpp deleted file mode 100644 index f5e5f17..0000000 --- a/Source/modules/asura-core/Graphics/binding/_texture.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "../texture.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Texture) - { - LUAX_REGISTER_METHODS(state, - { "SetFilterMode", _SetFilterMode }, - { "SetWrapMode", _SetWrapMode }, - { "GetFilterMode", _GetFilterMode }, - { "GetWrapMode", _GetWrapMode }, - { "IsGenMipmap", _IsGenMipmap } - ); - } - - LUAX_POSTPROCESS(Texture) - { - LUAX_REGISTER_ENUM(state, "EColorFormat", - { "UNKNOWN", COLOR_FORMAT_UNKNOWN }, - { "RGBA8", COLOR_FORMAT_RGBA8 }, - { "RGBA32F", COLOR_FORMAT_RGBA32F } - ); - LUAX_REGISTER_ENUM(state, "EFilterMode", - { "NEAREST", FILTER_MODE_NEAREST }, - { "LINEAR", FILTER_MODE_LINEAR } - ); - LUAX_REGISTER_ENUM(state, "EWrapMode", - { "REPEAT", WRAP_MODE_REPEAT }, - { "MIRROR", WRAP_MODE_MIRROR }, - { "CLAMPTOEDGE", WRAP_MODE_CLAMPTOEDGE }, - { "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER } - ); - - } - - // texture:SetFilterMode(minFilter, magFilter) - LUAX_IMPL_METHOD(Texture, _SetFilterMode) - { - LUAX_PREPARE(L, Texture); - FilterMode min = (FilterMode)state.CheckValue(2); - FilterMode mag = (FilterMode)state.CheckValue(3); - self->SetFilterMode(min, mag); - return 0; - } - - // texture:SetWrapMode(wrap_mode) - LUAX_IMPL_METHOD(Texture, _SetWrapMode) - { - LUAX_PREPARE(L, Texture); - WrapMode wrap_mode = (WrapMode)state.CheckValue(2); - self->SetWrapMode(wrap_mode); - return 0; - } - - // min, mag = texture:GetFilterMode() - LUAX_IMPL_METHOD(Texture, _GetFilterMode) - { - LUAX_PREPARE(L, Texture); - state.Push((int)self->m_MinFilter); - state.Push((int)self->m_MagFilter); - return 2; - } - - // wrapmode= texture:GetWrapMode() - LUAX_IMPL_METHOD(Texture, _GetWrapMode) - { - LUAX_PREPARE(L, Texture); - state.Push((int)self->m_WrapMode); - return 1; - } - - // texture:IsGenMipmap() - LUAX_IMPL_METHOD(Texture, _IsGenMipmap) - { - LUAX_PREPARE(L, Texture); - state.Push(self->IsGenMipmap()); - return 1; - } - - } -} \ No newline at end of file diff --git a/Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp b/Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp deleted file mode 100644 index 8ed487b..0000000 --- a/Source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "../VertexBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(VertexBuffer) - { - LUAX_REGISTER_METHODS(state, - { "New", _New } - ); - } - - LUAX_POSTPROCESS(VertexBuffer) - { - - } - - // vbo = VertexBuffer.New(usage, data_type, count) - LUAX_IMPL_METHOD(VertexBuffer, _New) - { - LUAX_STATE(L); - - BufferUsage usage = (BufferUsage)state.CheckValue(1); - BufferDataType datatype = (BufferDataType)state.CheckValue(2); - uint count = state.CheckValue(3); - - VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype)); - vbo->PushLuaxUserdata(state); - - return 1; - } - - } -} diff --git a/Source/modules/asura-core/Input/InputDevice.h b/Source/modules/asura-core/Input/InputDevice.h index 2b3ff9b..42dfe43 100644 --- a/Source/modules/asura-core/Input/InputDevice.h +++ b/Source/modules/asura-core/Input/InputDevice.h @@ -16,6 +16,7 @@ namespace_begin(AsuraEngine) namespace_begin(Input) +// ´Ó²Ù×÷ϵͳ»ñµÃÊäÈë class InputDevice ASURA_FINAL { public: @@ -35,7 +36,7 @@ public: LRESULT OnInput(HWND window, UINT message, WPARAM wParam, LPARAM lParam); LRESULT OnDeviceChange(LPCWSTR name, bool add); - static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos); + static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos); #elif ASURA_RUNNER @@ -52,7 +53,7 @@ protected: bool UpdateState(); - MouseState m_Mouse; + MouseState m_Mouse; KeyboardState m_Keyboard; JoystickState m_Joysticks; diff --git a/Source/modules/asura-core/Input/InputEvent.h b/Source/modules/asura-core/Input/InputEvent.h index c643b75..fc7b9f6 100644 --- a/Source/modules/asura-core/Input/InputEvent.h +++ b/Source/modules/asura-core/Input/InputEvent.h @@ -32,7 +32,7 @@ struct InputEvent LRESULT OnInput(HWND window, UINT message, WPARAM wParam, LPARAM lParam); LRESULT OnDeviceChange(LPCWSTR name, bool add); - static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos); + static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos); #elif ASURA_RUNNER diff --git a/Source/modules/asura-core/Input/InputManager.cpp b/Source/modules/asura-core/Input/InputManager.cpp index cec1b36..03200f5 100644 --- a/Source/modules/asura-core/Input/InputManager.cpp +++ b/Source/modules/asura-core/Input/InputManager.cpp @@ -82,12 +82,12 @@ bool InputManager::GetKeyUp(int key) } -const AEMath::Vector2f& InputManager::GetMouseDelta() +const Vector2f& InputManager::GetMouseDelta() { return m_MouseDelta; } -const AEMath::Vector2f& InputManager::GetMousePosition() +const Vector2f& InputManager::GetMousePosition() { return m_MousePos; } @@ -114,11 +114,11 @@ void InputManager::SetKeyState(int key, bool state) m_CurrentKeyState[key] = state; } -void InputManager::SetMouseDelta(const AEMath::Vector2f& delta) +void InputManager::SetMouseDelta(const Vector2f& delta) { } -void InputManager::SetMousePosition(const AEMath::Vector2f& pos) +void InputManager::SetMousePosition(const Vector2f& pos) { } diff --git a/Source/modules/asura-core/Input/InputManager.h b/Source/modules/asura-core/Input/InputManager.h index 3c44745..4071b66 100644 --- a/Source/modules/asura-core/Input/InputManager.h +++ b/Source/modules/asura-core/Input/InputManager.h @@ -40,15 +40,15 @@ public: bool GetKeyDown(int key); bool GetKeyUp(int key); - const AEMath::Vector2f& GetMouseDelta(); - const AEMath::Vector2f& GetMousePosition(); + const Vector2f& GetMouseDelta(); + const Vector2f& GetMousePosition(); float GetJoystickPosition(); void setJoystickPosition(); void SetKeyState(int key, bool state); - void SetMouseDelta(const AEMath::Vector2f& delta); - void SetMousePosition(const AEMath::Vector2f& pos); + void SetMouseDelta(const Vector2f& delta); + void SetMousePosition(const Vector2f& pos); void SetMouseButton(int button, bool enabled); void ProcessInput(); @@ -62,8 +62,8 @@ private: std::vector m_Axis; - AEMath::Vector2f m_MouseDelta; - AEMath::Vector2f m_MousePos; + Vector2f m_MouseDelta; + Vector2f m_MousePos; bool m_MousePresent; @@ -72,7 +72,7 @@ private: std::string m_InputString; std::string m_CompositionString; - AEMath::Vector2f m_TextFieldCursorPos; + Vector2f m_TextFieldCursorPos; bool m_TextFieldInput; bool m_EatKeyPressOnTextFieldFocus; diff --git a/Source/modules/asura-core/Mesh/Mesh2DData.h b/Source/modules/asura-core/Mesh/Mesh2DData.h index 3e30a06..f041e05 100644 --- a/Source/modules/asura-core/Mesh/Mesh2DData.h +++ b/Source/modules/asura-core/Mesh/Mesh2DData.h @@ -21,9 +21,9 @@ namespace_begin(Mesh) /// struct Vertex { - AEMath::Vector2f position; ///< ×ø±ê + Vector2f position; ///< ×ø±ê AEGraphics::Color color; ///< ÑÕÉ« - AEMath::Vector2f texCoord[4]; ///< UVs + Vector2f texCoord[4]; ///< UVs }; /// diff --git a/Source/modules/asura-json/Json/JsonData.cpp b/Source/modules/asura-json/Json/JsonData.cpp new file mode 100644 index 0000000..57ba705 --- /dev/null +++ b/Source/modules/asura-json/Json/JsonData.cpp @@ -0,0 +1,9 @@ +#include "JsonData.h" + + +namespace_begin(AsuraEngine) +namespace_begin(Json) + + +namespace_end +namespace_end diff --git a/Source/modules/asura-json/Json/JsonData.h b/Source/modules/asura-json/Json/JsonData.h new file mode 100644 index 0000000..2ae2798 --- /dev/null +++ b/Source/modules/asura-json/Json/JsonData.h @@ -0,0 +1,17 @@ +#ifndef _ASURA_JSON_H_ +#define _ASURA_JSON_H_ + +#include + +namespace_begin(AsuraEngine) +namespace_begin(Json) + +class JsonData +{ + +}; + +namespace_end +namespace_end + +#endif \ No newline at end of file diff --git a/Source/tests/win32/01-window/03_sub_menu.cpp b/Source/tests/win32/01-window/03_sub_menu.cpp index fed841d..9c4ee85 100644 --- a/Source/tests/win32/01-window/03_sub_menu.cpp +++ b/Source/tests/win32/01-window/03_sub_menu.cpp @@ -28,7 +28,7 @@ void AddMenus(HWND); HWND wnd; HWND wnd2; -AEMath::Recti viewport; +Recti viewport; string vert = R"( @@ -172,16 +172,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, case WM_SIZE: { - if (g_Device.Inited()) + if (g_GfxDevice.Inited()) { RECT rect; GetClientRect(hwnd, &rect); viewport.Set(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); - g_Device.SetViewport(viewport); + g_GfxDevice.SetViewport(viewport); } } case WM_PAINT: - if (!g_Device.Inited()) + if (!g_GfxDevice.Inited()) break; glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); @@ -206,28 +206,28 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, { int imgLoc = shader->GetUniformLocation("img"); - int code = g_Device.GetError(); - g_Device.SetActiveShader(shader); + int code = g_GfxDevice.GetError(); + g_GfxDevice.SetActiveShader(shader); shader->SetUniformTexture(imgLoc, *img); - g_Device.SetMatrixMode(MATRIX_MODE_PROJECTION); - g_Device.LoadIdentity(); - g_Device.Ortho(0, viewport.w, viewport.h, 0, -1, 1); - g_Device.SetMatrixMode(MATRIX_MODE_MODEL); - g_Device.LoadIdentity(); - g_Device.Translate(100, 100); - shader->SetUniformMatrix44(locs.m, g_Device.GetMatrix(MATRIX_MODE_MODEL)); - shader->SetUniformMatrix44(locs.v, g_Device.GetMatrix(MATRIX_MODE_VIEW)); - shader->SetUniformMatrix44(locs.p, g_Device.GetMatrix(MATRIX_MODE_PROJECTION)); + g_GfxDevice.SetMatrixMode(MATRIX_MODE_PROJECTION); + g_GfxDevice.LoadIdentity(); + g_GfxDevice.Ortho(0, viewport.w, viewport.h, 0, -1, 1); + g_GfxDevice.SetMatrixMode(MATRIX_MODE_MODEL); + g_GfxDevice.LoadIdentity(); + g_GfxDevice.Translate(100, 100); + shader->SetUniformMatrix44(locs.m, g_GfxDevice.GetMatrix(MATRIX_MODE_MODEL)); + shader->SetUniformMatrix44(locs.v, g_GfxDevice.GetMatrix(MATRIX_MODE_VIEW)); + shader->SetUniformMatrix44(locs.p, g_GfxDevice.GetMatrix(MATRIX_MODE_PROJECTION)); shader->SetAttribute(locs.pos, vb, 0, 4); shader->SetAttribute(locs.tex, vb, 2, 4); - g_Device.SetDrawColor(1, 1, 0, 1); - shader->SetUniformColor(locs.color, g_Device.GetDrawColor()); + g_GfxDevice.SetDrawColor(1, 1, 0, 1); + shader->SetUniformColor(locs.color, g_GfxDevice.GetDrawColor()); //glLineWidth(1); - g_Device.DrawArrays(GL_LINE_STRIP, 0, 5); - //g_Device.DrawArrays(GL_TRIANGLE_STRIP, 0, 4); + g_GfxDevice.DrawArrays(GL_LINE_STRIP, 0, 5); + //g_GfxDevice.DrawArrays(GL_TRIANGLE_STRIP, 0, 4); shader->DisableAttribute(locs.pos); shader->DisableAttribute(locs.tex); - g_Device.SetActiveShader(NULL); + g_GfxDevice.SetActiveShader(NULL); } glFlush(); BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); @@ -263,7 +263,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, RECT rect; GetWindowRect(hwnd, &rect); viewport.Set(0, 0, rect.right - rect.left, rect.bottom - rect.top); - if (!g_Device.Init(viewport)) + if (!g_GfxDevice.Init(viewport)) return 0; imgdata->Decode(db); diff --git a/bin/win64/01-window.exe b/bin/win64/01-window.exe index 70db8e5..e812b2e 100644 Binary files a/bin/win64/01-window.exe and b/bin/win64/01-window.exe differ diff --git a/bin/win64/SDL2.dll b/bin/win64/SDL2.dll index 8f849cd..8778af5 100644 Binary files a/bin/win64/SDL2.dll and b/bin/win64/SDL2.dll differ diff --git a/build/Asura.Editor/Asura.Editor.vcxproj b/build/Asura.Editor/Asura.Editor.vcxproj index d214c2e..542fcf2 100644 --- a/build/Asura.Editor/Asura.Editor.vcxproj +++ b/build/Asura.Editor/Asura.Editor.vcxproj @@ -129,7 +129,7 @@ - + @@ -137,13 +137,14 @@ - - + + + @@ -153,7 +154,7 @@ - + @@ -162,15 +163,17 @@ - - - - - + + + + + + + diff --git a/build/Asura.Editor/Asura.Editor.vcxproj.filters b/build/Asura.Editor/Asura.Editor.vcxproj.filters index bc89328..27c5a7e 100644 --- a/build/Asura.Editor/Asura.Editor.vcxproj.filters +++ b/build/Asura.Editor/Asura.Editor.vcxproj.filters @@ -10,9 +10,6 @@ {4be8ce5c-0921-4341-a976-92d31aa84c8c} - - {b4c26f9c-9f4e-4332-a6e2-33456b4abecb} - {7654ef3d-54c4-490f-bb24-e6a67bd63e1e} @@ -25,6 +22,9 @@ {799e7ea2-8870-4d1e-b278-b3a0dd912632} + + {b4c26f9c-9f4e-4332-a6e2-33456b4abecb} + @@ -36,9 +36,6 @@ Controls - - Controls - Controls @@ -51,12 +48,6 @@ Graphics - - Graphics - - - Graphics - Layout @@ -86,14 +77,20 @@ Controls + + System + + + Controls + + + Graphics + + + Graphics + - - Graphics\shaders - - - Graphics\shaders - Controls @@ -103,9 +100,6 @@ Controls - - Controls - Controls @@ -118,15 +112,6 @@ Graphics - - Graphics - - - Graphics - - - Graphics - Layout @@ -162,5 +147,29 @@ Controls + + System + + + Controls + + + Graphics + + + Graphics + + + Graphics\Shaders + + + Graphics\Shaders + + + Graphics\Shaders + + + Graphics + \ No newline at end of file diff --git a/build/Asura.sln b/build/Asura.sln index 5332a4a..938b621 100644 --- a/build/Asura.sln +++ b/build/Asura.sln @@ -119,6 +119,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RunnerConfigure", "configur EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asura-base", "modules\asura-base\asura-base.vcxproj", "{7D41093F-E356-4C5B-A25F-41779BF86E54}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Json", "external\Json\Json.vcxproj", "{01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -651,6 +653,16 @@ Global {7D41093F-E356-4C5B-A25F-41779BF86E54}.Release|x64.Build.0 = Release|x64 {7D41093F-E356-4C5B-A25F-41779BF86E54}.Release|x86.ActiveCfg = Release|Win32 {7D41093F-E356-4C5B-A25F-41779BF86E54}.Release|x86.Build.0 = Release|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x64.ActiveCfg = Debug|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x64.Build.0 = Debug|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x86.ActiveCfg = Debug|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Debug|x86.Build.0 = Debug|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|Any CPU.ActiveCfg = Release|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x64.ActiveCfg = Release|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x64.Build.0 = Release|x64 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x86.ActiveCfg = Release|Win32 + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -703,6 +715,7 @@ Global {93CFEFAB-3922-4D81-91FD-8A80E9785FC6} = {1C5D0C23-C0A9-4200-BD67-B5B8F6DDE41C} {9DD2D23B-BE70-4453-88C7-D904E024CB68} = {1C5D0C23-C0A9-4200-BD67-B5B8F6DDE41C} {7D41093F-E356-4C5B-A25F-41779BF86E54} = {CD115016-E377-4AC1-8595-DB2836CEFE7E} + {01B74F57-CC11-466C-B8F8-3AE4DB2EB44C} = {64D4E4B2-4A60-46F4-A500-370EFED4524F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {331032D8-F7CC-43E3-A03B-67108767F96B} diff --git a/build/modules/asura-base/asura-base.vcxproj b/build/modules/asura-base/asura-base.vcxproj index 89ba183..e8ecc4a 100644 --- a/build/modules/asura-base/asura-base.vcxproj +++ b/build/modules/asura-base/asura-base.vcxproj @@ -142,6 +142,8 @@ + + @@ -155,7 +157,6 @@ - @@ -185,6 +186,8 @@ + + @@ -200,6 +203,7 @@ + diff --git a/build/modules/asura-base/asura-base.vcxproj.filters b/build/modules/asura-base/asura-base.vcxproj.filters index 5f639bc..2aa1840 100644 --- a/build/modules/asura-base/asura-base.vcxproj.filters +++ b/build/modules/asura-base/asura-base.vcxproj.filters @@ -22,6 +22,9 @@ {b4b078e1-bb8d-4cb3-84b9-963e851be123} + + {9bfbea59-2b66-4aad-add2-ac9c737a1dc1} + @@ -82,9 +85,6 @@ Utilities - - Utilities - Utilities @@ -128,6 +128,12 @@ FileSystem\Binding + + Misc + + + Misc + @@ -249,6 +255,15 @@ Math + + Misc + + + Utilities + + + Misc + diff --git a/build/modules/asura-box2d/asura-box2d.vcxproj b/build/modules/asura-box2d/asura-box2d.vcxproj index b41df12..2a3c00b 100644 --- a/build/modules/asura-box2d/asura-box2d.vcxproj +++ b/build/modules/asura-box2d/asura-box2d.vcxproj @@ -118,33 +118,33 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + diff --git a/build/modules/asura-box2d/asura-box2d.vcxproj.filters b/build/modules/asura-box2d/asura-box2d.vcxproj.filters index 5415a04..b169c1a 100644 --- a/build/modules/asura-box2d/asura-box2d.vcxproj.filters +++ b/build/modules/asura-box2d/asura-box2d.vcxproj.filters @@ -2,88 +2,88 @@ - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - - Physics + + Physics2D - + {c01b5c57-f3a7-445f-aed3-e0a27dbe74c2} - - {3fb6587c-0c9d-4f6e-9e72-653032d9b238} + + {76f8cfef-3ffe-47a2-9e7c-b90f1d252bce} - - Physics\binding + + + Physics2D\Binding - - Physics\binding + + Physics2D\Binding - \ No newline at end of file diff --git a/build/modules/asura-core/asura-core.vcxproj b/build/modules/asura-core/asura-core.vcxproj index f548922..5b2dd32 100644 --- a/build/modules/asura-core/asura-core.vcxproj +++ b/build/modules/asura-core/asura-core.vcxproj @@ -128,19 +128,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -149,18 +149,17 @@ - - + - + - + @@ -194,8 +193,7 @@ - - + @@ -206,19 +204,18 @@ - - + - + - + @@ -264,7 +261,6 @@ - diff --git a/build/modules/asura-core/asura-core.vcxproj.filters b/build/modules/asura-core/asura-core.vcxproj.filters index cf39389..5ffc385 100644 --- a/build/modules/asura-core/asura-core.vcxproj.filters +++ b/build/modules/asura-core/asura-core.vcxproj.filters @@ -42,27 +42,6 @@ - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - Window\binding @@ -72,27 +51,12 @@ Image\binding - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - - - Graphics\Binding - Font Font - - Font - Graphics @@ -108,24 +72,15 @@ Graphics - - Graphics - Graphics Graphics - - Graphics - Graphics - - Graphics - Graphics @@ -215,18 +170,60 @@ Graphics - - Graphics - Input Input - + + Graphics + + + Font + + + Graphics + + + Graphics\Binding + + + Graphics\Binding + + Graphics\Binding + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics\Binding + + + Graphics + @@ -235,9 +232,6 @@ Font - - Font - Graphics @@ -259,27 +253,18 @@ Graphics - - Graphics - Graphics Graphics - - Graphics - Graphics Graphics - - Graphics - Graphics @@ -373,9 +358,6 @@ Threads - - Font - Graphics @@ -388,22 +370,28 @@ Graphics - - Graphics - Input Input + + Graphics + + + Font + + + Graphics + + + Graphics + Font - - Font - \ No newline at end of file diff --git a/build/modules/asura-json/asura-json.vcxproj b/build/modules/asura-json/asura-json.vcxproj index 64af220..bde2695 100644 --- a/build/modules/asura-json/asura-json.vcxproj +++ b/build/modules/asura-json/asura-json.vcxproj @@ -20,11 +20,11 @@ - + - + 15.0 diff --git a/build/modules/asura-json/asura-json.vcxproj.filters b/build/modules/asura-json/asura-json.vcxproj.filters index 7f255cb..86218ef 100644 --- a/build/modules/asura-json/asura-json.vcxproj.filters +++ b/build/modules/asura-json/asura-json.vcxproj.filters @@ -6,15 +6,15 @@ - + + Json - - + + Json - \ No newline at end of file diff --git a/samples/Hello/entities.folder.asset b/samples/Hello/entities.folder.asset index 1d8fd23..5d0e1a5 100644 --- a/samples/Hello/entities.folder.asset +++ b/samples/Hello/entities.folder.asset @@ -1,4 +1,4 @@ { - type="folder", - extern="entities" -} \ No newline at end of file + "frameGrid" : "folder", + "extern" : "entities" +} diff --git a/samples/Hello/gfx.folder.asset b/samples/Hello/gfx.folder.asset index 2ad12da..f9eefa7 100644 --- a/samples/Hello/gfx.folder.asset +++ b/samples/Hello/gfx.folder.asset @@ -1,4 +1,4 @@ { - type="folder", - extern="gfx" + "type" : "folder", + "extern" : "gfx" } \ No newline at end of file diff --git a/source/Asura.Editor/Controls/GUIPanel.cpp b/source/Asura.Editor/Controls/GUIPanel.cpp index 3a78af7..e69de29 100644 --- a/source/Asura.Editor/Controls/GUIPanel.cpp +++ b/source/Asura.Editor/Controls/GUIPanel.cpp @@ -1,6 +0,0 @@ -#include "GUIPanel.h" - -namespace_begin(AsuraEditor) - - -namespace_end diff --git a/source/Asura.Editor/Controls/GUIPanel.h b/source/Asura.Editor/Controls/GUIPanel.h index 0f98eaa..9ff6eed 100644 --- a/source/Asura.Editor/Controls/GUIPanel.h +++ b/source/Asura.Editor/Controls/GUIPanel.h @@ -1,11 +1,13 @@ -#ifndef _ASURA_EDITOR_GUI_PANEL_H_ -#define _ASURA_EDITOR_GUI_PANEL_H_ +#ifndef _ASURA_EDITOR_GUIPANEL_H_ +#define _ASURA_EDITOR_GUIPANEL_H_ #include +#include "../System/GUIWindow.h" + namespace_begin(AsuraEditor) -/// IMGUI panel +// GUIWindowµÄµ¥¸öÃæ°å class GUIPanel { public: @@ -15,10 +17,12 @@ public: private: + GUIWindow* m_GUIWindow; // ËùÊôµÄ»æÖÆ´°¿Ú }; + namespace_end #endif \ No newline at end of file diff --git a/source/Asura.Editor/Graphics/Pen.cpp b/source/Asura.Editor/Graphics/Pen.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/Asura.Editor/Graphics/Pen.h b/source/Asura.Editor/Graphics/Pen.h deleted file mode 100644 index b949d14..0000000 --- a/source/Asura.Editor/Graphics/Pen.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ASURA_EDITOR_PEN_H_ -#define _ASURA_EDITOR_PEN_H_ - - - - -#endif \ No newline at end of file diff --git a/source/Asura.Editor/Graphics/Shader.h b/source/Asura.Editor/Graphics/Shader.h index a3abec1..af291a5 100644 --- a/source/Asura.Editor/Graphics/Shader.h +++ b/source/Asura.Editor/Graphics/Shader.h @@ -3,16 +3,13 @@ namespace AsuraEditor { - namespace Graphics - { - struct ShaderProgram - { - const char* vert; - const char* frag; - }; +struct ShaderProgram +{ + const char* vert; + const char* frag; +}; - } } #endif \ No newline at end of file diff --git a/source/Asura.Editor/Graphics/Style.cpp b/source/Asura.Editor/Graphics/Style.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/Asura.Editor/Graphics/Style.h b/source/Asura.Editor/Graphics/Style.h deleted file mode 100644 index 2676c68..0000000 --- a/source/Asura.Editor/Graphics/Style.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _ASURA_EDITOR_GUI_STYLE_H_ -#define _ASURA_EDITOR_GUI_STYLE_H_ - -#include - -namespace_begin(AsuraEditor) - -class GUIStyle -{ - -}; - -namespace_end - -#endif \ No newline at end of file diff --git a/source/Asura.Editor/Graphics/shaders/image.shader.h b/source/Asura.Editor/Graphics/shaders/image.shader.h deleted file mode 100644 index cbdd542..0000000 --- a/source/Asura.Editor/Graphics/shaders/image.shader.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _ASURA_EDITOR_SHADER_H_ -#include "../shader.h" -#endif - -// »æÖÆ -static AsuraEditor::Graphics::ShaderProgram image_shader = -{ -R"( -in vec2 asura_position; -in vec2 asura_texcoord0; - -uniform mat4 asura_model_matrix; -uniform mat4 asura_view_matrix; -uniform mat4 asura_projection_matrix; - -void main() -{ - gl_Position = asura_projection_matrix * asura_view_matrix * asura_model_matrix * vec4(asura_position, 0, 1); - uv = asura_texcoord0; -} - -)", - -R"( -in vec2 uv; - -uniform sampler2D asura_maintex; - -void main() -{ - -} - -)" -}; \ No newline at end of file diff --git a/source/Asura.Editor/Graphics/shaders/polygon.shader.h b/source/Asura.Editor/Graphics/shaders/polygon.shader.h deleted file mode 100644 index a92e9a6..0000000 --- a/source/Asura.Editor/Graphics/shaders/polygon.shader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _ASURA_EDITOR_SHADER_H_ -#include "../shader.h" -#endif - -// »æÖÆ -static AsuraEditor::Graphics::ShaderProgram polygon_shader = -{ - R"( -in vec2 position; - -uniform mat4 mvp_matrix; - -void main() -{ - gl_Position = mvp_matrix * vec4(position, 0, 1); -} - -)", - -R"( -uniform vec4 color; - -void main() -{ - gl_FragColor = color; -} - -)" -}; \ No newline at end of file diff --git a/source/Asura.Editor/System/ContainerWindow.h b/source/Asura.Editor/System/ContainerWindow.h index 5893aff..06a7b82 100644 --- a/source/Asura.Editor/System/ContainerWindow.h +++ b/source/Asura.Editor/System/ContainerWindow.h @@ -11,9 +11,7 @@ namespace_begin(AsuraEditor) -/// -/// °üº¬±à¼­Æ÷´°¿ÚµÄnative´°¿Ú -/// +/// °üº¬±à¼­Æ÷´°¿ÚµÄnative´°¿Ú£¬·ÖΪÓÐmenuºÍûÓÐmenuµÄ£¬ÓÃÀ´ÈÝÄÉGUIWindow¡£ class ContainerWindow : public AEScripting::Portable { public: @@ -40,10 +38,9 @@ public: private: - ContainerWindow* mParent; - WindowStyle mStyle; - HWND mHWND; - HDC mHDC; + WindowStyle m_Style; + HWND m_HWND; + HDC m_HDC; luaxport: @@ -57,6 +54,9 @@ luaxport: }; +// ÈÝÄÉGUIWindowµÄ¿ò¼Ü +using ContainerFrame = ContainerWindow; + namespace_end #endif \ No newline at end of file diff --git a/source/Asura.Editor/System/Input.cpp b/source/Asura.Editor/System/Input.cpp index c10eb3b..80086d3 100644 --- a/source/Asura.Editor/System/Input.cpp +++ b/source/Asura.Editor/System/Input.cpp @@ -49,7 +49,7 @@ LRESULT Input::OnDeviceChange(LPCWSTR name, bool add) { } -bool Input::ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos) +bool Input::ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos) { } diff --git a/source/Asura.Editor/graphics/pen.cpp b/source/Asura.Editor/graphics/pen.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/Asura.Editor/graphics/pen.h b/source/Asura.Editor/graphics/pen.h deleted file mode 100644 index b949d14..0000000 --- a/source/Asura.Editor/graphics/pen.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _ASURA_EDITOR_PEN_H_ -#define _ASURA_EDITOR_PEN_H_ - - - - -#endif \ No newline at end of file diff --git a/source/Asura.Editor/graphics/shader.h b/source/Asura.Editor/graphics/shader.h index a3abec1..af291a5 100644 --- a/source/Asura.Editor/graphics/shader.h +++ b/source/Asura.Editor/graphics/shader.h @@ -3,16 +3,13 @@ namespace AsuraEditor { - namespace Graphics - { - struct ShaderProgram - { - const char* vert; - const char* frag; - }; +struct ShaderProgram +{ + const char* vert; + const char* frag; +}; - } } #endif \ No newline at end of file diff --git a/source/Asura.Editor/graphics/shaders/image.shader.h b/source/Asura.Editor/graphics/shaders/image.shader.h deleted file mode 100644 index cbdd542..0000000 --- a/source/Asura.Editor/graphics/shaders/image.shader.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _ASURA_EDITOR_SHADER_H_ -#include "../shader.h" -#endif - -// »æÖÆ -static AsuraEditor::Graphics::ShaderProgram image_shader = -{ -R"( -in vec2 asura_position; -in vec2 asura_texcoord0; - -uniform mat4 asura_model_matrix; -uniform mat4 asura_view_matrix; -uniform mat4 asura_projection_matrix; - -void main() -{ - gl_Position = asura_projection_matrix * asura_view_matrix * asura_model_matrix * vec4(asura_position, 0, 1); - uv = asura_texcoord0; -} - -)", - -R"( -in vec2 uv; - -uniform sampler2D asura_maintex; - -void main() -{ - -} - -)" -}; \ No newline at end of file diff --git a/source/Asura.Editor/graphics/shaders/polygon.shader.h b/source/Asura.Editor/graphics/shaders/polygon.shader.h deleted file mode 100644 index a92e9a6..0000000 --- a/source/Asura.Editor/graphics/shaders/polygon.shader.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _ASURA_EDITOR_SHADER_H_ -#include "../shader.h" -#endif - -// »æÖÆ -static AsuraEditor::Graphics::ShaderProgram polygon_shader = -{ - R"( -in vec2 position; - -uniform mat4 mvp_matrix; - -void main() -{ - gl_Position = mvp_matrix * vec4(position, 0, 1); -} - -)", - -R"( -uniform vec4 color; - -void main() -{ - gl_FragColor = color; -} - -)" -}; \ No newline at end of file diff --git a/source/Asura.Editor/graphics/style.cpp b/source/Asura.Editor/graphics/style.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/Asura.Editor/graphics/style.h b/source/Asura.Editor/graphics/style.h deleted file mode 100644 index 2676c68..0000000 --- a/source/Asura.Editor/graphics/style.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _ASURA_EDITOR_GUI_STYLE_H_ -#define _ASURA_EDITOR_GUI_STYLE_H_ - -#include - -namespace_begin(AsuraEditor) - -class GUIStyle -{ - -}; - -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-box2d/Physics/Body.h b/source/modules/asura-box2d/Physics/Body.h deleted file mode 100644 index d7e79d5..0000000 --- a/source/modules/asura-box2d/Physics/Body.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __ASURA_BOX2D_BODY_H__ -#define __ASURA_BOX2D_BODY_H__ - -#include - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class World; -class Joint; - -enum BodyType -{ - BODY_TYPE_INVALID, - BODY_TYPE_STATIC, - BODY_TYPE_DYNAMIC, - BODY_TYPE_KINEMATIC -}; - -class Body : public AEScripting::Portable -{ -public: - -private: - - friend class Joint; - - //----------------------------------------------------------------------------// - - LUAX_DECL_FACTORY(Body); - - LUAX_DECL_ENUM(BodyType, 1); - - LUAX_DECL_METHOD(_GetType); - LUAX_DECL_METHOD(_GetX); - LUAX_DECL_METHOD(_GetY); - LUAX_DECL_METHOD(_GetAngle); - LUAX_DECL_METHOD(_GetPosition); - LUAX_DECL_METHOD(_GetLinearVelocity); - LUAX_DECL_METHOD(_GetWorldCenter); - LUAX_DECL_METHOD(_GetLocalCenter); - LUAX_DECL_METHOD(_GetAngularVelocity); - LUAX_DECL_METHOD(_GetMass); - LUAX_DECL_METHOD(_GetInertia); - LUAX_DECL_METHOD(_GetMassData); - LUAX_DECL_METHOD(_GetAngularDamping); - LUAX_DECL_METHOD(_GetLinearDamping); - LUAX_DECL_METHOD(_GetGravityScale); - LUAX_DECL_METHOD(_GetGravityScale); - - //----------------------------------------------------------------------------// - - b2Body* m_Body; - World* m_World; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-box2d/Physics/ChainShape.h b/source/modules/asura-box2d/Physics/ChainShape.h deleted file mode 100644 index 2403587..0000000 --- a/source/modules/asura-box2d/Physics/ChainShape.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __ASURA_CHAIN_SHAPE_H__ -#define __ASURA_CHAIN_SHAPE_H__ - -#include - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class ChainShape - : AEScripting::Portable -{ -public: - - ChainShape(); - ~ChainShape(); - -private: - - b2ChainShape* m_Shape; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-box2d/Physics/CircleShape.h b/source/modules/asura-box2d/Physics/CircleShape.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/Contact.h b/source/modules/asura-box2d/Physics/Contact.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/DebugDraw.h b/source/modules/asura-box2d/Physics/DebugDraw.h deleted file mode 100644 index a92be43..0000000 --- a/source/modules/asura-box2d/Physics/DebugDraw.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _ASURA_BOX2D_DEBUG_DRAW_H_ -#define _ASURA_BOX2D_DEBUG_DRAW_H_ - -namespace AsuraEngine -{ - -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-box2d/Physics/DistanceJoint.h b/source/modules/asura-box2d/Physics/DistanceJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/EdgeShape.h b/source/modules/asura-box2d/Physics/EdgeShape.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/Fixture.h b/source/modules/asura-box2d/Physics/Fixture.h deleted file mode 100644 index 69f0153..0000000 --- a/source/modules/asura-box2d/Physics/Fixture.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ASRUA_ENGINE_FIXTURE_H_ -#define _ASRUA_ENGINE_FIXTURE_H_ - -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class Fixture -{ - -}; - -namespace_end -namespace_end - -#endif diff --git a/source/modules/asura-box2d/Physics/FrictionJoint.h b/source/modules/asura-box2d/Physics/FrictionJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/GearJoint.h b/source/modules/asura-box2d/Physics/GearJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/Joint.h b/source/modules/asura-box2d/Physics/Joint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/MotorJoint.h b/source/modules/asura-box2d/Physics/MotorJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/MouseJoint.h b/source/modules/asura-box2d/Physics/MouseJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/PolygonShape.h b/source/modules/asura-box2d/Physics/PolygonShape.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/PrismaticJoint.h b/source/modules/asura-box2d/Physics/PrismaticJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/PulleyJoint.h b/source/modules/asura-box2d/Physics/PulleyJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/RevoluteJoint.h b/source/modules/asura-box2d/Physics/RevoluteJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/RopeJoint.h b/source/modules/asura-box2d/Physics/RopeJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/Shape.h b/source/modules/asura-box2d/Physics/Shape.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/WeldJoint.h b/source/modules/asura-box2d/Physics/WeldJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/WheelJoint.h b/source/modules/asura-box2d/Physics/WheelJoint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/Physics/World.h b/source/modules/asura-box2d/Physics/World.h deleted file mode 100644 index a156c79..0000000 --- a/source/modules/asura-box2d/Physics/World.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASURA_BOX2D_WORLD_H__ -#define __ASURA_BOX2D_WORLD_H__ - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class World : public AEScripting::Portable -{ - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-box2d/Physics/binding/_body.cpp b/source/modules/asura-box2d/Physics/binding/_body.cpp deleted file mode 100644 index 0c9e3e8..0000000 --- a/source/modules/asura-box2d/Physics/binding/_body.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "../Body.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace Physics - { - - LUAX_REGISTRY(Body) - { - LUAX_REGISTER_METHODS(state, - { "GetType", _GetType }, - { "GetX", _GetX }, - { "GetY", _GetY }, - { "GetAngle", _GetAngle }, - { "GetPosition", _GetPosition }, - { "GetLinearVelocity", _GetLinearVelocity }, - { "GetWorldCenter", _GetWorldCenter }, - { "GetLocalCenter", _GetLocalCenter }, - { "GetAngularVelocity", _GetAngularVelocity }, - { "GetMass", _GetMass }, - { "GetInertia", _GetInertia }, - { "GetMassData", _GetMassData }, - { "GetAngularDamping", _GetAngularDamping }, - { "GetLinearDamping", _GetLinearDamping }, - { "GetGravityScale", _GetGravityScale }, - { "GetGravityScale", _GetGravityScale } - ); - } - - LUAX_POSTPROCESS(Body) - { - LUAX_REGISTER_ENUM(state, "EBodyType", - { "INVALID", BODY_TYPE_INVALID }, - { "STATIC", BODY_TYPE_STATIC }, - { "DYNAMIC", BODY_TYPE_DYNAMIC }, - { "KINEMATIC", BODY_TYPE_KINEMATIC } - ); - - } - - // body:GetType() - LUAX_IMPL_METHOD(Body, _GetType) - { - LUAX_PREPARE(L, Body); - return 0; - } - - // body:GetX() - LUAX_IMPL_METHOD(Body, _GetX) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetY() - LUAX_IMPL_METHOD(Body, _GetY) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngle() - LUAX_IMPL_METHOD(Body, _GetAngle) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetPosition() - LUAX_IMPL_METHOD(Body, _GetPosition) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLinearVelocity() - LUAX_IMPL_METHOD(Body, _GetLinearVelocity) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetWorldCenter() - LUAX_IMPL_METHOD(Body, _GetWorldCenter) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLocalCenter() - LUAX_IMPL_METHOD(Body, _GetLocalCenter) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngularVelocity() - LUAX_IMPL_METHOD(Body, _GetAngularVelocity) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetMass() - LUAX_IMPL_METHOD(Body, _GetMass) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetInertia() - LUAX_IMPL_METHOD(Body, _GetInertia) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetMassData() - LUAX_IMPL_METHOD(Body, _GetMassData) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngularDamping() - LUAX_IMPL_METHOD(Body, _GetAngularDamping) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLinearDamping() - LUAX_IMPL_METHOD(Body, _GetLinearDamping) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetGravityScale() - LUAX_IMPL_METHOD(Body, _GetGravityScale) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetGravityScale() - LUAX_IMPL_METHOD(Body, _GetGravityScale) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - } -} diff --git a/source/modules/asura-box2d/Physics/binding/_world.cpp b/source/modules/asura-box2d/Physics/binding/_world.cpp deleted file mode 100644 index 0940959..0000000 --- a/source/modules/asura-box2d/Physics/binding/_world.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "../World.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace Physics - { - /* - LUAX_REGISTRY(World) - { - - } - - LUAX_POSTPROCESS(World) - { - - } -*/ - } -} diff --git a/source/modules/asura-box2d/physics/binding/_body.cpp b/source/modules/asura-box2d/physics/binding/_body.cpp deleted file mode 100644 index 0c9e3e8..0000000 --- a/source/modules/asura-box2d/physics/binding/_body.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "../Body.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace Physics - { - - LUAX_REGISTRY(Body) - { - LUAX_REGISTER_METHODS(state, - { "GetType", _GetType }, - { "GetX", _GetX }, - { "GetY", _GetY }, - { "GetAngle", _GetAngle }, - { "GetPosition", _GetPosition }, - { "GetLinearVelocity", _GetLinearVelocity }, - { "GetWorldCenter", _GetWorldCenter }, - { "GetLocalCenter", _GetLocalCenter }, - { "GetAngularVelocity", _GetAngularVelocity }, - { "GetMass", _GetMass }, - { "GetInertia", _GetInertia }, - { "GetMassData", _GetMassData }, - { "GetAngularDamping", _GetAngularDamping }, - { "GetLinearDamping", _GetLinearDamping }, - { "GetGravityScale", _GetGravityScale }, - { "GetGravityScale", _GetGravityScale } - ); - } - - LUAX_POSTPROCESS(Body) - { - LUAX_REGISTER_ENUM(state, "EBodyType", - { "INVALID", BODY_TYPE_INVALID }, - { "STATIC", BODY_TYPE_STATIC }, - { "DYNAMIC", BODY_TYPE_DYNAMIC }, - { "KINEMATIC", BODY_TYPE_KINEMATIC } - ); - - } - - // body:GetType() - LUAX_IMPL_METHOD(Body, _GetType) - { - LUAX_PREPARE(L, Body); - return 0; - } - - // body:GetX() - LUAX_IMPL_METHOD(Body, _GetX) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetY() - LUAX_IMPL_METHOD(Body, _GetY) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngle() - LUAX_IMPL_METHOD(Body, _GetAngle) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetPosition() - LUAX_IMPL_METHOD(Body, _GetPosition) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLinearVelocity() - LUAX_IMPL_METHOD(Body, _GetLinearVelocity) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetWorldCenter() - LUAX_IMPL_METHOD(Body, _GetWorldCenter) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLocalCenter() - LUAX_IMPL_METHOD(Body, _GetLocalCenter) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngularVelocity() - LUAX_IMPL_METHOD(Body, _GetAngularVelocity) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetMass() - LUAX_IMPL_METHOD(Body, _GetMass) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetInertia() - LUAX_IMPL_METHOD(Body, _GetInertia) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetMassData() - LUAX_IMPL_METHOD(Body, _GetMassData) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetAngularDamping() - LUAX_IMPL_METHOD(Body, _GetAngularDamping) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetLinearDamping() - LUAX_IMPL_METHOD(Body, _GetLinearDamping) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetGravityScale() - LUAX_IMPL_METHOD(Body, _GetGravityScale) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - // body:GetGravityScale() - LUAX_IMPL_METHOD(Body, _GetGravityScale) - { - LUAX_PREPARE(L, Body); - - return 0; - } - - } -} diff --git a/source/modules/asura-box2d/physics/binding/_world.cpp b/source/modules/asura-box2d/physics/binding/_world.cpp deleted file mode 100644 index 0940959..0000000 --- a/source/modules/asura-box2d/physics/binding/_world.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "../World.h" - -using namespace std; - -namespace AsuraEngine -{ - namespace Physics - { - /* - LUAX_REGISTRY(World) - { - - } - - LUAX_POSTPROCESS(World) - { - - } -*/ - } -} diff --git a/source/modules/asura-box2d/physics/body.h b/source/modules/asura-box2d/physics/body.h deleted file mode 100644 index d7e79d5..0000000 --- a/source/modules/asura-box2d/physics/body.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef __ASURA_BOX2D_BODY_H__ -#define __ASURA_BOX2D_BODY_H__ - -#include - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class World; -class Joint; - -enum BodyType -{ - BODY_TYPE_INVALID, - BODY_TYPE_STATIC, - BODY_TYPE_DYNAMIC, - BODY_TYPE_KINEMATIC -}; - -class Body : public AEScripting::Portable -{ -public: - -private: - - friend class Joint; - - //----------------------------------------------------------------------------// - - LUAX_DECL_FACTORY(Body); - - LUAX_DECL_ENUM(BodyType, 1); - - LUAX_DECL_METHOD(_GetType); - LUAX_DECL_METHOD(_GetX); - LUAX_DECL_METHOD(_GetY); - LUAX_DECL_METHOD(_GetAngle); - LUAX_DECL_METHOD(_GetPosition); - LUAX_DECL_METHOD(_GetLinearVelocity); - LUAX_DECL_METHOD(_GetWorldCenter); - LUAX_DECL_METHOD(_GetLocalCenter); - LUAX_DECL_METHOD(_GetAngularVelocity); - LUAX_DECL_METHOD(_GetMass); - LUAX_DECL_METHOD(_GetInertia); - LUAX_DECL_METHOD(_GetMassData); - LUAX_DECL_METHOD(_GetAngularDamping); - LUAX_DECL_METHOD(_GetLinearDamping); - LUAX_DECL_METHOD(_GetGravityScale); - LUAX_DECL_METHOD(_GetGravityScale); - - //----------------------------------------------------------------------------// - - b2Body* m_Body; - World* m_World; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-box2d/physics/contact.h b/source/modules/asura-box2d/physics/contact.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/physics/fixture.h b/source/modules/asura-box2d/physics/fixture.h deleted file mode 100644 index 69f0153..0000000 --- a/source/modules/asura-box2d/physics/fixture.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ASRUA_ENGINE_FIXTURE_H_ -#define _ASRUA_ENGINE_FIXTURE_H_ - -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class Fixture -{ - -}; - -namespace_end -namespace_end - -#endif diff --git a/source/modules/asura-box2d/physics/joint.h b/source/modules/asura-box2d/physics/joint.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/physics/shape.h b/source/modules/asura-box2d/physics/shape.h deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-box2d/physics/world.h b/source/modules/asura-box2d/physics/world.h deleted file mode 100644 index a156c79..0000000 --- a/source/modules/asura-box2d/physics/world.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __ASURA_BOX2D_WORLD_H__ -#define __ASURA_BOX2D_WORLD_H__ - -#include -#include - -namespace_begin(AsuraEngine) -namespace_begin(Physics) - -class World : public AEScripting::Portable -{ - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/Font/TTF.cpp b/source/modules/asura-core/Font/TTF.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-core/Font/TTF.h b/source/modules/asura-core/Font/TTF.h deleted file mode 100644 index b83cf76..0000000 --- a/source/modules/asura-core/Font/TTF.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ASURA_TTF_H_ -#define _ASURA_TTF_H_ - -namespace AsuraEngine -{ - namespace Text - { - - class TTF - { - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/Font/Utf.hpp b/source/modules/asura-core/Font/Utf.hpp deleted file mode 100644 index 59f62ed..0000000 --- a/source/modules/asura-core/Font/Utf.hpp +++ /dev/null @@ -1,720 +0,0 @@ -#ifndef _ASURA_UTF_HPP_ -#define _ASURA_UTF_HPP_ - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include -#include -#include - -namespace AsuraEngine -{ - namespace Text - { - - template - class Utf; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-8 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<8> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-8 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-8 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-8 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-8. - /// - /// \param input Codepoint to encode as UTF-8 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-8 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint8 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-8 character - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-8 sequence - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element, thus the - /// total size can be different from (begin - end). - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-8 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-8 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - }; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-16 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<16> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-16 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-16 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-16 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-16. - /// - /// \param input Codepoint to encode as UTF-16 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-16 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint16 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-16 character - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-16 sequence - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element, thus the - /// total size can be different from (begin - end). - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-16 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-16 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - }; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-32 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<32> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-32 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// For UTF-32, the character value is the same as the codepoint. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-32 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-32. - /// For UTF-32, the codepoint is the same as the character value. - /// - /// \param input Codepoint to encode as UTF-32 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-32 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-32 character - /// - /// This function is trivial for UTF-32, which can store - /// every character in a single storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-32 sequence - /// - /// This function is trivial for UTF-32, which can store - /// every character in a single storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-32 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-32 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-32 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-32 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Decode a single ANSI character to UTF-32 - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param input Input ANSI character - /// \param locale Locale to use for conversion - /// - /// \return Converted character - /// - //////////////////////////////////////////////////////////// - template - static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Decode a single wide character to UTF-32 - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param input Input wide character - /// - /// \return Converted character - /// - //////////////////////////////////////////////////////////// - template - static Uint32 DecodeWide(In input); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character to ANSI - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param codepoint Iterator pointing to the beginning of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement if the input character is not convertible to ANSI (use 0 to skip it) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character to wide - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param codepoint Iterator pointing to the beginning of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement if the input character is not convertible to wide (use 0 to skip it) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0); - }; - -#include "Utf.inc" - - // Make typedefs to get rid of the template syntax - typedef Utf<8> Utf8; - typedef Utf<16> Utf16; - typedef Utf<32> Utf32; - - } // namespace sf - -} - - -#endif // SFML_UTF_HPP diff --git a/source/modules/asura-core/Font/Utf.inc b/source/modules/asura-core/Font/Utf.inc deleted file mode 100644 index 69a523b..0000000 --- a/source/modules/asura-core/Font/Utf.inc +++ /dev/null @@ -1,752 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// SFML - Simple and Fast Multimedia Library -// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -// References: -// -// https://www.unicode.org/ -// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c -// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h -// https://people.w3.org/rishida/scripts/uniview/conversion -// -//////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////// -template -In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement) -{ - // Some useful precomputed data - static const int trailing[256] = - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 - }; - static const Uint32 offsets[6] = - { - 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080 - }; - - // decode the character - int trailingBytes = trailing[static_cast(*begin)]; - if (begin + trailingBytes < end) - { - output = 0; - switch (trailingBytes) - { - case 5: output += static_cast(*begin++); output <<= 6; - case 4: output += static_cast(*begin++); output <<= 6; - case 3: output += static_cast(*begin++); output <<= 6; - case 2: output += static_cast(*begin++); output <<= 6; - case 1: output += static_cast(*begin++); output <<= 6; - case 0: output += static_cast(*begin++); - } - output -= offsets[trailingBytes]; - } - else - { - // Incomplete character - begin = end; - output = replacement; - } - - return begin; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement) -{ - // Some useful precomputed data - static const Uint8 firstBytes[7] = - { - 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC - }; - - // encode the character - if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF))) - { - // Invalid character - if (replacement) - *output++ = replacement; - } - else - { - // Valid character - - // Get the number of bytes to write - std::size_t bytestoWrite = 1; - if (input < 0x80) bytestoWrite = 1; - else if (input < 0x800) bytestoWrite = 2; - else if (input < 0x10000) bytestoWrite = 3; - else if (input <= 0x0010FFFF) bytestoWrite = 4; - - // Extract the bytes to write - Uint8 bytes[4]; - switch (bytestoWrite) - { - case 4: bytes[3] = static_cast((input | 0x80) & 0xBF); input >>= 6; - case 3: bytes[2] = static_cast((input | 0x80) & 0xBF); input >>= 6; - case 2: bytes[1] = static_cast((input | 0x80) & 0xBF); input >>= 6; - case 1: bytes[0] = static_cast (input | firstBytes[bytestoWrite]); - } - - // Add them to the output - output = std::copy(bytes, bytes + bytestoWrite, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<8>::Next(In begin, In end) -{ - Uint32 codepoint; - return Decode(begin, end, codepoint); -} - - -//////////////////////////////////////////////////////////// -template -std::size_t Utf<8>::Count(In begin, In end) -{ - std::size_t length = 0; - while (begin < end) - { - begin = Next(begin, end); - ++length; - } - - return length; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::FromAnsi(In begin, In end, Out output, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::FromWide(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeWide(*begin++); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::FromLatin1(In begin, In end, Out output) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - output = Encode(*begin++, output); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeWide(codepoint, output, replacement); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToLatin1(In begin, In end, Out output, char replacement) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - *output++ = codepoint < 256 ? static_cast(codepoint) : replacement; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToUtf8(In begin, In end, Out output) -{ - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToUtf16(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<16>::Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<8>::ToUtf32(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - *output++ = codepoint; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<16>::Decode(In begin, In end, Uint32& output, Uint32 replacement) -{ - Uint16 first = *begin++; - - // If it's a surrogate pair, first convert to a single UTF-32 character - if ((first >= 0xD800) && (first <= 0xDBFF)) - { - if (begin < end) - { - Uint32 second = *begin++; - if ((second >= 0xDC00) && (second <= 0xDFFF)) - { - // The second element is valid: convert the two elements to a UTF-32 character - output = ((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000; - } - else - { - // Invalid character - output = replacement; - } - } - else - { - // Invalid character - begin = end; - output = replacement; - } - } - else - { - // We can make a direct copy - output = first; - } - - return begin; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::Encode(Uint32 input, Out output, Uint16 replacement) -{ - if (input <= 0xFFFF) - { - // The character can be copied directly, we just need to check if it's in the valid range - if ((input >= 0xD800) && (input <= 0xDFFF)) - { - // Invalid character (this range is reserved) - if (replacement) - *output++ = replacement; - } - else - { - // Valid character directly convertible to a single UTF-16 character - *output++ = static_cast(input); - } - } - else if (input > 0x0010FFFF) - { - // Invalid character (greater than the maximum Unicode value) - if (replacement) - *output++ = replacement; - } - else - { - // The input character will be converted to two UTF-16 elements - input -= 0x0010000; - *output++ = static_cast((input >> 10) + 0xD800); - *output++ = static_cast((input & 0x3FFUL) + 0xDC00); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<16>::Next(In begin, In end) -{ - Uint32 codepoint; - return Decode(begin, end, codepoint); -} - - -//////////////////////////////////////////////////////////// -template -std::size_t Utf<16>::Count(In begin, In end) -{ - std::size_t length = 0; - while (begin < end) - { - begin = Next(begin, end); - ++length; - } - - return length; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::FromAnsi(In begin, In end, Out output, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::FromWide(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint = Utf<32>::DecodeWide(*begin++); - output = Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::FromLatin1(In begin, In end, Out output) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<32>::EncodeWide(codepoint, output, replacement); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToLatin1(In begin, In end, Out output, char replacement) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - { - *output++ = *begin < 256 ? static_cast(*begin) : replacement; - begin++; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToUtf8(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - output = Utf<8>::Encode(codepoint, output); - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToUtf16(In begin, In end, Out output) -{ - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<16>::ToUtf32(In begin, In end, Out output) -{ - while (begin < end) - { - Uint32 codepoint; - begin = Decode(begin, end, codepoint); - *output++ = codepoint; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<32>::Decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/) -{ - output = *begin++; - return begin; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::Encode(Uint32 input, Out output, Uint32 /*replacement*/) -{ - *output++ = input; - return output; -} - - -//////////////////////////////////////////////////////////// -template -In Utf<32>::Next(In begin, In /*end*/) -{ - return ++begin; -} - - -//////////////////////////////////////////////////////////// -template -std::size_t Utf<32>::Count(In begin, In end) -{ - return begin - end; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::FromAnsi(In begin, In end, Out output, const std::locale& locale) -{ - while (begin < end) - *output++ = DecodeAnsi(*begin++, locale); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::FromWide(In begin, In end, Out output) -{ - while (begin < end) - *output++ = DecodeWide(*begin++); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::FromLatin1(In begin, In end, Out output) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale) -{ - while (begin < end) - output = EncodeAnsi(*begin++, output, replacement, locale); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement) -{ - while (begin < end) - output = EncodeWide(*begin++, output, replacement); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToLatin1(In begin, In end, Out output, char replacement) -{ - // Latin-1 is directly compatible with Unicode encodings, - // and can thus be treated as (a sub-range of) UTF-32 - while (begin < end) - { - *output++ = *begin < 256 ? static_cast(*begin) : replacement; - begin++; - } - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToUtf8(In begin, In end, Out output) -{ - while (begin < end) - output = Utf<8>::Encode(*begin++, output); - - return output; -} - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToUtf16(In begin, In end, Out output) -{ - while (begin < end) - output = Utf<16>::Encode(*begin++, output); - - return output; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::ToUtf32(In begin, In end, Out output) -{ - return std::copy(begin, end, output); -} - - -//////////////////////////////////////////////////////////// -template -Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale) -{ - // On Windows, GCC's standard library (glibc++) has almost - // no support for Unicode stuff. As a consequence, in this - // context we can only use the default locale and ignore - // the one passed as parameter. - - #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \ - (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \ - !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */ - - (void)locale; // to avoid warnings - - wchar_t character = 0; - mbtowc(&character, &input, 1); - return static_cast(character); - - #else - - // Get the facet of the locale which deals with character conversion - const std::ctype& facet = std::use_facet< std::ctype >(locale); - - // Use the facet to convert each character of the input string - return static_cast(facet.widen(input)); - - #endif -} - - -//////////////////////////////////////////////////////////// -template -Uint32 Utf<32>::DecodeWide(In input) -{ - // The encoding of wide characters is not well defined and is left to the system; - // however we can safely assume that it is UCS-2 on Windows and - // UCS-4 on Unix systems. - // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4, - // and UCS-4 *is* UTF-32). - - return input; -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale) -{ - // On Windows, gcc's standard library (glibc++) has almost - // no support for Unicode stuff. As a consequence, in this - // context we can only use the default locale and ignore - // the one passed as parameter. - - #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \ - (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \ - !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */ - - (void)locale; // to avoid warnings - - char character = 0; - if (wctomb(&character, static_cast(codepoint)) >= 0) - *output++ = character; - else if (replacement) - *output++ = replacement; - - return output; - - #else - - // Get the facet of the locale which deals with character conversion - const std::ctype& facet = std::use_facet< std::ctype >(locale); - - // Use the facet to convert each character of the input string - *output++ = facet.narrow(static_cast(codepoint), replacement); - - return output; - - #endif -} - - -//////////////////////////////////////////////////////////// -template -Out Utf<32>::EncodeWide(Uint32 codepoint, Out output, wchar_t replacement) -{ - // The encoding of wide characters is not well defined and is left to the system; - // however we can safely assume that it is UCS-2 on Windows and - // UCS-4 on Unix systems. - // For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4). - // For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32). - - switch (sizeof(wchar_t)) - { - case 4: - { - *output++ = static_cast(codepoint); - break; - } - - default: - { - if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF))) - { - *output++ = static_cast(codepoint); - } - else if (replacement) - { - *output++ = replacement; - } - break; - } - } - - return output; -} diff --git a/source/modules/asura-core/Graphics/DrawInfo.h b/source/modules/asura-core/Graphics/DrawInfo.h index 0082102..6167359 100644 --- a/source/modules/asura-core/Graphics/DrawInfo.h +++ b/source/modules/asura-core/Graphics/DrawInfo.h @@ -6,6 +6,14 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +struct ShaderUniform; + +struct ShaderUniformSheet +{ + + +}; + /// struct DrawInfo { diff --git a/source/modules/asura-core/Graphics/GPUBuffer.cpp b/source/modules/asura-core/Graphics/GPUBuffer.cpp index f28b914..ded4708 100644 --- a/source/modules/asura-core/Graphics/GPUBuffer.cpp +++ b/source/modules/asura-core/Graphics/GPUBuffer.cpp @@ -69,16 +69,16 @@ bool GPUBuffer::Fill(const void * data, size_t size, uint offset) return false; if (m_Buffer == 0) { - g_Device.WipeError(); + g_GfxDevice.WipeError(); glGenBuffers(1, &m_Buffer); if (m_Buffer == 0) throw Exception("OpenGL glGenBuffers failed."); glBindBuffer(m_Target, m_Buffer); glBufferData(m_Target, m_Size, NULL, m_Usage); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) { glBindBuffer(m_Target, 0); - throw Exception("OpenGL glBufferData failed. Errorcode=%d.", g_Device.GetError()); + throw Exception("OpenGL glBufferData failed. Errorcode=%d.", g_GfxDevice.GetError()); } #if ASURA_DEBUG m_Data = (byte*)malloc(size); @@ -87,11 +87,12 @@ bool GPUBuffer::Fill(const void * data, size_t size, uint offset) } else glBindBuffer(m_Target, m_Buffer); - glBufferSubData(m_Target, offset, size, data); - if (g_Device.HasError()) + //glBufferSubData(m_Target, offset, size, data); + GL_CALL(glBufferSubData, m_Target, offset, size, data); + if (g_GfxDevice.HasError()) { glBindBuffer(m_Target, 0); - throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", g_Device.GetError()); + throw Exception("OpenGL glBufferSubData failed. Errorcode=%d.", g_GfxDevice.GetError()); } glBindBuffer(m_Target, 0); #if ASURA_DEBUG diff --git a/source/modules/asura-core/Graphics/GfxDevice.cpp b/source/modules/asura-core/Graphics/GfxDevice.cpp index 529a76c..ab5e281 100644 --- a/source/modules/asura-core/Graphics/GfxDevice.cpp +++ b/source/modules/asura-core/Graphics/GfxDevice.cpp @@ -7,7 +7,7 @@ #include "MatrixStack.h" #include "Color.h" -using namespace AEMath; + namespace_begin(AsuraEngine) namespace_begin(Graphics) @@ -16,7 +16,13 @@ namespace_begin(Graphics) static bool instantiated = false; #endif -GfxDevice g_Device; +#if ASURA_GL_PROFILE +#define Stats(f) m_Stats.f +#else +#define Stats(f) +#endif + +GfxDevice g_GfxDevice; GfxDevice::GfxDevice() { @@ -32,12 +38,12 @@ GfxDevice::~GfxDevice() GfxDevice& GfxDevice::Get() { - return g_Device; + return g_GfxDevice; } static bool inited = false; -bool GfxDevice::Init(const AEMath::Recti& view) +bool GfxDevice::Init(const Recti& view) { bool loaded = false; #if ASURA_OPENGL_LOADER & ASURA_OPENGL_GLAD @@ -74,113 +80,101 @@ GLenum GfxDevice::GetError() void GfxDevice::SetDrawColor(float r, float g, float b, float a) { - state.drawColor.Set(r, g, b, a); + m_State.drawColor.Set(r, g, b, a); } Color& GfxDevice::GetDrawColor() { - return state.drawColor; + return m_State.drawColor; } void GfxDevice::SetViewport(const Recti v) { - state.viewport = v; + m_State.viewport = v; glViewport(v.x, v.y, v.w, v.h); } const Recti& GfxDevice::GetViewport() { - return state.viewport; + return m_State.viewport; } void GfxDevice::SetActiveShader(Shader* shader) { - if (state.shader == shader) + if (m_State.activeShader == shader) return; - if (state.shader) - state.shader->OnDisable(); - state.shader = shader; + if (m_State.activeShader) + m_State.activeShader->OnDisable(); + m_State.activeShader = shader; if (shader) { GLint program = shader->GetGLProgram(); glUseProgram(program); -#if ASURA_GL_PROFILE - ++stats.shaderSwitch; -#endif shader->OnEnable(); + Stats(AddShaderSwitch()); } } Shader* GfxDevice::GetActiveShader() const { - return state.shader; -} - -void GfxDevice::DrawArrays(GLenum mode, GLint first, GLsizei count) -{ - glDrawArrays(mode, first, count); -#if ASURA_GL_PROFILE - ++stats.drawCall; -#endif - if (state.shader) - state.shader->OnUsed(); + return m_State.activeShader; } void GfxDevice::PushMatrix () { - state.matrix[state.matrixMode].Push (); + m_State.matrix[m_State.matrixMode].Push (); } void GfxDevice::PopMatrix () { - state.matrix[state.matrixMode].Pop(); + m_State.matrix[m_State.matrixMode].Pop(); } void GfxDevice::LoadIdentity() { - state.matrix[state.matrixMode].LoadIdentity(); + m_State.matrix[m_State.matrixMode].LoadIdentity(); } void GfxDevice::Rotate (float angle) { - state.matrix[state.matrixMode].Rotate(angle); + m_State.matrix[m_State.matrixMode].Rotate(angle); } void GfxDevice::Translate (float x, float y) { - state.matrix[state.matrixMode].Translate(x, y); + m_State.matrix[m_State.matrixMode].Translate(x, y); } void GfxDevice::Scale (float x, float y) { - state.matrix[state.matrixMode].Scale(x, y); + m_State.matrix[m_State.matrixMode].Scale(x, y); } void GfxDevice::Ortho(float l, float r, float b, float t, float n, float f) { - state.matrix[state.matrixMode].Ortho(l, r, b, t, n, f); + m_State.matrix[m_State.matrixMode].Ortho(l, r, b, t, n, f); } -AEMath::Matrix44& GfxDevice::GetMatrix(MatrixMode mode) +Matrix44& GfxDevice::GetMatrix(MatrixMode mode) { - return state.matrix[mode].GetTop(); + return m_State.matrix[mode].GetTop(); } -AEMath::Matrix44 GfxDevice::GetMVPMatrix() +Matrix44 GfxDevice::GetMVPMatrix() { - return state.matrix[MATRIX_MODE_PROJECTION].GetTop() - * state.matrix[MATRIX_MODE_VIEW].GetTop() - * state.matrix[MATRIX_MODE_MODEL].GetTop(); + return m_State.matrix[MATRIX_MODE_PROJECTION].GetTop() + * m_State.matrix[MATRIX_MODE_VIEW].GetTop() + * m_State.matrix[MATRIX_MODE_MODEL].GetTop(); } uint GfxDevice::GetMatrixDepth() { - return state.matrix[state.matrixMode].GetCapacity(); + return m_State.matrix[m_State.matrixMode].GetCapacity(); } uint GfxDevice::GetMatrixIndex() { - return state.matrix[state.matrixMode].GetTopIndex(); + return m_State.matrix[m_State.matrixMode].GetTopIndex(); } diff --git a/source/modules/asura-core/Graphics/GfxDevice.h b/source/modules/asura-core/Graphics/GfxDevice.h index 2b105df..7ef03a3 100644 --- a/source/modules/asura-core/Graphics/GfxDevice.h +++ b/source/modules/asura-core/Graphics/GfxDevice.h @@ -16,10 +16,40 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +class Mesh; class Profiler; class Shader; class GPUBuffer; class Canvas; +class DynamicVBO; +class VBO; +class VBOList; + +#define GFX_STATS_PROPERTY(TYPE,PROP_NAME,VAR_NAME) \ +private: \ + TYPE VAR_NAME; \ +public: \ + void Set##PROP_NAME (TYPE val) { VAR_NAME = val; } \ + TYPE Get##PROP_NAME () {return VAR_NAME; } \ + void Add##PROP_NAME (TYPE v=1) { VAR_NAME+=v;}; + +struct GfxDeviceStats +{ + GFX_STATS_PROPERTY(uint, DrawCall, drawCall); ///< ͳ¼Ædrawcall + GFX_STATS_PROPERTY(uint, CanvasSwitch, canvasSwitch); ///< Çл»textureµÄ´ÎÊý + GFX_STATS_PROPERTY(uint, ShaderSwitch, shaderSwitch); ///< Çл»shaderµÄ´ÎÊý + GFX_STATS_PROPERTY(uint64, PrimsCount, primsCount); ///< ͼԪÊýÁ¿Í³¼Æ + + void Reset() + { + drawCall = 0; + canvasSwitch = 0; + shaderSwitch = 0; + primsCount = 0; + } +}; + +#undef GFX_STATS_PROPERTY enum MatrixMode { @@ -28,6 +58,20 @@ enum MatrixMode MATRIX_MODE_VIEW = 2, }; + +enum GfxPrimitiveType +{ + GFX_PRIMITIVE_TRIANGLES = 0, + GFX_PRIMITIVE_TRIANGLESTRIPDEPRECATED, + GFX_PRIMITIVE_QUADS, + GFX_PRIMITIVE_LINES, + GFX_PRIMITIVE_LINESTRIP, + GFX_PRIMITIVE_POINTS, + + GFX_PRIMITIVE_TYPECOUNT, // KEEP THIS LAST! + GFX_PRIMITIVE_FORCE32BITINT = 0X7FFFFFFF // FORCE 32 BIT ENUM SIZE +}; + enum GLParams { GL_PARAM_MAX_TEXTURE_UNIT = 1, @@ -44,12 +88,12 @@ public: int GetParam(GLParams param); - bool Init(const AEMath::Recti& viewport); + bool Init(const Recti& viewport); bool Inited(); - void SetViewport(const AEMath::Recti viewport); + void SetViewport(const Recti viewport); - const AEMath::Recti& GetViewport(); + const Recti& GetViewport(); void PushMatrix(); void PopMatrix(); @@ -63,10 +107,8 @@ public: uint GetMatrixDepth(); uint GetMatrixIndex(); - void DrawArrays(GLenum mode, GLint first, GLsizei count); - - AEMath::Matrix44& GetMatrix(MatrixMode mode); - AEMath::Matrix44 GetMVPMatrix(); + Matrix44& GetMatrix(MatrixMode mode); + Matrix44 GetMVPMatrix(); void SetDrawColor(float r, float g, float b, float a); Color& GetDrawColor(); @@ -74,36 +116,47 @@ public: void SetActiveShader(Shader* = NULL); Shader* GetActiveShader() const; + VBO* CreateVBO(); + void DeleteVBO(); + + void DrawMesh(Mesh* mesh); + void DrawVBO(VBO* vbo); + void DrawDynamicVBO(); + void DrawTexture(Texture*); + void WipeError(); bool HasError(); GLenum GetError(); - GET_SET(MatrixMode, MatrixMode, state.matrixMode); - GET_SET(Canvas*, ActiveCanvas, state.canvas); + GET_SET(MatrixMode, MatrixMode, m_State.matrixMode); + GET_SET(Canvas*, ActiveCanvas, m_State.activeCanvas); private: + void BeforeDrawCall(); + + // Callbacks + void OnCreateVBO(VBO* vbo); + void OnDeleteVBO(VBO* vbo); + friend class Profiler; - struct - { - AEMath::Recti viewport; ///< µ±Ç°µÄÊÓÇø£¬ÔÚÇл»HDC»òÕß±¾´°¿Ú´óС¸Ä±ä»òÕß²¿·ÖË¢ÐÂʱ±ä¶¯ - MatrixStack matrix[3]; ///< model, view, projection¾ØÕó - MatrixMode matrixMode; ///< µ±Ç°²Ù×÷µÄ¾ØÕó - Color drawColor; ///< »æÖƵÄÑÕÉ« - Canvas* canvas; ///< µ±Ç°canvas - Shader* shader; ///< µ±Ç°Ê¹ÓõÄshader - } state; + struct { + Recti viewport; ///< µ±Ç°µÄÊÓÇø£¬ÔÚÇл»HDC»òÕß±¾´°¿Ú´óС¸Ä±ä»òÕß²¿·ÖË¢ÐÂʱ±ä¶¯ + MatrixStack matrix[3]; ///< model, view, projection¾ØÕó + MatrixMode matrixMode; ///< µ±Ç°²Ù×÷µÄ¾ØÕó + Color drawColor; ///< »æÖƵÄÑÕÉ« + Canvas* activeCanvas; ///< µ±Ç°canvas + Shader* activeShader; ///< µ±Ç°Ê¹ÓõÄshader + } m_State; #if ASURA_GL_PROFILE - struct - { - uint drawCall; ///< ͳ¼Ædrawcall - uint canvasSwitch; ///< Çл»textureµÄ´ÎÊý - uint shaderSwitch; ///< Çл»shaderµÄ´ÎÊý - } stats; + GfxDeviceStats m_Stats; #endif + DynamicVBO* m_DynamicVBO; + VBOList* m_VBOList; + luaxport: LUAX_DECL_SINGLETON(GfxDevice); @@ -127,13 +180,12 @@ luaxport: }; -extern GfxDevice g_Device; - - -#define GL_CALL(x) do { x; /*GLAssert(); */} while(0) - +// È«¾Ögfx device£¬runnerºÍeditor¶¼ÊÊÓà +extern GfxDevice g_GfxDevice; +inline GfxDevice& GetGfxDevice() { return g_GfxDevice; }; +#define GL_CALL(f, ...) do { f(__VA_ARGS__); /*GLAssert(); */} while(0) namespace_end namespace_end diff --git a/source/modules/asura-core/Graphics/Image.cpp b/source/modules/asura-core/Graphics/Image.cpp deleted file mode 100644 index 36d2478..0000000 --- a/source/modules/asura-core/Graphics/Image.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include - -#include "../CoreConfig.h" - -#include "Shader.h" -#include "Image.h" -#include "GfxDevice.h" - -using namespace AEFileSystem; -using namespace AEImage; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -Image::Image() - : m_Width(0) - , m_Height(0) -{ -} - -Image::~Image() -{ -} - -bool Image::Load(ImageData* imgData) -{ - if (!imgData) return false; - - if (m_TexID == 0) - { - glGenTextures(1, &m_TexID); - if (m_TexID == 0) - throw Exception("OpenGL glGenTextures failed."); - } - - glBindTexture(GL_TEXTURE_2D, m_TexID); - imgData->Lock(); - int width = imgData->width; - int height = imgData->height; - TextureFormat tf = ConvertColorFormat(imgData->format); - glTexImage2D( - GL_TEXTURE_2D - , 0 - , tf.internalformat - , width, height - , 0 - , tf.externalformat - , tf.type - , imgData->pixels - ); - - m_Width = imgData->width; - m_Height = imgData->height; - imgData->Unlock(); - GLenum err = glGetError(); - if (err != GL_NO_ERROR) - throw Exception("OpenGL glTexImage2D cause error, error code=%d", err); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -bool Image::Load(ImageData* imgData, const AEMath::Vector2i& pos) -{ - if (!imgData) return false; - - glBindTexture(GL_TEXTURE_2D, m_TexID); - imgData->Lock(); - int width = imgData->width; - int height = imgData->height; - TextureFormat tf = ConvertColorFormat(imgData->format); - glTexSubImage2D( - GL_TEXTURE_2D - , 0 - , pos.x - , pos.y - , imgData->width - , imgData->height - , tf.externalformat - , tf.type - , imgData->pixels - ); - imgData->Unlock(); - GLenum err = glGetError(); - if (err != GL_NO_ERROR) - throw Exception("OpenGL glTexSubImage2D cause error, error code=%d", err); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -uint32 Image::GetWidth() -{ - return m_Width; -} - -uint32 Image::GetHeight() -{ - return m_Height; -} - -namespace_end -namespace_end \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/Image.h b/source/modules/asura-core/Graphics/Image.h deleted file mode 100644 index a76d06f..0000000 --- a/source/modules/asura-core/Graphics/Image.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _ASURA_ENGINE_IMAGE_H_ -#define _ASURA_ENGINE_IMAGE_H_ - -// asura modules -#include -#include -#include -#include -#include -#include - -// module -#include "../Image/ImageData.h" - -// folder -#include "Color.h" -#include "Color32.h" -#include "RenderState.h" -#include "GPUBuffer.h" -#include "Texture.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -class Image ASURA_FINAL : public AEScripting::Portable -{ -public: - - Image(); - ~Image(); - - bool Load(AEImage::ImageData* decodeData); - bool Load(AEImage::ImageData* decodeData, const AEMath::Vector2i& pos); - - uint GetWidth(); - uint GetHeight(); - - GPUBuffer* GenGPUBuffer(); - -private: - - uint32 m_Width, m_Height; - -luaxport: - - LUAX_DECL_FACTORY(Image, Texture); - - LUAX_DECL_METHOD(_New); - LUAX_DECL_METHOD(_Load); - LUAX_DECL_METHOD(_GetWidth); - LUAX_DECL_METHOD(_GetHeight); - LUAX_DECL_METHOD(_GetSize); - LUAX_DECL_METHOD(_GetPixel); - LUAX_DECL_METHOD(_Render); - -}; - -namespace_end -namespace_end - -namespace AEGraphics = AsuraEngine::Graphics; - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/MatrixStack.cpp b/source/modules/asura-core/Graphics/MatrixStack.cpp index 987d29c..88b9b6b 100644 --- a/source/modules/asura-core/Graphics/MatrixStack.cpp +++ b/source/modules/asura-core/Graphics/MatrixStack.cpp @@ -36,7 +36,7 @@ bool MatrixStack::Pop() return true; } -AEMath::Matrix44& MatrixStack::GetTop() +Matrix44& MatrixStack::GetTop() { return m_Stack[top]; } diff --git a/source/modules/asura-core/Graphics/MatrixStack.h b/source/modules/asura-core/Graphics/MatrixStack.h index 8dd56bf..15ae7e5 100644 --- a/source/modules/asura-core/Graphics/MatrixStack.h +++ b/source/modules/asura-core/Graphics/MatrixStack.h @@ -8,17 +8,9 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) -/// -/// Õ»µÄ¾ØÕóÉî¶È¡£ -/// -#define ASURA_MAX_MATRIX_STACK_DEPTH 32 // 2KB - -/// -/// ±£´æÕ»×´Ì¬£¬ÓÃÀ´»Ö¸´Ö®Ç°µÄ״̬¡£Õ»ÖеÄÒ»¸ö¾ØÕóstack[i]µÄÖµÊÇstack[0]*..*stack[i-1] -/// µÄÖµ£¬²¢¸½¼ÓһϵÁÐtransform¡£ -/// -/// TODO: template MatrixStack -/// +// ±£´æÕ»×´Ì¬£¬ÓÃÀ´»Ö¸´Ö®Ç°µÄ״̬¡£Õ»ÖеÄÒ»¸ö¾ØÕóstack[i]µÄÖµÊÇstack[0]*..*stack[i-1]µÄÖµ£¬²¢¸½¼ÓһϵÁÐtransform¡£ +// +// TODO: template MatrixStack class MatrixStack { public: @@ -30,11 +22,11 @@ public: bool Push(); bool Pop(); - AEMath::Matrix44& GetTop(); - void GetTop(ASURA_OUT AEMath::Matrix44& mat44); + Matrix44& GetTop(); + void GetTop(ASURA_OUT Matrix44& mat44); - void LoadMatrix(const AEMath::Matrix44& mat44); - void MultMatrix(const AEMath::Matrix44& mat44); + void LoadMatrix(const Matrix44& mat44); + void MultMatrix(const Matrix44& mat44); void Rotate(float angle); void Translate(float x, float y); @@ -47,8 +39,8 @@ public: private: - AEMath::Matrix44 m_Stack[ASURA_MAX_MATRIX_STACK_DEPTH]; - uint8 top; + Matrix44 m_Stack[32]; // 2kB + uint8 m_Top; }; diff --git a/source/modules/asura-core/Graphics/Mesh2D.cpp b/source/modules/asura-core/Graphics/Mesh2D.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-core/Graphics/Mesh2D.h b/source/modules/asura-core/Graphics/Mesh2D.h deleted file mode 100644 index 7a0f62e..0000000 --- a/source/modules/asura-core/Graphics/Mesh2D.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _ASURA_ENGINE_MESH2D_H__ -#define _ASURA_ENGINE_MESH2D_H__ - -// cpp -#include - -// asura modules -#include -#include - -// module -#include "../Mesh/Mesh2dData.h" - -// folder -#include "Color.h" -#include "VertexBuffer.h" -#include "IndexBuffer.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -/// -/// 2D mesh£¬ÓÃÓÚ×öһЩ¶¥µã¶¯»­¡£ -/// https://en.wikipedia.org/wiki/Polygon_mesh -/// -class Mesh2D ASURA_FINAL - : public Scripting::Portable -{ -public: - - Mesh2D(); - ~Mesh2D(); - - bool Load(AEMesh::Mesh2DData* data); - -private: - - VertexBuffer* m_VBO; ///< vertex buffer - IndexBuffer* m_IBO; ///< index buffer - -luaxport: - - LUAX_DECL_FACTORY(Mesh2D); - - LUAX_DECL_METHOD(_SetVertex); - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/RenderTarget.cpp b/source/modules/asura-core/Graphics/RenderTarget.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-core/Graphics/RenderTarget.h b/source/modules/asura-core/Graphics/RenderTarget.h deleted file mode 100644 index ab09e35..0000000 --- a/source/modules/asura-core/Graphics/RenderTarget.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _ASURA_ENGINE_RENDERTARGET_H_ -#define _ASURA_ENGINE_RENDERTARGET_H_ - -#include -#include -#include - -#include "Texture.h" -#include "Color.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -/// -/// ¿É±»×÷ΪäÖȾĿ±êµÄÀ࣬ÅÉÉúÀàÓÐ -/// Canvas(RenderTexture) -/// Window(RenderWindow) -/// -class RenderTarget : public AEScripting::Object -{ -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; - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/Shader.cpp b/source/modules/asura-core/Graphics/Shader.cpp index 329b3f1..56d638d 100644 --- a/source/modules/asura-core/Graphics/Shader.cpp +++ b/source/modules/asura-core/Graphics/Shader.cpp @@ -24,12 +24,12 @@ Shader::~Shader() void Shader::SetActive(Shader* shader) { - g_Device.SetActiveShader(shader); + g_GfxDevice.SetActiveShader(shader); } Shader* Shader::GetActive() { - return g_Device.GetActiveShader(); + return g_GfxDevice.GetActiveShader(); } bool Shader::Load(const string& vert, const string& frag) @@ -157,56 +157,56 @@ GLuint Shader::GetGLProgram() void Shader::SetUniformFloat(uint loc, float value) { - if(g_Device.GetActiveShader() == this) + if(g_GfxDevice.GetActiveShader() == this) glUniform1f(loc, value); } bool Shader::SetUniformTexture(uint loc, const Texture& texture) { - if (g_Device.GetActiveShader() != this) + if (g_GfxDevice.GetActiveShader() != this) return false; - g_Device.WipeError(); + g_GfxDevice.WipeError(); glActiveTexture(GL_TEXTURE0 + texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; GLint tex = texture.GetGLTexture(); glBindTexture(GL_TEXTURE_2D, tex); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; glUniform1i(loc, texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; ++texUnit; } void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform2f(loc, vec2.x, vec2.y); } void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform3f(loc, vec3.x, vec3.y, vec3.z); } void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w); } void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements()); } void Shader::SetUniformColor(uint loc, const Color& color) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, color.r, color.g, color.b, color.a); } diff --git a/source/modules/asura-core/Graphics/Shader.h b/source/modules/asura-core/Graphics/Shader.h index 615b028..6d7ef90 100644 --- a/source/modules/asura-core/Graphics/Shader.h +++ b/source/modules/asura-core/Graphics/Shader.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -23,10 +24,21 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +enum ShaderChannel +{ + SHADER_CHANNEL_NONE = -1, + SHADER_CHANNEL_VERTEX = 0, // Vertex (vector3) + SHADER_CHANNEL_NORMAL, // Normal (vector3) + SHADER_CHANNEL_COLOR, // Vertex color + SHADER_CHANNEL_TEXCOORD0, // UV set 0 (vector2) + SHADER_CHANNEL_TEXCOORD1, // UV set 1 (vector2) + SHADER_CHANNEL_TANGENT, // Tangent (vector4) + SHADER_CHANNEL_COUNT, // Keep this last! +}; + /// -/// Ò»¸öshaderÊÇÒ»¸öÔÚ²ÄÖʼ乲ÏíµÄ³ÌÐò¡£Shader±¾Éí²»±£´æuniformsºÍ¶¥µãÊý¾Ý£¬Ö»ÌṩÉèÖà uniformsºÍuse×ÅÉ« -/// Æ÷µÄ·½·¨¡£±à¼­Æ÷Õë¶Ôÿ¸öshader£¬»áͨ¹ýshader´úÂëÕÒµ½ÉùÃ÷µÄuniforms±äÁ¿£¬²¢±©Â¶¸øframeworkµÄmaterial -/// ÉèÖᣠ+/// Ò»¸öshaderÊÇÒ»¸öÔÚ²ÄÖʼ乲ÏíµÄ³ÌÐò¡£Shader±¾Éí²»±£´æuniformsºÍ¶¥µãÊý¾Ý£¬Ö»ÌṩÉèÖà uniformsºÍuse×ÅÉ«Æ÷µÄ·½·¨¡£ +/// ±à¼­Æ÷Õë¶Ôÿ¸öshader£¬»áͨ¹ýshader´úÂëÕÒµ½ÉùÃ÷µÄuniforms±äÁ¿£¬²¢±©Â¶¸øframeworkµÄmaterialÉèÖᣠ/// class Shader ASURA_FINAL : public Scripting::Portable @@ -64,10 +76,10 @@ public: bool SetUniformTexture(uint loc, const Texture& texture); float GetUniformFloat(uint loc); - AEMath::Vector2f GetUniformVector2(uint loc); - AEMath::Vector3f GetUniformVector3(uint loc); - AEMath::Vector4f GetUniformVector4s(uint loc); - AEMath::Matrix44 GetUniformMatrix44(uint loc); + Vector2f GetUniformVector2(uint loc); + Vector3f GetUniformVector3(uint loc); + Vector4f GetUniformVector4s(uint loc); + Matrix44 GetUniformMatrix44(uint loc); GLuint GetGLProgram(); @@ -109,6 +121,7 @@ luaxport: }; +// GPU program typedef Shader GpuProgram; namespace_end diff --git a/source/modules/asura-core/Graphics/Texture.h b/source/modules/asura-core/Graphics/Texture.h index 76b9a8f..572fad4 100644 --- a/source/modules/asura-core/Graphics/Texture.h +++ b/source/modules/asura-core/Graphics/Texture.h @@ -3,6 +3,7 @@ #include #include +#include #include "../CoreConfig.h" @@ -14,6 +15,17 @@ namespace_begin(Graphics) class RenderTarget; +/// ͼƬÊý¾Ý +class ImageData +{ +public: + uint8* GetData(); +private: + int m_Format; + uint8* m_ImageData; + Vector2i m_ImageSize; +}; + /// UV²ÉÑù·½Ê½ enum WrapMode { @@ -34,8 +46,8 @@ enum FilterMode enum ColorFormat { COLOR_FORMAT_UNKNOWN, - COLOR_FORMAT_RGBA8, ///< RGBA¶¼ÊÇ8bits int - COLOR_FORMAT_RGBA32F, ///< RGBA¶¼ÊÇ32bits float + COLOR_FORMAT_RGBA8, + COLOR_FORMAT_RGBA32F, }; /// ÎÆÀí¸ñʽ£¬GPUÄÚ²¿ºÍCPUÍⲿ¸ñʽ @@ -50,11 +62,14 @@ struct TextureFormat /// 2DÎÆÀí³éÏóÀ࣬ÔÚ2d meshºÍrender targetÖб»Ê¹Óá£TextureµÄäÖȾԭµãÔÚ×óÉϽǣ¬ÓÎÏ·ÀïÃæµÄÉϲã»áÒԵѿ¨¶û /// ×ø±êϵΪ±ê×¼¡£ÔÚEditorÀïÃæ½çÃæºÍ×é¼þÒ²ÊÇÒÔ×óÉϽÇΪԭµã£¬ÕâÑùÊÇΪÁË·½±ã¡£ /// -ASURA_ABSTRACT class Texture : public AEScripting::Object +class Texture : public AEScripting::Object { public: - LUAX_DECL_ABSTRACT_FACTORY(Texture); + LUAX_DECL_FACTORY(Texture); + + // Texture generator + static Texture* GenerateTexture(); Texture(); virtual ~Texture(); @@ -67,9 +82,12 @@ public: void GetFilterMode(); void GetWrapMode(); - /// Èç¹ûÉèÖÃU»òV·½ÏòfilterΪ bool IsGenMipmap(); + int GetWidth(); + int GetHeight(); + Vector2i GetSize(); + protected: /// ת»»color formatΪtexture format¡£ @@ -79,7 +97,12 @@ protected: FilterMode m_MinFilter; FilterMode m_MagFilter; WrapMode m_WrapMode; + int m_UsageMode; bool m_IsGenMipmap; + Vector2f m_TexelSize; + Vector2f m_UVScale; + +luaxport: LUAX_DECL_ENUM(ColorFormat, 1); LUAX_DECL_ENUM(FilterMode, 1); @@ -90,11 +113,12 @@ protected: LUAX_DECL_METHOD(_GetFilterMode); LUAX_DECL_METHOD(_GetWrapMode); LUAX_DECL_METHOD(_IsGenMipmap); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetSize); }; -typedef Texture Drawable; - namespace_end namespace_end diff --git a/source/modules/asura-core/Graphics/VBO.cpp b/source/modules/asura-core/Graphics/VBO.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-core/Graphics/VBO.h b/source/modules/asura-core/Graphics/VBO.h deleted file mode 100644 index f80991e..0000000 --- a/source/modules/asura-core/Graphics/VBO.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ASURA_ENGINE_VBO_H_ -#define _ASURA_ENGINE_VBO_H_ - -#include - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -struct VertexBufferData -{ - -}; - -struct IndexBufferData -{ - -}; - -class VBO -{ - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/binding/_canvas.cpp b/source/modules/asura-core/Graphics/binding/_canvas.cpp deleted file mode 100644 index 44841f5..0000000 --- a/source/modules/asura-core/Graphics/binding/_canvas.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "../Canvas.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Canvas) - { - LUAX_REGISTER_METHODS(state, - { "SetSize", _SetSize }, - { "Bind", _Bind }, - { "Unbind", _Unbind } - ); - } - - LUAX_POSTPROCESS(Canvas) - { - - } - - // canvas:SetSize() - LUAX_IMPL_METHOD(Canvas, _SetSize) - { - LUAX_PREPARE(L, Canvas); - return 0; - - } - - // canvas:Bind() - LUAX_IMPL_METHOD(Canvas, _Bind) - { - LUAX_PREPARE(L, Canvas); - - return 0; - } - - // canvas:Unbind() - LUAX_IMPL_METHOD(Canvas, _Unbind) - { - LUAX_PREPARE(L, Canvas); - return 0; - - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_color.cpp b/source/modules/asura-core/Graphics/binding/_color.cpp deleted file mode 100644 index 008d9c2..0000000 --- a/source/modules/asura-core/Graphics/binding/_color.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "../Color.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - -LUAX_REGISTRY(Color) -{ - LUAX_REGISTER_METHODS(state, - { "ToColor32", _ToColor32 }, - { "SetColor", _SetColor }, - { "GetColor", _GetColor }, - { "GetR", _GetR }, - { "GetG", _GetG }, - { "GetB", _GetB }, - { "GetA", _GetA }, - { "__eq", ___eq }, - { "__add", ___add }, - { "__sub", ___sub }, - { "__mul", ___mul }, - { "__div", ___div } - ); -} - -LUAX_POSTPROCESS(Color) -{ - -} - -// color:ToColor32() -LUAX_IMPL_METHOD(Color, _ToColor32) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:SetColor() -LUAX_IMPL_METHOD(Color, _SetColor) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetColor() -LUAX_IMPL_METHOD(Color, _GetColor) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetR() -LUAX_IMPL_METHOD(Color, _GetR) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetG() -LUAX_IMPL_METHOD(Color, _GetG) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetB() -LUAX_IMPL_METHOD(Color, _GetB) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetA() -LUAX_IMPL_METHOD(Color, _GetA) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__eq() -LUAX_IMPL_METHOD(Color, ___eq) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__add() -LUAX_IMPL_METHOD(Color, ___add) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__sub() -LUAX_IMPL_METHOD(Color, ___sub) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__mul() -LUAX_IMPL_METHOD(Color, ___mul) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__div() -LUAX_IMPL_METHOD(Color, ___div) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -} -} \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/binding/_color32.cpp b/source/modules/asura-core/Graphics/binding/_color32.cpp deleted file mode 100644 index 7613361..0000000 --- a/source/modules/asura-core/Graphics/binding/_color32.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "../Color32.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Color32) - { - LUAX_REGISTER_METHODS(state, - { "ToColor", _ToColor }, - { "GetRed", _GetRed }, - { "GetGreen", _GetGreen }, - { "GetBlue", _GetBlue }, - { "GetAlpha", _GetAlpha } - ); - } - - LUAX_POSTPROCESS(Color32) - { - - } - - // color32:ToColor() - LUAX_IMPL_METHOD(Color32, _ToColor) - { - LUAX_PREPARE(L, Color32); - return 0; - - } - - // color32:GetRed() - LUAX_IMPL_METHOD(Color32, _GetRed) - { - LUAX_PREPARE(L, Color32); - return 0; - } - - // color32:GetGreen() - LUAX_IMPL_METHOD(Color32, _GetGreen) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - // color32:GetBlue() - LUAX_IMPL_METHOD(Color32, _GetBlue) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - // color32:GetAlpha() - LUAX_IMPL_METHOD(Color32, _GetAlpha) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - } -} - \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/binding/_gfx_device.cpp b/source/modules/asura-core/Graphics/binding/_gfx_device.cpp deleted file mode 100644 index f6c2004..0000000 --- a/source/modules/asura-core/Graphics/binding/_gfx_device.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "../GfxDevice.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(GfxDevice) - { - LUAX_REGISTER_METHODS(state, - { "SetMatrixMode", _SetMatrixMode }, - { "GetMatrixMode", _GetMatrixMode }, - { "PushMatrix", _PushMatrix }, - { "PopMatrix", _PopMatrix }, - { "LoadIdentity", _LoadIdentity }, - { "Rotate", _Rotate }, - { "Translate", _Translate }, - { "Scale", _Scale }, - { "Ortho", _Ortho }, - { "GetMatrixDepth", _GetMatrixDepth }, - { "GetMatrixIndex", _GetMatrixIndex }, - { "UseShader", _UseShader }, - { "UnuseShader", _UnuseShader } - ); - } - - LUAX_POSTPROCESS(GfxDevice) - { - LUAX_REGISTER_ENUM(state, "EMatrixMode", - { "PROJECTION", MATRIX_MODE_PROJECTION }, - { "0", 0 }, - { "MODEL", MATRIX_MODE_MODEL }, - { "1", 1 }, - { "VIEW", MATRIX_MODE_VIEW }, - { "2", 2 } - ); - LUAX_REGISTER_ENUM(state, "EGLParams", - { "MAX_TEXTURE_UNIT", GL_PARAM_MAX_TEXTURE_UNIT }, - { "1", 1 } - ); - - } - - // gfxdevice:SetMatrixMode() - LUAX_IMPL_METHOD(GfxDevice, _SetMatrixMode) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixMode() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixMode) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:PushMatrix() - LUAX_IMPL_METHOD(GfxDevice, _PushMatrix) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:PopMatrix() - LUAX_IMPL_METHOD(GfxDevice, _PopMatrix) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:LoadIdentity() - LUAX_IMPL_METHOD(GfxDevice, _LoadIdentity) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Rotate() - LUAX_IMPL_METHOD(GfxDevice, _Rotate) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Translate() - LUAX_IMPL_METHOD(GfxDevice, _Translate) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Scale() - LUAX_IMPL_METHOD(GfxDevice, _Scale) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Ortho() - LUAX_IMPL_METHOD(GfxDevice, _Ortho) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixDepth() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixDepth) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixIndex() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixIndex) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:UseShader() - LUAX_IMPL_METHOD(GfxDevice, _UseShader) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:UnuseShader() - LUAX_IMPL_METHOD(GfxDevice, _UnuseShader) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp b/source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp deleted file mode 100644 index 8c39a59..0000000 --- a/source/modules/asura-core/Graphics/binding/_gpu_buffer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include - -#include "../image.h" -#include "../GPUBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(GPUBuffer) - { - LUAX_REGISTER_METHODS(state, - { "Fill", _Fill }, - { "GetSize", _GetSize }, - { "GetCount", _GetCount } - ); - } - - LUAX_POSTPROCESS(GPUBuffer) - { - LUAX_REGISTER_ENUM(state, "EBufferType", - { "VERTEX", BUFFER_TYPE_VERTEX }, - { "INDEX", BUFFER_TYPE_INDEX } - ); - LUAX_REGISTER_ENUM(state, "EBufferUsage", - { "STREAM", BUFFER_USAGE_STREAM }, - { "DYNAMIC", BUFFER_USAGE_DYNAMIC }, - { "STATIC", BUFFER_USAGE_STATIC } - ); - LUAX_REGISTER_ENUM(state, "EBufferDataType", - { "INT", BUFFER_DATA_TYPE_INT }, - { "FLOAT", BUFFER_DATA_TYPE_FLOAT }, - { "UNSIGNED_BYTE", BUFFER_DATA_TYPE_UNSIGNED_BYTE } - ); - - } - - // buffer = GPUBuffer.New(bufferType, bufferUsage, bufferDataType, size) - // buffer = GPUBuffer.New(image) - // buffer = GPUBuffer.New(mesh2d) - // buffer = GPUBuffer.New(canvas) - // buffer = GPUBuffer.New(shape) - //LUAX_IMPL_METHOD(GPUBuffer, _New) - //{ - // LUAX_STATE(L); - - // return 0; - //} - - // gpubuffer:Fill({data_unit_list}, offseti) - // data_unit_list £º´æ·ÅÊý¾ÝµÄtable - // offseti : ¿ªÊ¼¸²¸ÇµÄµØ·½ËùÔÚµÄË÷Òý(´Ó0¿ªÊ¼£© - LUAX_IMPL_METHOD(GPUBuffer, _Fill) - { - LUAX_PREPARE(L, GPUBuffer); - - // ʹÓÃbuffer¶ÔÓ¦µÄÀàÐÍÊý¾ÝÐÞ¸Äbuffer£¬ÔÚµÚÒ»´Îµ÷ÓÃʱ»á³õʼ»¯size´óСµÄbuffer£¬È»ºóÌî³ä¡£ - int offset = state.GetValue(3, 0); - int count = lua_objlen(L, 2); - int size = count * self->GetDataTypeSize(); - byte* data = (byte*)malloc(size); - int unit = self->GetDataTypeSize(); - int i = 1; - lua_rawgeti(L, 2, i); - while (!lua_isnil(L, -1)) - { - switch (self->m_DataType) - { - case GL_INT: - { - int n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - case GL_FLOAT: - { - float n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - case GL_UNSIGNED_BYTE: - { - unsigned char n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - } - state.Pop(1); // value - lua_rawgeti(L, 2, ++i); - } - state.Pop(); // nil - - self->Fill(data, size, offset * unit); - - free(data); - return 0; - } - - // gpubuffer:GetSize() - LUAX_IMPL_METHOD(GPUBuffer, _GetSize) - { - LUAX_PREPARE(L, GPUBuffer); - state.Push(self->m_Size); - return 0; - } - - LUAX_IMPL_METHOD(GPUBuffer, _GetCount) - { - LUAX_PREPARE(L, GPUBuffer); - state.Push(self->m_Size / self->GetDataTypeSize()); - return 0; - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_image.cpp b/source/modules/asura-core/Graphics/binding/_image.cpp deleted file mode 100644 index 0e4cb16..0000000 --- a/source/modules/asura-core/Graphics/binding/_image.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "../image.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Image) - { - LUAX_INHERIT(state, Texture); - - LUAX_REGISTER_METHODS(state, - { "New", _New }, - { "GetWidth", _GetWidth }, - { "GetHeight", _GetHeight }, - { "GetSize", _GetSize }, - { "Render", _Render } - ); - } - - LUAX_POSTPROCESS(Image) - { - } - - // image = Image.New() - LUAX_IMPL_METHOD(Image, _New) - { - LUAX_STATE(L); - Image* img = new Image(); - img->PushLuaxUserdata(state); - return 1; - } - - // width = image:GetWidth() - LUAX_IMPL_METHOD(Image, _GetWidth) - { - LUAX_PREPARE(L, Image); - state.Push(self->GetWidth()); - return 1; - } - - // height = image:GetHeight() - LUAX_IMPL_METHOD(Image, _GetHeight) - { - LUAX_PREPARE(L, Image); - state.Push(self->GetHeight()); - return 1; - } - - // width, height = image:GetSize() - LUAX_IMPL_METHOD(Image, _GetSize) - { - LUAX_PREPARE(L, Image); - int width = self->GetWidth(); - int height = self->GetHeight(); - state.Push(width); - state.Push(height); - return 2; - } - - // image:Render() - LUAX_IMPL_METHOD(Image, _Render) - { - LUAX_PREPARE(L, Image); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_index_buffer.cpp b/source/modules/asura-core/Graphics/binding/_index_buffer.cpp deleted file mode 100644 index 151dc98..0000000 --- a/source/modules/asura-core/Graphics/binding/_index_buffer.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "../IndexBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(IndexBuffer) - { - LUAX_REGISTER_METHODS(state, - { "New", _New } - ); - } - - LUAX_POSTPROCESS(IndexBuffer) - { - - } - - // IndexBuffer.New() - LUAX_IMPL_METHOD(IndexBuffer, _New) - { - LUAX_STATE(L); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_mesh2d.cpp b/source/modules/asura-core/Graphics/binding/_mesh2d.cpp deleted file mode 100644 index 4e3f426..0000000 --- a/source/modules/asura-core/Graphics/binding/_mesh2d.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "../mesh2d.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Mesh2D) - { - - } - - LUAX_POSTPROCESS(Mesh2D) - { - - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_shader.cpp b/source/modules/asura-core/Graphics/binding/_shader.cpp deleted file mode 100644 index 85fd388..0000000 --- a/source/modules/asura-core/Graphics/binding/_shader.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "../shader.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Shader) - { - LUAX_REGISTER_METHODS(state, - { "New", _New }, - { "Load", _Load }, - { "Update", _Update }, - { "HasUniform", _HasUniform }, - { "GetUniformLocation", _GetUniformLocation }, - { "SetBuiltInUniforms", _SetBuiltInUniforms }, - { "SetUniformFloat", _SetUniformFloat }, - { "SetUniformTexture", _SetUniformTexture }, - { "SetUniformVector2", _SetUniformVector2 }, - { "SetUniformVector3", _SetUniformVector3 }, - { "SetUniformVector4", _SetUniformVector4 }, - { "SetUniformColor", _SetUniformColor }, - { "SetBuiltInUniforms", _SetBuiltInUniforms } - ); - } - - LUAX_POSTPROCESS(Shader) - { - - } - - // Shader.New() - LUAX_IMPL_METHOD(Shader, _New) - { - LUAX_STATE(L); - - return 0; - } - - // shader:Load() - LUAX_IMPL_METHOD(Shader, _Load) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:Update() - LUAX_IMPL_METHOD(Shader, _Update) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:HasUniform() - LUAX_IMPL_METHOD(Shader, _HasUniform) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:GetUniformLocation() - LUAX_IMPL_METHOD(Shader, _GetUniformLocation) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetBuiltInUniforms() - LUAX_IMPL_METHOD(Shader, _SetBuiltInUniforms) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformFloat() - LUAX_IMPL_METHOD(Shader, _SetUniformFloat) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformTexture() - LUAX_IMPL_METHOD(Shader, _SetUniformTexture) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector2() - LUAX_IMPL_METHOD(Shader, _SetUniformVector2) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector3() - LUAX_IMPL_METHOD(Shader, _SetUniformVector3) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector4() - LUAX_IMPL_METHOD(Shader, _SetUniformVector4) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformColor() - LUAX_IMPL_METHOD(Shader, _SetUniformColor) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_sprite_batch.cpp b/source/modules/asura-core/Graphics/binding/_sprite_batch.cpp deleted file mode 100644 index 6b7d25c..0000000 --- a/source/modules/asura-core/Graphics/binding/_sprite_batch.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "../SpriteBatch.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(SpriteBatch) - { - - } - - LUAX_POSTPROCESS(SpriteBatch) - { - - } - - } -} diff --git a/source/modules/asura-core/Graphics/binding/_texture.cpp b/source/modules/asura-core/Graphics/binding/_texture.cpp deleted file mode 100644 index f5e5f17..0000000 --- a/source/modules/asura-core/Graphics/binding/_texture.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "../texture.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Texture) - { - LUAX_REGISTER_METHODS(state, - { "SetFilterMode", _SetFilterMode }, - { "SetWrapMode", _SetWrapMode }, - { "GetFilterMode", _GetFilterMode }, - { "GetWrapMode", _GetWrapMode }, - { "IsGenMipmap", _IsGenMipmap } - ); - } - - LUAX_POSTPROCESS(Texture) - { - LUAX_REGISTER_ENUM(state, "EColorFormat", - { "UNKNOWN", COLOR_FORMAT_UNKNOWN }, - { "RGBA8", COLOR_FORMAT_RGBA8 }, - { "RGBA32F", COLOR_FORMAT_RGBA32F } - ); - LUAX_REGISTER_ENUM(state, "EFilterMode", - { "NEAREST", FILTER_MODE_NEAREST }, - { "LINEAR", FILTER_MODE_LINEAR } - ); - LUAX_REGISTER_ENUM(state, "EWrapMode", - { "REPEAT", WRAP_MODE_REPEAT }, - { "MIRROR", WRAP_MODE_MIRROR }, - { "CLAMPTOEDGE", WRAP_MODE_CLAMPTOEDGE }, - { "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER } - ); - - } - - // texture:SetFilterMode(minFilter, magFilter) - LUAX_IMPL_METHOD(Texture, _SetFilterMode) - { - LUAX_PREPARE(L, Texture); - FilterMode min = (FilterMode)state.CheckValue(2); - FilterMode mag = (FilterMode)state.CheckValue(3); - self->SetFilterMode(min, mag); - return 0; - } - - // texture:SetWrapMode(wrap_mode) - LUAX_IMPL_METHOD(Texture, _SetWrapMode) - { - LUAX_PREPARE(L, Texture); - WrapMode wrap_mode = (WrapMode)state.CheckValue(2); - self->SetWrapMode(wrap_mode); - return 0; - } - - // min, mag = texture:GetFilterMode() - LUAX_IMPL_METHOD(Texture, _GetFilterMode) - { - LUAX_PREPARE(L, Texture); - state.Push((int)self->m_MinFilter); - state.Push((int)self->m_MagFilter); - return 2; - } - - // wrapmode= texture:GetWrapMode() - LUAX_IMPL_METHOD(Texture, _GetWrapMode) - { - LUAX_PREPARE(L, Texture); - state.Push((int)self->m_WrapMode); - return 1; - } - - // texture:IsGenMipmap() - LUAX_IMPL_METHOD(Texture, _IsGenMipmap) - { - LUAX_PREPARE(L, Texture); - state.Push(self->IsGenMipmap()); - return 1; - } - - } -} \ No newline at end of file diff --git a/source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp b/source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp deleted file mode 100644 index 8ed487b..0000000 --- a/source/modules/asura-core/Graphics/binding/_vertex_buffer.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "../VertexBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(VertexBuffer) - { - LUAX_REGISTER_METHODS(state, - { "New", _New } - ); - } - - LUAX_POSTPROCESS(VertexBuffer) - { - - } - - // vbo = VertexBuffer.New(usage, data_type, count) - LUAX_IMPL_METHOD(VertexBuffer, _New) - { - LUAX_STATE(L); - - BufferUsage usage = (BufferUsage)state.CheckValue(1); - BufferDataType datatype = (BufferDataType)state.CheckValue(2); - uint count = state.CheckValue(3); - - VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype)); - vbo->PushLuaxUserdata(state); - - return 1; - } - - } -} diff --git a/source/modules/asura-core/Input/InputDevice.h b/source/modules/asura-core/Input/InputDevice.h index 2b3ff9b..42dfe43 100644 --- a/source/modules/asura-core/Input/InputDevice.h +++ b/source/modules/asura-core/Input/InputDevice.h @@ -16,6 +16,7 @@ namespace_begin(AsuraEngine) namespace_begin(Input) +// ´Ó²Ù×÷ϵͳ»ñµÃÊäÈë class InputDevice ASURA_FINAL { public: @@ -35,7 +36,7 @@ public: LRESULT OnInput(HWND window, UINT message, WPARAM wParam, LPARAM lParam); LRESULT OnDeviceChange(LPCWSTR name, bool add); - static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos); + static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos); #elif ASURA_RUNNER @@ -52,7 +53,7 @@ protected: bool UpdateState(); - MouseState m_Mouse; + MouseState m_Mouse; KeyboardState m_Keyboard; JoystickState m_Joysticks; diff --git a/source/modules/asura-core/Input/InputEvent.h b/source/modules/asura-core/Input/InputEvent.h index c643b75..fc7b9f6 100644 --- a/source/modules/asura-core/Input/InputEvent.h +++ b/source/modules/asura-core/Input/InputEvent.h @@ -32,7 +32,7 @@ struct InputEvent LRESULT OnInput(HWND window, UINT message, WPARAM wParam, LPARAM lParam); LRESULT OnDeviceChange(LPCWSTR name, bool add); - static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, AEMath::Vector2f& newPos); + static bool ConvertPositionToClientAreaCoord(HWND activeWindow, POINT position, Vector2f& newPos); #elif ASURA_RUNNER diff --git a/source/modules/asura-core/Input/InputManager.cpp b/source/modules/asura-core/Input/InputManager.cpp index cec1b36..03200f5 100644 --- a/source/modules/asura-core/Input/InputManager.cpp +++ b/source/modules/asura-core/Input/InputManager.cpp @@ -82,12 +82,12 @@ bool InputManager::GetKeyUp(int key) } -const AEMath::Vector2f& InputManager::GetMouseDelta() +const Vector2f& InputManager::GetMouseDelta() { return m_MouseDelta; } -const AEMath::Vector2f& InputManager::GetMousePosition() +const Vector2f& InputManager::GetMousePosition() { return m_MousePos; } @@ -114,11 +114,11 @@ void InputManager::SetKeyState(int key, bool state) m_CurrentKeyState[key] = state; } -void InputManager::SetMouseDelta(const AEMath::Vector2f& delta) +void InputManager::SetMouseDelta(const Vector2f& delta) { } -void InputManager::SetMousePosition(const AEMath::Vector2f& pos) +void InputManager::SetMousePosition(const Vector2f& pos) { } diff --git a/source/modules/asura-core/Input/InputManager.h b/source/modules/asura-core/Input/InputManager.h index 3c44745..4071b66 100644 --- a/source/modules/asura-core/Input/InputManager.h +++ b/source/modules/asura-core/Input/InputManager.h @@ -40,15 +40,15 @@ public: bool GetKeyDown(int key); bool GetKeyUp(int key); - const AEMath::Vector2f& GetMouseDelta(); - const AEMath::Vector2f& GetMousePosition(); + const Vector2f& GetMouseDelta(); + const Vector2f& GetMousePosition(); float GetJoystickPosition(); void setJoystickPosition(); void SetKeyState(int key, bool state); - void SetMouseDelta(const AEMath::Vector2f& delta); - void SetMousePosition(const AEMath::Vector2f& pos); + void SetMouseDelta(const Vector2f& delta); + void SetMousePosition(const Vector2f& pos); void SetMouseButton(int button, bool enabled); void ProcessInput(); @@ -62,8 +62,8 @@ private: std::vector m_Axis; - AEMath::Vector2f m_MouseDelta; - AEMath::Vector2f m_MousePos; + Vector2f m_MouseDelta; + Vector2f m_MousePos; bool m_MousePresent; @@ -72,7 +72,7 @@ private: std::string m_InputString; std::string m_CompositionString; - AEMath::Vector2f m_TextFieldCursorPos; + Vector2f m_TextFieldCursorPos; bool m_TextFieldInput; bool m_EatKeyPressOnTextFieldFocus; diff --git a/source/modules/asura-core/Mesh/Mesh2DData.h b/source/modules/asura-core/Mesh/Mesh2DData.h index 3e30a06..f041e05 100644 --- a/source/modules/asura-core/Mesh/Mesh2DData.h +++ b/source/modules/asura-core/Mesh/Mesh2DData.h @@ -21,9 +21,9 @@ namespace_begin(Mesh) /// struct Vertex { - AEMath::Vector2f position; ///< ×ø±ê + Vector2f position; ///< ×ø±ê AEGraphics::Color color; ///< ÑÕÉ« - AEMath::Vector2f texCoord[4]; ///< UVs + Vector2f texCoord[4]; ///< UVs }; /// diff --git a/source/modules/asura-core/font/ttf.cpp b/source/modules/asura-core/font/ttf.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-core/font/ttf.h b/source/modules/asura-core/font/ttf.h deleted file mode 100644 index b83cf76..0000000 --- a/source/modules/asura-core/font/ttf.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _ASURA_TTF_H_ -#define _ASURA_TTF_H_ - -namespace AsuraEngine -{ - namespace Text - { - - class TTF - { - - }; - - } -} - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/font/utf.hpp b/source/modules/asura-core/font/utf.hpp deleted file mode 100644 index 59f62ed..0000000 --- a/source/modules/asura-core/font/utf.hpp +++ /dev/null @@ -1,720 +0,0 @@ -#ifndef _ASURA_UTF_HPP_ -#define _ASURA_UTF_HPP_ - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include -#include -#include -#include - -namespace AsuraEngine -{ - namespace Text - { - - template - class Utf; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-8 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<8> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-8 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-8 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-8 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-8. - /// - /// \param input Codepoint to encode as UTF-8 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-8 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint8 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-8 character - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-8 sequence - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element, thus the - /// total size can be different from (begin - end). - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-8 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-8 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-8 characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - }; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-16 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<16> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-16 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-16 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-16 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-16. - /// - /// \param input Codepoint to encode as UTF-16 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-16 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint16 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-16 character - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-16 sequence - /// - /// This function is necessary for multi-elements encodings, as - /// a single character may use more than 1 storage element, thus the - /// total size can be different from (begin - end). - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-16 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-16 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-16 characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - }; - - //////////////////////////////////////////////////////////// - /// \brief Specialization of the Utf template for UTF-32 - /// - //////////////////////////////////////////////////////////// - template <> - class Utf<32> - { - public: - - //////////////////////////////////////////////////////////// - /// \brief Decode a single UTF-32 character - /// - /// Decoding a character means finding its unique 32-bits - /// code (called the codepoint) in the Unicode standard. - /// For UTF-32, the character value is the same as the codepoint. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Codepoint of the decoded UTF-32 character - /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character - /// - /// Encoding a character means converting a unique 32-bits - /// code (called the codepoint) in the target encoding, UTF-32. - /// For UTF-32, the codepoint is the same as the character value. - /// - /// \param input Codepoint to encode as UTF-32 - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to UTF-32 (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out Encode(Uint32 input, Out output, Uint32 replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Advance to the next UTF-32 character - /// - /// This function is trivial for UTF-32, which can store - /// every character in a single storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static In Next(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Count the number of characters of a UTF-32 sequence - /// - /// This function is trivial for UTF-32, which can store - /// every character in a single storage element. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// - /// \return Iterator pointing to one past the last read element of the input sequence - /// - //////////////////////////////////////////////////////////// - template - static std::size_t Count(In begin, In end); - - //////////////////////////////////////////////////////////// - /// \brief Convert an ANSI characters range to UTF-32 - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert a wide characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromWide(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out FromLatin1(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-32 characters range to ANSI characters - /// - /// The current global locale will be used by default, unless you - /// pass a custom one in the \a locale parameter. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-32 characters range to wide characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToLatin1(In begin, In end, Out output, char replacement = 0); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-8 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf8(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-16 - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf16(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Convert a UTF-32 characters range to UTF-32 - /// - /// This functions does nothing more than a direct copy; - /// it is defined only to provide the same interface as other - /// specializations of the sf::Utf<> template, and allow - /// generic code to be written on top of it. - /// - /// \param begin Iterator pointing to the beginning of the input sequence - /// \param end Iterator pointing to the end of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out ToUtf32(In begin, In end, Out output); - - //////////////////////////////////////////////////////////// - /// \brief Decode a single ANSI character to UTF-32 - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param input Input ANSI character - /// \param locale Locale to use for conversion - /// - /// \return Converted character - /// - //////////////////////////////////////////////////////////// - template - static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Decode a single wide character to UTF-32 - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param input Input wide character - /// - /// \return Converted character - /// - //////////////////////////////////////////////////////////// - template - static Uint32 DecodeWide(In input); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character to ANSI - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param codepoint Iterator pointing to the beginning of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement if the input character is not convertible to ANSI (use 0 to skip it) - /// \param locale Locale to use for conversion - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale()); - - //////////////////////////////////////////////////////////// - /// \brief Encode a single UTF-32 character to wide - /// - /// This function does not exist in other specializations - /// of sf::Utf<>, it is defined for convenience (it is used by - /// several other conversion functions). - /// - /// \param codepoint Iterator pointing to the beginning of the input sequence - /// \param output Iterator pointing to the beginning of the output sequence - /// \param replacement Replacement if the input character is not convertible to wide (use 0 to skip it) - /// - /// \return Iterator to the end of the output sequence which has been written - /// - //////////////////////////////////////////////////////////// - template - static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0); - }; - -#include "Utf.inc" - - // Make typedefs to get rid of the template syntax - typedef Utf<8> Utf8; - typedef Utf<16> Utf16; - typedef Utf<32> Utf32; - - } // namespace sf - -} - - -#endif // SFML_UTF_HPP diff --git a/source/modules/asura-core/graphics/binding/_canvas.cpp b/source/modules/asura-core/graphics/binding/_canvas.cpp deleted file mode 100644 index 44841f5..0000000 --- a/source/modules/asura-core/graphics/binding/_canvas.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "../Canvas.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Canvas) - { - LUAX_REGISTER_METHODS(state, - { "SetSize", _SetSize }, - { "Bind", _Bind }, - { "Unbind", _Unbind } - ); - } - - LUAX_POSTPROCESS(Canvas) - { - - } - - // canvas:SetSize() - LUAX_IMPL_METHOD(Canvas, _SetSize) - { - LUAX_PREPARE(L, Canvas); - return 0; - - } - - // canvas:Bind() - LUAX_IMPL_METHOD(Canvas, _Bind) - { - LUAX_PREPARE(L, Canvas); - - return 0; - } - - // canvas:Unbind() - LUAX_IMPL_METHOD(Canvas, _Unbind) - { - LUAX_PREPARE(L, Canvas); - return 0; - - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_color.cpp b/source/modules/asura-core/graphics/binding/_color.cpp deleted file mode 100644 index 008d9c2..0000000 --- a/source/modules/asura-core/graphics/binding/_color.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "../Color.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - -LUAX_REGISTRY(Color) -{ - LUAX_REGISTER_METHODS(state, - { "ToColor32", _ToColor32 }, - { "SetColor", _SetColor }, - { "GetColor", _GetColor }, - { "GetR", _GetR }, - { "GetG", _GetG }, - { "GetB", _GetB }, - { "GetA", _GetA }, - { "__eq", ___eq }, - { "__add", ___add }, - { "__sub", ___sub }, - { "__mul", ___mul }, - { "__div", ___div } - ); -} - -LUAX_POSTPROCESS(Color) -{ - -} - -// color:ToColor32() -LUAX_IMPL_METHOD(Color, _ToColor32) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:SetColor() -LUAX_IMPL_METHOD(Color, _SetColor) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetColor() -LUAX_IMPL_METHOD(Color, _GetColor) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetR() -LUAX_IMPL_METHOD(Color, _GetR) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetG() -LUAX_IMPL_METHOD(Color, _GetG) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetB() -LUAX_IMPL_METHOD(Color, _GetB) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:GetA() -LUAX_IMPL_METHOD(Color, _GetA) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__eq() -LUAX_IMPL_METHOD(Color, ___eq) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__add() -LUAX_IMPL_METHOD(Color, ___add) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__sub() -LUAX_IMPL_METHOD(Color, ___sub) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__mul() -LUAX_IMPL_METHOD(Color, ___mul) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -// color:__div() -LUAX_IMPL_METHOD(Color, ___div) -{ - LUAX_PREPARE(L, Color); - - return 0; -} - -} -} \ No newline at end of file diff --git a/source/modules/asura-core/graphics/binding/_color32.cpp b/source/modules/asura-core/graphics/binding/_color32.cpp deleted file mode 100644 index 7613361..0000000 --- a/source/modules/asura-core/graphics/binding/_color32.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "../Color32.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Color32) - { - LUAX_REGISTER_METHODS(state, - { "ToColor", _ToColor }, - { "GetRed", _GetRed }, - { "GetGreen", _GetGreen }, - { "GetBlue", _GetBlue }, - { "GetAlpha", _GetAlpha } - ); - } - - LUAX_POSTPROCESS(Color32) - { - - } - - // color32:ToColor() - LUAX_IMPL_METHOD(Color32, _ToColor) - { - LUAX_PREPARE(L, Color32); - return 0; - - } - - // color32:GetRed() - LUAX_IMPL_METHOD(Color32, _GetRed) - { - LUAX_PREPARE(L, Color32); - return 0; - } - - // color32:GetGreen() - LUAX_IMPL_METHOD(Color32, _GetGreen) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - // color32:GetBlue() - LUAX_IMPL_METHOD(Color32, _GetBlue) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - // color32:GetAlpha() - LUAX_IMPL_METHOD(Color32, _GetAlpha) - { - LUAX_PREPARE(L, Color32); - - return 0; - } - - } -} - \ No newline at end of file diff --git a/source/modules/asura-core/graphics/binding/_gfx_device.cpp b/source/modules/asura-core/graphics/binding/_gfx_device.cpp deleted file mode 100644 index f6c2004..0000000 --- a/source/modules/asura-core/graphics/binding/_gfx_device.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include "../GfxDevice.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(GfxDevice) - { - LUAX_REGISTER_METHODS(state, - { "SetMatrixMode", _SetMatrixMode }, - { "GetMatrixMode", _GetMatrixMode }, - { "PushMatrix", _PushMatrix }, - { "PopMatrix", _PopMatrix }, - { "LoadIdentity", _LoadIdentity }, - { "Rotate", _Rotate }, - { "Translate", _Translate }, - { "Scale", _Scale }, - { "Ortho", _Ortho }, - { "GetMatrixDepth", _GetMatrixDepth }, - { "GetMatrixIndex", _GetMatrixIndex }, - { "UseShader", _UseShader }, - { "UnuseShader", _UnuseShader } - ); - } - - LUAX_POSTPROCESS(GfxDevice) - { - LUAX_REGISTER_ENUM(state, "EMatrixMode", - { "PROJECTION", MATRIX_MODE_PROJECTION }, - { "0", 0 }, - { "MODEL", MATRIX_MODE_MODEL }, - { "1", 1 }, - { "VIEW", MATRIX_MODE_VIEW }, - { "2", 2 } - ); - LUAX_REGISTER_ENUM(state, "EGLParams", - { "MAX_TEXTURE_UNIT", GL_PARAM_MAX_TEXTURE_UNIT }, - { "1", 1 } - ); - - } - - // gfxdevice:SetMatrixMode() - LUAX_IMPL_METHOD(GfxDevice, _SetMatrixMode) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixMode() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixMode) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:PushMatrix() - LUAX_IMPL_METHOD(GfxDevice, _PushMatrix) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:PopMatrix() - LUAX_IMPL_METHOD(GfxDevice, _PopMatrix) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:LoadIdentity() - LUAX_IMPL_METHOD(GfxDevice, _LoadIdentity) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Rotate() - LUAX_IMPL_METHOD(GfxDevice, _Rotate) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Translate() - LUAX_IMPL_METHOD(GfxDevice, _Translate) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Scale() - LUAX_IMPL_METHOD(GfxDevice, _Scale) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:Ortho() - LUAX_IMPL_METHOD(GfxDevice, _Ortho) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixDepth() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixDepth) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:GetMatrixIndex() - LUAX_IMPL_METHOD(GfxDevice, _GetMatrixIndex) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:UseShader() - LUAX_IMPL_METHOD(GfxDevice, _UseShader) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - // gfxdevice:UnuseShader() - LUAX_IMPL_METHOD(GfxDevice, _UnuseShader) - { - LUAX_PREPARE(L, GfxDevice); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp b/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp deleted file mode 100644 index 8c39a59..0000000 --- a/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -#include - -#include "../image.h" -#include "../GPUBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(GPUBuffer) - { - LUAX_REGISTER_METHODS(state, - { "Fill", _Fill }, - { "GetSize", _GetSize }, - { "GetCount", _GetCount } - ); - } - - LUAX_POSTPROCESS(GPUBuffer) - { - LUAX_REGISTER_ENUM(state, "EBufferType", - { "VERTEX", BUFFER_TYPE_VERTEX }, - { "INDEX", BUFFER_TYPE_INDEX } - ); - LUAX_REGISTER_ENUM(state, "EBufferUsage", - { "STREAM", BUFFER_USAGE_STREAM }, - { "DYNAMIC", BUFFER_USAGE_DYNAMIC }, - { "STATIC", BUFFER_USAGE_STATIC } - ); - LUAX_REGISTER_ENUM(state, "EBufferDataType", - { "INT", BUFFER_DATA_TYPE_INT }, - { "FLOAT", BUFFER_DATA_TYPE_FLOAT }, - { "UNSIGNED_BYTE", BUFFER_DATA_TYPE_UNSIGNED_BYTE } - ); - - } - - // buffer = GPUBuffer.New(bufferType, bufferUsage, bufferDataType, size) - // buffer = GPUBuffer.New(image) - // buffer = GPUBuffer.New(mesh2d) - // buffer = GPUBuffer.New(canvas) - // buffer = GPUBuffer.New(shape) - //LUAX_IMPL_METHOD(GPUBuffer, _New) - //{ - // LUAX_STATE(L); - - // return 0; - //} - - // gpubuffer:Fill({data_unit_list}, offseti) - // data_unit_list £º´æ·ÅÊý¾ÝµÄtable - // offseti : ¿ªÊ¼¸²¸ÇµÄµØ·½ËùÔÚµÄË÷Òý(´Ó0¿ªÊ¼£© - LUAX_IMPL_METHOD(GPUBuffer, _Fill) - { - LUAX_PREPARE(L, GPUBuffer); - - // ʹÓÃbuffer¶ÔÓ¦µÄÀàÐÍÊý¾ÝÐÞ¸Äbuffer£¬ÔÚµÚÒ»´Îµ÷ÓÃʱ»á³õʼ»¯size´óСµÄbuffer£¬È»ºóÌî³ä¡£ - int offset = state.GetValue(3, 0); - int count = lua_objlen(L, 2); - int size = count * self->GetDataTypeSize(); - byte* data = (byte*)malloc(size); - int unit = self->GetDataTypeSize(); - int i = 1; - lua_rawgeti(L, 2, i); - while (!lua_isnil(L, -1)) - { - switch (self->m_DataType) - { - case GL_INT: - { - int n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - case GL_FLOAT: - { - float n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - case GL_UNSIGNED_BYTE: - { - unsigned char n = state.CheckValue(-1); - memcpy(data + (i - 1)*unit, &n, unit); - break; - } - } - state.Pop(1); // value - lua_rawgeti(L, 2, ++i); - } - state.Pop(); // nil - - self->Fill(data, size, offset * unit); - - free(data); - return 0; - } - - // gpubuffer:GetSize() - LUAX_IMPL_METHOD(GPUBuffer, _GetSize) - { - LUAX_PREPARE(L, GPUBuffer); - state.Push(self->m_Size); - return 0; - } - - LUAX_IMPL_METHOD(GPUBuffer, _GetCount) - { - LUAX_PREPARE(L, GPUBuffer); - state.Push(self->m_Size / self->GetDataTypeSize()); - return 0; - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_image.cpp b/source/modules/asura-core/graphics/binding/_image.cpp deleted file mode 100644 index 0e4cb16..0000000 --- a/source/modules/asura-core/graphics/binding/_image.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "../image.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Image) - { - LUAX_INHERIT(state, Texture); - - LUAX_REGISTER_METHODS(state, - { "New", _New }, - { "GetWidth", _GetWidth }, - { "GetHeight", _GetHeight }, - { "GetSize", _GetSize }, - { "Render", _Render } - ); - } - - LUAX_POSTPROCESS(Image) - { - } - - // image = Image.New() - LUAX_IMPL_METHOD(Image, _New) - { - LUAX_STATE(L); - Image* img = new Image(); - img->PushLuaxUserdata(state); - return 1; - } - - // width = image:GetWidth() - LUAX_IMPL_METHOD(Image, _GetWidth) - { - LUAX_PREPARE(L, Image); - state.Push(self->GetWidth()); - return 1; - } - - // height = image:GetHeight() - LUAX_IMPL_METHOD(Image, _GetHeight) - { - LUAX_PREPARE(L, Image); - state.Push(self->GetHeight()); - return 1; - } - - // width, height = image:GetSize() - LUAX_IMPL_METHOD(Image, _GetSize) - { - LUAX_PREPARE(L, Image); - int width = self->GetWidth(); - int height = self->GetHeight(); - state.Push(width); - state.Push(height); - return 2; - } - - // image:Render() - LUAX_IMPL_METHOD(Image, _Render) - { - LUAX_PREPARE(L, Image); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_index_buffer.cpp b/source/modules/asura-core/graphics/binding/_index_buffer.cpp deleted file mode 100644 index 151dc98..0000000 --- a/source/modules/asura-core/graphics/binding/_index_buffer.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "../IndexBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(IndexBuffer) - { - LUAX_REGISTER_METHODS(state, - { "New", _New } - ); - } - - LUAX_POSTPROCESS(IndexBuffer) - { - - } - - // IndexBuffer.New() - LUAX_IMPL_METHOD(IndexBuffer, _New) - { - LUAX_STATE(L); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_mesh2d.cpp b/source/modules/asura-core/graphics/binding/_mesh2d.cpp deleted file mode 100644 index 4e3f426..0000000 --- a/source/modules/asura-core/graphics/binding/_mesh2d.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "../mesh2d.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Mesh2D) - { - - } - - LUAX_POSTPROCESS(Mesh2D) - { - - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_shader.cpp b/source/modules/asura-core/graphics/binding/_shader.cpp deleted file mode 100644 index 85fd388..0000000 --- a/source/modules/asura-core/graphics/binding/_shader.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "../shader.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Shader) - { - LUAX_REGISTER_METHODS(state, - { "New", _New }, - { "Load", _Load }, - { "Update", _Update }, - { "HasUniform", _HasUniform }, - { "GetUniformLocation", _GetUniformLocation }, - { "SetBuiltInUniforms", _SetBuiltInUniforms }, - { "SetUniformFloat", _SetUniformFloat }, - { "SetUniformTexture", _SetUniformTexture }, - { "SetUniformVector2", _SetUniformVector2 }, - { "SetUniformVector3", _SetUniformVector3 }, - { "SetUniformVector4", _SetUniformVector4 }, - { "SetUniformColor", _SetUniformColor }, - { "SetBuiltInUniforms", _SetBuiltInUniforms } - ); - } - - LUAX_POSTPROCESS(Shader) - { - - } - - // Shader.New() - LUAX_IMPL_METHOD(Shader, _New) - { - LUAX_STATE(L); - - return 0; - } - - // shader:Load() - LUAX_IMPL_METHOD(Shader, _Load) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:Update() - LUAX_IMPL_METHOD(Shader, _Update) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:HasUniform() - LUAX_IMPL_METHOD(Shader, _HasUniform) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:GetUniformLocation() - LUAX_IMPL_METHOD(Shader, _GetUniformLocation) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetBuiltInUniforms() - LUAX_IMPL_METHOD(Shader, _SetBuiltInUniforms) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformFloat() - LUAX_IMPL_METHOD(Shader, _SetUniformFloat) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformTexture() - LUAX_IMPL_METHOD(Shader, _SetUniformTexture) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector2() - LUAX_IMPL_METHOD(Shader, _SetUniformVector2) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector3() - LUAX_IMPL_METHOD(Shader, _SetUniformVector3) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformVector4() - LUAX_IMPL_METHOD(Shader, _SetUniformVector4) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - // shader:SetUniformColor() - LUAX_IMPL_METHOD(Shader, _SetUniformColor) - { - LUAX_PREPARE(L, Shader); - - return 0; - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_sprite_batch.cpp b/source/modules/asura-core/graphics/binding/_sprite_batch.cpp deleted file mode 100644 index 6b7d25c..0000000 --- a/source/modules/asura-core/graphics/binding/_sprite_batch.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "../SpriteBatch.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(SpriteBatch) - { - - } - - LUAX_POSTPROCESS(SpriteBatch) - { - - } - - } -} diff --git a/source/modules/asura-core/graphics/binding/_texture.cpp b/source/modules/asura-core/graphics/binding/_texture.cpp deleted file mode 100644 index f5e5f17..0000000 --- a/source/modules/asura-core/graphics/binding/_texture.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "../texture.h" - -using namespace std; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(Texture) - { - LUAX_REGISTER_METHODS(state, - { "SetFilterMode", _SetFilterMode }, - { "SetWrapMode", _SetWrapMode }, - { "GetFilterMode", _GetFilterMode }, - { "GetWrapMode", _GetWrapMode }, - { "IsGenMipmap", _IsGenMipmap } - ); - } - - LUAX_POSTPROCESS(Texture) - { - LUAX_REGISTER_ENUM(state, "EColorFormat", - { "UNKNOWN", COLOR_FORMAT_UNKNOWN }, - { "RGBA8", COLOR_FORMAT_RGBA8 }, - { "RGBA32F", COLOR_FORMAT_RGBA32F } - ); - LUAX_REGISTER_ENUM(state, "EFilterMode", - { "NEAREST", FILTER_MODE_NEAREST }, - { "LINEAR", FILTER_MODE_LINEAR } - ); - LUAX_REGISTER_ENUM(state, "EWrapMode", - { "REPEAT", WRAP_MODE_REPEAT }, - { "MIRROR", WRAP_MODE_MIRROR }, - { "CLAMPTOEDGE", WRAP_MODE_CLAMPTOEDGE }, - { "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER } - ); - - } - - // texture:SetFilterMode(minFilter, magFilter) - LUAX_IMPL_METHOD(Texture, _SetFilterMode) - { - LUAX_PREPARE(L, Texture); - FilterMode min = (FilterMode)state.CheckValue(2); - FilterMode mag = (FilterMode)state.CheckValue(3); - self->SetFilterMode(min, mag); - return 0; - } - - // texture:SetWrapMode(wrap_mode) - LUAX_IMPL_METHOD(Texture, _SetWrapMode) - { - LUAX_PREPARE(L, Texture); - WrapMode wrap_mode = (WrapMode)state.CheckValue(2); - self->SetWrapMode(wrap_mode); - return 0; - } - - // min, mag = texture:GetFilterMode() - LUAX_IMPL_METHOD(Texture, _GetFilterMode) - { - LUAX_PREPARE(L, Texture); - state.Push((int)self->m_MinFilter); - state.Push((int)self->m_MagFilter); - return 2; - } - - // wrapmode= texture:GetWrapMode() - LUAX_IMPL_METHOD(Texture, _GetWrapMode) - { - LUAX_PREPARE(L, Texture); - state.Push((int)self->m_WrapMode); - return 1; - } - - // texture:IsGenMipmap() - LUAX_IMPL_METHOD(Texture, _IsGenMipmap) - { - LUAX_PREPARE(L, Texture); - state.Push(self->IsGenMipmap()); - return 1; - } - - } -} \ No newline at end of file diff --git a/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp b/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp deleted file mode 100644 index 8ed487b..0000000 --- a/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "../VertexBuffer.h" - -using namespace std; -using namespace Luax; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - - - LUAX_REGISTRY(VertexBuffer) - { - LUAX_REGISTER_METHODS(state, - { "New", _New } - ); - } - - LUAX_POSTPROCESS(VertexBuffer) - { - - } - - // vbo = VertexBuffer.New(usage, data_type, count) - LUAX_IMPL_METHOD(VertexBuffer, _New) - { - LUAX_STATE(L); - - BufferUsage usage = (BufferUsage)state.CheckValue(1); - BufferDataType datatype = (BufferDataType)state.CheckValue(2); - uint count = state.CheckValue(3); - - VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype)); - vbo->PushLuaxUserdata(state); - - return 1; - } - - } -} diff --git a/source/modules/asura-core/graphics/image.cpp b/source/modules/asura-core/graphics/image.cpp deleted file mode 100644 index 36d2478..0000000 --- a/source/modules/asura-core/graphics/image.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include - -#include "../CoreConfig.h" - -#include "Shader.h" -#include "Image.h" -#include "GfxDevice.h" - -using namespace AEFileSystem; -using namespace AEImage; - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -Image::Image() - : m_Width(0) - , m_Height(0) -{ -} - -Image::~Image() -{ -} - -bool Image::Load(ImageData* imgData) -{ - if (!imgData) return false; - - if (m_TexID == 0) - { - glGenTextures(1, &m_TexID); - if (m_TexID == 0) - throw Exception("OpenGL glGenTextures failed."); - } - - glBindTexture(GL_TEXTURE_2D, m_TexID); - imgData->Lock(); - int width = imgData->width; - int height = imgData->height; - TextureFormat tf = ConvertColorFormat(imgData->format); - glTexImage2D( - GL_TEXTURE_2D - , 0 - , tf.internalformat - , width, height - , 0 - , tf.externalformat - , tf.type - , imgData->pixels - ); - - m_Width = imgData->width; - m_Height = imgData->height; - imgData->Unlock(); - GLenum err = glGetError(); - if (err != GL_NO_ERROR) - throw Exception("OpenGL glTexImage2D cause error, error code=%d", err); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -bool Image::Load(ImageData* imgData, const AEMath::Vector2i& pos) -{ - if (!imgData) return false; - - glBindTexture(GL_TEXTURE_2D, m_TexID); - imgData->Lock(); - int width = imgData->width; - int height = imgData->height; - TextureFormat tf = ConvertColorFormat(imgData->format); - glTexSubImage2D( - GL_TEXTURE_2D - , 0 - , pos.x - , pos.y - , imgData->width - , imgData->height - , tf.externalformat - , tf.type - , imgData->pixels - ); - imgData->Unlock(); - GLenum err = glGetError(); - if (err != GL_NO_ERROR) - throw Exception("OpenGL glTexSubImage2D cause error, error code=%d", err); - glBindTexture(GL_TEXTURE_2D, 0); - - return true; -} - -uint32 Image::GetWidth() -{ - return m_Width; -} - -uint32 Image::GetHeight() -{ - return m_Height; -} - -namespace_end -namespace_end \ No newline at end of file diff --git a/source/modules/asura-core/graphics/image.h b/source/modules/asura-core/graphics/image.h deleted file mode 100644 index a76d06f..0000000 --- a/source/modules/asura-core/graphics/image.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _ASURA_ENGINE_IMAGE_H_ -#define _ASURA_ENGINE_IMAGE_H_ - -// asura modules -#include -#include -#include -#include -#include -#include - -// module -#include "../Image/ImageData.h" - -// folder -#include "Color.h" -#include "Color32.h" -#include "RenderState.h" -#include "GPUBuffer.h" -#include "Texture.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -class Image ASURA_FINAL : public AEScripting::Portable -{ -public: - - Image(); - ~Image(); - - bool Load(AEImage::ImageData* decodeData); - bool Load(AEImage::ImageData* decodeData, const AEMath::Vector2i& pos); - - uint GetWidth(); - uint GetHeight(); - - GPUBuffer* GenGPUBuffer(); - -private: - - uint32 m_Width, m_Height; - -luaxport: - - LUAX_DECL_FACTORY(Image, Texture); - - LUAX_DECL_METHOD(_New); - LUAX_DECL_METHOD(_Load); - LUAX_DECL_METHOD(_GetWidth); - LUAX_DECL_METHOD(_GetHeight); - LUAX_DECL_METHOD(_GetSize); - LUAX_DECL_METHOD(_GetPixel); - LUAX_DECL_METHOD(_Render); - -}; - -namespace_end -namespace_end - -namespace AEGraphics = AsuraEngine::Graphics; - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/graphics/mesh2d.cpp b/source/modules/asura-core/graphics/mesh2d.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/source/modules/asura-core/graphics/mesh2d.h b/source/modules/asura-core/graphics/mesh2d.h deleted file mode 100644 index 7a0f62e..0000000 --- a/source/modules/asura-core/graphics/mesh2d.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _ASURA_ENGINE_MESH2D_H__ -#define _ASURA_ENGINE_MESH2D_H__ - -// cpp -#include - -// asura modules -#include -#include - -// module -#include "../Mesh/Mesh2dData.h" - -// folder -#include "Color.h" -#include "VertexBuffer.h" -#include "IndexBuffer.h" - -namespace_begin(AsuraEngine) -namespace_begin(Graphics) - -/// -/// 2D mesh£¬ÓÃÓÚ×öһЩ¶¥µã¶¯»­¡£ -/// https://en.wikipedia.org/wiki/Polygon_mesh -/// -class Mesh2D ASURA_FINAL - : public Scripting::Portable -{ -public: - - Mesh2D(); - ~Mesh2D(); - - bool Load(AEMesh::Mesh2DData* data); - -private: - - VertexBuffer* m_VBO; ///< vertex buffer - IndexBuffer* m_IBO; ///< index buffer - -luaxport: - - LUAX_DECL_FACTORY(Mesh2D); - - LUAX_DECL_METHOD(_SetVertex); - -}; - -namespace_end -namespace_end - -#endif \ No newline at end of file diff --git a/source/modules/asura-core/graphics/shader.cpp b/source/modules/asura-core/graphics/shader.cpp index 329b3f1..56d638d 100644 --- a/source/modules/asura-core/graphics/shader.cpp +++ b/source/modules/asura-core/graphics/shader.cpp @@ -24,12 +24,12 @@ Shader::~Shader() void Shader::SetActive(Shader* shader) { - g_Device.SetActiveShader(shader); + g_GfxDevice.SetActiveShader(shader); } Shader* Shader::GetActive() { - return g_Device.GetActiveShader(); + return g_GfxDevice.GetActiveShader(); } bool Shader::Load(const string& vert, const string& frag) @@ -157,56 +157,56 @@ GLuint Shader::GetGLProgram() void Shader::SetUniformFloat(uint loc, float value) { - if(g_Device.GetActiveShader() == this) + if(g_GfxDevice.GetActiveShader() == this) glUniform1f(loc, value); } bool Shader::SetUniformTexture(uint loc, const Texture& texture) { - if (g_Device.GetActiveShader() != this) + if (g_GfxDevice.GetActiveShader() != this) return false; - g_Device.WipeError(); + g_GfxDevice.WipeError(); glActiveTexture(GL_TEXTURE0 + texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; GLint tex = texture.GetGLTexture(); glBindTexture(GL_TEXTURE_2D, tex); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; glUniform1i(loc, texUnit); - if (g_Device.HasError()) + if (g_GfxDevice.HasError()) return false; ++texUnit; } void Shader::SetUniformVector2(uint loc, const Math::Vector2f& vec2) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform2f(loc, vec2.x, vec2.y); } void Shader::SetUniformVector3(uint loc, const Math::Vector3f& vec3) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform3f(loc, vec3.x, vec3.y, vec3.z); } void Shader::SetUniformVector4(uint loc, const Math::Vector4f& vec4) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, vec4.x, vec4.y, vec4.z, vec4.w); } void Shader::SetUniformMatrix44(uint loc, const Math::Matrix44& mat) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniformMatrix4fv(loc, 1, GL_FALSE, mat.GetElements()); } void Shader::SetUniformColor(uint loc, const Color& color) { - if (g_Device.GetActiveShader() == this) + if (g_GfxDevice.GetActiveShader() == this) glUniform4f(loc, color.r, color.g, color.b, color.a); } diff --git a/source/modules/asura-core/graphics/shader.h b/source/modules/asura-core/graphics/shader.h index 615b028..6d7ef90 100644 --- a/source/modules/asura-core/graphics/shader.h +++ b/source/modules/asura-core/graphics/shader.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -23,10 +24,21 @@ namespace_begin(AsuraEngine) namespace_begin(Graphics) +enum ShaderChannel +{ + SHADER_CHANNEL_NONE = -1, + SHADER_CHANNEL_VERTEX = 0, // Vertex (vector3) + SHADER_CHANNEL_NORMAL, // Normal (vector3) + SHADER_CHANNEL_COLOR, // Vertex color + SHADER_CHANNEL_TEXCOORD0, // UV set 0 (vector2) + SHADER_CHANNEL_TEXCOORD1, // UV set 1 (vector2) + SHADER_CHANNEL_TANGENT, // Tangent (vector4) + SHADER_CHANNEL_COUNT, // Keep this last! +}; + /// -/// Ò»¸öshaderÊÇÒ»¸öÔÚ²ÄÖʼ乲ÏíµÄ³ÌÐò¡£Shader±¾Éí²»±£´æuniformsºÍ¶¥µãÊý¾Ý£¬Ö»ÌṩÉèÖà uniformsºÍuse×ÅÉ« -/// Æ÷µÄ·½·¨¡£±à¼­Æ÷Õë¶Ôÿ¸öshader£¬»áͨ¹ýshader´úÂëÕÒµ½ÉùÃ÷µÄuniforms±äÁ¿£¬²¢±©Â¶¸øframeworkµÄmaterial -/// ÉèÖᣠ+/// Ò»¸öshaderÊÇÒ»¸öÔÚ²ÄÖʼ乲ÏíµÄ³ÌÐò¡£Shader±¾Éí²»±£´æuniformsºÍ¶¥µãÊý¾Ý£¬Ö»ÌṩÉèÖà uniformsºÍuse×ÅÉ«Æ÷µÄ·½·¨¡£ +/// ±à¼­Æ÷Õë¶Ôÿ¸öshader£¬»áͨ¹ýshader´úÂëÕÒµ½ÉùÃ÷µÄuniforms±äÁ¿£¬²¢±©Â¶¸øframeworkµÄmaterialÉèÖᣠ/// class Shader ASURA_FINAL : public Scripting::Portable @@ -64,10 +76,10 @@ public: bool SetUniformTexture(uint loc, const Texture& texture); float GetUniformFloat(uint loc); - AEMath::Vector2f GetUniformVector2(uint loc); - AEMath::Vector3f GetUniformVector3(uint loc); - AEMath::Vector4f GetUniformVector4s(uint loc); - AEMath::Matrix44 GetUniformMatrix44(uint loc); + Vector2f GetUniformVector2(uint loc); + Vector3f GetUniformVector3(uint loc); + Vector4f GetUniformVector4s(uint loc); + Matrix44 GetUniformMatrix44(uint loc); GLuint GetGLProgram(); @@ -109,6 +121,7 @@ luaxport: }; +// GPU program typedef Shader GpuProgram; namespace_end diff --git a/source/modules/asura-core/graphics/texture.h b/source/modules/asura-core/graphics/texture.h index 76b9a8f..572fad4 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -3,6 +3,7 @@ #include #include +#include #include "../CoreConfig.h" @@ -14,6 +15,17 @@ namespace_begin(Graphics) class RenderTarget; +/// ͼƬÊý¾Ý +class ImageData +{ +public: + uint8* GetData(); +private: + int m_Format; + uint8* m_ImageData; + Vector2i m_ImageSize; +}; + /// UV²ÉÑù·½Ê½ enum WrapMode { @@ -34,8 +46,8 @@ enum FilterMode enum ColorFormat { COLOR_FORMAT_UNKNOWN, - COLOR_FORMAT_RGBA8, ///< RGBA¶¼ÊÇ8bits int - COLOR_FORMAT_RGBA32F, ///< RGBA¶¼ÊÇ32bits float + COLOR_FORMAT_RGBA8, + COLOR_FORMAT_RGBA32F, }; /// ÎÆÀí¸ñʽ£¬GPUÄÚ²¿ºÍCPUÍⲿ¸ñʽ @@ -50,11 +62,14 @@ struct TextureFormat /// 2DÎÆÀí³éÏóÀ࣬ÔÚ2d meshºÍrender targetÖб»Ê¹Óá£TextureµÄäÖȾԭµãÔÚ×óÉϽǣ¬ÓÎÏ·ÀïÃæµÄÉϲã»áÒԵѿ¨¶û /// ×ø±êϵΪ±ê×¼¡£ÔÚEditorÀïÃæ½çÃæºÍ×é¼þÒ²ÊÇÒÔ×óÉϽÇΪԭµã£¬ÕâÑùÊÇΪÁË·½±ã¡£ /// -ASURA_ABSTRACT class Texture : public AEScripting::Object +class Texture : public AEScripting::Object { public: - LUAX_DECL_ABSTRACT_FACTORY(Texture); + LUAX_DECL_FACTORY(Texture); + + // Texture generator + static Texture* GenerateTexture(); Texture(); virtual ~Texture(); @@ -67,9 +82,12 @@ public: void GetFilterMode(); void GetWrapMode(); - /// Èç¹ûÉèÖÃU»òV·½ÏòfilterΪ bool IsGenMipmap(); + int GetWidth(); + int GetHeight(); + Vector2i GetSize(); + protected: /// ת»»color formatΪtexture format¡£ @@ -79,7 +97,12 @@ protected: FilterMode m_MinFilter; FilterMode m_MagFilter; WrapMode m_WrapMode; + int m_UsageMode; bool m_IsGenMipmap; + Vector2f m_TexelSize; + Vector2f m_UVScale; + +luaxport: LUAX_DECL_ENUM(ColorFormat, 1); LUAX_DECL_ENUM(FilterMode, 1); @@ -90,11 +113,12 @@ protected: LUAX_DECL_METHOD(_GetFilterMode); LUAX_DECL_METHOD(_GetWrapMode); LUAX_DECL_METHOD(_IsGenMipmap); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetSize); }; -typedef Texture Drawable; - namespace_end namespace_end diff --git a/source/tests/win32/01-window/03_sub_menu.cpp b/source/tests/win32/01-window/03_sub_menu.cpp index fed841d..9c4ee85 100644 --- a/source/tests/win32/01-window/03_sub_menu.cpp +++ b/source/tests/win32/01-window/03_sub_menu.cpp @@ -28,7 +28,7 @@ void AddMenus(HWND); HWND wnd; HWND wnd2; -AEMath::Recti viewport; +Recti viewport; string vert = R"( @@ -172,16 +172,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, case WM_SIZE: { - if (g_Device.Inited()) + if (g_GfxDevice.Inited()) { RECT rect; GetClientRect(hwnd, &rect); viewport.Set(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); - g_Device.SetViewport(viewport); + g_GfxDevice.SetViewport(viewport); } } case WM_PAINT: - if (!g_Device.Inited()) + if (!g_GfxDevice.Inited()) break; glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); @@ -206,28 +206,28 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, { int imgLoc = shader->GetUniformLocation("img"); - int code = g_Device.GetError(); - g_Device.SetActiveShader(shader); + int code = g_GfxDevice.GetError(); + g_GfxDevice.SetActiveShader(shader); shader->SetUniformTexture(imgLoc, *img); - g_Device.SetMatrixMode(MATRIX_MODE_PROJECTION); - g_Device.LoadIdentity(); - g_Device.Ortho(0, viewport.w, viewport.h, 0, -1, 1); - g_Device.SetMatrixMode(MATRIX_MODE_MODEL); - g_Device.LoadIdentity(); - g_Device.Translate(100, 100); - shader->SetUniformMatrix44(locs.m, g_Device.GetMatrix(MATRIX_MODE_MODEL)); - shader->SetUniformMatrix44(locs.v, g_Device.GetMatrix(MATRIX_MODE_VIEW)); - shader->SetUniformMatrix44(locs.p, g_Device.GetMatrix(MATRIX_MODE_PROJECTION)); + g_GfxDevice.SetMatrixMode(MATRIX_MODE_PROJECTION); + g_GfxDevice.LoadIdentity(); + g_GfxDevice.Ortho(0, viewport.w, viewport.h, 0, -1, 1); + g_GfxDevice.SetMatrixMode(MATRIX_MODE_MODEL); + g_GfxDevice.LoadIdentity(); + g_GfxDevice.Translate(100, 100); + shader->SetUniformMatrix44(locs.m, g_GfxDevice.GetMatrix(MATRIX_MODE_MODEL)); + shader->SetUniformMatrix44(locs.v, g_GfxDevice.GetMatrix(MATRIX_MODE_VIEW)); + shader->SetUniformMatrix44(locs.p, g_GfxDevice.GetMatrix(MATRIX_MODE_PROJECTION)); shader->SetAttribute(locs.pos, vb, 0, 4); shader->SetAttribute(locs.tex, vb, 2, 4); - g_Device.SetDrawColor(1, 1, 0, 1); - shader->SetUniformColor(locs.color, g_Device.GetDrawColor()); + g_GfxDevice.SetDrawColor(1, 1, 0, 1); + shader->SetUniformColor(locs.color, g_GfxDevice.GetDrawColor()); //glLineWidth(1); - g_Device.DrawArrays(GL_LINE_STRIP, 0, 5); - //g_Device.DrawArrays(GL_TRIANGLE_STRIP, 0, 4); + g_GfxDevice.DrawArrays(GL_LINE_STRIP, 0, 5); + //g_GfxDevice.DrawArrays(GL_TRIANGLE_STRIP, 0, 4); shader->DisableAttribute(locs.pos); shader->DisableAttribute(locs.tex); - g_Device.SetActiveShader(NULL); + g_GfxDevice.SetActiveShader(NULL); } glFlush(); BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); @@ -263,7 +263,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, RECT rect; GetWindowRect(hwnd, &rect); viewport.Set(0, 0, rect.right - rect.left, rect.bottom - rect.top); - if (!g_Device.Init(viewport)) + if (!g_GfxDevice.Init(viewport)) return 0; imgdata->Decode(db); -- cgit v1.1-26-g67d0