Compare commits

...

29 Commits

Author SHA1 Message Date
elipzer
5ac67dece7 Final Pong Touches 2018-10-18 12:28:46 -04:00
elipzer
30933b53ce Pong Works! 2018-10-18 00:48:05 -04:00
elipzer
56af508ef4 Bouncing works... Kindof...
Need to fix for bottom and left cases
2018-10-17 19:53:36 -04:00
elipzer
d2afef5090 Scene renders. Need to do collision and whatnot 2018-10-17 19:21:58 -04:00
elipzer
fd4cd2a407 Lit pipelines work!
Problem was that I didn't set the material (or the normals)
2018-10-17 15:09:32 -04:00
elipzer
8ee0ab2edb Lighting works... Just not properly
Commiting now so that there is something displaying for the lit
scene.
2018-10-15 22:38:59 -04:00
elipzer
98c6d3868c Added the base to the lit pipeline.
Still need to allow for adding lights!
2018-10-15 19:53:22 -04:00
elipzer
04c31686ec Fixed reverse-texture rendering by flipping the camera "handedness" 2018-10-15 11:42:12 -04:00
elipzer
402ef29734 Fixed broken UV coords.
Was caused by sending the incorrect number of coords per each
vertex. Now there's a problem in that the UVS are flipped
horizontally
2018-10-15 11:28:35 -04:00
elipzer
94de35536a Got it working but its not working...
The UVs are off for some reason but I'm not 100% sure why. Possibly
caused by some sort of offset not being accounted for.
2018-10-14 21:19:38 -04:00
elipzer
e3c85324c6 Changed Filters to be more representitive
Also moved all the code for each pipeline into the header files
rather than the .cpp files to keep it all in one place.
Considering just moving all the code into one file just to make it
easier to create new pipelines but that may be overkill and may
make the project harder to maintain in the future.
2018-10-14 15:44:04 -04:00
elipzer
0c767e9441 Added Pipelines!
Greatly streamline the concept of rendering and abstract rendering
so that scenes can render from many different pipelines if they
want to!.
2018-10-14 15:06:51 -04:00
elipzer
bb4592ed63 Got the batch rendering to be similar to where I want it.
Changing the mechanic of the renderer to support pipelines.
One scene could have multiple pipelines. The pipelines allow for
one shader, one camera, and multiple batches.
2018-10-14 00:52:32 -04:00
elipzer
2f6c5ee319 Starting off with specified rendering.
Almost there. Just an odd linker error so far.
2018-10-13 15:26:22 -04:00
elipzer
6020231c23 Removed duplicate constructor problems using the 'using' directive 2018-10-13 14:07:08 -04:00
elipzer
cbcf9dad21 Got rid of unused file and updated filters for builtin/example 2018-10-11 15:50:08 -04:00
elipzer
ce4a2a24ce Re-formatted Engine Filters 2018-10-11 15:37:16 -04:00
elipzer
e84ad4f9a1 Renamed project names (but not file names) to proper names.
Still need to find a way to rename the project file names.
2018-10-11 01:32:32 -04:00
elipzer
7cbe8acf30 Libraries Work!
Now the code is being compiled through .lib files!
2018-10-11 01:26:24 -04:00
elipzer
5db5ce971c Probably BREAKING - Moved everything into proper directories
Also added a copy pre-build even for .h files into the include
directory for charcoal and charcoal-builtin
2018-10-10 23:56:39 -04:00
Elipzer
8da055a018 Filters update for removing stdafx.cpp 2018-10-10 17:44:49 -04:00
Elipzer
8867e8086e Changed stdafx.h to be deps.h 2018-10-10 17:44:15 -04:00
elipzer
0ad7f7d96d Added the new project folders
Still need to setup DLL stuff with dll export/imports.

Using DLLs should make the project faster to build AND should make
it easier to distribute.
2018-10-10 11:25:37 -04:00
elipzer
43ddc00224 Remove CHECK_GL_ERR from TexturedBatch.cpp 2018-10-10 10:56:35 -04:00
elipzer
49f7a3e2d7 Fixed the textured cube from being broken.
The problem was caused by vector re-allocation. This is a similar
problem to what happened with the mesh factory. It was solved by
converting the texture factory to use lists instead of vectors.

The reason for using lists is to prevent the need for explicit
deallocation of resources and instead allow the use of a list to
automatically allocate/deallocate the textures/samplers/meshes.
2018-10-10 10:54:13 -04:00
Elipzer
5a9765b111 Image Rendering almost works!
There is an OpenGL error (1282) invalid operation that is getting
caught when switching to the imagescene. This needs to get fixed
and then hopefully the whole thing will work.
2018-10-09 19:58:26 -04:00
elipzer
b7456401e0 Almost able to render the image
Added image scene to render an image in a scene. There is also now
a testing image that is an uber meme. Currently the problem is
that the spritebatch cannot use the offsetof macro because it is a
templated class. Possible solutions to this are changing it to be
specifyable or implemented per vertex type as the other batches
have been.
2018-10-09 11:42:17 -04:00
elipzer
a8abb4afc9 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.
2018-10-08 15:19:48 -04:00
elipzer
07a781c075 Started image loading with lodepng 2018-10-07 21:51:05 -04:00
130 changed files with 11138 additions and 1669 deletions

8
.gitignore vendored
View File

@ -329,4 +329,10 @@ ASALocalRun/
.mfractor/
# Local History for Visual Studio
.localhistory/
.localhistory/
# Generated Files/Directories
include/charcoal-builtin/
include/charcoal/
lib/charcoal-builtin.lib
lib/charcoal.lib

View File

@ -2,19 +2,18 @@
#include <vector>
#include "Application.h"
#include "Scene.h"
#include "Prerenderable.h"
#include <charcoal/Application.h>
#include <charcoal/Scene.h>
#include <charcoal/Prerenderable.h>
namespace charcoal
{
namespace builtin
{
class AutoPrerenderingScene : public Scene
class AutoPrerenderingScene : public charcoal::Scene
{
public:
AutoPrerenderingScene(Application& application) : Scene(application) {}
virtual ~AutoPrerenderingScene() {}
using charcoal::Scene::Scene;
void prerender() override;

View File

@ -0,0 +1,30 @@
#pragma once
#include "BasicTypes.h"
#include "PoseableBatch.h"
namespace charcoal
{
namespace builtin
{
namespace basic
{
class Batch : public PoseableBatch<Vertex, Index, 1>
{
public:
using PoseableBatch<Vertex, Index, 1>::PoseableBatch;
protected:
void setup_vao_vertex() override
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), NULL);
glVertexAttribDivisor(0, 0);
}
};
}
}
}

View File

