Cleaned up File Names

This commit is contained in:
elipzer 2018-09-11 01:18:17 -04:00
parent 1d19d370cb
commit 6164aa82b2
24 changed files with 259 additions and 324 deletions

View File

@ -1,17 +1,17 @@
#include "MyApplication.h"
MyApplication::MyApplication(int width, int height)
: Application(width, height), m_simple_scene(*this), m_object_oriented_scene(*this), m_3d_scene(*this)
: Application(width, height), m_basic_scene(*this), m_simple_2d_scene(*this), m_simple_3d_scene(*this)
{
}
void MyApplication::init()
{
m_simple_scene.init();
m_object_oriented_scene.init();
m_3d_scene.init();
m_basic_scene.init();
m_simple_2d_scene.init();
m_simple_3d_scene.init();
m_p_current_scene = &m_simple_scene;
m_p_current_scene = &m_basic_scene;
m_p_current_scene->use();
}
@ -19,15 +19,15 @@ void MyApplication::update(float delta_time, clock_t clock)
{
if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_1))
{
swap_scene(&m_simple_scene);
swap_scene(&m_basic_scene);
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_2))
{
swap_scene(&m_object_oriented_scene);
swap_scene(&m_simple_2d_scene);
}
else if (m_glfw_input_manager.is_key_pressed(GLFW_KEY_3))
{
swap_scene(&m_3d_scene);
swap_scene(&m_simple_3d_scene);
}
m_p_current_scene->update(delta_time, clock);
}

View File

@ -1,9 +1,9 @@
#pragma once
#include "Application.h"
#include "MySimpleScene.h"
#include "MyObjectOrientedScene.h"
#include "My3DScene.h"
#include "MyBasicScene.h"
#include "MySimple2DScene.h"
#include "MySimple3DScene.h"
class MyApplication :
public Application
@ -24,8 +24,8 @@ private:
void swap_scene(Scene* scene);
Scene* m_p_current_scene = nullptr;
MySimpleScene m_simple_scene;
MyObjectOrientedScene m_object_oriented_scene;
My3DScene m_3d_scene;
MyBasicScene m_basic_scene;
MySimple2DScene m_simple_2d_scene;
MySimple3DScene m_simple_3d_scene;
};

View File

