Added a Sprite class to render 2D things
The sprite inherits from Poseable. It is intended to allow for pure 2D rendering or integration of sprites/particles into 3D scenes. Eventually an ImageScene should be created to test out the image loading, sprite movement and rotation, and 2D camera functionality for the builtin engine.
This commit is contained in:
parent
07a781c075
commit
a8abb4afc9
@ -1,11 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ImageLoaderImage.h"
|
#include <vector>
|
||||||
|
|
||||||
namespace charcoal
|
namespace charcoal
|
||||||
{
|
{
|
||||||
namespace image_loader
|
namespace image_loader
|
||||||
{
|
{
|
||||||
|
struct ImageRGBA
|
||||||
|
{
|
||||||
|
std::vector<unsigned char> data;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
};
|
||||||
|
|
||||||
ImageRGBA load_file(const std::string& filename);
|
ImageRGBA load_file(const std::string& filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace charcoal
|
|
||||||
{
|
|
||||||
namespace image_loader
|
|
||||||
{
|
|
||||||
struct ImageRGBA
|
|
||||||
{
|
|
||||||
std::vector<unsigned char> data;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -182,6 +182,7 @@
|
|||||||
<ClCompile Include="Shader.cpp" />
|
<ClCompile Include="Shader.cpp" />
|
||||||
<ClCompile Include="ShaderProgram.cpp" />
|
<ClCompile Include="ShaderProgram.cpp" />
|
||||||
<ClCompile Include="Sampler.cpp" />
|
<ClCompile Include="Sampler.cpp" />
|
||||||
|
<ClCompile Include="Sprite.cpp" />
|
||||||
<ClCompile Include="stdafx.cpp">
|
<ClCompile Include="stdafx.cpp">
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||||
@ -211,7 +212,6 @@
|
|||||||
<ClInclude Include="Exception.h" />
|
<ClInclude Include="Exception.h" />
|
||||||
<ClInclude Include="FPS.h" />
|
<ClInclude Include="FPS.h" />
|
||||||
<ClInclude Include="ImageLoader.h" />
|
<ClInclude Include="ImageLoader.h" />
|
||||||
<ClInclude Include="ImageLoaderImage.h" />
|
|
||||||
<ClInclude Include="LitBatch.h" />
|
<ClInclude Include="LitBatch.h" />
|
||||||
<ClInclude Include="LitScene.h" />
|
<ClInclude Include="LitScene.h" />
|
||||||
<ClInclude Include="LitShaderProgram.h" />
|
<ClInclude Include="LitShaderProgram.h" />
|
||||||
@ -228,6 +228,8 @@
|
|||||||
<ClInclude Include="PoseableBatch.h" />
|
<ClInclude Include="PoseableBatch.h" />
|
||||||
<ClInclude Include="Prerenderable.h" />
|
<ClInclude Include="Prerenderable.h" />
|
||||||
<ClInclude Include="Sampler.h" />
|
<ClInclude Include="Sampler.h" />
|
||||||
|
<ClInclude Include="Sprite.h" />
|
||||||
|
<ClInclude Include="SpriteBatch.h" />
|
||||||
<ClInclude Include="Texture.h" />
|
<ClInclude Include="Texture.h" />
|
||||||
<ClInclude Include="TexturedBatch.h" />
|
<ClInclude Include="TexturedBatch.h" />
|
||||||
<ClInclude Include="TexturedTypes.h" />
|
<ClInclude Include="TexturedTypes.h" />
|
||||||
|
@ -70,36 +70,12 @@
|
|||||||
<Filter Include="Header Files\Engine\builtin\Scenes">
|
<Filter Include="Header Files\Engine\builtin\Scenes">
|
||||||
<UniqueIdentifier>{b3bc2383-d099-4fac-a51c-d2d4a8e7dea3}</UniqueIdentifier>
|
<UniqueIdentifier>{b3bc2383-d099-4fac-a51c-d2d4a8e7dea3}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Header Files\Engine\builtin\Scenes\LitShadowed">
|
|
||||||
<UniqueIdentifier>{2f2c0657-4ba3-4314-86dd-a600f533f746}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files\Engine\builtin\Scenes\Basic">
|
|
||||||
<UniqueIdentifier>{f3f94b58-31cf-4a57-bc2a-0c3a33a6b9ee}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files\Engine\builtin\Scenes\Lit">
|
|
||||||
<UniqueIdentifier>{fa76cc6e-e866-4987-8263-85abac1ac2c6}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Header Files\Engine\builtin\Scenes\Textured">
|
|
||||||
<UniqueIdentifier>{2e0e6381-fca9-42aa-87a9-04495a753104}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\Engine\builtin\General">
|
<Filter Include="Source Files\Engine\builtin\General">
|
||||||
<UniqueIdentifier>{a9e42739-f380-4358-83e5-f994cab7e55c}</UniqueIdentifier>
|
<UniqueIdentifier>{a9e42739-f380-4358-83e5-f994cab7e55c}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\Engine\builtin\Scenes">
|
<Filter Include="Source Files\Engine\builtin\Scenes">
|
||||||
<UniqueIdentifier>{f9faae2c-4381-4a2e-a0be-27920a52dc4d}</UniqueIdentifier>
|
<UniqueIdentifier>{f9faae2c-4381-4a2e-a0be-27920a52dc4d}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\Engine\builtin\Scenes\Lit">
|
|
||||||
<UniqueIdentifier>{a67acfda-71a8-46cf-8207-bfdece4228ac}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\Engine\builtin\Scenes\Basic">
|
|
||||||
<UniqueIdentifier>{283b2135-b031-48f0-b3cc-564a864e13bd}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\Engine\builtin\Scenes\LitShadowed">
|
|
||||||
<UniqueIdentifier>{ca87b30d-8b69-4c09-90a5-1fe317322c4c}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\Engine\builtin\Scenes\Textured">
|
|
||||||
<UniqueIdentifier>{4c6497d4-160a-45a1-a23b-7bf905de0824}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Source Files\Engine\builtin\Scenes\Shaders">
|
<Filter Include="Source Files\Engine\builtin\Scenes\Shaders">
|
||||||
<UniqueIdentifier>{ca004137-6425-4863-b91a-cf32988855be}</UniqueIdentifier>
|
<UniqueIdentifier>{ca004137-6425-4863-b91a-cf32988855be}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@ -121,6 +97,48 @@
|
|||||||
<Filter Include="Source Files\Engine\Plugins\LodePNG">
|
<Filter Include="Source Files\Engine\Plugins\LodePNG">
|
||||||
<UniqueIdentifier>{b8357bff-b6be-4ee1-b45e-2f1e0fee90e1}</UniqueIdentifier>
|
<UniqueIdentifier>{b8357bff-b6be-4ee1-b45e-2f1e0fee90e1}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\3D">
|
||||||
|
<UniqueIdentifier>{32da6379-79e0-4266-9f92-896845c98850}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\2D">
|
||||||
|
<UniqueIdentifier>{e9fecf63-116f-4e49-a6a0-aee4bdb9c09a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\3D\LitShadowed">
|
||||||
|
<UniqueIdentifier>{2f2c0657-4ba3-4314-86dd-a600f533f746}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\3D\Basic">
|
||||||
|
<UniqueIdentifier>{f3f94b58-31cf-4a57-bc2a-0c3a33a6b9ee}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\3D\Lit">
|
||||||
|
<UniqueIdentifier>{fa76cc6e-e866-4987-8263-85abac1ac2c6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\3D\Textured">
|
||||||
|
<UniqueIdentifier>{2e0e6381-fca9-42aa-87a9-04495a753104}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\Engine\builtin\Scenes\2D\Image">
|
||||||
|
<UniqueIdentifier>{af291666-8e83-495d-979d-8eaa9aacc295}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\2D">
|
||||||
|
<UniqueIdentifier>{6b8de3ed-e727-4558-8522-07d2b397c6c8}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\3D">
|
||||||
|
<UniqueIdentifier>{da4a1131-4c15-462b-91c9-625d59096f73}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\3D\LitShadowed">
|
||||||
|
<UniqueIdentifier>{ca87b30d-8b69-4c09-90a5-1fe317322c4c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\3D\Basic">
|
||||||
|
<UniqueIdentifier>{283b2135-b031-48f0-b3cc-564a864e13bd}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\3D\Lit">
|
||||||
|
<UniqueIdentifier>{a67acfda-71a8-46cf-8207-bfdece4228ac}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\3D\Textured">
|
||||||
|
<UniqueIdentifier>{4c6497d4-160a-45a1-a23b-7bf905de0824}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\Engine\builtin\Scenes\2D\Image">
|
||||||
|
<UniqueIdentifier>{492583f7-cffd-4d22-82c6-88be804e2f2f}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
@ -178,31 +196,31 @@
|
|||||||
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
|
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="BasicBatch.cpp">
|
<ClCompile Include="BasicBatch.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\Basic</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\Basic</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="BasicScene.cpp">
|
<ClCompile Include="BasicScene.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\Basic</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\Basic</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="LitBatch.cpp">
|
<ClCompile Include="LitBatch.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\Lit</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\Lit</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="LitScene.cpp">
|
<ClCompile Include="LitScene.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\Lit</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\Lit</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TexturedBatch.cpp">
|
<ClCompile Include="TexturedBatch.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\Textured</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\Textured</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TexturedScene.cpp">
|
<ClCompile Include="TexturedScene.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\Textured</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\Textured</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="MyBuiltinTexturedScene.cpp">
|
<ClCompile Include="MyBuiltinTexturedScene.cpp">
|
||||||
<Filter>Source Files\Example\Application</Filter>
|
<Filter>Source Files\Example\Application</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="LitShadowedBatch.cpp">
|
<ClCompile Include="LitShadowedBatch.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\LitShadowed</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\LitShadowed</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="LitShadowedScene.cpp">
|
<ClCompile Include="LitShadowedScene.cpp">
|
||||||
<Filter>Source Files\Engine\builtin\Scenes\LitShadowed</Filter>
|
<Filter>Source Files\Engine\builtin\Scenes\3D\LitShadowed</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="MyBuiltinLitShadowedScene.cpp">
|
<ClCompile Include="MyBuiltinLitShadowedScene.cpp">
|
||||||
<Filter>Source Files\Example\Application</Filter>
|
<Filter>Source Files\Example\Application</Filter>
|
||||||
@ -231,6 +249,9 @@
|
|||||||
<ClCompile Include="lodepng.cpp">
|
<ClCompile Include="lodepng.cpp">
|
||||||
<Filter>Source Files\Engine\Plugins\LodePNG</Filter>
|
<Filter>Source Files\Engine\Plugins\LodePNG</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Sprite.cpp">
|
||||||
|
<Filter>Source Files\Engine\Baseline</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Application.h">
|
<ClInclude Include="Application.h">
|
||||||
@ -297,31 +318,31 @@
|
|||||||
<Filter>Header Files\Example\Application</Filter>
|
<Filter>Header Files\Example\Application</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="BasicBatch.h">
|
<ClInclude Include="BasicBatch.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Basic</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="BasicScene.h">
|
<ClInclude Include="BasicScene.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Basic</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="BasicShaderProgram.h">
|
<ClInclude Include="BasicShaderProgram.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Basic</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitBatch.h">
|
<ClInclude Include="LitBatch.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Lit</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitScene.h">
|
<ClInclude Include="LitScene.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Lit</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitShaderProgram.h">
|
<ClInclude Include="LitShaderProgram.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Lit</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TexturedBatch.h">
|
<ClInclude Include="TexturedBatch.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Textured</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TexturedScene.h">
|
<ClInclude Include="TexturedScene.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Textured</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TexturedShaderProgram.h">
|
<ClInclude Include="TexturedShaderProgram.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Textured</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="MyBuiltinTexturedScene.h">
|
<ClInclude Include="MyBuiltinTexturedScene.h">
|
||||||
<Filter>Header Files\Example\Application</Filter>
|
<Filter>Header Files\Example\Application</Filter>
|
||||||
@ -330,28 +351,28 @@
|
|||||||
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
|
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitShadowedBatch.h">
|
<ClInclude Include="LitShadowedBatch.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\LitShadowed</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitShadowedScene.h">
|
<ClInclude Include="LitShadowedScene.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\LitShadowed</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitShadowedShaderProgram.h">
|
<ClInclude Include="LitShadowedShaderProgram.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\LitShadowed</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="MyBuiltinLitShadowedScene.h">
|
<ClInclude Include="MyBuiltinLitShadowedScene.h">
|
||||||
<Filter>Header Files\Example\Application</Filter>
|
<Filter>Header Files\Example\Application</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="BasicTypes.h">
|
<ClInclude Include="BasicTypes.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Basic</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitTypes.h">
|
<ClInclude Include="LitTypes.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Lit</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="TexturedTypes.h">
|
<ClInclude Include="TexturedTypes.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\Textured</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="LitShadowedTypes.h">
|
<ClInclude Include="LitShadowedTypes.h">
|
||||||
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
|
<Filter>Header Files\Engine\builtin\Scenes\3D\LitShadowed</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="constants.h">
|
<ClInclude Include="constants.h">
|
||||||
<Filter>Header Files\Engine\Baseline</Filter>
|
<Filter>Header Files\Engine\Baseline</Filter>
|
||||||
@ -428,12 +449,15 @@
|
|||||||
<ClInclude Include="ImageLoader.h">
|
<ClInclude Include="ImageLoader.h">
|
||||||
<Filter>Header Files\Engine\Baseline\ImageLoader</Filter>
|
<Filter>Header Files\Engine\Baseline\ImageLoader</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="ImageLoaderImage.h">
|
|
||||||
<Filter>Header Files\Engine\Baseline\ImageLoader</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="lodepng.h">
|
<ClInclude Include="lodepng.h">
|
||||||
<Filter>Header Files\Engine\Plugins\LodePNG</Filter>
|
<Filter>Header Files\Engine\Plugins\LodePNG</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="SpriteBatch.h">
|
||||||
|
<Filter>Header Files\Engine\builtin\General</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Sprite.h">
|
||||||
|
<Filter>Header Files\Engine\Baseline</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="MySimpleVS.glsl">
|
<None Include="MySimpleVS.glsl">
|
||||||
|
@ -18,6 +18,21 @@ namespace charcoal
|
|||||||
)
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void Poseable::reset_orientation()
|
||||||
|
{
|
||||||
|
m_orientation_matrix[0][0] = 1.0f;
|
||||||
|
m_orientation_matrix[0][1] = 0.0f;
|
||||||
|
m_orientation_matrix[0][2] = 0.0f;
|
||||||
|
|
||||||
|
m_orientation_matrix[1][0] = 0.0f;
|
||||||
|
m_orientation_matrix[1][1] = 1.0f;
|
||||||
|
m_orientation_matrix[1][2] = 0.0f;
|
||||||
|
|
||||||
|
m_orientation_matrix[2][0] = 0.0f;
|
||||||
|
m_orientation_matrix[2][1] = 0.0f;
|
||||||
|
m_orientation_matrix[2][2] = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
void Poseable::update_position(const vec3& position)
|
void Poseable::update_position(const vec3& position)
|
||||||
{
|
{
|
||||||
m_orientation_matrix[3][0] = position.x;
|
m_orientation_matrix[3][0] = position.x;
|
||||||
|
@ -17,6 +17,8 @@ namespace charcoal
|
|||||||
const vec3& right = vec3(1.0f, 0.0f, 0.0f)
|
const vec3& right = vec3(1.0f, 0.0f, 0.0f)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void reset_orientation();
|
||||||
|
|
||||||
void update_position(const vec3& position);
|
void update_position(const vec3& position);
|
||||||
// Assumes that forward, up, and right are orthogonal and normalized
|
// Assumes that forward, up, and right are orthogonal and normalized
|
||||||
void update_orientation(const vec3& forward, const vec3& up, const vec3& right);
|
void update_orientation(const vec3& forward, const vec3& up, const vec3& right);
|
||||||
|
28
OpenGLEngine/Sprite.cpp
Normal file
28
OpenGLEngine/Sprite.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "Sprite.h"
|
||||||
|
|
||||||
|
namespace charcoal
|
||||||
|
{
|
||||||
|
Sprite::Sprite(const vec2& position) : Poseable(vec3(position, 0.0f))
|
||||||
|
{}
|
||||||
|
|
||||||
|
void Sprite::update_position(const vec2& position)
|
||||||
|
{
|
||||||
|
Poseable::update_position(vec3(position, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sprite::update_rotation(float angle)
|
||||||
|
{
|
||||||
|
Poseable::reset_orientation();
|
||||||
|
rotate(angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sprite::translate(const vec2& translation)
|
||||||
|
{
|
||||||
|
Poseable::translate(vec3(translation, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sprite::rotate(float angle)
|
||||||
|
{
|
||||||
|
Poseable::rotate(vec3(0.0f, 0.0f, 1.0f), angle);
|
||||||
|
}
|
||||||
|
}
|
22
OpenGLEngine/Sprite.h
Normal file
22
OpenGLEngine/Sprite.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
#include "Poseable.h"
|
||||||
|
|
||||||
|
namespace charcoal
|
||||||
|
{
|
||||||
|
class Sprite : private Poseable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sprite(const vec2& position = vec2(0.0f, 0.0f));
|
||||||
|
|
||||||
|
void update_position(const vec2& position);
|
||||||
|
void update_rotation(float angle);
|
||||||
|
|
||||||
|
void translate(const vec2& translation);
|
||||||
|
void rotate(float angle);
|
||||||
|
|
||||||
|
const mat4& get_orientation_matrix() const { return Poseable::get_orientation_matrix(); }
|
||||||
|
};
|
||||||
|
}
|
26
OpenGLEngine/SpriteBatch.h
Normal file
26
OpenGLEngine/SpriteBatch.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "BuiltinBatch.h"
|
||||||
|
|
||||||
|
namespace charcoal
|
||||||
|
{
|
||||||
|
namespace builtin
|
||||||
|
{
|
||||||
|
template <typename VertexType, typename IndexType, typename RenderableT = RenderableT<VertexType, IndexType> >
|
||||||
|
class SpriteBatch : public builtin::Batch<VertexType, IndexType, 1, RenderableT>
|
||||||
|
{
|
||||||
|
SpriteBatch(
|
||||||
|
RenderableT* renderable,
|
||||||
|
int element_count
|
||||||
|
) : PoseableBatch(renderable, element_count, element_count)
|
||||||
|
{}
|
||||||
|
|
||||||
|
SpriteBatch(
|
||||||
|
RenderableT* renderable,
|
||||||
|
int element_count,
|
||||||
|
int element_render_count
|
||||||
|
) : builtin::Batch<VertexType, IndexType, 1, RenderableT>(renderable, element_render_count), m_pose_elements(element_count)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user