@ -0,0 +1,31 @@
#pragma once
#include "GLUtil.h"
#include "BuiltinPipeline.h"
#include "WithCamera.h"
#include "BasicShaderProgram.h"
#include "BasicBatch.h"
namespace charcoal
{
namespace builtin
{
namespace basic
{
class Pipeline : public builtin::Pipeline<ShaderProgram, Batch>, public WithCamera
{
protected:
void prepare_opengl() override
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void prepare_uniforms() override
{
glutil::uniform_matrix(0, get_camera()->get_world_to_view_matrix());
}
};
}
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "VertexFragmentShaderProgram.h"
#include <charcoal/VertexFragmentShaderProgram.h>
namespace charcoal
{

View File

@ -2,6 +2,7 @@
#include "BuiltinTypes.h"
namespace charcoal
{
namespace builtin

View File

@ -1,7 +1,7 @@
#pragma once
#include "Prerenderable.h"
#include "Batch.h"
#include <charcoal/Prerenderable.h>
#include <charcoal/Batch.h>
namespace charcoal
{
@ -11,10 +11,7 @@ namespace charcoal
class Batch : public Prerenderable, public charcoal::Batch<VertexType, IndexType, element_buffer_count, RenderableT>
{
public:
Batch(
const RenderableT* renderable,
int element_render_count
) : charcoal::Batch<VertexType, IndexType, element_buffer_count, RenderableT>(renderable, element_render_count) {}
using charcoal::Batch<VertexType, IndexType, element_buffer_count, RenderableT>::Batch;
void prerender() override { charcoal::Batch<VertexType, IndexType, element_buffer_count, RenderableT>::prerender(); }
};

View File

@ -0,0 +1,18 @@
#pragma once
#include <charcoal/Prerenderable.h>
#include <charcoal/Camera2D.h>
namespace charcoal
{
namespace builtin
{
class Camera2D : public Prerenderable, public charcoal::Camera2D
{
public:
using charcoal::Camera2D::Camera2D;
void prerender() override { charcoal::Camera2D::prerender(); }
};
}
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <charcoal/Prerenderable.h>
#include <charcoal/Camera3D.h>
namespace charcoal
{
namespace builtin
{
class Camera3D : public Prerenderable, public charcoal::Camera3D
{
public:
using charcoal::Camera3D::Camera3D;
void prerender() override { charcoal::Camera3D::prerender(); }
};
}
}

View File

@ -0,0 +1,31 @@
#pragma once
#include <charcoal/Pipeline.h>
namespace charcoal
{
namespace builtin
{
template <typename ShaderProgramType, typename BatchType>
class Pipeline : public charcoal::Pipeline<ShaderProgramType, BatchType>
{
public:
void render() override
{
prepare_opengl();
charcoal::Pipeline<ShaderProgramType, BatchType>::m_shader_program.use();
prepare_uniforms();
for (auto iter = charcoal::Pipeline<ShaderProgramType, BatchType>::m_batches.begin(); iter != charcoal::Pipeline<ShaderProgramType, BatchType>::m_batches.end(); ++iter)
{
BatchType* batch = *iter;
batch->render();
}
}
protected:
virtual void prepare_opengl() {};
virtual void prepare_uniforms() {};
};
}
}

View File

@ -1,10 +1,12 @@
#pragma once
#include <glm/glm.hpp>
#include "Renderable.h"
#include <charcoal/Renderable.h>
#include <charcoal/VertexFragmentShaderProgram.h>
#include <charcoal/TextureRenderable.h>
#include "PoseableBatch.h"
#include "VertexFragmentShaderProgram.h"
#include "TextureRenderable.h"
namespace charcoal
{
@ -22,12 +24,12 @@ namespace charcoal
// Shader Data Types
struct Light
struct PhongLight
{
typedef vec3 Power;
typedef vec3 Fade;
Light(
PhongLight(
const Position& position,
const Power& power,
const ColorRGB& ambient,
@ -51,9 +53,9 @@ namespace charcoal
Fade fade;
};
struct Material
struct PhongMaterial
{
Material(
PhongMaterial(
float ambient = 1.0f,
float diffuse = 1.0f,
float specular = 0.0f,
@ -84,11 +86,11 @@ namespace charcoal
{
void set_position(const Position& position) { this->position = position; }
void set_normal(const Normal& normal) { this->normal = normal; }
void set_material(const Material& material) { this->material = material; }
void set_material(const PhongMaterial& material) { this->material = material; }
Position position;
Normal normal;
Material material;
PhongMaterial material;
};
struct PTVertex

View File

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{29E6293C-506A-4FDD-8E3D-36674AD8163D}</ProjectGuid>
<RootNamespace>CharcoalBuiltin</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<ProjectName>charcoal-builtin</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(SolutionDir)lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(SolutionDir)lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SHADER_PATH=R"($(SolutionDir)shaders\)";IMAGE_PATH=R"($(SolutionDir)images\)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>copy "$(TargetPath)" "$(SolutionDir)lib\charcoal-builtin.lib"
copy "$(ProjectDir)*.h" "$(SolutionDir)include\charcoal-builtin\"</Command>
<Message>Output LIB Setup</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>SHADER_PATH=R"($(SolutionDir)shaders\)";IMAGE_PATH=R"($(SolutionDir)images\)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>copy "$(TargetPath)" "$(SolutionDir)lib\charcoal-builtin.lib"
copy "$(ProjectDir)*.h" "$(SolutionDir)include\charcoal-builtin\"</Command>
<Message>Output LIB Setup</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AutoPrerenderingScene.cpp" />
<ClCompile Include="GLUtil.cpp" />
<ClCompile Include="TextureGenerator.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="AutoPrerenderingScene.h" />
<ClInclude Include="BasicBatch.h" />
<ClInclude Include="BasicPipeline.h" />
<ClInclude Include="BasicShaderProgram.h" />
<ClInclude Include="BasicTypes.h" />
<ClInclude Include="Batched.h" />
<ClInclude Include="BuiltinBatch.h" />
<ClInclude Include="BuiltinCamera2D.h" />
<ClInclude Include="BuiltinCamera3D.h" />
<ClInclude Include="BuiltinPipeline.h" />
<ClInclude Include="BuiltinTypes.h" />
<ClInclude Include="GLUtil.h" />
<ClInclude Include="LitBatch.h" />
<ClInclude Include="LitPipeline.h" />
<ClInclude Include="LitShaderProgram.h" />
<ClInclude Include="LitTypes.h" />
<ClInclude Include="MeshGenerator.h" />
<ClInclude Include="PoseableBatch.h" />
<ClInclude Include="SpriteBatch.h" />
<ClInclude Include="TexturedBatch.h" />
<ClInclude Include="TexturedPipeline.h" />
<ClInclude Include="TexturedRenderable.h" />
<ClInclude Include="TexturedShaderProgram.h" />
<ClInclude Include="TexturedTypes.h" />
<ClInclude Include="TextureGenerator.h" />
<ClInclude Include="WithCamera.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\General">
<UniqueIdentifier>{5df56e70-8319-4228-b684-c38dd8730bd2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\General">
<UniqueIdentifier>{38a6019a-d441-4f64-a1d3-00b15fce2106}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Pipelines">
<UniqueIdentifier>{808e9376-c6b7-4d65-806e-935f34d5ec4a}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Pipelines\Basic">
<UniqueIdentifier>{1dbc28a4-b52f-4171-a385-79490dfa9b0a}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Pipelines\Textured">
<UniqueIdentifier>{a0a4d461-a490-40ce-bc57-22c47460f60e}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Pipelines\Lit">
<UniqueIdentifier>{bc6d5912-669e-4e73-8e9e-67e1d4af38be}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="GLUtil.cpp">
<Filter>Source Files\General</Filter>
</ClCompile>
<ClCompile Include="AutoPrerenderingScene.cpp">
<Filter>Source Files\General</Filter>
</ClCompile>
<ClCompile Include="TextureGenerator.cpp">
<Filter>Source Files\General</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BasicShaderProgram.h">
<Filter>Header Files\Pipelines\Basic</Filter>
</ClInclude>
<ClInclude Include="BasicTypes.h">
<Filter>Header Files\Pipelines\Basic</Filter>
</ClInclude>
<ClInclude Include="AutoPrerenderingScene.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="Batched.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="BuiltinBatch.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="BuiltinCamera2D.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="BuiltinCamera3D.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="BuiltinTypes.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="GLUtil.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="MeshGenerator.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="PoseableBatch.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="SpriteBatch.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="TextureGenerator.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="WithCamera.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="BasicBatch.h">
<Filter>Header Files\Pipelines\Basic</Filter>
</ClInclude>
<ClInclude Include="BasicPipeline.h">
<Filter>Header Files\Pipelines\Basic</Filter>
</ClInclude>
<ClInclude Include="BuiltinPipeline.h">
<Filter>Header Files\General</Filter>
</ClInclude>
<ClInclude Include="TexturedBatch.h">
<Filter>Header Files\Pipelines\Textured</Filter>
</ClInclude>
<ClInclude Include="TexturedTypes.h">
<Filter>Header Files\Pipelines\Textured</Filter>
</ClInclude>
<ClInclude Include="TexturedShaderProgram.h">
<Filter>Header Files\Pipelines\Textured</Filter>
</ClInclude>
<ClInclude Include="TexturedPipeline.h">
<Filter>Header Files\Pipelines\Textured</Filter>
</ClInclude>
<ClInclude Include="TexturedRenderable.h">
<Filter>Header Files\Pipelines\Textured</Filter>
</ClInclude>
<ClInclude Include="LitBatch.h">
<Filter>Header Files\Pipelines\Lit</Filter>
</ClInclude>
<ClInclude Include="LitTypes.h">
<Filter>Header Files\Pipelines\Lit</Filter>
</ClInclude>
<ClInclude Include="LitShaderProgram.h">
<Filter>Header Files\Pipelines\Lit</Filter>
</ClInclude>
<ClInclude Include="LitPipeline.h">
<Filter>Header Files\Pipelines\Lit</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,6 +1,6 @@
#include "GLUtil.h"
#include "stdafx.h"
#include <charcoal/deps.h>
namespace charcoal
{
@ -38,9 +38,9 @@ namespace charcoal
glUniformMatrix4fv(uniform_index, 1, transpose ? GL_TRUE : GL_FALSE, &matrix[0][0]);
}
void uniform_lights(int uniform_index, const std::vector<Light>& lights)
void uniform_lights(int uniform_index, const std::vector<PhongLight>& lights)
{
for (std::vector<Light>::size_type i = 0; i < lights.size(); ++i)
for (std::vector<PhongLight>::size_type i = 0; i < lights.size(); ++i)
{
glUniform3fv(uniform_index++, 1, &lights[i].position[0]);
glUniform3fv(uniform_index++, 1, &lights[i].power[0]);

View File

@ -19,7 +19,7 @@ namespace charcoal
void uniform_float(int uniform_index, float value);
void uniform_vec3(int uniform_index, const vec3& value);
void uniform_matrix(int uniform_index, const mat4& matrix, bool transpose = false);
void uniform_lights(int uniform_index, const std::vector<Light>& lights); // TODO: This may want to be moved somewhere else
void uniform_lights(int uniform_index, const std::vector<PhongLight>& lights); // TODO: This may want to be moved somewhere else
}
}
}

View File

@ -0,0 +1,36 @@
#pragma once
#include "LitTypes.h"
#include "PoseableBatch.h"
namespace charcoal
{
namespace builtin
{
namespace lit
{
class Batch : public PoseableBatch<Vertex, Index, 3>
{
public:
using PoseableBatch<Vertex, Index, 3>::PoseableBatch;
protected:
void setup_vao_vertex() override
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, normal));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, material));
glVertexAttribDivisor(0, 0);
glVertexAttribDivisor(1, 0);
glVertexAttribDivisor(2, 0);
}
};
}
}
}

View File

@ -0,0 +1,47 @@
#pragma once
#include "GLUtil.h"
#include "BuiltinPipeline.h"
#include "WithCamera.h"
#include "LitShaderProgram.h"
#include "LitBatch.h"
namespace charcoal
{
namespace builtin
{
namespace lit
{
// TODO: May want to abstract this into a base pipeline class since this is the same as basic::Pipeline
class Pipeline : public builtin::Pipeline<ShaderProgram, Batch>, public WithCamera
{
public:
void reset_lights()
{
m_lights.clear();
}
void add_light(const Light& light)
{
m_lights.push_back(light);
}
protected:
void prepare_opengl() override
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void prepare_uniforms() override
{
glutil::uniform_matrix(0, get_camera()->get_world_to_view_matrix());
glutil::uniform_vec3(4, get_camera()->get_position());
glutil::uniform_uint(5, (unsigned int)m_lights.size());
glutil::uniform_lights(6, m_lights);
}
private:
std::vector<PhongLight> m_lights;
};
}
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "VertexFragmentShaderProgram.h"
#include <charcoal/VertexFragmentShaderProgram.h>
namespace charcoal
{
@ -8,7 +8,6 @@ namespace charcoal
{
namespace lit
{
// TODO: Add constants for the uniform and vertex attribute locations (for all shader programs)
class ShaderProgram : public VertexFragmentShaderProgram
{
public:

View File

@ -8,10 +8,10 @@ namespace charcoal
{
namespace lit
{
typedef PhongLight Light;
typedef PNMVertex Vertex;
typedef Index Index;
typedef RenderableT<Vertex, Index> Renderable;
typedef Light Light;
}
}
}

View File

@ -4,8 +4,9 @@
#include <glm/glm.hpp>
#include "MeshFactory.h"
#include "Mesh.h"
#include <charcoal/MeshFactory.h>
#include <charcoal/Mesh.h>
#include "BuiltinTypes.h"
// TODO: Consider a mesh generator for every render type (i.e. basic::meshgenerator, lit::meshgenerator, etc.)
@ -19,7 +20,7 @@ namespace charcoal
namespace meshgenerator
{
template <typename VertexType, typename IndexType>
Mesh<VertexType, IndexType>* set_material(Mesh<VertexType, IndexType>* mesh, const Material& material)
Mesh<VertexType, IndexType>* set_material(Mesh<VertexType, IndexType>* mesh, const PhongMaterial& material)
{
for (unsigned int i = 0; i < mesh->vertex_count; ++i)
{
@ -648,6 +649,172 @@ namespace charcoal
}
// TODO: Mesh<PNTVertex, Index>* gen_cube(const DrawMode& draw_mode, float width, float height, float depth);
template <typename VertexType, typename IndexType>
Mesh<VertexType, IndexType>* gen_rect_p(const DrawMode& draw_mode, float width, float height, float offset_x = 0.0f, float offset_y = 0.0f)
{
float half_width = width / 2.0f;
float half_height = height / 2.0f;
Mesh<VertexType, IndexType>* mesh;
Position pos0(offset_x - half_width, offset_y - half_height, 0.0f);
Position pos1(offset_x - half_width, offset_y + half_height, 0.0f);
Position pos2(offset_x + half_width, offset_y - half_height, 0.0f);
Position pos3(offset_x + half_width, offset_y + half_height, 0.0f);
switch (draw_mode)
{
case DrawMode::DRAW_TRIANGLES:
mesh = MeshFactory<VertexType, IndexType>::create_mesh(4, 6);
mesh->vertices[0].set_position(pos0);
mesh->vertices[1].set_position(pos1);
mesh->vertices[2].set_position(pos2);
mesh->vertices[3].set_position(pos3);
mesh->indices[0] = 1;
mesh->indices[1] = 3;
mesh->indices[2] = 0;
mesh->indices[3] = 0;
mesh->indices[4] = 3;
mesh->indices[5] = 2;
return mesh;
case DrawMode::DRAW_TRIANGLE_STRIP:
mesh = MeshFactory<VertexType, IndexType>::create_mesh(4, 4);
mesh->vertices[0].set_position(pos0);
mesh->vertices[1].set_position(pos1);
mesh->vertices[2].set_position(pos2);
mesh->vertices[3].set_position(pos3);
mesh->indices[0] = 1;
mesh->indices[1] = 3;
mesh->indices[2] = 0;
mesh->indices[3] = 2;
return mesh;
case DrawMode::DRAW_TRIANGLE_FAN:
mesh = MeshFactory<VertexType, IndexType>::create_mesh(4, 4);
mesh->vertices[0].set_position(pos0);
mesh->vertices[1].set_position(pos1);
mesh->vertices[2].set_position(pos2);
mesh->vertices[3].set_position(pos3);
mesh->indices[0] = 1;
mesh->indices[1] = 3;
mesh->indices[2] = 2;
mesh->indices[3] = 0;
return mesh;
case DrawMode::DRAW_POINTS: // TODO: Point, lines, line_strip, line_loop
case DrawMode::DRAW_LINES:
case DrawMode::DRAW_LINE_STRIP:
case DrawMode::DRAW_LINE_LOOP:
case DrawMode::DRAW_LINE_STRIP_ADJACENCY:
case DrawMode::DRAW_LINES_ADJACENCY:
case DrawMode::DRAW_TRIANGLE_STRIP_ADJACENCY:
case DrawMode::DRAW_TRIANGLES_ADJACENCY:
case DrawMode::DRAW_PATCHES:
default:
throw EXCEPTION("Unable to gen_rect_pt for current draw mode: " + std::to_string(draw_mode));
}
}
template <typename VertexType, typename IndexType>
Mesh<VertexType, IndexType>* gen_rect_pt(const DrawMode& draw_mode, float width, float height, float offset_x = 0.0f, float offset_y = 0.0f)
{
float half_width = width / 2.0f;
float half_height = height / 2.0f;
Mesh<VertexType, IndexType>* mesh;
Position pos0(offset_x - half_width, offset_y - half_width, 0.0f);
Position pos1(offset_x - half_width, offset_y + half_width, 0.0f);
Position pos2(offset_x + half_width, offset_y - half_width, 0.0f);
Position pos3(offset_x + half_width, offset_y + half_width, 0.0f);
UV uv0(0.0f, 1.0f);
UV uv1(0.0f, 0.0f);
UV uv2(1.0f, 1.0f);
UV uv3(1.0f, 0.0f);
switch (draw_mode)
{
case DrawMode::DRAW_TRIANGLES:
mesh = MeshFactory<VertexType, IndexType>::create_mesh(4, 6);
mesh->vertices[0].set_uv(uv0);
mesh->vertices[1].set_uv(uv1);
mesh->vertices[2].set_uv(uv2);
mesh->vertices[3].set_uv(uv3);
mesh->vertices[0].set_position(pos0);
mesh->vertices[1].set_position(pos1);
mesh->vertices[2].set_position(pos2);
mesh->vertices[3].set_position(pos3);
mesh->indices[0] = 1;
mesh->indices[1] = 3;
mesh->indices[2] = 0;
mesh->indices[3] = 0;
mesh->indices[4] = 3;
mesh->indices[5] = 2;
return mesh;
case DrawMode::DRAW_TRIANGLE_STRIP:
mesh = MeshFactory<VertexType, IndexType>::create_mesh(4, 4);
mesh->vertices[0].set_uv(uv0);
mesh->vertices[1].set_uv(uv1);
mesh->vertices[2].set_uv(uv2);
mesh->vertices[3].set_uv(uv3);
mesh->vertices[0].set_position(pos0);
mesh->vertices[1].set_position(pos1);
mesh->vertices[2].set_position(pos2);
mesh->vertices[3].set_position(pos3);
mesh->indices[0] = 1;
mesh->indices[1] = 3;
mesh->indices[2] = 0;
mesh->indices[3] = 2;
return mesh;
case DrawMode::DRAW_TRIANGLE_FAN:
mesh = MeshFactory<VertexType, IndexType>::create_mesh(4, 4);
mesh->vertices[0].set_uv(uv0);
mesh->vertices[1].set_uv(uv1);
mesh->vertices[2].set_uv(uv2);
mesh->vertices[3].set_uv(uv3);
mesh->vertices[0].set_position(pos0);
mesh->vertices[1].set_position(pos1);
mesh->vertices[2].set_position(pos2);
mesh->vertices[3].set_position(pos3);
mesh->indices[0] = 1;
mesh->indices[1] = 3;
mesh->indices[2] = 2;
mesh->indices[3] = 0;
return mesh;
case DrawMode::DRAW_POINTS:
case DrawMode::DRAW_LINES:
case DrawMode::DRAW_LINE_STRIP:
case DrawMode::DRAW_LINE_LOOP:
case DrawMode::DRAW_LINE_STRIP_ADJACENCY:
case DrawMode::DRAW_LINES_ADJACENCY:
case DrawMode::DRAW_TRIANGLE_STRIP_ADJACENCY:
case DrawMode::DRAW_TRIANGLES_ADJACENCY:
case DrawMode::DRAW_PATCHES:
default:
throw EXCEPTION("Unable to gen_rect_pt for current draw mode: " + std::to_string(draw_mode));
}
}
}
}
}

View File

@ -0,0 +1,78 @@
#pragma once
#include <charcoal/Batch.h>
#include <charcoal/Renderable.h>
#include <charcoal/Poseable.h>
#include "BuiltinBatch.h"
namespace charcoal
{
namespace builtin
{
// Note: If anything is changed in this file, it must also be changed in Poseable2DBatch
template <typename VertexType, typename IndexType, int orientation_attrib_offset, typename RenderableT = RenderableT<VertexType, IndexType> >
class PoseableBatch : public builtin::Batch<VertexType, IndexType, 1, RenderableT>
{
public:
PoseableBatch(
RenderableT* renderable,
int element_count
) : PoseableBatch(renderable, element_count, element_count)
{}
PoseableBatch(
RenderableT* renderable,
int element_count,
int element_render_count
) : builtin::Batch<VertexType, IndexType, 1, RenderableT>(renderable, element_render_count), m_orientation_elements(element_count)
{}
virtual ~PoseableBatch() {}
void reset_rendered() { charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_render_count = 0; }
void add_rendered(const Poseable& poseable) { m_orientation_elements[charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_render_count++] = poseable.get_orientation_matrix(); }
protected:
void setup_element_buffers()
{
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
glBufferData(GL_ARRAY_BUFFER, m_orientation_elements.size() * sizeof(mat4), NULL, GL_STREAM_DRAW);
}
void update_element_buffers()
{
// TODO: There are probably better ways to do this. Should check with the old engine to see what I did there.
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
glBufferData(GL_ARRAY_BUFFER, m_orientation_elements.size() * sizeof(mat4), NULL, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, m_orientation_elements.size() * sizeof(mat4), m_orientation_elements.data());
}
virtual void setup_vao_vertex() = 0;
void setup_vao() override
{
setup_vao_vertex();
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
glEnableVertexAttribArray(orientation_attrib_offset + 0);
glEnableVertexAttribArray(orientation_attrib_offset + 1);
glEnableVertexAttribArray(orientation_attrib_offset + 2);
glEnableVertexAttribArray(orientation_attrib_offset + 3);
glVertexAttribPointer(orientation_attrib_offset + 0, 4, GL_FLOAT, GL_FALSE, sizeof(mat4), (void*)(0 * sizeof(mat4::col_type)));
glVertexAttribPointer(orientation_attrib_offset + 1, 4, GL_FLOAT, GL_FALSE, sizeof(mat4), (void*)(1 * sizeof(mat4::col_type)));
glVertexAttribPointer(orientation_attrib_offset + 2, 4, GL_FLOAT, GL_FALSE, sizeof(mat4), (void*)(2 * sizeof(mat4::col_type)));
glVertexAttribPointer(orientation_attrib_offset + 3, 4, GL_FLOAT, GL_FALSE, sizeof(mat4), (void*)(3 * sizeof(mat4::col_type)));
glVertexAttribDivisor(orientation_attrib_offset + 0, 1); // Send the orientation data for each instance drawn
glVertexAttribDivisor(orientation_attrib_offset + 1, 1); // Send the orientation data for each instance drawn
glVertexAttribDivisor(orientation_attrib_offset + 2, 1); // Send the orientation data for each instance drawn
glVertexAttribDivisor(orientation_attrib_offset + 3, 1); // Send the orientation data for each instance drawn
}
std::vector<mat4> m_orientation_elements;
};
}
}

View File

@ -0,0 +1,29 @@
#pragma once
#include <charcoal/Poseable2D.h>
#include <charcoal/TextureRenderable.h>
#include "PoseableBatch.h"
namespace charcoal
{
namespace builtin
{
template <typename VertexType, typename IndexType, int position_offset, int uv_offset>
class SpriteBatch : public PoseableBatch<VertexType, IndexType, TextureRenderable<VertexType, IndexType> >
{
public:
// Note: This is VERY similar to builtin::textured::Batch
// Note: Uses GL_TEXTURE0. The uniform for this texture should be set in the scene before rendering.
using PoseableBatch<VertexType, IndexType, TextureRenderable<VertexType, IndexType> >::PoseableBatch;
void preprender() const override
{
// Note: Uses GL_TEXTURE0. The uniform for this texture should be set in the scene.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, charcoal::Batch<VertexType, IndexType, 1, TextureRenderable<VertexType, IndexType> >::m_p_renderable->get_texture()->get_texture());
glBindSampler(0, charcoal::Batch<VertexType, IndexType, 1, TextureRenderable<VertexType, IndexType> >::m_p_renderable->get_sampler()->get_sampler());
}
};
}
}

View File

@ -1,10 +1,6 @@
#pragma once
#include "TextureGenerator.h"
#include <vector>
#include "Texture.h"
#include "Sampler.h"
#include "TextureFactory.h"
#include <charcoal/TextureFactory.h>
namespace charcoal
{
@ -54,7 +50,7 @@ namespace charcoal
return TextureFactory::gen_texture(Texture::Format::RGBA, Texture::Type::UNSIGNED_BYTE, 6, 1, values, Texture::InternalFormat::RGBA);
}
Sampler* gen_quick_sampler()
{
return TextureFactory::gen_sampler(Sampler::Wrap::REPEAT, Sampler::Wrap::REPEAT, Sampler::MagFilter::NEAREST, Sampler::MinFilter::NEAREST);

View File

@ -0,0 +1,19 @@
#pragma once
#include <vector>
#include <charcoal/Texture.h>
#include <charcoal/Sampler.h>
namespace charcoal
{
namespace builtin
{
namespace texturegenerator
{
Texture* gen_quick_cube_texture();
Sampler* gen_quick_sampler();
}
}
}

View File

@ -0,0 +1,40 @@
#pragma once
#include "TexturedTypes.h"
#include "TexturedRenderable.h"
#include "PoseableBatch.h"
namespace charcoal
{
namespace builtin
{
namespace textured
{
class Batch : public PoseableBatch<Vertex, Index, 2, Renderable>
{
public:
using PoseableBatch<Vertex, Index, 2, Renderable>::PoseableBatch;
protected:
void setup_vao_vertex() override
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, position));
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, uv));
glVertexAttribDivisor(0, 0);
glVertexAttribDivisor(1, 0);
}
void preprender() const override {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_p_renderable->get_texture()->get_texture());
glBindSampler(0, m_p_renderable->get_sampler()->get_sampler());
}
};
}
}
}

View File

@ -0,0 +1,31 @@
#pragma once
#include "GLUtil.h"
#include "BuiltinPipeline.h"
#include "WithCamera.h"
#include "TexturedShaderProgram.h"
#include "TexturedBatch.h"
namespace charcoal
{
namespace builtin
{
namespace textured
{
class Pipeline : public builtin::Pipeline<ShaderProgram, Batch>, public WithCamera
{
protected:
void prepare_opengl() override
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void prepare_uniforms() override
{
glutil::uniform_matrix(0, get_camera()->get_world_to_view_matrix());
}
};
}
}
}

View File

@ -0,0 +1,38 @@
#pragma once
#include <charcoal/Renderable.h>
#include <charcoal/Texture.h>
#include <charcoal/Sampler.h>
#include "TexturedTypes.h"
namespace charcoal
{
namespace builtin
{
namespace textured
{
class Renderable : public RenderableT<Vertex, Index>
{
public:
Renderable(
const Mesh<Vertex, Index>* mesh,
const DrawMode& draw_mode,
Texture* texture,
Sampler* sampler
)
: RenderableT<Vertex, Index>(mesh, draw_mode),
m_p_texture(texture),
m_p_sampler(sampler)
{}
Texture* get_texture() const { return m_p_texture; }
Sampler* get_sampler() const { return m_p_sampler; }
private:
Texture* m_p_texture;
Sampler* m_p_sampler;
};
}
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "VertexFragmentShaderProgram.h"
#include <charcoal/VertexFragmentShaderProgram.h>
namespace charcoal
{

View File

@ -1,6 +1,5 @@
#pragma once
#include "TextureRenderable.h"
#include "BuiltinTypes.h"
namespace charcoal
@ -11,7 +10,6 @@ namespace charcoal
{
typedef PTVertex Vertex;
typedef Index Index;
typedef TextureRenderable<Vertex, Index> Renderable;
}
}
}

View File

@ -0,0 +1,20 @@
#pragma once
#include <charcoal/Camera.h>
namespace charcoal
{
namespace builtin
{
class WithCamera
{
public:
void set_camera(Camera* camera) { m_p_camera = camera; }
Camera* get_camera() { return m_p_camera; }
private:
Camera* m_p_camera = nullptr;
};
}
}

156
Example/Example.vcxproj Normal file
View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="MyApplication.cpp" />
<ClCompile Include="MyBasicScene.cpp" />
<ClCompile Include="MyBatch.cpp" />
<ClCompile Include="MyBuiltinCubeScene.cpp" />
<ClCompile Include="MyBuiltinLitScene.cpp" />
<ClCompile Include="MyBuiltinTexturedScene.cpp" />
<ClCompile Include="MyPongScene.cpp" />
<ClCompile Include="MySimple2DScene.cpp" />
<ClCompile Include="MySimple3DScene.cpp" />
<ClCompile Include="MySimpleCubeScene.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="MyApplication.h" />
<ClInclude Include="MyBasicScene.h" />
<ClInclude Include="MyBasicShaderProgram.h" />
<ClInclude Include="MyBatch.h" />
<ClInclude Include="MyBuiltinCubeScene.h" />
<ClInclude Include="MyBuiltinTexturedScene.h" />
<ClInclude Include="MyBuiltinLitScene.h" />
<ClInclude Include="MyPongScene.h" />
<ClInclude Include="MySimple2DScene.h" />
<ClInclude Include="MySimple3DScene.h" />
<ClInclude Include="MySimpleCubeScene.h" />
<ClInclude Include="MySimpleShaderProgram.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{2713E882-5224-490A-A056-F6AD20C42B12}</ProjectGuid>
<RootNamespace>Example</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(SolutionDir)lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(SolutionDir)lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>SHADER_PATH=R"($(SolutionDir)shaders\)";IMAGE_PATH=R"($(SolutionDir)images\)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>SHADER_PATH=R"($(SolutionDir)shaders\)";IMAGE_PATH=R"($(SolutionDir)images\)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MyApplication.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyBasicScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyBatch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinCubeScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MySimple2DScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MySimple3DScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MySimpleCubeScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinTexturedScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinLitScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MyPongScene.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MyApplication.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBasicShaderProgram.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBatch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MySimpleShaderProgram.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBasicScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinCubeScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MySimple2DScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MySimple3DScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MySimpleCubeScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinTexturedScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinLitScene.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MyPongScene.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -7,9 +7,9 @@ MyApplication::MyApplication(int width, int height)
m_simple_3d_scene(*this),
m_simple_cube_scene(*this),
m_builtin_basic_cube_scene(*this),
m_builtin_lit_scene(*this),
m_builtin_textured_scene(*this),
m_builtin_lit_shadowed_scene(*this)
m_builtin_lit_scene(*this),
m_pong_scene(*this)
{}
void MyApplication::init()
@ -19,9 +19,9 @@ void MyApplication::init()
m_simple_3d_scene.init();
m_simple_cube_scene.init();
m_builtin_basic_cube_scene.init();
m_builtin_lit_scene.init();
m_builtin_textured_scene.init();
m_builtin_lit_shadowed_scene.init();
m_builtin_lit_scene.init();
m_pong_scene.init();
m_p_current_scene = &m_basic_scene;
m_p_current_scene->use();
@ -51,15 +51,15 @@ void MyApplication::update(float delta_time, clock_t clock)
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_6))
{
swap_scene(&m_builtin_lit_scene);
swap_scene(&m_builtin_textured_scene);
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_7))
{
swap_scene(&m_builtin_textured_scene);
swap_scene(&m_builtin_lit_scene);
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_8))
{
swap_scene(&m_builtin_lit_shadowed_scene);
swap_scene(&m_pong_scene);
}
m_p_current_scene->update(delta_time, clock);
}

View File

@ -1,19 +1,20 @@
#pragma once
#include "Application.h"
#include <charcoal/Application.h>
#include <charcoal/Scene.h>
#include "MyBasicScene.h"
#include "MySimple2DScene.h"
#include "MySimple3DScene.h"
#include "MySimpleCubeScene.h"
#include "MyBuiltinCubeScene.h"
#include "MyBuiltinLitScene.h"
#include "MyBuiltinTexturedScene.h"
#include "MyBuiltinLitShadowedScene.h"
#include "MyBuiltinLitScene.h"
#include "MyPongScene.h"
using namespace charcoal;
class MyApplication :
public Application
class MyApplication : public Application
{
public:
MyApplication(int width = -1, int height = -1);
@ -38,8 +39,8 @@ private:
MySimple3DScene m_simple_3d_scene;
MySimpleCubeScene m_simple_cube_scene;
MyBuiltinCubeScene m_builtin_basic_cube_scene;
MyBuiltinLitScene m_builtin_lit_scene;
MyBuiltinTexturedScene m_builtin_textured_scene;
MyBuiltinLitShadowedScene m_builtin_lit_shadowed_scene;
MyBuiltinLitScene m_builtin_lit_scene;
MyPongScene m_pong_scene;
};

View File

@ -1,6 +1,6 @@
#pragma once
#include "Scene.h"
#include <charcoal/Scene.h>
#include "MyBasicShaderProgram.h"

View File

@ -1,9 +1,9 @@
#pragma once
#include "VertexFragmentShaderProgram.h"
#include "Shader.h"
#include "Mesh.h"
#include "Renderable.h"
#include <charcoal/Shader.h>
#include <charcoal/Mesh.h>
#include <charcoal/Renderable.h>
#include <charcoal/VertexFragmentShaderProgram.h>
using namespace charcoal;

View File

@ -1,8 +1,7 @@
#pragma once
#include "Batch.h"
#include "Poseable.h"
#include <charcoal/Batch.h>
#include <charcoal/Poseable.h>
#include "MySimpleShaderProgram.h"

View File

@ -1,17 +1,24 @@
#include "MyBuiltinCubeScene.h"
#include "MeshGenerator.h"
#include <charcoal/constants.h>
#include "constants.h"
#include <charcoal-builtin/MeshGenerator.h>
#include <charcoal-builtin/GLUtil.h>
MyBuiltinCubeScene::MyBuiltinCubeScene(Application& application)
: basic::Scene(application),
: Scene(application),
m_shape(meshgenerator::gen_cube_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f), DrawMode::DRAW_TRIANGLES),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)),
m_batch(add_batch(&m_shape, 1))
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)),
m_batch(&m_shape, 2)
{
add_prerenderable(&m_camera);
set_camera(&m_camera);
m_pipeline.add_batch(&m_batch);
m_pipeline.set_camera(&m_camera);
}
void MyBuiltinCubeScene::init()
{
m_batch.init();
}
void MyBuiltinCubeScene::update(float delta_time, clock_t clock)
@ -30,11 +37,11 @@ void MyBuiltinCubeScene::update(float delta_time, clock_t clock)
radians = (float)TAU * c / intervals;
{
Poseable& pose = m_batch.get_pose(0);
pose.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
pose.update_position(vec3(3 * (float)cos(radians), 0.0f, 0.0f));
}
m_pose_a.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
m_pose_a.update_position(vec3(3 * (float)cos(radians), 1.0f, 0.0f));
m_pose_b.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
m_pose_b.update_position(vec3(-3 * (float)cos(radians), -1.0f, 0.0f));
vec3 camera_translation(0.0f, 0.0f, 0.0f);
@ -51,5 +58,21 @@ void MyBuiltinCubeScene::update(float delta_time, clock_t clock)
m_camera.translate(camera_translation * delta_time);
m_camera.rotate(vec3(0.0f, 1.0f, 0.0f), camera_rotation * (float)TAU_1_8 * delta_time);
m_batch.reset_rendered();
m_batch.add_rendered(m_pose_a);
m_batch.add_rendered(m_pose_b);
}
void MyBuiltinCubeScene::prerender()
{
m_camera.prerender();
m_batch.prerender();
}
void MyBuiltinCubeScene::render()
{
glutil::clear_screen();
m_pipeline.render();
}