@ -1,16 +1,16 @@
#include "MySimpleScene.h"
#include "MyBasicScene.h"
MySimpleScene::MySimpleScene(Application& application)
MyBasicScene::MyBasicScene(Application& application)
: Scene(application)
{
}
MySimpleScene::~MySimpleScene()
MyBasicScene::~MyBasicScene()
{
}
void MySimpleScene::init()
void MyBasicScene::init()
{
float points[] = {
0.0f, 0.5f, 0.0f,
@ -29,21 +29,21 @@ void MySimpleScene::init()
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
}
void MySimpleScene::use()
void MyBasicScene::use()
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void MySimpleScene::unuse()
void MyBasicScene::unuse()
{
}
void MySimpleScene::update(float delta_time, clock_t clock)
void MyBasicScene::update(float delta_time, clock_t clock)
{
}
void MySimpleScene::render()
void MyBasicScene::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_shader_program.use();

View File

@ -2,15 +2,13 @@
#include "Scene.h"
#include "MyBatch.h"
#include "MyShaderProgram.h"
#include "MyBasicShaderProgram.h"
class MySimpleScene :
public Scene
class MyBasicScene : public Scene
{
public:
MySimpleScene(Application& application);
~MySimpleScene();
MyBasicScene(Application& application);
~MyBasicScene();
void init() override;
@ -23,7 +21,7 @@ public:
void render() override;
private:
MyShaderProgram m_shader_program;
MyBasicShaderProgram m_shader_program;
GLuint m_vbo;
GLuint m_vao;

View File

@ -0,0 +1,13 @@
#include "MyBasicShaderProgram.h"
#include "Util.h"
MyBasicShaderProgram::MyBasicShaderProgram()
// TEMP Hardcode in the path. (Should Use Relative Path to General Shader Dir)
: m_vertex_shader(Util::load_file("D:/Development/C++/OpenGLEngine/OpenGLEngine/MyBasicVS.glsl"), VERTEX_SHADER),
m_fragment_shader(Util::load_file("D:/Development/C++/OpenGLEngine/OpenGLEngine/MyBasicFS.glsl"), FRAGMENT_SHADER)
{
attach_shader(m_vertex_shader);
attach_shader(m_fragment_shader);
link();
}

View File

@ -5,7 +5,7 @@
#include "Mesh.h"
#include "Renderable.h"
class MyShaderProgram : public ShaderProgram
class MyBasicShaderProgram : public ShaderProgram
{
public:
struct Vertex
@ -13,24 +13,23 @@ public:
Vertex() {}
Vertex(float x, float y, float z)
: x(x), y(y), z(z)
{
}
{}
float x;
float y;
float z;
};
struct Color // Try changing to normalized unsigned chars (0-255) for the example
struct Color
{
float r;
float g;
float b;
float a;
float r = 0.0f;
float g = 0.0f;
float b = 0.0f;
float a = 1.0f;
};
typedef unsigned int Index;
typedef Renderable<Vertex, Index> Renderable;
typedef Mesh<Vertex, Index> Mesh;
MyShaderProgram();
MyBasicShaderProgram();
private:
Shader m_vertex_shader;

View File

@ -3,7 +3,7 @@
void MyBatch::setup_element_buffers()
{
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[COLOR_VBO_INDEX]);
glBufferData(GL_ARRAY_BUFFER, m_color_elements.size() * sizeof(MyBatchTestShaderProgram::Color), NULL, GL_STREAM_DRAW);
glBufferData(GL_ARRAY_BUFFER, m_color_elements.size() * sizeof(MySimpleShaderProgram::Color), NULL, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[POSEABLE_VBO_INDEX]);
glBufferData(GL_ARRAY_BUFFER, m_poseable_elements.size() * sizeof(Poseable), NULL, GL_STREAM_DRAW);
@ -39,8 +39,8 @@ void MyBatch::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, m_element_buffers[COLOR_VBO_INDEX]);
glBufferData(GL_ARRAY_BUFFER, m_color_elements.size() * sizeof(MyBatchTestShaderProgram::Color), NULL, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, m_color_elements.size() * sizeof(MyBatchTestShaderProgram::Color), m_color_elements.data());
glBufferData(GL_ARRAY_BUFFER, m_color_elements.size() * sizeof(MySimpleShaderProgram::Color), NULL, GL_STREAM_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, m_color_elements.size() * sizeof(MySimpleShaderProgram::Color), m_color_elements.data());
glBindBuffer(GL_ARRAY_BUFFER, m_element_buffers[POSEABLE_VBO_INDEX]);
glBufferData(GL_ARRAY_BUFFER, m_poseable_elements.size() * sizeof(Poseable), NULL, GL_STREAM_DRAW);

View File

@ -4,23 +4,23 @@
#include "Poseable.h"
#include "MyBatchTestShaderProgram.h"
#include "MySimpleShaderProgram.h"
class MyBatch : public Batch<MyBatchTestShaderProgram::Vertex, MyBatchTestShaderProgram::Index, 2>
class MyBatch : public Batch<MySimpleShaderProgram::Vertex, MySimpleShaderProgram::Index, 2>
{
public:
MyBatch(
const MyBatchTestShaderProgram::Renderable* renderable,
const MySimpleShaderProgram::Renderable* renderable,
const SizeType& element_count
) : MyBatch(renderable, element_count, element_count) {}
MyBatch(
const MyBatchTestShaderProgram::Renderable* renderable,
const MySimpleShaderProgram::Renderable* renderable,
const SizeType& element_count,
const SizeType& element_render_count
) : Batch(renderable, element_render_count), m_color_elements(element_count), m_poseable_elements(element_count) {}
MyBatchTestShaderProgram::Color& get_color(const SizeType& index) { return m_color_elements[index]; }
MySimpleShaderProgram::Color& get_color(const SizeType& index) { return m_color_elements[index]; }
Poseable& get_pose(const SizeType& index) { return m_poseable_elements[index]; }
@ -35,6 +35,6 @@ private:
const int COLOR_VBO_INDEX = 0;
const int POSEABLE_VBO_INDEX = 1;
std::vector<MyBatchTestShaderProgram::Color> m_color_elements;
std::vector<MySimpleShaderProgram::Color> m_color_elements;
std::vector<Poseable> m_poseable_elements;
};

View File

@ -1,13 +0,0 @@
#include "MyBatchTestShaderProgram.h"
#include "Util.h"
MyBatchTestShaderProgram::MyBatchTestShaderProgram()
// TEMP Hardcode in the path. (Should Use Relative Path to General Shader Dir)
: m_vertex_shader(Util::load_file("D:\\Development\\C++\\OpenGLEngine\\OpenGLEngine\\MyBatchTestVertexShader.glsl"), VERTEX_SHADER),
m_fragment_shader(Util::load_file("D:\\Development\\C++\\OpenGLEngine\\OpenGLEngine\\MyBatchTestFragmentShader.glsl"), FRAGMENT_SHADER)
{
attach_shader(m_vertex_shader);
attach_shader(m_fragment_shader);
link();
}

View File

@ -1,14 +0,0 @@
#version 430
layout(location = 0) in vec3 vertex_position;
layout(location = 1) in vec4 vertex_color;
layout(location = 2) in mat4 m;
// TODO: Try this with location 0
layout(location = 6) uniform mat4 pv;
out vec4 fragment_color;
void main()
{
fragment_color = vertex_color;
gl_Position = pv * m * vec4(vertex_position, 1.0);
}

View File

@ -1,138 +0,0 @@
#include "MyObjectOrientedScene.h"
#include <cmath>
#include <iostream>
#include "constants.h"
#include "Util.h"
#include "DrawMode.h"
#include "MeshFactory.h"
#define FIRST_VERT -50.0f, 50.0f, 0.0f
#define SECOND_VERT 50.0f, 150.0f, 0.0f
#define THIRD_VERT -100.0f, -50.0f, 0.0f
#define FOURTH_VERT 100.0f, -50.0f, 0.0f
MyObjectOrientedScene::MyObjectOrientedScene(Application& application)
: Scene(application),
m_shape(MeshFactory<MyBatchTestShaderProgram::Vertex, MyBatchTestShaderProgram::Index>::gen(
DrawMode::DRAW_TRIANGLES,
MyBatchTestShaderProgram::Vertex(FIRST_VERT),
MyBatchTestShaderProgram::Vertex(SECOND_VERT),
MyBatchTestShaderProgram::Vertex(THIRD_VERT),
MyBatchTestShaderProgram::Vertex(FOURTH_VERT)
), DrawMode::DRAW_TRIANGLES),
m_batch(&m_shape, 2),
m_camera(vec3(m_screen_size, 2.0f))// TODO: change this back to just m_screen_size
{
}
MyObjectOrientedScene::~MyObjectOrientedScene()
{
}
void MyObjectOrientedScene::init()
{
m_batch.init();
}
void MyObjectOrientedScene::use()
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void MyObjectOrientedScene::unuse()
{
}
void MyObjectOrientedScene::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)egm::TAU * c / intervals;
{
MyBatchTestShaderProgram::Color& color = m_batch.get_color(0);
color.r = brightness;
color.g = brightness;
color.b = brightness;
color.a = 1.0f;
Poseable& pose = m_batch.get_pose(0);
pose.update_position(vec3(cos(radians) * 50, 2.0f, 0.0f));
}
{
MyBatchTestShaderProgram::Color& color = m_batch.get_color(1);
color.r = 1.0f - brightness;
color.g = 1.0f - brightness;
color.b = 1.0f - brightness;
color.a = 1.0f;
Poseable& pose = m_batch.get_pose(1);
pose.update_position(vec3(-3.0f, -2.0f, 0.0f));
}
vec2 camera_translation(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;
m_camera.translate(camera_translation * delta_time * 100.0f);
const mat4& projection = m_camera.get_projection_matrix();
const mat4& camera_orientation = m_camera.get_orientation_matrix();
const mat4& world_to_view = m_camera.get_world_to_view_matrix();
const mat4& orientation = m_batch.get_pose(0).get_orientation_matrix();
const mat4 mvp = world_to_view * orientation;
vec4 first_vert(FIRST_VERT, 1.0f);
vec4 second_vert(SECOND_VERT, 1.0f);
vec4 third_vert(THIRD_VERT, 1.0f);
vec4 fourth_vert(FOURTH_VERT, 1.0f);
Util::set_console_position(0, 0);
std::cout << "Projection" << std::endl;
Util::print_matrix(projection);
std::cout << "World to View" << std::endl;
Util::print_matrix(world_to_view);
std::cout << "Pose 0 Orientation" << std::endl;
Util::print_matrix(orientation);
std::cout << "Full Projection Matrix" << std::endl;
Util::print_matrix(world_to_view * orientation);
std::cout << " First Second Third Fourth " << std::endl;
Util::print_matrix(mat4(mvp * first_vert, mvp * second_vert, mvp * third_vert, mvp * fourth_vert));
// TODO: Make a prerender function or move this to render
m_batch.prerender();
}
void MyObjectOrientedScene::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_shader_program.use();
glUniformMatrix4fv(6, 1, GL_FALSE, &m_camera.get_world_to_view_matrix()[0][0]);
m_batch.render();
}
#undef FIRST_VERT
#undef SECOND_VERT
#undef THIRD_VERT
#undef FOURTH_VERT

