Compare commits
No commits in common. "67a0aa7a28f2a5d6d8ef44c19dbc17d4ed4d1822" and "ee0950e4ab6cb9e9fec2f3f5b575ded1a11315cf" have entirely different histories.
67a0aa7a28
...
ee0950e4ab
|
@ -1,11 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.28)
|
||||||
project(voxel-game VERSION 0.0.4)
|
project(voxel-game VERSION 0.0.2)
|
||||||
|
|
||||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||||
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
|
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
add_subdirectory(lib/blt-with-graphics)
|
add_subdirectory(lib/blt-with-graphics)
|
||||||
|
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
#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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VOXEL_GAME_BLOCK_H
|
|
||||||
#define VOXEL_GAME_BLOCK_H
|
|
||||||
|
|
||||||
#include <voxel/fwdecl.h>
|
|
||||||
#include <array>
|
|
||||||
#include <variant>
|
|
||||||
|
|
||||||
namespace voxel
|
|
||||||
{
|
|
||||||
enum class face_t : blt::u32
|
|
||||||
{
|
|
||||||
NORTH, SOUTH, EAST, WEST, UP, DOWN, COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr inline blt::u32 face_to_int(face_t face)
|
|
||||||
{
|
|
||||||
return static_cast<blt::u32>(face);
|
|
||||||
}
|
|
||||||
|
|
||||||
class textured_block_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit textured_block_t(texture_id_t id)
|
|
||||||
{
|
|
||||||
for (auto& f : faces)
|
|
||||||
f = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit textured_block_t(texture_id_t top, texture_id_t id)
|
|
||||||
{
|
|
||||||
for (auto& f : faces)
|
|
||||||
f = id;
|
|
||||||
faces[face_to_int(face_t::UP)] = top;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit textured_block_t(texture_id_t top, texture_id_t bottom, texture_id_t sides)
|
|
||||||
{
|
|
||||||
for (auto& f : faces)
|
|
||||||
f = sides;
|
|
||||||
faces[face_to_int(face_t::UP)] = top;
|
|
||||||
faces[face_to_int(face_t::DOWN)] = bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit textured_block_t(std::array<texture_id_t, face_to_int(face_t::COUNT)> faces): faces(faces)
|
|
||||||
{}
|
|
||||||
|
|
||||||
texture_id_t get_texture_facing(face_t face)
|
|
||||||
{
|
|
||||||
return faces[face_to_int(face)];
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::array<texture_id_t, face_to_int(face_t::COUNT)> faces{};
|
|
||||||
};
|
|
||||||
|
|
||||||
class block_model_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defines data about a block
|
|
||||||
*/
|
|
||||||
class block_t
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
private:
|
|
||||||
block_id_t id;
|
|
||||||
std::variant<block_model_t, textured_block_t> model;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //VOXEL_GAME_BLOCK_H
|
|
|
@ -1,50 +0,0 @@
|
||||||
#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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VOXEL_GAME_CHUNK_H
|
|
||||||
#define VOXEL_GAME_CHUNK_H
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <voxel/fwdecl.h>
|
|
||||||
#include <voxel/block.h>
|
|
||||||
#include <blt/std/hashmap.h>
|
|
||||||
|
|
||||||
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<vid_t, CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE> blocks;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //VOXEL_GAME_CHUNK_H
|
|
|
@ -1,40 +0,0 @@
|
||||||
#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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef VOXEL_GAME_FWDECL_H
|
|
||||||
#define VOXEL_GAME_FWDECL_H
|
|
||||||
|
|
||||||
#include <blt/std/types.h>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace voxel
|
|
||||||
{
|
|
||||||
|
|
||||||
inline constexpr blt::u64 CHUNK_SIZE = 32;
|
|
||||||
inline const blt::u64 CHUNK_MASK = static_cast<blt::u64>(std::log2(CHUNK_SIZE));
|
|
||||||
|
|
||||||
using block_id_t = blt::u64;
|
|
||||||
using texture_id_t = blt::u64;
|
|
||||||
using vid_t = blt::u16;
|
|
||||||
|
|
||||||
class block_t;
|
|
||||||
class chunk_t;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //VOXEL_GAME_FWDECL_H
|
|
|
@ -1,5 +0,0 @@
|
||||||
git pull
|
|
||||||
cd lib/blt-with-graphics
|
|
||||||
git pull
|
|
||||||
cd libraries/BLT
|
|
||||||
git pull
|
|
57
src/main.cpp
57
src/main.cpp
|
@ -1,57 +1,6 @@
|
||||||
/*
|
#include <iostream>
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include <blt/gfx/window.h>
|
|
||||||
#include "blt/gfx/renderer/resource_manager.h"
|
|
||||||
#include "blt/gfx/renderer/batch_2d_renderer.h"
|
|
||||||
#include "blt/gfx/renderer/camera.h"
|
|
||||||
#include <imgui.h>
|
|
||||||
#include <voxel/chunk.h>
|
|
||||||
|
|
||||||
blt::gfx::matrix_state_manager global_matrices;
|
int main()
|
||||||
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&)
|
|
||||||
{
|
{
|
||||||
using namespace blt::gfx;
|
std::cout << "Hello World!" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
* <Short Description>
|
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include <voxel/chunk.h>
|
|
Loading…
Reference in New Issue