View File

@ -0,0 +1,37 @@
#pragma once
#include <charcoal/Poseable.h>
#include <charcoal/Scene.h>
#include <charcoal-builtin/BuiltinCamera3D.h>
#include <charcoal-builtin/BasicPipeline.h>
using namespace charcoal;
using namespace charcoal::builtin;
class MyBuiltinCubeScene : public Scene
{
public:
MyBuiltinCubeScene(Application& application);
void init() override;
void use() override {}
void unuse() override {}
void update(float delta_time, clock_t clock) override;
void prerender() override;
void render() override;
private:
basic::Renderable m_shape;
builtin::Camera3D m_camera;
basic::Batch m_batch;
basic::Pipeline m_pipeline;
Poseable m_pose_a;
Poseable m_pose_b;
};

View File

@ -1,31 +1,40 @@
#include "MyBuiltinLitScene.h"
#include "MeshGenerator.h"
#include <charcoal/constants.h>
#include "constants.h"
#include <charcoal-builtin/MeshGenerator.h>
#include <charcoal-builtin/GLUtil.h>
// TODO: Consider just making a template class for testing out stuff like this...
// Especially considering that update and render are probably going to be relatively similar almost every time.
MyBuiltinLitScene::MyBuiltinLitScene(Application& application)
: lit::Scene(application),
: Scene(application),
m_shape(
meshgenerator::set_material<lit::Vertex, lit::Index>(
meshgenerator::gen_cube_pn<lit::Vertex, lit::Index>(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f),
Material(1.0f, 1.0f, 0.2f, 1.0f)
PhongMaterial(1.0f, 1.0f, 0.2f, 1.0f)
), DrawMode::DRAW_TRIANGLES
),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)),
m_batch(add_batch(&m_shape, 1))
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)),
m_batch(&m_shape, 2),
m_light(
Position(0.0f, 2.0f, 2.0f),
PhongLight::Power(0.2f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
PhongLight::Fade(1.0f, 0.1f, 0.01f)
)
{
add_prerenderable(&m_camera);
set_camera(&m_camera);
m_pipeline.add_batch(&m_batch);
m_pipeline.set_camera(&m_camera);
}
add_light(
Position(0.0f, 2.0f, -2.0f),
Light::Power(0.2f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
Light::Fade(1.0f, 0.1f, 0.01f)
);
void MyBuiltinLitScene::init()
{
m_batch.init();
}
void MyBuiltinLitScene::update(float delta_time, clock_t clock)
@ -44,11 +53,11 @@ void MyBuiltinLitScene::update(float delta_time, clock_t clock)
radians = (float)TAU * c / intervals;
{
Poseable& pose = m_batch.get_pose(0);
pose.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_8 * delta_time);
pose.update_position(vec3(3 * (float)cos(radians), 0.0f, 0.0f));
}
m_pose_a.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
m_pose_a.update_position(vec3(3 * (float)cos(radians), 1.0f, 0.0f));
m_pose_b.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
m_pose_b.update_position(vec3(-3 * (float)cos(radians), -1.0f, 0.0f));
vec3 camera_translation(0.0f, 0.0f, 0.0f);
@ -65,5 +74,24 @@ void MyBuiltinLitScene::update(float delta_time, clock_t clock)
m_camera.translate(camera_translation * delta_time);
m_camera.rotate(vec3(0.0f, 1.0f, 0.0f), camera_rotation * (float)TAU_1_8 * delta_time);
m_batch.reset_rendered();
m_batch.add_rendered(m_pose_a);
m_batch.add_rendered(m_pose_b);
m_pipeline.reset_lights();
m_pipeline.add_light(m_light);
}
void MyBuiltinLitScene::prerender()
{
m_camera.prerender();
m_batch.prerender();
}
void MyBuiltinLitScene::render()
{
glutil::clear_screen();
m_pipeline.render();
}