View File

@ -1,13 +0,0 @@
#include "MyShaderProgram.h"
#include "Util.h"
MyShaderProgram::MyShaderProgram()
// TEMP Hardcode in the path. (Should Use Relative Path to General Shader Dir)
: m_vertex_shader(Util::load_file("D:\\Development\\C++\\OpenGLEngine\\OpenGLEngine\\MyVertexShader.glsl"), VERTEX_SHADER),
m_fragment_shader(Util::load_file("D:\\Development\\C++\\OpenGLEngine\\OpenGLEngine\\MyFragmentShader.glsl"), FRAGMENT_SHADER)
{
attach_shader(m_vertex_shader);
attach_shader(m_fragment_shader);
link();
}

View File

@ -0,0 +1,102 @@
#include "MySimple2DScene.h"
#include "stdafx.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(
DrawMode::DRAW_TRIANGLES,
MySimpleShaderProgram::Vertex(-50.0f, 50.0f, 0.0f),
MySimpleShaderProgram::Vertex(50.0f, 150.0f, 0.0f),
MySimpleShaderProgram::Vertex(-100.0f, -50.0f, 0.0f),
MySimpleShaderProgram::Vertex(100.0f, -50.0f, 0.0f)
), DrawMode::DRAW_TRIANGLES),
m_batch(&m_shape, 2),
m_camera(m_screen_size)
{}
MySimple2DScene::~MySimple2DScene()
{}
void MySimple2DScene::init()
{
m_batch.init();
}
void MySimple2DScene::use()
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void MySimple2DScene::unuse()
{
}
void MySimple2DScene::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)egm::TAU * c / intervals;
{
MySimpleShaderProgram::Color& color = m_batch.get_color(0);
color.r = brightness;
color.g = brightness;
color.b = brightness;
color.a = 1.0f;
Poseable& pose = m_batch.get_pose(0);
pose.update_position(vec3(cos(radians) * 50, 0.0f, 0.0f));
}
{
MySimpleShaderProgram::Color& color = m_batch.get_color(1);
color.r = 1.0f - brightness;
color.g = 1.0f - brightness;
color.b = 1.0f - brightness;
color.a = 1.0f;
Poseable& pose = m_batch.get_pose(1);
pose.update_position(vec3(0.0f, sin(radians) * 50, 0.0f));
}
vec2 camera_translation(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;
m_camera.translate(camera_translation * delta_time * 100.0f);
// TODO: Make a prerender function or move this to render
m_batch.prerender();
}
void MySimple2DScene::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_shader_program.use();
glUniformMatrix4fv(0, 1, GL_FALSE, &m_camera.get_world_to_view_matrix()[0][0]);
m_batch.render();
}

