Move 2d square and triangle files
This commit is contained in:
parent
340b21f099
commit
bab9ef3c74
|
@ -1,6 +1,6 @@
|
||||||
#include "simpleengine/camera.h"
|
#include "simpleengine/camera.h"
|
||||||
#include "simpleengine/gfx/texture.h"
|
#include "simpleengine/gfx/texture.h"
|
||||||
#include "simpleengine/shapes/2d/square.h"
|
#include "simpleengine/objects/2d/shapes/square.h"
|
||||||
#include "simpleengine/vector.h"
|
#include "simpleengine/vector.h"
|
||||||
#include <glm/ext/matrix_clip_space.hpp>
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
#include <simpleengine/gfx/shader.h>
|
#include <simpleengine/gfx/shader.h>
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
#include <simpleengine/event/event.h>
|
#include <simpleengine/event/event.h>
|
||||||
#include <simpleengine/shader_program.h>
|
#include <simpleengine/shader_program.h>
|
||||||
#include <simpleengine/game.h>
|
#include <simpleengine/game.h>
|
||||||
#include <simpleengine/shapes/2d/triangle.h>
|
#include <simpleengine/objects/2d/shapes/triangle.h>
|
||||||
#include <simpleengine/vertex.h>
|
#include <simpleengine/vertex.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -21,37 +21,6 @@ CMRC_DECLARE(resource_shaders);
|
||||||
|
|
||||||
#include <SOIL2/SOIL2.h>
|
#include <SOIL2/SOIL2.h>
|
||||||
|
|
||||||
/* class Triangle3D : public simpleengine::shapes_2d::Triangle {
|
|
||||||
public:
|
|
||||||
glm::mat4 projection_matrix;
|
|
||||||
//glm::mat4 view_matrix;
|
|
||||||
|
|
||||||
const float fov = 70;
|
|
||||||
const float near_plane = 0.1f;
|
|
||||||
const float far_plane = 1000.f;
|
|
||||||
|
|
||||||
Triangle3D(simpleengine::gfx::Shader shader, std::vector<simpleengine::Vertex> vertices) :
|
|
||||||
simpleengine::shapes_2d::Triangle(shader, vertices) {
|
|
||||||
|
|
||||||
projection_matrix = glm::perspective(glm::radians(fov), 640.f / 480.f, near_plane, far_plane);
|
|
||||||
|
|
||||||
shader.use();
|
|
||||||
shader.set_uniform_matrix_4f("projection_matrix", projection_matrix, false);
|
|
||||||
//shader.set_uniform_matrix_4f("view_matrix", view_matrix, false);
|
|
||||||
shader.unuse();
|
|
||||||
}
|
|
||||||
|
|
||||||
Triangle3D(std::shared_ptr<GLuint> shader_program, std::vector<simpleengine::Vertex> vertices) :
|
|
||||||
simpleengine::shapes_2d::Triangle(shader_program, vertices) {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void render(GLFWwindow* target) override {
|
|
||||||
|
|
||||||
}
|
|
||||||
}; */
|
|
||||||
|
|
||||||
std::string read_resource_shader(const std::string& path) {
|
std::string read_resource_shader(const std::string& path) {
|
||||||
auto fs = cmrc::resource_shaders::get_filesystem();
|
auto fs = cmrc::resource_shaders::get_filesystem();
|
||||||
cmrc::file vertex_file = fs.open(path);
|
cmrc::file vertex_file = fs.open(path);
|
||||||
|
@ -82,7 +51,7 @@ int main(int argc, char *argv[]) {
|
||||||
{ simpleengine::Vectorf(0.f, 0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // top
|
{ simpleengine::Vectorf(0.f, 0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // top
|
||||||
};
|
};
|
||||||
|
|
||||||
auto tri = std::make_shared<simpleengine::shapes_2d::Triangle>(base_shader_program, vertices);
|
auto tri = std::make_shared<simpleengine::objects_2d::shapes::Triangle>(base_shader_program, vertices);
|
||||||
//tri->set_texture(wall_texture);
|
//tri->set_texture(wall_texture);
|
||||||
game.add_event(tri);
|
game.add_event(tri);
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,20 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include "../../renderable.h"
|
#include "../../../renderable.h"
|
||||||
#include "../../vertex.h"
|
#include "../../../vertex.h"
|
||||||
#include "../../transformable.h"
|
#include "../../../transformable.h"
|
||||||
#include "../../optional.h"
|
#include "../../../optional.h"
|
||||||
|
|
||||||
#include "../../gfx/vbo.h"
|
#include "../../../gfx/vbo.h"
|
||||||
#include "../../gfx/vao.h"
|
#include "../../../gfx/vao.h"
|
||||||
#include "../../gfx/texture.h"
|
#include "../../../gfx/texture.h"
|
||||||
#include "../../gfx/shader.h"
|
#include "../../../gfx/shader.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace simpleengine::shapes_2d {
|
namespace simpleengine::objects_2d::shapes {
|
||||||
class Square : public simpleengine::Renderable, public simpleengine::Transformable {
|
class Square : public simpleengine::Renderable, public simpleengine::Transformable {
|
||||||
private:
|
private:
|
||||||
using super = simpleengine::Renderable;
|
using super = simpleengine::Renderable;
|
|
@ -12,18 +12,18 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include "../../renderable.h"
|
#include "../../../renderable.h"
|
||||||
#include "../../vertex.h"
|
#include "../../../vertex.h"
|
||||||
#include "../../gfx/vbo.h"
|
#include "../../../gfx/vbo.h"
|
||||||
#include "../../gfx/vao.h"
|
#include "../../../gfx/vao.h"
|
||||||
#include "../../gfx/shader.h"
|
#include "../../../gfx/shader.h"
|
||||||
#include "../../gfx/texture.h"
|
#include "../../../gfx/texture.h"
|
||||||
#include "../../optional.h"
|
#include "../../../optional.h"
|
||||||
#include "../../transformable.h"
|
#include "../../../transformable.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace simpleengine::shapes_2d {
|
namespace simpleengine::objects_2d::shapes {
|
||||||
class Triangle : public simpleengine::Renderable, public simpleengine::Transformable {
|
class Triangle : public simpleengine::Renderable, public simpleengine::Transformable {
|
||||||
private:
|
private:
|
||||||
gfx::Shader shader; // This only stores the shader program
|
gfx::Shader shader; // This only stores the shader program
|
|
@ -1,6 +1,6 @@
|
||||||
#include "shapes/2d/square.h"
|
#include "objects/2d/shapes/square.h"
|
||||||
|
|
||||||
namespace simpleengine::shapes_2d {
|
namespace simpleengine::objects_2d::shapes {
|
||||||
Square::Square(gfx::Shader shader, std::vector<Vertex> vertices, std::vector<GLuint> indicies) :
|
Square::Square(gfx::Shader shader, std::vector<Vertex> vertices, std::vector<GLuint> indicies) :
|
||||||
super(nullptr), shader(shader), vertices(vertices), indicies(indicies),
|
super(nullptr), shader(shader), vertices(vertices), indicies(indicies),
|
||||||
ebo(gfx::VBO(GL_ELEMENT_ARRAY_BUFFER, false)), vbo(gfx::VBO(GL_ARRAY_BUFFER, false)),
|
ebo(gfx::VBO(GL_ELEMENT_ARRAY_BUFFER, false)), vbo(gfx::VBO(GL_ARRAY_BUFFER, false)),
|
|
@ -1,6 +1,6 @@
|
||||||
#include "shapes/2d/triangle.h"
|
#include "objects/2d/shapes/triangle.h"
|
||||||
|
|
||||||
namespace simpleengine::shapes_2d {
|
namespace simpleengine::objects_2d::shapes {
|
||||||
Triangle::Triangle(gfx::Shader shader, std::vector<Vertex> vertices) : simpleengine::Renderable(nullptr),
|
Triangle::Triangle(gfx::Shader shader, std::vector<Vertex> vertices) : simpleengine::Renderable(nullptr),
|
||||||
simpleengine::Transformable(glm::mat4(1.f)), shader(shader), vertices(vertices),
|
simpleengine::Transformable(glm::mat4(1.f)), shader(shader), vertices(vertices),
|
||||||
vbo(gfx::VBO(GL_ARRAY_BUFFER, false)), texture(nonstd::nullopt) {
|
vbo(gfx::VBO(GL_ARRAY_BUFFER, false)), texture(nonstd::nullopt) {
|
Loading…
Reference in New Issue