View File

@ -0,0 +1,39 @@
#pragma once
#include <charcoal/Poseable.h>
#include <charcoal/Scene.h>
#include <charcoal-builtin/BuiltinCamera3D.h>
#include <charcoal-builtin/LitPipeline.h>
using namespace charcoal;
using namespace charcoal::builtin;
class MyBuiltinLitScene : public Scene
{
public:
MyBuiltinLitScene(Application& application);
void init() override;
void use() override {}
void unuse() override {}
void update(float delta_time, clock_t clock) override;
void prerender() override;
void render() override;
private:
lit::Renderable m_shape;
builtin::Camera3D m_camera;
lit::Batch m_batch;
lit::Pipeline m_pipeline;
lit::Light m_light;
Poseable m_pose_a;
Poseable m_pose_b;
};

View File

@ -0,0 +1,98 @@
#include "MyBuiltinTexturedScene.h"
#include <charcoal/constants.h>
#include <charcoal/TextureFactory.h>
#include <charcoal-builtin/MeshGenerator.h>
#include <charcoal-builtin/TextureGenerator.h>
#include <charcoal-builtin/GLUtil.h>
MyBuiltinTexturedScene::MyBuiltinTexturedScene(Application& application)
: Scene(application),
m_sprite_image(image_loader::load_file(IMAGE_PATH "uber.png")),
m_cube(
meshgenerator::gen_cube_pt<textured::Vertex, textured::Index>(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f),
DRAW_TRIANGLES,
texturegenerator::gen_quick_cube_texture(),
texturegenerator::gen_quick_sampler()
),
m_sprite(
meshgenerator::gen_rect_pt<textured::Vertex, textured::Index>(DRAW_TRIANGLES, 2.0f, 2.0f),
DRAW_TRIANGLES,
TextureFactory::gen_image_texture(m_sprite_image),
texturegenerator::gen_quick_sampler()
),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f), vec3(0.0f, 0.0f, -1.0f)),
m_cube_batch(&m_cube, 2),
m_sprite_batch(&m_sprite, 1)
{
m_pipeline.add_batch(&m_cube_batch);
m_pipeline.add_batch(&m_sprite_batch);
m_pipeline.set_camera(&m_camera);
}
void MyBuiltinTexturedScene::init()
{
m_cube_batch.init();
m_sprite_batch.init();
}
void MyBuiltinTexturedScene::update(float delta_time, clock_t clock)
{
float brightness;
float radians;
clock_t c;
const clock_t intervals = 512 * CLOCKS_PER_SEC / 100;
const clock_t half_interval = 256 * CLOCKS_PER_SEC / 100;
c = clock % intervals;
if (c < half_interval)
brightness = (float)c / half_interval;
else
brightness = (float)(intervals - c) / half_interval;
radians = (float)TAU * c / intervals;
m_cube_pose_a.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
m_cube_pose_a.update_position(vec3(3 * (float)cos(radians), 1.0f, 0.0f));
m_cube_pose_b.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_2 * delta_time);
m_cube_pose_b.update_position(vec3(-3 * (float)cos(radians), -1.0f, 0.0f));
vec3 camera_translation(0.0f, 0.0f, 0.0f);
if (m_input_manager.is_key_down(GLFW_KEY_W)) camera_translation.y += 1;
if (m_input_manager.is_key_down(GLFW_KEY_S)) camera_translation.y -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_A)) camera_translation.x -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_D)) camera_translation.x += 1;
if (m_input_manager.is_key_down(GLFW_KEY_Q)) camera_translation.z -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_E)) camera_translation.z += 1;
float camera_rotation = 0.0f;
if (m_input_manager.is_key_down(GLFW_KEY_Z)) camera_rotation += 1;
if (m_input_manager.is_key_down(GLFW_KEY_C)) camera_rotation -= 1;
m_camera.translate(camera_translation * delta_time);
m_camera.rotate(vec3(0.0f, 1.0f, 0.0f), camera_rotation * (float)TAU_1_8 * delta_time);
m_cube_batch.reset_rendered();
m_cube_batch.add_rendered(m_cube_pose_a);
m_cube_batch.add_rendered(m_cube_pose_b);
m_sprite_batch.reset_rendered();
m_sprite_batch.add_rendered(m_sprite_pose);
}
void MyBuiltinTexturedScene::prerender()
{
m_camera.prerender();
m_cube_batch.prerender();
m_sprite_batch.prerender();
}
void MyBuiltinTexturedScene::render()
{
glutil::clear_screen();
m_pipeline.render();
}

View File

@ -0,0 +1,47 @@
#pragma once
#include <charcoal/Poseable.h>
#include <charcoal/Scene.h>
#include <charcoal/ImageLoader.h>
#include <charcoal-builtin/TexturedPipeline.h>
#include <charcoal-builtin/BuiltinCamera3D.h>
using namespace charcoal;
using namespace charcoal::builtin;
class MyBuiltinTexturedScene : public Scene
{
public:
MyBuiltinTexturedScene(Application& application);
void init() override;
void use() override {}
void unuse() override {}
void update(float delta_time, clock_t clock) override;
void prerender() override;
void render() override;
private:
image_loader::ImageRGBA m_sprite_image;
textured::Renderable m_cube;
textured::Renderable m_sprite;
builtin::Camera3D m_camera;
textured::Batch m_cube_batch;
textured::Batch m_sprite_batch;
textured::Pipeline m_pipeline;
Poseable m_cube_pose_a;
Poseable m_cube_pose_b;
Poseable m_sprite_pose;
};

277
Example/MyPongScene.cpp Normal file
View File

@ -0,0 +1,277 @@
#include "MyPongScene.h"
#include <stdlib.h> // rand
#include <charcoal/constants.h>
#include <charcoal/PhysicsTypes.h>
#include <charcoal/Collision.h>
#include <charcoal-builtin/MeshGenerator.h>
#include <charcoal-builtin/GLUtil.h>
#define LEFT_PADDLE_UP_KEY GLFW_KEY_A
#define LEFT_PADDLE_DOWN_KEY GLFW_KEY_Z
#define RIGHT_PADDLE_UP_KEY GLFW_KEY_APOSTROPHE
#define RIGHT_PADDLE_DOWN_KEY GLFW_KEY_SLASH
#define OUTLINE_THICKNESS 25.0f
#define OUTLINE_OFFSET 25.0f
#define OUTLINE_INWARDS (OUTLINE_OFFSET + OUTLINE_THICKNESS)
#define PADDLE_THICKNESS 25.0f
#define PADDLE_HEIGHT 150.0f
#define LIFE_THICKNESS 15.0f
#define LIFE_OFFSET 10.0f
#define LIFE_INWARDS (OUTLINE_INWARDS + LIFE_THICKNESS)
#define BALL_THICKNESS 25.0f
#define HALF_BALL_THICKNESS 12.5f
#define INITIAL_BALL_SPEED 250.0f
#define BALL_SPEED_INCREMENT 50.0f
#define PADDLE_SPEED 500.0f
#define STARTING_LIVES 5
MyPongScene::MyPongScene(Application& application)
: Scene(application),
m_outline_column(meshgenerator::gen_rect_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, m_screen_size.x - 2 * OUTLINE_THICKNESS, OUTLINE_THICKNESS), DRAW_TRIANGLES),
m_outline_row(meshgenerator::gen_rect_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, OUTLINE_THICKNESS, m_screen_size.y - 2 * OUTLINE_THICKNESS), DRAW_TRIANGLES),
m_ball(meshgenerator::gen_rect_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, BALL_THICKNESS, BALL_THICKNESS), DRAW_TRIANGLES),
m_life(meshgenerator::gen_rect_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, LIFE_THICKNESS, LIFE_THICKNESS), DRAW_TRIANGLES),
m_paddle(meshgenerator::gen_rect_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, PADDLE_THICKNESS, PADDLE_HEIGHT), DRAW_TRIANGLES),
m_outline_column_batch(&m_outline_column, 2),
m_outline_row_batch(&m_outline_row, 2),
m_ball_batch(&m_ball, 1),
m_life_batch(&m_life, STARTING_LIVES * 2),
m_paddle_batch(&m_paddle, 2),
m_outline_top_pose(glm::vec3(0.0f, (m_screen_size.y - OUTLINE_THICKNESS) / 2.0f - OUTLINE_OFFSET, 0.0f)),
m_outline_bottom_pose(glm::vec3(0.0f, -((m_screen_size.y - OUTLINE_THICKNESS) / 2.0f - OUTLINE_OFFSET), 0.0f)),
m_outline_left_pose(glm::vec3(-((m_screen_size.x - OUTLINE_THICKNESS) / 2.0f - OUTLINE_OFFSET), 0.0f, 0.0f)),
m_outline_right_pose(glm::vec3((m_screen_size.x - OUTLINE_THICKNESS) / 2.0f - OUTLINE_OFFSET, 0.0f, 0.0f)),
m_ball_pose(glm::vec3(0.0f, 0.0f, 0.0f)),
m_paddle_left_pose(glm::vec3(-(m_screen_size.x / 2.0f - OUTLINE_INWARDS - 2.5f * PADDLE_THICKNESS), 0.0f, 0.0f)),
m_paddle_right_pose(glm::vec3(m_screen_size.x / 2.0f - OUTLINE_INWARDS - 2.5f * PADDLE_THICKNESS, 0.0f, 0.0f)),
m_camera(m_screen_size),
m_left_lives(STARTING_LIVES),
m_right_lives(STARTING_LIVES)
{
m_pipeline.add_batch(&m_outline_column_batch);
m_pipeline.add_batch(&m_outline_row_batch);
m_pipeline.add_batch(&m_ball_batch);
m_pipeline.add_batch(&m_life_batch);
m_pipeline.add_batch(&m_paddle_batch);
m_pipeline.set_camera(&m_camera);
}
void MyPongScene::init()
{
// Batches
m_outline_column_batch.init();
m_outline_row_batch.init();
m_ball_batch.init();
m_life_batch.init();
m_paddle_batch.init();
// Set these once here since they will never change
m_outline_column_batch.reset_rendered();
m_outline_column_batch.add_rendered(m_outline_top_pose);
m_outline_column_batch.add_rendered(m_outline_bottom_pose);
m_outline_row_batch.reset_rendered();
m_outline_row_batch.add_rendered(m_outline_left_pose);
m_outline_row_batch.add_rendered(m_outline_right_pose);
reset_ball();
}
void MyPongScene::update(float delta_time, clock_t clock)
{
// Move Paddles
const glm::vec3 up(0.0f, 1.0f, 0.0f);
const glm::vec3 down(0.0f, -1.0f, 0.0f);
if (m_left_lives > 0)
{
if (m_input_manager.is_key_down(LEFT_PADDLE_UP_KEY))
{
m_paddle_left_pose.translate(up * PADDLE_SPEED * delta_time);
}
if (m_input_manager.is_key_down(LEFT_PADDLE_DOWN_KEY))
{
m_paddle_left_pose.translate(down * PADDLE_SPEED * delta_time);
}
}
if (m_right_lives > 0)
{
if (m_input_manager.is_key_down(RIGHT_PADDLE_UP_KEY))
{
m_paddle_right_pose.translate(up * PADDLE_SPEED * delta_time);
}
if (m_input_manager.is_key_down(RIGHT_PADDLE_DOWN_KEY))
{
m_paddle_right_pose.translate(down * PADDLE_SPEED * delta_time);
}
}
// Move ball
if (m_right_lives > 0 && m_left_lives > 0)
{
m_ball_pose.translate(glm::vec3(m_ball_direction * m_ball_speed * delta_time, 0.0f));
}
vec3 ball_position = m_ball_pose.get_position();
// Bounce Top and Bottom
if (ball_position.y + HALF_BALL_THICKNESS + OUTLINE_INWARDS > m_screen_size.y / 2.0f)
{
m_ball_direction.y = -glm::abs(m_ball_direction.y);
}
if (ball_position.y - HALF_BALL_THICKNESS - OUTLINE_INWARDS < -m_screen_size.y / 2.0f)
{
m_ball_direction.y = glm::abs(m_ball_direction.y);
}
// Scoring
if (ball_position.x + HALF_BALL_THICKNESS + OUTLINE_INWARDS > m_screen_size.x / 2.0f)
{
m_right_lives -= 1;
reset_ball();
}
if (ball_position.x - HALF_BALL_THICKNESS - OUTLINE_INWARDS < -m_screen_size.x / 2.0f)
{
m_left_lives -= 1;
reset_ball();
}
// Bounce off Paddles
glm::vec3 left_paddle_position = m_paddle_left_pose.get_position();
glm::vec3 right_paddle_position = m_paddle_right_pose.get_position();
physics::Rect ball_hitbox(glm::vec2(ball_position.x, ball_position.y), BALL_THICKNESS, BALL_THICKNESS);
physics::Rect left_paddle_hitbox(glm::vec2(left_paddle_position.x, left_paddle_position.y), PADDLE_THICKNESS, PADDLE_HEIGHT);
physics::Rect right_paddle_hitbox(glm::vec2(right_paddle_position.x, right_paddle_position.y), PADDLE_THICKNESS, PADDLE_HEIGHT);
if (physics::collision::rect_in_rect(ball_hitbox, left_paddle_hitbox))
{
float ball_y = m_ball_direction.y * m_ball_speed;
if (m_input_manager.is_key_down(LEFT_PADDLE_UP_KEY))
{
ball_y += PADDLE_SPEED;
}
else if (m_input_manager.is_key_down(LEFT_PADDLE_DOWN_KEY))
{
ball_y -= PADDLE_SPEED;
}
m_ball_direction = glm::normalize(glm::vec2(m_ball_speed, ball_y));
m_ball_speed += BALL_SPEED_INCREMENT;
}
if (physics::collision::rect_in_rect(ball_hitbox, right_paddle_hitbox))
{
float ball_y = m_ball_direction.y * m_ball_speed;
if (m_input_manager.is_key_down(RIGHT_PADDLE_UP_KEY))
{
ball_y += PADDLE_SPEED;
}
else if (m_input_manager.is_key_down(RIGHT_PADDLE_DOWN_KEY))
{
ball_y -= PADDLE_SPEED;
}
m_ball_direction = glm::normalize(glm::vec2(-m_ball_speed, ball_y));
m_ball_speed += BALL_SPEED_INCREMENT;
}
// Update Render Batches
m_ball_batch.reset_rendered();
m_ball_batch.add_rendered(m_ball_pose);
m_paddle_batch.reset_rendered();
m_paddle_batch.add_rendered(m_paddle_left_pose);
m_paddle_batch.add_rendered(m_paddle_right_pose);
// Update Life Render Batch
m_life_batch.reset_rendered();
Poseable left_life_pose(glm::vec3(-m_screen_size.x / 2.0f + LIFE_INWARDS, -m_screen_size.y / 2.0f + LIFE_INWARDS, 0.0f));
Poseable right_life_pose(glm::vec3(m_screen_size.x / 2.0f - LIFE_INWARDS, -m_screen_size.y / 2.0f + LIFE_INWARDS, 0.0f));
for (int i = 0; i < m_left_lives; ++i)
{
m_life_batch.add_rendered(left_life_pose);
left_life_pose.translate(glm::vec3(LIFE_THICKNESS + LIFE_OFFSET, 0.0f, 0.0f));
}
for (int i = 0; i < m_right_lives; ++i)
{
m_life_batch.add_rendered(right_life_pose);
right_life_pose.translate(glm::vec3(-(LIFE_THICKNESS + LIFE_OFFSET), 0.0f, 0.0f));
}
}
void MyPongScene::prerender()
{
m_camera.prerender();
m_outline_column_batch.prerender();
m_outline_row_batch.prerender();
m_ball_batch.prerender();
m_life_batch.prerender();
m_paddle_batch.prerender();
}
void MyPongScene::render()
{
glutil::clear_screen();
m_pipeline.render();
}
float MyPongScene::random()
{
return rand() / (float)RAND_MAX;
}
vec2 MyPongScene::rand_dir(float radians_low, float radians_high)
{
float radians = radians_low + random() * (radians_high - radians_low);
return glm::vec2(glm::cos(radians), glm::sin(radians));
}
void MyPongScene::reset_ball()
{
m_ball_speed = INITIAL_BALL_SPEED;
m_ball_pose.update_position(vec3(0.0f, 0.0f, 0.0f));
if (random() < 0.5)
{
// Toward right
m_ball_direction = rand_dir((float)charcoal::TAU_7_8, (float)charcoal::TAU_7_8 + (float)charcoal::TAU_1_4);
}
else
{
// Toward left
m_ball_direction = rand_dir((float)charcoal::TAU_3_8, (float)charcoal::TAU_5_8);
}
}