View File

@ -5,13 +5,13 @@
#include "Camera2D.h"
#include "MyBatch.h"
#include "MyBatchTestShaderProgram.h"
#include "MySimpleShaderProgram.h"
class MyObjectOrientedScene : public Scene
class MySimple2DScene : public Scene
{
public:
MyObjectOrientedScene(Application& application);
~MyObjectOrientedScene();
MySimple2DScene(Application& application);
~MySimple2DScene();
void init() override;
@ -22,9 +22,10 @@ public:
void update(float delta_time, clock_t clock) override;
void render() override;
private:
MyBatch m_batch;
MyBatchTestShaderProgram::Renderable m_shape;
MyBatchTestShaderProgram m_shader_program;
MySimpleShaderProgram::Renderable m_shape;
MySimpleShaderProgram m_shader_program;
Camera2D m_camera;
};

View File

@ -1,4 +1,4 @@
#include "My3DScene.h"
#include "MySimple3DScene.h"
#include "stdafx.h"
@ -9,43 +9,40 @@
#include "DrawMode.h"
#include "MeshFactory.h"
#include "Util.h"
#define FIRST_VERT -1.0f, 1.0f, 0.0f
My3DScene::My3DScene(Application& application)
MySimple3DScene::MySimple3DScene(Application& application)
: Scene(application),
m_shape(MeshFactory<MyBatchTestShaderProgram::Vertex, MyBatchTestShaderProgram::Index>::gen(
m_shape(MeshFactory<MySimpleShaderProgram::Vertex, MySimpleShaderProgram::Index>::gen(
DrawMode::DRAW_TRIANGLES,
MyBatchTestShaderProgram::Vertex(FIRST_VERT),
MyBatchTestShaderProgram::Vertex(1.0f, 1.0f, 0.0f),
MyBatchTestShaderProgram::Vertex(-2.0f, -1.0f, 0.0f),
MyBatchTestShaderProgram::Vertex(2.0f, -1.0f, 0.0f)
MySimpleShaderProgram::Vertex(-1.0f, 1.0f, 0.0f),
MySimpleShaderProgram::Vertex(1.0f, 1.0f, 0.0f),
MySimpleShaderProgram::Vertex(-2.0f, -1.0f, 0.0f),
MySimpleShaderProgram::Vertex(2.0f, -1.0f, 0.0f)
), DrawMode::DRAW_TRIANGLES),
m_batch(&m_shape, 2),
m_camera((float)egm::TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, -5.0f))
{}
My3DScene::~My3DScene()
MySimple3DScene::~MySimple3DScene()
{}
void My3DScene::init()
void MySimple3DScene::init()
{
m_batch.init();
}
void My3DScene::use()
void MySimple3DScene::use()
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
}
void My3DScene::unuse()
void MySimple3DScene::unuse()
{
}
void My3DScene::update(float delta_time, clock_t clock)
void MySimple3DScene::update(float delta_time, clock_t clock)
{
float brightness;
float radians;
@ -62,7 +59,7 @@ void My3DScene::update(float delta_time, clock_t clock)
radians = (float)egm::TAU * c / intervals;
{
MyBatchTestShaderProgram::Color& color = m_batch.get_color(0);
MySimpleShaderProgram::Color& color = m_batch.get_color(0);
color.r = brightness;
color.g = brightness;
color.b = brightness;
@ -73,7 +70,7 @@ void My3DScene::update(float delta_time, clock_t clock)
}
{
MyBatchTestShaderProgram::Color& color = m_batch.get_color(1);
MySimpleShaderProgram::Color& color = m_batch.get_color(1);
color.r = 1.0f - brightness;
color.g = 1.0f - brightness;
color.b = 1.0f - brightness;
@ -94,30 +91,14 @@ void My3DScene::update(float delta_time, clock_t clock)
m_camera.translate(camera_translation * delta_time);
const mat4& world_to_view = m_camera.get_world_to_view_matrix();
const mat4& orientation = m_batch.get_pose(0).get_orientation_matrix();
const vec4 first_vert(FIRST_VERT, 1.0f);
Util::set_console_position(0, 0);
std::cout << "World to View" << std::endl;
Util::print_matrix(m_camera.get_world_to_view_matrix());
std::cout << "Pose 0 Orientation" << std::endl;
Util::print_matrix(m_batch.get_pose(0).get_orientation_matrix());
std::cout << "First Vert" << std::endl;
Util::print_vec(first_vert);
std::cout << "Projected Position" << std::endl;
Util::print_vec(world_to_view * orientation * first_vert);
// TODO: Make a prerender function or move this to render
m_batch.prerender();
}
void My3DScene::render()
void MySimple3DScene::render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_shader_program.use();
glUniformMatrix4fv(6, 1, GL_FALSE, &m_camera.get_world_to_view_matrix()[0][0]);
glUniformMatrix4fv(0, 1, GL_FALSE, &m_camera.get_world_to_view_matrix()[0][0]);
m_batch.render();
}
#undef FIRST_VERT

