diff --git a/CMakeLists.txt b/CMakeLists.txt index fa707cb..a8aa3df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.28) -project(voxel-game VERSION 0.0.2) +cmake_minimum_required(VERSION 3.25) +project(voxel-game VERSION 0.0.3) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) add_subdirectory(lib/blt-with-graphics) diff --git a/include/voxel/chunk.h b/include/voxel/chunk.h new file mode 100644 index 0000000..f10db34 --- /dev/null +++ b/include/voxel/chunk.h @@ -0,0 +1,49 @@ +#pragma once +/* + * 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 . + */ + +#ifndef VOXEL_GAME_CHUNK_H +#define VOXEL_GAME_CHUNK_H + +#include +#include +#include + +namespace voxel +{ + enum class chunk_generation_state_t + { + empty, // no data exists in chunk + empty_structure, // chunk was created for the purpose of storing a structure + biomes, // chunk generated biomes + noise, // chunk generated noise map + surface, // chunk generated surface details + carvers, // rivers + features, // structure generation + full + }; + + class chunk_t + { + public: + private: + chunk_generation_state_t state; + std::array blocks; + }; +} + +#endif //VOXEL_GAME_CHUNK_H diff --git a/include/voxel/fwdecl.h b/include/voxel/fwdecl.h new file mode 100644 index 0000000..9bb3d09 --- /dev/null +++ b/include/voxel/fwdecl.h @@ -0,0 +1,37 @@ +#pragma once +/* + * 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 . + */ + +#ifndef VOXEL_GAME_FWDECL_H +#define VOXEL_GAME_FWDECL_H + +#include +#include + +namespace voxel +{ + + inline constexpr blt::u64 CHUNK_SIZE = 32; + inline const blt::u64 CHUNK_MASK = static_cast(std::log2(CHUNK_SIZE)); + + using vid_t = blt::u16; + + class chunk_t; + +} + +#endif //VOXEL_GAME_FWDECL_H diff --git a/pull_all.sh b/pull_all.sh new file mode 100755 index 0000000..d1aa177 --- /dev/null +++ b/pull_all.sh @@ -0,0 +1,5 @@ +git pull +cd lib/blt-with-graphics +git pull +cd libraries/BLT +git pull diff --git a/src/main.cpp b/src/main.cpp index 6f2b004..fac3176 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,57 @@ -#include +/* + * 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 +#include -int main() +blt::gfx::matrix_state_manager global_matrices; +blt::gfx::resource_manager resources; +blt::gfx::batch_renderer_2d renderer_2d(resources, global_matrices); +blt::gfx::first_person_camera camera; + +void init(const blt::gfx::window_data&) { - std::cout << "Hello World!" << std::endl; + using namespace blt::gfx; + + + global_matrices.create_internals(); + resources.load_resources(); + renderer_2d.create(); } + +void update(const blt::gfx::window_data& data) +{ + global_matrices.update_perspectives(data.width, data.height, 90, 0.1, 2000); + + camera.update(); + camera.update_view(global_matrices); + global_matrices.update(); + + renderer_2d.render(data.width, data.height); +} + +int main(int, const char**) +{ + 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