64
Example/MyPongScene.h Normal file
View File

@ -0,0 +1,64 @@
#pragma once
#include <charcoal/Poseable.h>
#include <charcoal/Scene.h>
#include <charcoal-builtin/BuiltinCamera2D.h>
#include <charcoal-builtin/BasicPipeline.h>
using namespace charcoal;
using namespace charcoal::builtin;
class MyPongScene : public Scene
{
public:
MyPongScene(Application& application);
void init() override;
void use() override {}
void unuse() override {}
void update(float delta_time, clock_t clock) override;
void prerender() override;
void render() override;
private:
float random();
vec2 rand_dir(float radians_low, float radians_high);
void reset_ball();
basic::Renderable m_outline_column;
basic::Renderable m_outline_row;
basic::Renderable m_ball;
basic::Renderable m_life;
basic::Renderable m_paddle;
basic::Batch m_outline_column_batch;
basic::Batch m_outline_row_batch;
basic::Batch m_ball_batch;
basic::Batch m_life_batch;
basic::Batch m_paddle_batch;
Poseable m_outline_top_pose;
Poseable m_outline_bottom_pose;
Poseable m_outline_left_pose;
Poseable m_outline_right_pose;
Poseable m_ball_pose;
Poseable m_paddle_left_pose;
Poseable m_paddle_right_pose;
builtin::Camera2D m_camera;
basic::Pipeline m_pipeline;
float m_ball_speed;
glm::vec2 m_ball_direction;
int m_left_lives;
int m_right_lives;
};

View File

@ -1,15 +1,13 @@
#include "MySimple2DScene.h"
#include "stdafx.h"
#include <charcoal/deps.h>
#include <charcoal/constants.h>
#include <charcoal/DrawMode.h>
#include <charcoal/MeshFactory.h>
#include <cmath>
#include <iostream>
#include "constants.h"
#include "DrawMode.h"
#include "MeshFactory.h"
MySimple2DScene::MySimple2DScene(Application& application)
: Scene(application),
m_shape(MeshFactory<MySimpleShaderProgram::Vertex, MySimpleShaderProgram::Index>::gen(

View File

@ -1,8 +1,7 @@
#pragma once
#include "Scene.h"
#include "Camera2D.h"
#include <charcoal/Scene.h>
#include <charcoal/Camera2D.h>
#include "MyBatch.h"
#include "MySimpleShaderProgram.h"
@ -31,5 +30,5 @@ private:
MySimpleShaderProgram m_shader_program;
MySimpleShaderProgram::RenderableT m_shape;
MyBatch m_batch;
Camera2D m_camera;
charcoal::Camera2D m_camera;
};

View File

@ -1,15 +1,13 @@
#include "MySimple3DScene.h"
#include "stdafx.h"
#include <charcoal/deps.h>
#include <charcoal/constants.h>
#include <charcoal/DrawMode.h>
#include <charcoal/MeshFactory.h>
#include <cmath>
#include <iostream>
#include "constants.h"
#include "DrawMode.h"
#include "MeshFactory.h"
MySimple3DScene::MySimple3DScene(Application& application)
: Scene(application),
m_shape(MeshFactory<MySimpleShaderProgram::Vertex, MySimpleShaderProgram::Index>::gen(
@ -20,7 +18,7 @@ MySimple3DScene::MySimple3DScene(Application& application)
MySimpleShaderProgram::Vertex(2.0f, -1.0f, 0.0f)
), DrawMode::DRAW_TRIANGLES),
m_batch(&m_shape, 2),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f))
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f))
{}
MySimple3DScene::~MySimple3DScene()

View File

@ -1,8 +1,7 @@
#pragma once
#include "Scene.h"
#include "Camera3D.h"
#include <charcoal/Scene.h>
#include <charcoal/Camera3D.h>
#include "MyBatch.h"
#include "MySimpleShaderProgram.h"

View File

@ -1,9 +1,8 @@
#include "MySimpleCubeScene.h"
#include "constants.h"
#include "MeshFactory.h"
#include "DrawMode.h"
#include <charcoal/constants.h>
#include <charcoal/MeshFactory.h>
#include <charcoal/DrawMode.h>
MySimpleCubeScene::MySimpleCubeScene(Application& application)
: Scene(application),
@ -19,7 +18,7 @@ MySimpleCubeScene::MySimpleCubeScene(Application& application)
MySimpleShaderProgram::Vertex( 1.0f, -1.0f, 1.0f)
), DrawMode::DRAW_TRIANGLES),
m_batch(&m_shape, 1),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f))
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f))
{}
MySimpleCubeScene::~MySimpleCubeScene()

View File

@ -1,8 +1,7 @@
#pragma once
#include "Scene.h"
#include "Camera3D.h"
#include <charcoal/Scene.h>
#include <charcoal/Camera3D.h>
#include "MyBatch.h"
#include "MySimpleShaderProgram.h"

View File

@ -1,9 +1,9 @@
#pragma once
#include "VertexFragmentShaderProgram.h"
#include "Shader.h"
#include "Mesh.h"
#include "Renderable.h"
#include <charcoal/VertexFragmentShaderProgram.h>
#include <charcoal/Shader.h>
#include <charcoal/Mesh.h>
#include <charcoal/Renderable.h>
using namespace charcoal;

View File

@ -1,9 +1,11 @@
#include "stdafx.h"
#pragma comment(lib, "charcoal.lib")
#pragma comment(lib, "charcoal-builtin.lib")
#include <charcoal/deps.h>
#include <charcoal/Exception.h>
#include <string>
#include "Exception.h"
#include "MyApplication.h"
int main(int argc, char** argv)

View File

@ -5,6 +5,17 @@ VisualStudioVersion = 15.0.27703.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGLEngine", "OpenGLEngine\OpenGLEngine.vcxproj", "{C03B666E-F3CE-4223-977D-9D6E2952F22E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Example", "Example\Example.vcxproj", "{2713E882-5224-490A-A056-F6AD20C42B12}"
ProjectSection(ProjectDependencies) = postProject
{29E6293C-506A-4FDD-8E3D-36674AD8163D} = {29E6293C-506A-4FDD-8E3D-36674AD8163D}
{C03B666E-F3CE-4223-977D-9D6E2952F22E} = {C03B666E-F3CE-4223-977D-9D6E2952F22E}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CharcoalBuiltin", "CharcoalBuiltin\CharcoalBuiltin.vcxproj", "{29E6293C-506A-4FDD-8E3D-36674AD8163D}"
ProjectSection(ProjectDependencies) = postProject
{C03B666E-F3CE-4223-977D-9D6E2952F22E} = {C03B666E-F3CE-4223-977D-9D6E2952F22E}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@ -21,6 +32,22 @@ Global
{C03B666E-F3CE-4223-977D-9D6E2952F22E}.Release|x64.Build.0 = Release|x64
{C03B666E-F3CE-4223-977D-9D6E2952F22E}.Release|x86.ActiveCfg = Release|Win32
{C03B666E-F3CE-4223-977D-9D6E2952F22E}.Release|x86.Build.0 = Release|Win32
{2713E882-5224-490A-A056-F6AD20C42B12}.Debug|x64.ActiveCfg = Debug|x64
{2713E882-5224-490A-A056-F6AD20C42B12}.Debug|x64.Build.0 = Debug|x64
{2713E882-5224-490A-A056-F6AD20C42B12}.Debug|x86.ActiveCfg = Debug|Win32
{2713E882-5224-490A-A056-F6AD20C42B12}.Debug|x86.Build.0 = Debug|Win32
{2713E882-5224-490A-A056-F6AD20C42B12}.Release|x64.ActiveCfg = Release|x64
{2713E882-5224-490A-A056-F6AD20C42B12}.Release|x64.Build.0 = Release|x64
{2713E882-5224-490A-A056-F6AD20C42B12}.Release|x86.ActiveCfg = Release|Win32
{2713E882-5224-490A-A056-F6AD20C42B12}.Release|x86.Build.0 = Release|Win32
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Debug|x64.ActiveCfg = Debug|x64
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Debug|x64.Build.0 = Debug|x64
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Debug|x86.ActiveCfg = Debug|Win32
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Debug|x86.Build.0 = Debug|Win32
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Release|x64.ActiveCfg = Release|x64
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Release|x64.Build.0 = Release|x64
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Release|x86.ActiveCfg = Release|Win32
{29E6293C-506A-4FDD-8E3D-36674AD8163D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,6 +1,6 @@
#pragma once
#include "stdafx.h"
#include "deps.h"
#include <glm/glm.hpp>

View File

@ -1,32 +0,0 @@
#include "BasicBatch.h"
namespace charcoal
{
namespace builtin
{
namespace basic
{
void Batch::setup_vao()
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), NULL);
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glEnableVertexAttribArray(3);
glEnableVertexAttribArray(4);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4)));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4)));
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4)));
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4)));
glVertexAttribDivisor(0, 0); // Send the mesh data once
glVertexAttribDivisor(1, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(2, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(3, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(4, 1); // Send the offset data for each instance drawn
}
}
}
}

View File

@ -1,33 +0,0 @@
#pragma once
#include "PoseableBatch.h"
#include "BasicTypes.h"
namespace charcoal
{
namespace builtin
{
namespace basic
{
class Batch : public PoseableBatch<Vertex, Index, Renderable>
{
public:
Batch(
Renderable* renderable,
int element_count
) : PoseableBatch<Vertex, Index, Renderable>(renderable, element_count)
{}
Batch(
Renderable* renderable,
int element_count,
int element_render_count
) : PoseableBatch<Vertex, Index, Renderable>(renderable, element_count, element_render_count)
{}
protected:
void setup_vao() override;
};
}
}
}

View File

@ -1,48 +0,0 @@
#include "BasicScene.h"
#include "stdafx.h"
#include "GLUtil.h"
#include "MeshFactory.h"
namespace charcoal
{
namespace builtin
{
namespace basic
{
void Scene::init()
{
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
Batch& batch = *iter;
batch.init();
add_prerenderable(&batch);
}
}
void Scene::use()
{
// TODO: move to glutil
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void Scene::unuse()
{
}
void Scene::render()
{
glutil::clear_screen();
m_shader_program.use();
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
iter->render();
}
}
}
}
}

View File

