diff --git a/examples/basic/basic.cpp b/examples/basic/basic.cpp new file mode 100644 index 0000000..735886a --- /dev/null +++ b/examples/basic/basic.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2024 Brett Terpstra + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include "blt/gfx/renderer/resource_manager.h" +#include "blt/gfx/renderer/batch_2d_renderer.h" +#include "blt/gfx/renderer/camera.h" +#include + +blt::gfx::matrix_state_manager global_matrices; +blt::gfx::resource_manager resources; +blt::gfx::batch_renderer_2d renderer_2d(resources); +blt::gfx::first_person_camera camera; + +void init() +{ + using namespace blt::gfx; + + + global_matrices.create_internals(); + resources.load_resources(); + renderer_2d.create(); +} + +void update(std::int32_t width, std::int32_t height) +{ + global_matrices.update_perspectives(width, height, 90, 0.1, 2000); + + camera.update(); + camera.update_view(global_matrices); + global_matrices.update(); + + renderer_2d.render(); +} + +int main(int argc, const char** argv) +{ + blt::gfx::init(blt::gfx::window_data{"My Sexy Window", init, update}.setSyncInterval(1)); + global_matrices.cleanup(); + resources.cleanup(); + renderer_2d.cleanup(); + blt::gfx::cleanup(); +} \ No newline at end of file diff --git a/include/blt/gfx/renderer/batch_2d_renderer.h b/include/blt/gfx/renderer/batch_2d_renderer.h index 5b50c94..38337c3 100644 --- a/include/blt/gfx/renderer/batch_2d_renderer.h +++ b/include/blt/gfx/renderer/batch_2d_renderer.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace blt::gfx { diff --git a/tests/src/main.cpp b/tests/src/main.cpp index 45c336b..3bb1943 100644 --- a/tests/src/main.cpp +++ b/tests/src/main.cpp @@ -58,18 +58,18 @@ void init() resources.enqueue("../resources/textures/cumdollar.jpg", "ibuythat"); resources.enqueue("../resources/textures/dfoedbi-28157978-1555-45c3-b2f4-d5e5fe25b253.png", "niko"); - auto object = blt::gfx::quick_load("../resources/models/many_objects.obj"); + auto object = blt::parse::quick_load("../resources/models/many_objects.obj"); vbo_t vertices_vbo; vertices_vbo.create(); - vertices_vbo.allocate(static_cast(object.vertex_data().size() * sizeof(blt::gfx::constructed_vertex_t)), object.vertex_data().data()); + vertices_vbo.allocate(static_cast(object.vertex_data().size() * sizeof(blt::parse::constructed_vertex_t)), object.vertex_data().data()); auto ptr = vertex_array::createSharedVBO(vertices_vbo); for (auto obj : object.objects()) { vbo_t indices_vbo; indices_vbo.create(GL_ELEMENT_ARRAY_BUFFER); - indices_vbo.allocate(static_cast(obj.indices.size() * sizeof(blt::gfx::triangle_t)), obj.indices.data()); + indices_vbo.allocate(static_cast(obj.indices.size() * sizeof(blt::parse::triangle_t)), obj.indices.data()); auto* vao = new vertex_array(); vao->bindVBO(ptr, 0, 3, GL_FLOAT, sizeof(float) * (3 + 3 + 2), 0);