View File

@ -5,14 +5,13 @@
#include "Camera3D.h"
#include "MyBatch.h"
#include "MyShaderProgram.h"
#include "MySimpleShaderProgram.h"
class My3DScene :
public Scene
class MySimple3DScene : public Scene
{
public:
My3DScene(Application& application);
~My3DScene();
MySimple3DScene(Application& application);
~MySimple3DScene();
void init() override;
@ -26,8 +25,8 @@ public:
private:
MyBatch m_batch;
MyBatchTestShaderProgram::Renderable m_shape;
MyBatchTestShaderProgram m_shader_program;
MySimpleShaderProgram::Renderable m_shape;
MySimpleShaderProgram m_shader_program;
Camera3D m_camera;
};

View File

@ -0,0 +1,13 @@
#include "MySimpleShaderProgram.h"
#include "Util.h"
MySimpleShaderProgram::MySimpleShaderProgram()
// TEMP Hardcode in the path. (Should Use Relative Path to General Shader Dir)
: m_vertex_shader(Util::load_file("D:/Development/C++/OpenGLEngine/OpenGLEngine/MySimpleVS.glsl"), VERTEX_SHADER),
m_fragment_shader(Util::load_file("D:/Development/C++/OpenGLEngine/OpenGLEngine/MySimpleFS.glsl"), FRAGMENT_SHADER)
{
attach_shader(m_vertex_shader);
attach_shader(m_fragment_shader);
link();
}