@ -1,45 +0,0 @@
#pragma once
#include <vector>
#include "Application.h"
#include "AutoPrerenderingScene.h"
#include "BasicShaderProgram.h"
#include "BasicTypes.h"
#include "Camera.h"
#include "Batched.h"
#include "BasicBatch.h"
#include "constants.h"
namespace charcoal
{
namespace builtin
{
namespace basic
{
class Scene : public AutoPrerenderingScene, public Batched<Renderable, Batch>
{
public:
Scene(Application& application) : AutoPrerenderingScene(application) {}
virtual ~Scene() {}
void init() override;
void use() override;
void unuse() override;
void render() override;
protected:
void set_camera(const Camera* p_camera) { m_p_camera = p_camera; }
private:
ShaderProgram m_shader_program;
const Camera* m_p_camera = nullptr;
};
}
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "stdafx.h"
#include "deps.h"
#include <cstddef>
#include <vector>

View File

@ -1,21 +0,0 @@
#pragma once
#include "Prerenderable.h"
#include "Camera2D.h"
namespace charcoal
{
namespace builtin
{
class Camera2D : public Prerenderable, public charcoal::Camera2D
{
public:
Camera2D(const vec2& size, const vec2& position = vec2(0.0f, 0.0f))
: charcoal::Camera2D(size, position) {}
Camera2D(const vec3& size = vec3(2.0f, 2.0f, 2.0f), const vec3& position = vec3(0.0f, 0.0f, 0.0f))
: charcoal::Camera2D(size, position) {}
void prerender() override { charcoal::Camera2D::prerender(); }
};
}
}

View File

@ -1,27 +0,0 @@
#pragma once
#include "Prerenderable.h"
#include "Camera3D.h"
namespace charcoal
{
namespace builtin
{
class Camera3D : public Prerenderable, public charcoal::Camera3D
{
public:
Camera3D(
float fov_y,
float aspect_ratio,
float znear,
float zfar,
const vec3& position,
const vec3& forward = vec3(0.0f, 0.0f, 1.0f),
const vec3& up = vec3(0.0f, 1.0f, 0.0f),
const vec3& right = vec3(0.0f) // Zero for auto-calculated
) : charcoal::Camera3D(fov_y, aspect_ratio, znear, zfar, position, forward, up, right) {}
void prerender() override { charcoal::Camera3D::prerender(); }
};
}
}

View File

@ -17,7 +17,7 @@ namespace charcoal
float znear,
float zfar,
const vec3& position,
const vec3& forward = vec3(0.0f, 0.0f, 1.0f),
const vec3& forward = vec3(0.0f, 0.0f, -1.0f),
const vec3& up = vec3(0.0f, 1.0f, 0.0f),
const vec3& right = vec3(0.0f) // Zero for auto-calculated
);
@ -27,7 +27,7 @@ namespace charcoal
// Updates the orientation based on three vectors.
// If right is equal to zero it is calculated with glm::cross(forward, up).
// Then the true up is calculated with glm::cross(right, forward)
void update_orientation(const vec3& forward = vec3(0.0f, 0.0f, 1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f));
void update_orientation(const vec3& forward = vec3(0.0f, 0.0f, -1.0f), const vec3& up = vec3(0.0f, 1.0f, 0.0f), const vec3& right = vec3(0.0f));
// Directly sets the forward, up, and right values.
void direct_update_orientation(const vec3& forward, const vec3& up, const vec3& right);

37
OpenGLEngine/Collision.h Normal file
View File

@ -0,0 +1,37 @@
#pragma once
#include "PhysicsTypes.h"
namespace charcoal
{
namespace physics
{
namespace collision
{
// 4 comparisons
bool point_in_rect(const Rect& rect, float x, float y)
{
return
y < rect.top &&
y > rect.bottom &&
x > rect.left &&
x < rect.right;
}
// 8 * 4 = 32 comparisons
bool rect_in_rect(const Rect& a, const Rect& b)
{
return
point_in_rect(a, b.left, b.top) ||
point_in_rect(a, b.left, b.bottom) ||
point_in_rect(a, b.right, b.top) ||
point_in_rect(a, b.right, b.bottom) ||
point_in_rect(b, a.left, a.top) ||
point_in_rect(b, a.left, a.bottom) ||
point_in_rect(b, a.right, a.top) ||
point_in_rect(b, a.right, a.bottom);
}
}
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "stdafx.h"
#include "deps.h"
namespace charcoal
{

View File

@ -1,18 +0,0 @@
#pragma once
class FileUtil
{
public:
class File
{
public:
File(const std::string& path);
unsigned long get_size();
char* get_contents();
private:
const std::string m_path;
};
};

View File

@ -1,6 +1,6 @@
#pragma once
#include "stdafx.h"
#include "deps.h"
#include "InputManager.h"

View File

@ -0,0 +1,18 @@
#include "ImageLoader.h"
#include "lodepng.h"
namespace charcoal
{
namespace image_loader
{
ImageRGBA load_file(const std::string& filename)
{
std::vector<unsigned char> file_data;
lodepng::load_file(file_data, filename);
ImageRGBA ret;
lodepng::decode(ret.data, ret.width, ret.height, file_data);
return ret;
}
}
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <vector>
namespace charcoal
{
namespace image_loader
{
struct ImageRGBA
{
std::vector<unsigned char> data;
unsigned int width;
unsigned int height;
};
ImageRGBA load_file(const std::string& filename);
}
}

View File

@ -1,38 +0,0 @@
#include "LitBatch.h"
namespace charcoal
{
namespace builtin
{
namespace lit
{
void Batch::setup_vao()
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(offsetof(Vertex, position)));
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(offsetof(Vertex, normal)));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(offsetof(Vertex, material)));
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]);
glEnableVertexAttribArray(3);
glEnableVertexAttribArray(4);
glEnableVertexAttribArray(5);
glEnableVertexAttribArray(6);
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4)));
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4)));
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4)));
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4)));
glVertexAttribDivisor(0, 0); // Send the mesh data once
glVertexAttribDivisor(1, 0); // Send the mesh data once
glVertexAttribDivisor(2, 0); // Send the mesh data once
glVertexAttribDivisor(3, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(4, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(5, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(6, 1); // Send the offset data for each instance drawn
}
}
}
}

View File

@ -1,33 +0,0 @@
#pragma once
#include "PoseableBatch.h"
#include "LitTypes.h"
namespace charcoal
{
namespace builtin
{
namespace lit
{
class Batch : public PoseableBatch<Vertex, Index, Renderable>
{
public:
Batch(
Renderable* renderable,
int element_count
) : PoseableBatch<Vertex, Index, Renderable>(renderable, element_count)
{}
Batch(
Renderable* renderable,
int element_count,
int element_render_count
) : PoseableBatch<Vertex, Index, Renderable>(renderable, element_count, element_render_count)
{}
protected:
void setup_vao() override;
};
}
}
}

View File

@ -1,52 +0,0 @@
#include "LitScene.h"
#include "stdafx.h"
#include "Util.h"
#include "GLUtil.h"
#include "MeshFactory.h"
namespace charcoal
{
namespace builtin
{
namespace lit
{
void Scene::init()
{
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
Batch& batch = *iter;
batch.init();
add_prerenderable(&batch);
}
}
void Scene::use()
{
// TODO: move to glutil
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void Scene::unuse()
{
}
void Scene::render()
{
glutil::clear_screen();
m_shader_program.use();
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
glutil::uniform_vec3(4, m_p_camera->get_position());
glutil::uniform_uint(5, (unsigned int)m_lights.size());
glutil::uniform_lights(6, m_lights);
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
iter->render();
}
}
}
}
}

View File

@ -1,56 +0,0 @@
#pragma once
#include <vector>
#include "AutoPrerenderingScene.h"
#include "LitTypes.h"
#include "Camera.h"
#include "Batched.h"
#include "LitBatch.h"
#include "LitShaderProgram.h"
namespace charcoal
{
namespace builtin
{
namespace lit
{
// A scene lit by the Phong Reflection Model (See https://en.wikipedia.org/wiki/Phong_reflection_model )
class Scene : public AutoPrerenderingScene, public Batched<Renderable, Batch>
{
public:
Scene(Application& application) : AutoPrerenderingScene(application) {}
virtual ~Scene() {}
void init() override;
void use() override;
void unuse() override;
void render() override;
protected:
void set_camera(const Camera* p_camera) { m_p_camera = p_camera; }
Light& add_light(
const Position& position,
const Light::Power& power,
const ColorRGB ambient,
const ColorRGB diffuse,
const ColorRGB specular,
const Light::Fade& fade
)
{
m_lights.emplace_back(position, power, ambient, diffuse, specular, fade);
return m_lights.back();
}
private:
ShaderProgram m_shader_program;
const Camera* m_p_camera = nullptr;
std::vector<Light> m_lights;
};
}
}
}

View File

@ -1,38 +0,0 @@
#include "LitShadowedBatch.h"
namespace charcoal
{
namespace builtin
{
namespace litshadowed
{
void Batch::setup_vao()
{
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(offsetof(Vertex, position)));
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(offsetof(Vertex, normal)));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)(offsetof(Vertex, material)));
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[0]);
glEnableVertexAttribArray(3);
glEnableVertexAttribArray(4);
glEnableVertexAttribArray(5);
glEnableVertexAttribArray(6);
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(0 * sizeof(vec4)));
glVertexAttribPointer(4, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(1 * sizeof(vec4)));
glVertexAttribPointer(5, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(2 * sizeof(vec4)));
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(Poseable), (void*)(3 * sizeof(vec4)));
glVertexAttribDivisor(0, 0); // Send the mesh data once
glVertexAttribDivisor(1, 0); // Send the mesh data once
glVertexAttribDivisor(2, 0); // Send the mesh data once
glVertexAttribDivisor(3, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(4, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(5, 1); // Send the offset data for each instance drawn
glVertexAttribDivisor(6, 1); // Send the offset data for each instance drawn
}
}
}
}

View File

@ -1,33 +0,0 @@
#pragma once
#include "PoseableBatch.h"
#include "LitShadowedTypes.h"
namespace charcoal
{
namespace builtin
{
namespace litshadowed
{
class Batch : public PoseableBatch<Vertex, Index, Renderable>
{
public:
Batch(
Renderable* renderable,
int element_count
) : PoseableBatch<Vertex, Index, Renderable>(renderable, element_count)
{}
Batch(
Renderable* renderable,
int element_count,
int element_render_count
) : PoseableBatch<Vertex, Index, Renderable>(renderable, element_count, element_render_count)
{}
protected:
void setup_vao() override;
};
}
}
}

View File

@ -1,52 +0,0 @@
#include "LitShadowedScene.h"
#include "stdafx.h"
#include "Util.h"
#include "GLUtil.h"
#include "MeshFactory.h"
namespace charcoal
{
namespace builtin
{
namespace litshadowed
{
void Scene::init()
{
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
Batch& batch = *iter;
batch.init();
add_prerenderable(&batch);
}
}
void Scene::use()
{
// TODO: move to glutil
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void Scene::unuse()
{
}
void Scene::render()
{
glutil::clear_screen();
m_shader_program.use();
glutil::uniform_matrix(0, m_p_camera->get_world_to_view_matrix());
glutil::uniform_vec3(4, m_p_camera->get_position());
glutil::uniform_uint(5, (unsigned int)m_lights.size());
glutil::uniform_lights(6, m_lights);
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
{
iter->render();
}
}
}
}
}

View File

@ -1,56 +0,0 @@
#pragma once
#include <vector>
#include "AutoPrerenderingScene.h"
#include "LitShadowedTypes.h"
#include "Camera.h"
#include "Batched.h"
#include "LitShadowedBatch.h"
#include "LitShadowedShaderProgram.h"
namespace charcoal
{
namespace builtin
{
namespace litshadowed
{
// A scene lit by the Phong Reflection Model (See https://en.wikipedia.org/wiki/Phong_reflection_model )
class Scene : public AutoPrerenderingScene, public Batched<Renderable, Batch>
{
public:
Scene(Application& application) : AutoPrerenderingScene(application) {}
virtual ~Scene() {}
void init() override;
void use() override;
void unuse() override;
void render() override;
protected:
void set_camera(const Camera* p_camera) { m_p_camera = p_camera; }
Light& add_light(
const Position& position,
const Light::Power& power,
const ColorRGB ambient,
const ColorRGB diffuse,
const ColorRGB specular,
const Light::Fade& fade
)
{
m_lights.emplace_back(position, power, ambient, diffuse, specular, fade);
return m_lights.back();
}
private:
ShaderProgram m_shader_program;
const Camera* m_p_camera = nullptr;
std::vector<Light> m_lights;
};
}
}
}

View File

@ -1,19 +0,0 @@
#pragma once
#include "VertexFragmentShaderProgram.h"
namespace charcoal
{
namespace builtin
{
namespace litshadowed
{
// TODO: Add constants for the uniform and vertex attribute locations (for all shader programs)
class ShaderProgram : public VertexFragmentShaderProgram
{
public:
ShaderProgram() : VertexFragmentShaderProgram(SHADER_PATH "LitShadowedVS.glsl", SHADER_PATH "LitShadowedFS.glsl") {}
};
}
}
}

View File

@ -1,17 +0,0 @@
#pragma once
#include "BuiltinTypes.h"
namespace charcoal
{
namespace builtin
{
namespace litshadowed
{
typedef PNMVertex Vertex;
typedef Index Index;
typedef RenderableT<Vertex, Index> Renderable;
typedef Light Light;
}
}
}

View File

@ -1,19 +0,0 @@
#pragma once
#include "BasicScene.h"
#include "BuiltinCamera3D.h"
using namespace charcoal;
using namespace charcoal::builtin;
class MyBuiltinCubeScene : public basic::Scene
{
public:
MyBuiltinCubeScene(Application& application);
void update(float delta_time, clock_t clock) override;
private:
basic::Renderable m_shape;
builtin::Camera3D m_camera;
basic::Batch& m_batch;
};

View File

@ -1,20 +0,0 @@
#pragma once
#include "LitScene.h"
#include "BuiltinCamera3D.h"
using namespace charcoal;
using namespace charcoal::builtin;
// TODO: Use the lit namespace in builtin
class MyBuiltinLitScene : public lit::Scene
{
public:
MyBuiltinLitScene(Application& application);
void update(float delta_time, clock_t clock) override;
private:
lit::Renderable m_shape;
builtin::Camera3D m_camera;
lit::Batch& m_batch;
};

View File

@ -1,76 +0,0 @@
#include "MyBuiltinLitShadowedScene.h"
#include "MeshGenerator.h"
#include "constants.h"
MyBuiltinLitShadowedScene::MyBuiltinLitShadowedScene(Application& application)
: litshadowed::Scene(application),
m_cube(
meshgenerator::set_material<litshadowed::Vertex, litshadowed::Index>(
meshgenerator::gen_cube_pn<litshadowed::Vertex, litshadowed::Index>(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f),
Material(1.0f, 1.0f, 0.2f, 1.0f)
), DrawMode::DRAW_TRIANGLES
),
m_plane(
meshgenerator::set_material<litshadowed::Vertex, litshadowed::Index>(
meshgenerator::gen_plane_pn<litshadowed::Vertex, litshadowed::Index>(DRAW_TRIANGLES, 4.0f, 4.0f),
Material(1.0f, 1.0f, 0.2f, 1.0f)
), DrawMode::DRAW_TRIANGLES
),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)),
m_cube_batch(add_batch(&m_cube, 1)),
m_plane_batch(add_batch(&m_plane, 1))
{
add_prerenderable(&m_camera);
set_camera(&m_camera);
add_light(
Position(0.0f, 2.0f, -2.0f),
Light::Power(0.2f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
ColorRGB(1.0f, 1.0f, 1.0f),
Light::Fade(1.0f, 0.1f, 0.01f)
);
}
void MyBuiltinLitShadowedScene::update(float delta_time, clock_t clock)
{
float brightness;
float radians;
clock_t c;
const clock_t intervals = 512 * CLOCKS_PER_SEC / 100;
const clock_t half_interval = 256 * CLOCKS_PER_SEC / 100;
c = clock % intervals;
if (c < half_interval)
brightness = (float)c / half_interval;
else
brightness = (float)(intervals - c) / half_interval;
radians = (float)TAU * c / intervals;
{
Poseable& pose = m_cube_batch.get_pose(0);
pose.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_8 * delta_time);
pose.update_position(vec3(3 * (float)cos(radians), 0.0f, 0.0f));
}
vec3 camera_translation(0.0f, 0.0f, 0.0f);
if (m_input_manager.is_key_down(GLFW_KEY_W)) camera_translation.y += 1;
if (m_input_manager.is_key_down(GLFW_KEY_S)) camera_translation.y -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_A)) camera_translation.x -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_D)) camera_translation.x += 1;
if (m_input_manager.is_key_down(GLFW_KEY_Q)) camera_translation.z -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_E)) camera_translation.z += 1;
float camera_rotation = 0.0f;
if (m_input_manager.is_key_down(GLFW_KEY_Z)) camera_rotation += 1;
if (m_input_manager.is_key_down(GLFW_KEY_C)) camera_rotation -= 1;
m_camera.translate(camera_translation * delta_time);
m_camera.rotate(vec3(0.0f, 1.0f, 0.0f), camera_rotation * (float)TAU_1_8 * delta_time);
}

