|
|
|
@ -12,6 +12,7 @@
|
|
|
|
|
#include <simpleengine/game.h>
|
|
|
|
|
#include <simpleengine/vertex.h>
|
|
|
|
|
#include <simpleengine/objects/3d/obj_model.h>
|
|
|
|
|
#include <simpleengine/gfx/shaders/core_3d_shader.h>
|
|
|
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <iostream>
|
|
|
|
@ -23,6 +24,8 @@ CMRC_DECLARE(resource_shaders);
|
|
|
|
|
|
|
|
|
|
#include <SOIL2/SOIL2.h>
|
|
|
|
|
|
|
|
|
|
namespace se = simpleengine;
|
|
|
|
|
|
|
|
|
|
std::string read_resource_shader(const std::string& path) {
|
|
|
|
|
auto fs = cmrc::resource_shaders::get_filesystem();
|
|
|
|
|
cmrc::file vertex_file = fs.open(path);
|
|
|
|
@ -31,43 +34,34 @@ std::string read_resource_shader(const std::string& path) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
simpleengine::Game game(640, 480, "SimpleEngine 3D OpenGL - Developer Testing", GLFW_OPENGL_CORE_PROFILE, 4, 4, false);
|
|
|
|
|
se::Game game(640, 480, "SimpleEngine 3D OpenGL - Developer Testing", GLFW_OPENGL_CORE_PROFILE, 4, 4, false);
|
|
|
|
|
|
|
|
|
|
// Load shaders
|
|
|
|
|
std::string vertex_core = read_resource_shader("shaders/vertex_core.glsl");
|
|
|
|
|
std::string fragment_core = read_resource_shader("shaders/fragment_core.glsl");
|
|
|
|
|
/* se::gfx::Texture wall_texture("resources/wall.jpg");
|
|
|
|
|
se::gfx::Texture crate_texture("resources/container.jpg", true, true); */
|
|
|
|
|
|
|
|
|
|
// Compile shader program
|
|
|
|
|
simpleengine::ShaderProgram shader_prog;
|
|
|
|
|
shader_prog.add_shader_from_source(simpleengine::gfx::ShaderType::ST_Vertex, vertex_core);
|
|
|
|
|
shader_prog.add_shader_from_source(simpleengine::gfx::ShaderType::ST_Fragment, fragment_core);
|
|
|
|
|
shader_prog.link();
|
|
|
|
|
simpleengine::gfx::Shader core_shader = shader_prog.shaders.front();
|
|
|
|
|
// Load core shaders from simpleengine resources
|
|
|
|
|
se::gfx::shaders::Core3dShader core_shader;
|
|
|
|
|
|
|
|
|
|
/* simpleengine::gfx::Texture wall_texture("resources/wall.jpg");
|
|
|
|
|
simpleengine::gfx::Texture crate_texture("resources/container.jpg", true, true); */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto light = std::make_shared<simpleengine::gfx::Light>(core_shader, glm::vec3(0.f, 0.f, -20.f), glm::vec3(1.f, 1.f, 1.f));
|
|
|
|
|
auto light = std::make_shared<se::gfx::Light>(core_shader, glm::vec3(0.f, 0.f, -20.f), glm::vec3(1.f, 1.f, 1.f));
|
|
|
|
|
game.add_event(light);
|
|
|
|
|
|
|
|
|
|
simpleengine::gfx::Texture white_texture("resources/white_texture.png");
|
|
|
|
|
se::gfx::Texture white_texture("examples/dev_testing/resources/white_texture.png");
|
|
|
|
|
/* white_texture.shine_damper = 10;
|
|
|
|
|
white_texture.reflectivity = 1; */
|
|
|
|
|
auto dragon = std::make_shared<simpleengine::objects_3d::ObjModel>(game.get_window(), core_shader, white_texture, "resources/dragon.obj");
|
|
|
|
|
auto dragon = std::make_shared<se::objects_3d::ObjModel>(game.get_window(), core_shader, white_texture, "examples/dev_testing/resources/dragon.obj");
|
|
|
|
|
dragon->translate(0.f, -5.f, -25.f);
|
|
|
|
|
game.add_event(dragon);
|
|
|
|
|
|
|
|
|
|
/* simpleengine::gfx::Texture stall_texture("resources/stallTexture.png");
|
|
|
|
|
auto stall = std::make_shared<simpleengine::objects_3d::ObjModel>(game.get_window(), core_shader, stall_texture, "resources/stall.obj");
|
|
|
|
|
/* se::gfx::Texture stall_texture("resources/stallTexture.png");
|
|
|
|
|
auto stall = std::make_shared<se::objects_3d::ObjModel>(game.get_window(), core_shader, stall_texture, "resources/stall.obj");
|
|
|
|
|
stall->translate(0.f, -4.f, -25.f);
|
|
|
|
|
game.add_event(stall); */
|
|
|
|
|
|
|
|
|
|
/* std::vector<simpleengine::Vertex> square_vertices = {
|
|
|
|
|
{ simpleengine::Vectorf(0.5f, 0.5f, -1.f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(0.f, 0.f) }, // top right
|
|
|
|
|
{ simpleengine::Vectorf(0.5f, -0.5f, -1.f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) }, // bottom right
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f, -0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // bottom left
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f, 0.5f, -1.f), glm::vec3(.5f, 0.5f, 0.f), glm::vec2(0.5f, 1.0f) }, // top left
|
|
|
|
|
/* std::vector<se::Vertex> square_vertices = {
|
|
|
|
|
{ se::Vectorf(0.5f, 0.5f, -1.f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(0.f, 0.f) }, // top right
|
|
|
|
|
{ se::Vectorf(0.5f, -0.5f, -1.f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) }, // bottom right
|
|
|
|
|
{ se::Vectorf(-0.5f, -0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // bottom left
|
|
|
|
|
{ se::Vectorf(-0.5f, 0.5f, -1.f), glm::vec3(.5f, 0.5f, 0.f), glm::vec2(0.5f, 1.0f) }, // top left
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::vector<GLuint> indicies = {
|
|
|
|
@ -75,52 +69,52 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
1, 2, 3
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto square = std::make_shared<simpleengine::gfx::Model>(game.get_window(), core_shader, square_vertices, indicies);
|
|
|
|
|
auto square = std::make_shared<se::gfx::Model>(game.get_window(), core_shader, square_vertices, indicies);
|
|
|
|
|
square->translate(1.25f, 0.f, -1.f);
|
|
|
|
|
square->scale(.75f);
|
|
|
|
|
game.add_event(square);
|
|
|
|
|
|
|
|
|
|
std::vector<simpleengine::Vertex> tri_vertices = {
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f, -0.5f, -1.f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(0.f, 0.f) }, // top right
|
|
|
|
|
{ simpleengine::Vectorf(0.5f, -0.5f, -1.f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) }, // bottom right
|
|
|
|
|
{ simpleengine::Vectorf(0.f, 0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // bottom left
|
|
|
|
|
std::vector<se::Vertex> tri_vertices = {
|
|
|
|
|
{ se::Vectorf(-0.5f, -0.5f, -1.f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(0.f, 0.f) }, // top right
|
|
|
|
|
{ se::Vectorf(0.5f, -0.5f, -1.f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) }, // bottom right
|
|
|
|
|
{ se::Vectorf(0.f, 0.5f, -1.f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.5f, 1.0f) }, // bottom left
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto tri = std::make_shared<simpleengine::gfx::Model>(game.get_window(), core_shader, tri_vertices);
|
|
|
|
|
auto tri = std::make_shared<se::gfx::Model>(game.get_window(), core_shader, tri_vertices);
|
|
|
|
|
tri->translate(-1.25f, 0.f, -1.f);
|
|
|
|
|
tri->scale(.75f);
|
|
|
|
|
game.add_event(tri); */
|
|
|
|
|
|
|
|
|
|
/* std::vector<simpleengine::Vertex> cube_vertices = {
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,0.5f,-0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,-0.5f,-0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,0.5f,-0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
/* std::vector<se::Vertex> cube_vertices = {
|
|
|
|
|
{ se::Vectorf(-0.5f,0.5f,-0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,-0.5f,-0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,0.5f,-0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,0.5f,0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,-0.5f,0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,-0.5f,0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,0.5f,0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,-0.5f,0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,-0.5f,0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,0.5f,-0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,-0.5f,0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,0.5f,-0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,-0.5f,0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,0.5f,-0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,-0.5f,0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,0.5f,-0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,-0.5f,0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,0.5f,0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,0.5f,-0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,0.5f,0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,0.5f,-0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,-0.5f,0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ simpleengine::Vectorf(-0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,-0.5f,-0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ simpleengine::Vectorf(0.5f,-0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,-0.5f,0.5f), glm::vec3(1.f, 0.f, 0.f), glm::vec2(1.f, 1.f) },
|
|
|
|
|
{ se::Vectorf(-0.5f,-0.5f,-0.5f), glm::vec3(0.f, 1.f, 0.f), glm::vec2(1.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,-0.5f,-0.5f), glm::vec3(0.f, 0.f, 1.f), glm::vec2(0.f, 0.f) },
|
|
|
|
|
{ se::Vectorf(0.5f,-0.5f,0.5f), glm::vec3(1.f, 1.f, 0.f), glm::vec2(0.f, 1.f) },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::vector<GLuint> cube_indicies = {
|
|
|
|
@ -138,10 +132,10 @@ int main(int argc, char *argv[]) {
|
|
|
|
|
23,21,22
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto cube = std::make_shared<simpleengine::gfx::Model>(game.get_window(), core_shader, cube_vertices, cube_indicies);
|
|
|
|
|
auto cube = std::make_shared<se::gfx::Model>(game.get_window(), core_shader, cube_vertices, cube_indicies);
|
|
|
|
|
game.add_event(cube); */
|
|
|
|
|
|
|
|
|
|
auto camera = std::make_shared<simpleengine::Camera>(game.get_window(), core_shader, 70, glm::vec3(0, 0, -10));
|
|
|
|
|
auto camera = std::make_shared<se::Camera>(game.get_window(), core_shader, 70, glm::vec3(0, 0, -10));
|
|
|
|
|
game.add_event(camera);
|
|
|
|
|
|
|
|
|
|
return game.run();
|
|
|
|
|