View File

@ -5,7 +5,7 @@
#include "Mesh.h"
#include "Renderable.h"
class MyBatchTestShaderProgram : public ShaderProgram
class MySimpleShaderProgram : public ShaderProgram
{
public:
struct Vertex
@ -18,24 +18,18 @@ public:
float y;
float z;
};
struct Color // Try changing to normalized unsigned chars (0-255) for the example
struct Color
{
float r = 0.0f;
float g = 0.0f;
float b = 0.0f;
float a = 1.0f;
};
struct Offset
{
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
};
typedef unsigned int Index;
typedef Renderable<Vertex, Index> Renderable;
typedef Mesh<Vertex, Index> Mesh;
MyBatchTestShaderProgram();
MySimpleShaderProgram();
private:
Shader m_vertex_shader;

View File

@ -0,0 +1,13 @@
#version 430
layout(location = 0) in vec3 vertex_position;
layout(location = 1) in vec4 vertex_color;
layout(location = 2) in mat4 model_to_world;
layout(location = 0) uniform mat4 world_to_projection;
out vec4 fragment_color;
void main()
{
fragment_color = vertex_color;
gl_Position = world_to_projection * model_to_world * vec4(vertex_position, 1.0);
}

View File

@ -156,13 +156,13 @@
<ClCompile Include="GLFWInputManager.cpp" />
<ClCompile Include="InputManager.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="My3DScene.cpp" />
<ClCompile Include="MySimple3DScene.cpp" />
<ClCompile Include="MyApplication.cpp" />
<ClCompile Include="MyBatch.cpp" />
<ClCompile Include="MyBatchTestShaderProgram.cpp" />
<ClCompile Include="MyObjectOrientedScene.cpp" />
<ClCompile Include="MyShaderProgram.cpp" />
<ClCompile Include="MySimpleScene.cpp" />
<ClCompile Include="MySimpleShaderProgram.cpp" />
<ClCompile Include="MySimple2DScene.cpp" />
<ClCompile Include="MyBasicShaderProgram.cpp" />
<ClCompile Include="MyBasicScene.cpp" />
<ClCompile Include="Poseable.cpp" />
<ClCompile Include="Shader.cpp" />
<ClCompile Include="ShaderProgram.cpp" />
@ -186,13 +186,13 @@
<ClInclude Include="InputManager.h" />
<ClInclude Include="Mesh.h" />
<ClInclude Include="MeshFactory.h" />
<ClInclude Include="My3DScene.h" />
<ClInclude Include="MySimple3DScene.h" />
<ClInclude Include="MyApplication.h" />
<ClInclude Include="MyBatch.h" />
<ClInclude Include="MyBatchTestShaderProgram.h" />
<ClInclude Include="MyObjectOrientedScene.h" />
<ClInclude Include="MyShaderProgram.h" />
<ClInclude Include="MySimpleScene.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" />
@ -202,10 +202,10 @@
<ClInclude Include="Util.h" />
</ItemGroup>
<ItemGroup>
<None Include="MyBatchTestFragmentShader.glsl" />
<None Include="MyBatchTestVertexShader.glsl" />
<None Include="MyFragmentShader.glsl" />
<None Include="MyVertexShader.glsl" />
<None Include="MySimpleFS.glsl" />
<None Include="MySimpleVS.glsl" />
<None Include="MyBasicFS.glsl" />
<None Include="MyBasicVS.glsl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -84,12 +84,6 @@
<ClCompile Include="MyBatch.cpp">
<Filter>Source Files\Example\Rendering</Filter>
</ClCompile>
<ClCompile Include="MyBatchTestShaderProgram.cpp">
<Filter>Source Files\Example\Rendering</Filter>
</ClCompile>
<ClCompile Include="MyShaderProgram.cpp">
<Filter>Source Files\Example\Rendering</Filter>
</ClCompile>
<ClCompile Include="MyApplication.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
@ -102,15 +96,21 @@
<ClCompile Include="Poseable.cpp">
<Filter>Source Files\Engine</Filter>
</ClCompile>
<ClCompile Include="My3DScene.cpp">
<ClCompile Include="MySimple2DScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MyObjectOrientedScene.cpp">
<ClCompile Include="MySimple3DScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MySimpleScene.cpp">
<ClCompile Include="MyBasicScene.cpp">
<Filter>Source Files\Example\Application</Filter>
</ClCompile>
<ClCompile Include="MyBasicShaderProgram.cpp">
<Filter>Source Files\Example\Rendering</Filter>
</ClCompile>
<ClCompile Include="MySimpleShaderProgram.cpp">
<Filter>Source Files\Example\Rendering</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Exception.h">
@ -164,12 +164,6 @@
<ClInclude Include="MyBatch.h">
<Filter>Header Files\Example\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyBatchTestShaderProgram.h">
<Filter>Header Files\Example\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyShaderProgram.h">
<Filter>Header Files\Example\Rendering</Filter>
</ClInclude>
<ClInclude Include="MyApplication.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
@ -182,30 +176,36 @@
<ClInclude Include="Poseable.h">
<Filter>Header Files\Engine</Filter>
</ClInclude>
<ClInclude Include="My3DScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="MyObjectOrientedScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="MySimpleScene.h">
<Filter>Header Files\Example\Application</Filter>
</ClInclude>
<ClInclude Include="constants.h">
<Filter>Header Files\Engine</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>
</ItemGroup>
<ItemGroup>
<None Include="MyVertexShader.glsl">
<None Include="MySimpleVS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="MyFragmentShader.glsl">
<None Include="MyBasicFS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="MyBatchTestFragmentShader.glsl">
<None Include="MyBasicVS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
<None Include="MyBatchTestVertexShader.glsl">
<None Include="MySimpleFS.glsl">
<Filter>Source Files\Example\Rendering\Shader Code</Filter>
</None>
</ItemGroup>