View File

@ -1,21 +0,0 @@
#pragma once
#include "LitShadowedScene.h"
#include "BuiltinCamera3D.h"
using namespace charcoal;
using namespace charcoal::builtin;
class MyBuiltinLitShadowedScene : public litshadowed::Scene
{
public:
MyBuiltinLitShadowedScene(Application& application);
void update(float delta_time, clock_t clock) override;
private:
litshadowed::Renderable m_cube;
litshadowed::Renderable m_plane;
builtin::Camera3D m_camera;
litshadowed::Batch& m_cube_batch;
litshadowed::Batch& m_plane_batch;
};

View File

@ -1,61 +0,0 @@
#include "MyBuiltinTexturedScene.h"
#include "MeshGenerator.h"
#include "TextureGenerator.h"
#include "constants.h"
MyBuiltinTexturedScene::MyBuiltinTexturedScene(Application& application)
: textured::Scene(application),
m_shape(
meshgenerator::gen_cube_pt<textured::Vertex, textured::Index>(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f),
texturegenerator::gen_quick_cube_texture(),
texturegenerator::gen_quick_sampler(),
DrawMode::DRAW_TRIANGLES
),
m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f)),
m_batch(add_batch(&m_shape, 1))
{
add_prerenderable(&m_camera);
set_camera(&m_camera);
}
void MyBuiltinTexturedScene::update(float delta_time, clock_t clock)
{
float brightness;
float radians;
clock_t c;
const clock_t intervals = 512 * CLOCKS_PER_SEC / 100;
const clock_t half_interval = 256 * CLOCKS_PER_SEC / 100;
c = clock % intervals;
if (c < half_interval)
brightness = (float)c / half_interval;
else
brightness = (float)(intervals - c) / half_interval;
radians = (float)TAU * c / intervals;
{
Poseable& pose = m_batch.get_pose(0);
pose.rotate(glm::normalize(vec3(1.0f, 1.0f, 0.0f)), (float)TAU_1_4 * delta_time);
pose.update_position(vec3(3 * (float)cos(radians), 0.0f, 0.0f));
}
vec3 camera_translation(0.0f, 0.0f, 0.0f);
if (m_input_manager.is_key_down(GLFW_KEY_W)) camera_translation.y += 1;
if (m_input_manager.is_key_down(GLFW_KEY_S)) camera_translation.y -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_A)) camera_translation.x -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_D)) camera_translation.x += 1;
if (m_input_manager.is_key_down(GLFW_KEY_Q)) camera_translation.z -= 1;
if (m_input_manager.is_key_down(GLFW_KEY_E)) camera_translation.z += 1;
float camera_rotation = 0.0f;
if (m_input_manager.is_key_down(GLFW_KEY_Z)) camera_rotation += 1;
if (m_input_manager.is_key_down(GLFW_KEY_C)) camera_rotation -= 1;
m_camera.translate(camera_translation * delta_time);
m_camera.rotate(vec3(0.0f, 1.0f, 0.0f), camera_rotation * (float)TAU_1_8 * delta_time);
}

View File

@ -1,19 +0,0 @@
#pragma once
#include "TexturedScene.h"
#include "BuiltinCamera3D.h"
using namespace charcoal;
using namespace charcoal::builtin;
class MyBuiltinTexturedScene : public textured::Scene
{
public:
MyBuiltinTexturedScene(Application& application);
void update(float delta_time, clock_t clock) override;
private:
textured::Renderable m_shape;
builtin::Camera3D m_camera;
textured::Batch& m_batch;
};

View File

