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.
This commit is contained in:
parent
0c767e9441
commit
e3c85324c6
@ -1,19 +0,0 @@
|
||||
#include "BasicBatch.h"
|
||||
|
||||
namespace charcoal
|
||||
{
|
||||
namespace builtin
|
||||
{
|
||||
namespace basic
|
||||
{
|
||||
void Batch::setup_vao_vertex()
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_vertex_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), NULL);
|
||||
|
||||
glVertexAttribDivisor(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,14 @@ namespace charcoal
|
||||
public:
|
||||
using PoseableBatch<Vertex, Index, 1>::PoseableBatch;
|
||||
protected:
|
||||
virtual void setup_vao_vertex() override;
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +0,0 @@
|
||||
#include "BasicPipeline.h"
|
||||
|
||||
#include "GLUtil.h"
|
||||
|
||||
namespace charcoal
|
||||
{
|
||||
namespace builtin
|
||||
{
|
||||
namespace basic
|
||||
{
|
||||
void Pipeline::render()
|
||||
{
|
||||
glutil::clear_screen();
|
||||
m_shader_program.use();
|
||||
glutil::uniform_matrix(0, get_camera()->get_world_to_view_matrix());
|
||||
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
|
||||
{
|
||||
Batch* batch = *iter;
|
||||
batch->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <charcoal/Pipeline.h>
|
||||
#include "GLUtil.h"
|
||||
#include "BuiltinPipeline.h"
|
||||
#include "WithCamera.h"
|
||||
#include "BasicShaderProgram.h"
|
||||
#include "BasicBatch.h"
|
||||
@ -11,10 +12,19 @@ namespace charcoal
|
||||
{
|
||||
namespace basic
|
||||
{
|
||||
class Pipeline : public charcoal::Pipeline<ShaderProgram, Batch>, public WithCamera
|
||||
class Pipeline : public builtin::Pipeline<ShaderProgram, Batch>, public WithCamera
|
||||
{
|
||||
public:
|
||||
void render() override;
|
||||
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());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
#include "BasicScene.h"
|
||||
|
||||
#include <charcoal/deps.h>
|
||||
#include <charcoal/MeshFactory.h>
|
||||
|
||||
#include "GLUtil.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, get_camera()->get_world_to_view_matrix());
|
||||
for (auto iter = m_batches.begin(); iter != m_batches.end(); ++iter)
|
||||
{
|
||||
iter->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <charcoal/Application.h>
|
||||
#include <charcoal/Camera.h>
|
||||
#include <charcoal/constants.h>
|
||||
|
||||
#include "AutoPrerenderingScene.h"
|
||||
|
||||
#include "BasicShaderProgram.h"
|
||||
#include "BasicTypes.h"
|
||||
#include "BasicBatch.h"
|
||||
#include "Batched.h"
|
||||
#include "WithCamera.h"
|
||||
|
||||
namespace charcoal
|
||||
{
|
||||
namespace builtin
|
||||
{
|
||||
namespace basic
|
||||
{
|
||||
class Scene : public AutoPrerenderingScene, public Batched<Renderable, Batch>, public WithCamera
|
||||
{
|
||||
public:
|
||||
Scene(Application& application) : AutoPrerenderingScene(application) {}
|
||||
|
||||
void init() override;
|
||||
|
||||
void use() override;
|
||||
|
||||
void unuse() override;
|
||||
|
||||
void render() override;
|
||||
|
||||
private:
|
||||
ShaderProgram m_shader_program;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
30
CharcoalBuiltin/BuiltinPipeline.h
Normal file
30
CharcoalBuiltin/BuiltinPipeline.h
Normal file
@ -0,0 +1,30 @@
|
||||
#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();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void prepare_opengl() {};
|
||||
|
||||
virtual void prepare_uniforms() {};
|
||||
};
|
||||
}
|
||||
}
|
@ -140,9 +140,6 @@ copy "$(ProjectDir)*.h" "$(SolutionDir)include\charcoal-builtin\"</Command>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AutoPrerenderingScene.cpp" />
|
||||
<ClCompile Include="BasicBatch.cpp" />
|
||||
<ClCompile Include="BasicPipeline.cpp" />
|
||||
<ClCompile Include="BasicScene.cpp" />
|
||||
<ClCompile Include="GLUtil.cpp" />
|
||||
<ClCompile Include="TextureGenerator.cpp" />
|
||||
</ItemGroup>
|
||||
@ -150,13 +147,13 @@ copy "$(ProjectDir)*.h" "$(SolutionDir)include\charcoal-builtin\"</Command>
|
||||
<ClInclude Include="AutoPrerenderingScene.h" />
|
||||
<ClInclude Include="BasicBatch.h" />
|
||||
<ClInclude Include="BasicPipeline.h" />
|
||||
<ClInclude Include="BasicScene.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="MeshGenerator.h" />
|
||||
|
@ -13,23 +13,17 @@
|
||||
<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\Scenes">
|
||||
<UniqueIdentifier>{808e9376-c6b7-4d65-806e-935f34d5ec4a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\Scenes\Basic">
|
||||
<UniqueIdentifier>{1dbc28a4-b52f-4171-a385-79490dfa9b0a}</UniqueIdentifier>
|
||||
</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="Source Files\Scenes">
|
||||
<UniqueIdentifier>{49e6ab0e-f7a1-45ca-812a-44bc15016b45}</UniqueIdentifier>
|
||||
<Filter Include="Header Files\Pipelines">
|
||||
<UniqueIdentifier>{808e9376-c6b7-4d65-806e-935f34d5ec4a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Scenes\Basic">
|
||||
<UniqueIdentifier>{e167753a-dc8e-4c92-ad62-22b272484656}</UniqueIdentifier>
|
||||
<Filter Include="Header Files\Pipelines\Basic">
|
||||
<UniqueIdentifier>{1dbc28a4-b52f-4171-a385-79490dfa9b0a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -42,25 +36,13 @@
|
||||
<ClCompile Include="TextureGenerator.cpp">
|
||||
<Filter>Source Files\General</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BasicBatch.cpp">
|
||||
<Filter>Source Files\Scenes\Basic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BasicScene.cpp">
|
||||
<Filter>Source Files\Scenes\Basic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BasicPipeline.cpp">
|
||||
<Filter>Source Files\Scenes\Basic</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="BasicScene.h">
|
||||
<Filter>Header Files\Scenes\Basic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BasicShaderProgram.h">
|
||||
<Filter>Header Files\Scenes\Basic</Filter>
|
||||
<Filter>Header Files\Pipelines\Basic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BasicTypes.h">
|
||||
<Filter>Header Files\Scenes\Basic</Filter>
|
||||
<Filter>Header Files\Pipelines\Basic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AutoPrerenderingScene.h">
|
||||
<Filter>Header Files\General</Filter>
|
||||
@ -99,10 +81,13 @@
|
||||
<Filter>Header Files\General</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BasicBatch.h">
|
||||
<Filter>Header Files\Scenes\Basic</Filter>
|
||||
<Filter>Header Files\Pipelines\Basic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BasicPipeline.h">
|
||||
<Filter>Header Files\Scenes\Basic</Filter>
|
||||
<Filter>Header Files\Pipelines\Basic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BuiltinPipeline.h">
|
||||
<Filter>Header Files\General</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <charcoal-builtin/MeshGenerator.h>
|
||||
|
||||
#include <charcoal-builtin/GLUtil.h>
|
||||
|
||||
MyBuiltinCubeScene::MyBuiltinCubeScene(Application& application)
|
||||
: Scene(application),
|
||||
m_shape(meshgenerator::gen_cube_p<basic::Vertex, basic::Index>(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f), DrawMode::DRAW_TRIANGLES),
|
||||
@ -19,13 +21,6 @@ void MyBuiltinCubeScene::init()
|
||||
m_batch.init();
|
||||
}
|
||||
|
||||
void MyBuiltinCubeScene::use()
|
||||
{
|
||||
// TODO: Pipeline these
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
}
|
||||
|
||||
void MyBuiltinCubeScene::update(float delta_time, clock_t clock)
|
||||
{
|
||||
float brightness;
|
||||
@ -43,10 +38,10 @@ void MyBuiltinCubeScene::update(float delta_time, clock_t clock)
|
||||
radians = (float)TAU * c / intervals;
|
||||
|
||||
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), 0.0f, 0.0f));
|
||||
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), 0.0f, 0.0f));
|
||||
m_pose_b.update_position(vec3(-3 * (float)cos(radians), -1.0f, 0.0f));
|
||||
|
||||
vec3 camera_translation(0.0f, 0.0f, 0.0f);
|
||||
|
||||
@ -77,6 +72,7 @@ void MyBuiltinCubeScene::prerender()
|
||||
|
||||
void MyBuiltinCubeScene::render()
|
||||
{
|
||||
glutil::clear_screen();
|
||||
m_pipeline.render();
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
|
||||
void init() override;
|
||||
|
||||
void use() override;
|
||||
void use() override {}
|
||||
|
||||
void unuse() override {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user