@ -23,6 +23,7 @@
<ProjectGuid>{C03B666E-F3CE-4223-977D-9D6E2952F22E}</ProjectGuid>
<RootNamespace>OpenGLEngine</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
<ProjectName>charcoal</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -39,7 +40,7 @@
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
@ -70,10 +71,10 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LibraryPath>$(ProjectDir)..\lib;$(LibraryPath)</LibraryPath>
<LibraryPath>$(SolutionDir)lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(ProjectDir)..\lib;$(LibraryPath)</LibraryPath>
<LibraryPath>$(SolutionDir)lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@ -91,17 +92,16 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>SHADER_PATH=R"($(ProjectDir))";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SHADER_PATH=R"($(SolutionDir)shaders\)";IMAGE_PATH=R"($(SolutionDir)images\)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link />
<PostBuildEvent>
<Message>
</Message>
<Command>
</Command>
<Message>Prepare LIB Information</Message>
<Command>copy "$(TargetPath)" "$(SolutionDir)lib\charcoal.lib"
copy "$(ProjectDir)*.h" "$(SolutionDir)include\charcoal\"</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>copy "$(ProjectDir)..\dll\*" "$(OutDir)"</Command>
<Command>copy "$(SolutionDir)dll\*" "$(OutDir)"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Copy DLLs</Message>
@ -131,20 +131,19 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(ProjectDir)..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>SHADER_PATH=R"($(ProjectDir))";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>SHADER_PATH=R"($(SolutionDir)shaders\)";IMAGE_PATH=R"($(SolutionDir)images\)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Message>
</Message>
<Command>
</Command>
<Message>Prepare LIB Information</Message>
<Command>copy "$(TargetPath)" "$(SolutionDir)lib\charcoal.lib"
copy "$(ProjectDir)*.h" "$(SolutionDir)include\charcoal\"</Command>
</PostBuildEvent>
<PreBuildEvent>
<Command>copy "$(ProjectDir)..\dll\*" "$(OutDir)"</Command>
<Command>copy "$(SolutionDir)dll\*" "$(OutDir)"</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Copy DLLs</Message>
@ -152,122 +151,54 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Application.cpp" />
<ClCompile Include="AutoPrerenderingScene.cpp" />
<ClCompile Include="BasicBatch.cpp" />
<ClCompile Include="BasicScene.cpp" />
<ClCompile Include="Camera2D.cpp" />
<ClCompile Include="Camera3D.cpp" />
<ClCompile Include="FPS.cpp" />
<ClCompile Include="LitBatch.cpp" />
<ClCompile Include="LitScene.cpp" />
<ClCompile Include="LitShadowedBatch.cpp" />
<ClCompile Include="LitShadowedScene.cpp" />
<ClCompile Include="MyBuiltinCubeScene.cpp" />
<ClCompile Include="ImageLoader.cpp" />
<ClCompile Include="lodepng.cpp" />
<ClCompile Include="GLFWInputManager.cpp" />
<ClCompile Include="GLUtil.cpp" />
<ClCompile Include="InputManager.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="MyBuiltinLitScene.cpp" />
<ClCompile Include="MyBuiltinLitShadowedScene.cpp" />
<ClCompile Include="MyBuiltinTexturedScene.cpp" />
<ClCompile Include="MySimpleCubeScene.cpp" />
<ClCompile Include="MySimple3DScene.cpp" />
<ClCompile Include="MyApplication.cpp" />
<ClCompile Include="MyBatch.cpp" />
<ClCompile Include="MySimple2DScene.cpp" />
<ClCompile Include="MyBasicScene.cpp" />
<ClCompile Include="Poseable.cpp" />
<ClCompile Include="Poseable2D.cpp" />
<ClCompile Include="Shader.cpp" />
<ClCompile Include="ShaderProgram.cpp" />
<ClCompile Include="Sampler.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TexturedBatch.cpp" />
<ClCompile Include="TexturedScene.cpp" />
<ClCompile Include="TextureFactory.cpp" />
<ClCompile Include="Util.cpp" />
<ClCompile Include="VertexFragmentShaderProgram.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Application.h" />
<ClInclude Include="AutoPrerenderingScene.h" />
<ClInclude Include="BasicBatch.h" />
<ClInclude Include="BasicScene.h" />
<ClInclude Include="BasicShaderProgram.h" />
<ClInclude Include="BasicTypes.h" />
<ClInclude Include="Batch.h" />
<ClInclude Include="Batched.h" />
<ClInclude Include="BuiltinBatch.h" />
<ClInclude Include="BuiltinCamera3D.h" />
<ClInclude Include="BuiltinCamera2D.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="Camera2D.h" />
<ClInclude Include="Camera3D.h" />
<ClInclude Include="Collision.h" />
<ClInclude Include="constants.h" />
<ClInclude Include="DrawMode.h" />
<ClInclude Include="Exception.h" />
<ClInclude Include="FPS.h" />
<ClInclude Include="LitBatch.h" />
<ClInclude Include="LitScene.h" />
<ClInclude Include="LitShaderProgram.h" />
<ClInclude Include="LitShadowedBatch.h" />
<ClInclude Include="LitShadowedScene.h" />
<ClInclude Include="LitShadowedShaderProgram.h" />
<ClInclude Include="LitShadowedTypes.h" />
<ClInclude Include="LitTypes.h" />
<ClInclude Include="MyBuiltinCubeScene.h" />
<ClInclude Include="MyBuiltinLitScene.h" />
<ClInclude Include="MyBuiltinLitShadowedScene.h" />
<ClInclude Include="MyBuiltinTexturedScene.h" />
<ClInclude Include="PoseableBatch.h" />
<ClInclude Include="Prerenderable.h" />
<ClInclude Include="ImageLoader.h" />
<ClInclude Include="lodepng.h" />
<ClInclude Include="PhysicsTypes.h" />
<ClInclude Include="Pipeline.h" />
<ClInclude Include="Sampler.h" />
<ClInclude Include="Poseable2D.h" />
<ClInclude Include="Texture.h" />
<ClInclude Include="TexturedBatch.h" />
<ClInclude Include="TexturedTypes.h" />
<ClInclude Include="TextureFactory.h" />
<ClInclude Include="TextureGenerator.h" />
<ClInclude Include="TextureRenderable.h" />
<ClInclude Include="TexturedScene.h" />
<ClInclude Include="TexturedShaderProgram.h" />
<ClInclude Include="VertexFragmentShaderProgram.h" />
<ClInclude Include="GLFWInputManager.h" />
<ClInclude Include="GLUtil.h" />
<ClInclude Include="InputManager.h" />
<ClInclude Include="Mesh.h" />
<ClInclude Include="MeshFactory.h" />
<ClInclude Include="MeshGenerator.h" />
<ClInclude Include="MySimpleCubeScene.h" />
<ClInclude Include="MySimple3DScene.h" />
<ClInclude Include="MyApplication.h" />
<ClInclude Include="MyBatch.h" />
<ClInclude Include="MySimpleShaderProgram.h" />
<ClInclude Include="MySimple2DScene.h" />
<ClInclude Include="MyBasicShaderProgram.h" />
<ClInclude Include="MyBasicScene.h" />
<ClInclude Include="Poseable.h" />
<ClInclude Include="Renderable.h" />
<ClInclude Include="Scene.h" />
<ClInclude Include="Shader.h" />
<ClInclude Include="ShaderProgram.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="deps.h" />
<ClInclude Include="Util.h" />
<ClInclude Include="BuiltinTypes.h" />
</ItemGroup>
<ItemGroup>
<None Include="BasicFS.glsl" />
<None Include="BasicVS.glsl" />
<None Include="LitShadowedFS.glsl" />
<None Include="LitShadowedVS.glsl" />
<None Include="MySimpleFS.glsl" />
<None Include="MySimpleVS.glsl" />
<None Include="MyBasicFS.glsl" />
<None Include="MyBasicVS.glsl" />
<None Include="LitVS.glsl" />
<None Include="LitFS.glsl" />
<None Include="TexturedFS.glsl" />
<None Include="TexturedVS.glsl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -13,431 +13,189 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Header Files\Example">
<UniqueIdentifier>{6a527248-fa21-4720-8864-49088116987e}</UniqueIdentifier>
<Filter Include="Source Files\Plugins">
<UniqueIdentifier>{1efd8145-fcba-4c08-8267-7180c458a942}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Example">
<UniqueIdentifier>{6f8b9833-6eed-478e-a52d-38bdb2573b92}</UniqueIdentifier>
<Filter Include="Source Files\Plugins\LodePNG">
<UniqueIdentifier>{b8357bff-b6be-4ee1-b45e-2f1e0fee90e1}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine">
<UniqueIdentifier>{053be292-7a70-4d73-8b07-dcb85d3d6ace}</UniqueIdentifier>
<Filter Include="Header Files\Plugins">
<UniqueIdentifier>{bb1d7dfe-7df9-4d4a-a110-de57a7f79f3a}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine">
<UniqueIdentifier>{c38724ea-6e5b-4561-bb97-74da2a031319}</UniqueIdentifier>
<Filter Include="Header Files\Plugins\LodePNG">
<UniqueIdentifier>{b7246e93-9a5b-4c40-9539-0edd785cdcde}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Example\Application">
<UniqueIdentifier>{3f9911e0-108f-4258-99c4-3f56e80ac27e}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Example\Rendering">
<UniqueIdentifier>{fd515372-39af-44d2-af2c-634b28e91878}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Example\Application">
<UniqueIdentifier>{dab3e00b-75ef-4281-b922-5ca6576c2dee}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Example\Rendering">
<UniqueIdentifier>{3361920b-2846-44ef-a1d1-5f867859bbbf}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Example\Rendering\Shader Code">
<UniqueIdentifier>{0c68fb1a-eaef-450c-ab9e-56bcfd75fdff}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\builtin">
<UniqueIdentifier>{65489d6f-e0f8-4530-8e9b-769234deea85}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine\builtin">
<UniqueIdentifier>{233b4bce-fc64-4ad1-994e-c986befa7ff2}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\Baseline">
<UniqueIdentifier>{c67a5bf1-f6fb-4148-904d-9f96a3c34c88}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\Baseline\Rendering">
<UniqueIdentifier>{51327f54-6f84-477f-8db8-883b91ebc5c2}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\Baseline\Application">
<Filter Include="Header Files\Application">
<UniqueIdentifier>{2d1806dc-3a5d-4237-b7e3-4fe6d6576dc2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine\Baseline">
<UniqueIdentifier>{5c0adf5c-83f0-46f0-89c8-83cdf8f0090d}</UniqueIdentifier>
<Filter Include="Header Files\ImageLoader">
<UniqueIdentifier>{ca80863e-8d81-4a1d-96e2-47fc58c65ed4}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine\Baseline\Rendering">
<UniqueIdentifier>{1bb31cb4-7b36-47b6-b9ee-3d5de57f8f0c}</UniqueIdentifier>
<Filter Include="Header Files\Types">
<UniqueIdentifier>{5a91799f-d6ee-429d-bd88-659dcc370de1}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine\Baseline\Application">
<Filter Include="Header Files\Factories">
<UniqueIdentifier>{5ceb1305-c3dd-47ce-bc85-c16c4af13c59}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Application">
<UniqueIdentifier>{e8ae51e5-5508-47c6-804c-6d13408b8d13}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\builtin\General">
<UniqueIdentifier>{9cd2885f-9d3b-439c-b206-e3d53f6d7191}</UniqueIdentifier>
<Filter Include="Source Files\ImageLoader">
<UniqueIdentifier>{7627441b-5417-427d-a082-9413952614b4}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\builtin\Scenes">
<UniqueIdentifier>{b3bc2383-d099-4fac-a51c-d2d4a8e7dea3}</UniqueIdentifier>
<Filter Include="Source Files\Factories">
<UniqueIdentifier>{4c95594f-63ac-4f42-b1ca-cd3db04b6e9e}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine\builtin\Scenes\LitShadowed">
<UniqueIdentifier>{2f2c0657-4ba3-4314-86dd-a600f533f746}</UniqueIdentifier>
<Filter Include="Source Files\Types">
<UniqueIdentifier>{c8d9e420-19ab-4706-9a82-5a4537142b5c}</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">
<UniqueIdentifier>{a9e42739-f380-4358-83e5-f994cab7e55c}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Engine\builtin\Scenes">
<UniqueIdentifier>{f9faae2c-4381-4a2e-a0be-27920a52dc4d}</UniqueIdentifier>
</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">
<UniqueIdentifier>{ca004137-6425-4863-b91a-cf32988855be}</UniqueIdentifier>
<Filter Include="Header Files\Physics">
<UniqueIdentifier>{4bd056e0-f68e-4aa4-b62d-a142ccf08a21}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files\Example</Filter>
</ClCompile>
<ClCompile Include="Application.cpp">
<Filter>Source Files\Engine\Baseline\Application</Filter>
<Filter>Source Files\Application</Filter>
</ClCompile>
<ClCompile Include="FPS.cpp">
<Filter>Source Files\Engine\Baseline\Application</Filter>
<Filter>Source Files\Application</Filter>
</ClCompile>
<ClCompile Include="GLFWInputManager.cpp">
<Filter>Source Files\Engine\Baseline\Application</Filter>
<Filter>Source Files\Application</Filter>
</ClCompile>
<ClCompile Include="InputManager.cpp">
<Filter>Source Files\Engine\Baseline\Application</Filter>
<Filter>Source Files\Application</Filter>
</ClCompile>
<ClCompile Include="ShaderProgram.cpp">
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
<ClCompile Include="ImageLoader.cpp">
<Filter>Source Files\ImageLoader</Filter>
</ClCompile>
<ClCompile Include="Shader.cpp">
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
</ClCompile>
<ClCompile Include="MyBatch.cpp">
<Filter>Source Files\Example\Rendering</Filter>
</ClCompile>
<ClCompile Include="MyApplication.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="Camera2D.cpp">
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
</ClCompile>
<ClCompile Include="Camera3D.cpp">
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
</ClCompile>
<ClCompile Include="MySimple2DScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MySimple3DScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MyBasicScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MySimpleCubeScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinCubeScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinLitScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="VertexFragmentShaderProgram.cpp">
<Filter>Source Files\Engine\Baseline\Rendering</Filter>
</ClCompile>
<ClCompile Include="BasicBatch.cpp">
<Filter>Source Files\Engine\builtin\Scenes\Basic</Filter>
</ClCompile>
<ClCompile Include="BasicScene.cpp">
<Filter>Source Files\Engine\builtin\Scenes\Basic</Filter>
</ClCompile>
<ClCompile Include="LitBatch.cpp">
<Filter>Source Files\Engine\builtin\Scenes\Lit</Filter>
</ClCompile>
<ClCompile Include="LitScene.cpp">
<Filter>Source Files\Engine\builtin\Scenes\Lit</Filter>
</ClCompile>
<ClCompile Include="TexturedBatch.cpp">
<Filter>Source Files\Engine\builtin\Scenes\Textured</Filter>
</ClCompile>
<ClCompile Include="TexturedScene.cpp">
<Filter>Source Files\Engine\builtin\Scenes\Textured</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinTexturedScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="LitShadowedBatch.cpp">
<Filter>Source Files\Engine\builtin\Scenes\LitShadowed</Filter>
</ClCompile>
<ClCompile Include="LitShadowedScene.cpp">
<Filter>Source Files\Engine\builtin\Scenes\LitShadowed</Filter>
</ClCompile>
<ClCompile Include="MyBuiltinLitShadowedScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="Poseable.cpp">
<Filter>Source Files\Engine\Baseline</Filter>
</ClCompile>
<ClCompile Include="Sampler.cpp">
<Filter>Source Files\Engine\Baseline</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files\Engine\Baseline</Filter>
<ClCompile Include="lodepng.cpp">
<Filter>Source Files\Plugins\LodePNG</Filter>
</ClCompile>
<ClCompile Include="Util.cpp">
<Filter>Source Files\Engine\Baseline</Filter>
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AutoPrerenderingScene.cpp">
<Filter>Source Files\Engine\builtin\General</Filter>
<ClCompile Include="Poseable.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="GLUtil.cpp">
<Filter>Source Files\Engine\builtin\General</Filter>
<ClCompile Include="Poseable2D.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="Sampler.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="Camera2D.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="Camera3D.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="Shader.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="ShaderProgram.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="VertexFragmentShaderProgram.cpp">
<Filter>Source Files\Types</Filter>
</ClCompile>
<ClCompile Include="TextureFactory.cpp">
<Filter>Source Files\Factories</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Application.h">
<Filter>Header Files\Engine\Baseline\Application</Filter>
<Filter>Header Files\Application</Filter>
</ClInclude>
<ClInclude Include="FPS.h">
<Filter>Header Files\Engine\Baseline\Application</Filter>
<Filter>Header Files\Application</Filter>
</ClInclude>
<ClInclude Include="GLFWInputManager.h">
<Filter>Header Files\Engine\Baseline\Application</Filter>
<Filter>Header Files\Application</Filter>
</ClInclude>
<ClInclude Include="InputManager.h">
<Filter>Header Files\Engine\Baseline\Application</Filter>
<Filter>Header Files\Application</Filter>
</ClInclude>
<ClInclude Include="Scene.h">
<Filter>Header Files\Engine\Baseline\Application</Filter>
<Filter>Header Files\Application</Filter>
</ClInclude>
<ClInclude Include="ShaderProgram.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
<ClInclude Include="ImageLoader.h">
<Filter>Header Files\ImageLoader</Filter>
</ClInclude>
<ClInclude Include="Camera.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
</ClInclude>
<ClInclude Include="Batch.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyBatch.h">
<Filter>Header Files\Example\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyApplication.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="Camera2D.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
</ClInclude>
<ClInclude Include="Camera3D.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
</ClInclude>
<ClInclude Include="MySimple2DScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="MySimple3DScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="MyBasicScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="MySimpleShaderProgram.h">
<Filter>Header Files\Example\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyBasicShaderProgram.h">
<Filter>Header Files\Example\Rendering</Filter>
</ClInclude>
<ClInclude Include="MySimpleCubeScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="VertexFragmentShaderProgram.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinCubeScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinLitScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="BasicBatch.h">
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
</ClInclude>
<ClInclude Include="BasicScene.h">
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
</ClInclude>
<ClInclude Include="BasicShaderProgram.h">
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
</ClInclude>
<ClInclude Include="LitBatch.h">
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
</ClInclude>
<ClInclude Include="LitScene.h">
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
</ClInclude>
<ClInclude Include="LitShaderProgram.h">
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
</ClInclude>
<ClInclude Include="TexturedBatch.h">
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
</ClInclude>
<ClInclude Include="TexturedScene.h">
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
</ClInclude>
<ClInclude Include="TexturedShaderProgram.h">
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinTexturedScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="Shader.h">
<Filter>Header Files\Engine\Baseline\Rendering</Filter>
</ClInclude>
<ClInclude Include="LitShadowedBatch.h">
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
</ClInclude>
<ClInclude Include="LitShadowedScene.h">
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
</ClInclude>
<ClInclude Include="LitShadowedShaderProgram.h">
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
</ClInclude>
<ClInclude Include="MyBuiltinLitShadowedScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="BasicTypes.h">
<Filter>Header Files\Engine\builtin\Scenes\Basic</Filter>
</ClInclude>
<ClInclude Include="LitTypes.h">
<Filter>Header Files\Engine\builtin\Scenes\Lit</Filter>
</ClInclude>
<ClInclude Include="TexturedTypes.h">
<Filter>Header Files\Engine\builtin\Scenes\Textured</Filter>
</ClInclude>
<ClInclude Include="LitShadowedTypes.h">
<Filter>Header Files\Engine\builtin\Scenes\LitShadowed</Filter>
<ClInclude Include="lodepng.h">
<Filter>Header Files\Plugins\LodePNG</Filter>
</ClInclude>
<ClInclude Include="constants.h">
<Filter>Header Files\Engine\Baseline</Filter>
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DrawMode.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="Exception.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="Mesh.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="MeshFactory.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="Poseable.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="Renderable.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="Sampler.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="Texture.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="TextureFactory.h">
<Filter>Header Files\Engine\Baseline</Filter>
</ClInclude>
<ClInclude Include="TextureRenderable.h">
<Filter>Header Files\Engine\Baseline</Filter>
<ClInclude Include="deps.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Util.h">
<Filter>Header Files\Engine\Baseline</Filter>
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AutoPrerenderingScene.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Mesh.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Batched.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Poseable.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="BuiltinBatch.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Poseable2D.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="BuiltinCamera2D.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Renderable.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="BuiltinCamera3D.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Sampler.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="BuiltinTypes.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Texture.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="GLUtil.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="TextureRenderable.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="MeshGenerator.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="DrawMode.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="PoseableBatch.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="Exception.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Prerenderable.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="MeshFactory.h">
<Filter>Header Files\Factories</Filter>
</ClInclude>
<ClInclude Include="TextureGenerator.h">
<Filter>Header Files\Engine\builtin\General</Filter>
<ClInclude Include="TextureFactory.h">
<Filter>Header Files\Factories</Filter>
</ClInclude>
<ClInclude Include="Batch.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Camera.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Camera2D.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Camera3D.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Shader.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="ShaderProgram.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="VertexFragmentShaderProgram.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Pipeline.h">
<Filter>Header Files\Types</Filter>
</ClInclude>
<ClInclude Include="Collision.h">
<Filter>Header Files\Physics</Filter>
</ClInclude>
<ClInclude Include="PhysicsTypes.h">
<Filter>Header Files\Physics</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="MySimpleVS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="MyBasicFS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="MyBasicVS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="MySimpleFS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="BasicFS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="BasicVS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="LitVS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="LitFS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="TexturedVS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="TexturedFS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="LitShadowedFS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
<None Include="LitShadowedVS.glsl">
<Filter>Source Files\Engine\builtin\Scenes\Shaders</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,29 @@
#pragma once
#include <glm/glm.hpp>
namespace charcoal
{
namespace physics
{
using namespace glm;
struct Rect
{
Rect(float top, float bottom, float left, float right)
: top(top), bottom(bottom), left(left), right(right)
{}
Rect(const glm::vec2& top_left, const glm::vec2& bottom_right)
: top(top_left.y), bottom(bottom_right.y), left(top_left.x), right(bottom_right.x)
{}
Rect(const glm::vec2& center, float width, float height)
: top(center.y + height / 2.0f), bottom(center.y - height / 2.0f), left(center.x - width / 2.0f), right(center.x + width / 2.0f)
{}
float top;
float bottom;
float left;
float right;
};
}
}

18
OpenGLEngine/Pipeline.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#include <vector>
namespace charcoal
{
template <typename ShaderProgramType, typename BatchType>
class Pipeline
{
public:
void add_batch(BatchType* batch) { m_batches.emplace_back(batch); }
virtual void render() = 0;
protected:
ShaderProgramType m_shader_program;
std::vector<BatchType*> m_batches;
};
}

View File

@ -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)
{
m_orientation_matrix[3][0] = position.x;

View File

@ -17,6 +17,8 @@ namespace charcoal
const vec3& right = vec3(1.0f, 0.0f, 0.0f)
);
void reset_orientation();
void update_position(const vec3& position);
// Assumes that forward, up, and right are orthogonal and normalized
void update_orientation(const vec3& forward, const vec3& up, const vec3& right);
@ -24,8 +26,12 @@ namespace charcoal
void translate(const vec3& translation);
void rotate(const vec3& axis, float angle);
void set_orientation_matrix(const mat4& orientation_matrix) { m_orientation_matrix = orientation_matrix; }
const mat4& get_orientation_matrix() const { return m_orientation_matrix; }
vec3 get_position() const { return vec3(m_orientation_matrix[3][0], m_orientation_matrix[3][1], m_orientation_matrix[3][2]); }
protected:
mat4 m_orientation_matrix;
};

View File

@ -0,0 +1,28 @@
#include "Poseable2D.h"
namespace charcoal
{
Poseable2D::Poseable2D(const vec2& position) : Poseable(vec3(position, 0.0f))
{}
void Poseable2D::update_position(const vec2& position)
{
Poseable::update_position(vec3(position, 0.0f));
}
void Poseable2D::update_rotation(float angle)
{
Poseable::reset_orientation();
rotate(angle);
}
void Poseable2D::translate(const vec2& translation)
{
Poseable::translate(vec3(translation, 0.0f));
}
void Poseable2D::rotate(float angle)
{
Poseable::rotate(vec3(0.0f, 0.0f, 1.0f), angle);
}
}

23
OpenGLEngine/Poseable2D.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <glm/glm.hpp>
#include "Poseable.h"
namespace charcoal
{
class Poseable2D : private Poseable
{
public:
// TODO: Implementation??
Poseable2D(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(); }
};
}

View File

@ -1,53 +0,0 @@
#pragma once
#include "Batch.h"
#include "BuiltinBatch.h"
#include "Renderable.h"
#include "Poseable.h"
namespace charcoal
{
namespace builtin
{
template <typename VertexType, typename IndexType, typename RenderableT = RenderableT<VertexType, IndexType> >
class PoseableBatch : public builtin::Batch<VertexType, IndexType, 1, RenderableT>
{
public:
// TODO: Figure out how to get rid of this typename garbage. If that it figured out, m_element_buffers should get fixed.
PoseableBatch(
RenderableT* renderable,
int element_count
) : PoseableBatch(renderable, element_count, element_count)
{}
PoseableBatch(
RenderableT* renderable,
int element_count,
int element_render_count
) : builtin::Batch<VertexType, IndexType, 1, RenderableT>(renderable, element_render_count), m_pose_elements(element_count)
{}
virtual ~PoseableBatch() {}
Poseable& get_pose(int index) { return m_pose_elements[index]; }
const Poseable& get_pose(int index) const { return m_pose_elements[index]; }
protected:
void setup_element_buffers()
{
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
glBufferData(GL_ARRAY_BUFFER, m_pose_elements.size() * sizeof(Poseable), NULL, GL_STREAM_DRAW);
}
void update_element_buffers()
{
// TODO: There are probably better ways to do this. Should check with the old engine to see what I did there.
glBindBuffer(GL_ARRAY_BUFFER, charcoal::Batch<VertexType, IndexType, 1, RenderableT>::m_element_buffers[0]);
glBufferData(GL_ARRAY_BUFFER, m_pose_elements.size() * sizeof(Poseable), NULL, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, m_pose_elements.size() * sizeof(Poseable), m_pose_elements.data());
}
std::vector<Poseable> m_pose_elements;
};
}
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "stdafx.h"
#include "deps.h"
#include <type_traits>

View File

@ -1,6 +1,6 @@
#pragma once
#include "stdafx.h"
#include "deps.h"
namespace charcoal
{

Some files were not shown because too many files have changed in this diff Show More