working on texture array loading in the blt backend
parent
67a0aa7a28
commit
c7385c6ea6
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(voxel-game VERSION 0.0.4)
|
project(voxel-game VERSION 0.0.5)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -9,13 +9,15 @@ set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
add_subdirectory(lib/blt-with-graphics)
|
add_subdirectory(lib/blt-with-graphics)
|
||||||
|
|
||||||
|
add_compile_definitions(VOXEL_RES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res")
|
||||||
|
|
||||||
include_directories(include/)
|
include_directories(include/)
|
||||||
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||||
|
|
||||||
add_executable(voxel-game ${PROJECT_BUILD_FILES})
|
add_executable(voxel-game ${PROJECT_BUILD_FILES})
|
||||||
|
|
||||||
target_compile_options(voxel-game PRIVATE -Wall -Wextra -Werror -Wpedantic -Wno-comment)
|
target_compile_options(voxel-game PRIVATE -Wall -Wextra -Wpedantic -Wno-comment)
|
||||||
target_link_options(voxel-game PRIVATE -Wall -Wextra -Werror -Wpedantic -Wno-comment)
|
target_link_options(voxel-game PRIVATE -Wall -Wextra -Wpedantic -Wno-comment)
|
||||||
|
|
||||||
target_link_libraries(voxel-game PRIVATE BLT_WITH_GRAPHICS)
|
target_link_libraries(voxel-game PRIVATE BLT_WITH_GRAPHICS)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
#echo "Running CMake!"
|
||||||
args="$@"
|
args="$@"
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
nix-shell --pure --run "cmake $args" $SCRIPT_DIR/default.nix
|
CLION=$(which clion)
|
||||||
|
CLION_DIR=$(nix-store -r $CLION 2>/dev/null)
|
||||||
|
CMAKE_DIR="$CLION_DIR/clion/bin/cmake/linux/x64/bin/cmake"
|
||||||
|
export NIXPKGS_ALLOW_UNFREE=1
|
||||||
|
nix-shell --pure --run "$CMAKE_DIR $args" $SCRIPT_DIR/default.nix
|
||||||
|
exit
|
||||||
|
|
13
default.nix
13
default.nix
|
@ -1,11 +1,17 @@
|
||||||
let
|
{ pkgs ? (import <nixpkgs> {
|
||||||
pkgs = import <nixpkgs> {};
|
config.allowUnfree = true;
|
||||||
in pkgs.mkShell
|
config.segger-jlink.acceptLicense = true;
|
||||||
|
}), ... }:
|
||||||
|
pkgs.mkShell
|
||||||
{
|
{
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
cmake
|
cmake
|
||||||
gcc
|
gcc
|
||||||
|
clang
|
||||||
ninja
|
ninja
|
||||||
|
jetbrains.clion
|
||||||
|
renderdoc
|
||||||
|
valgrind
|
||||||
];
|
];
|
||||||
propagatedBuildInputs = with pkgs; [
|
propagatedBuildInputs = with pkgs; [
|
||||||
xorg.libX11
|
xorg.libX11
|
||||||
|
@ -37,6 +43,7 @@ in pkgs.mkShell
|
||||||
git
|
git
|
||||||
libGL
|
libGL
|
||||||
libGL.dev
|
libGL.dev
|
||||||
|
glfw
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace voxel
|
||||||
{
|
{
|
||||||
|
|
||||||
inline constexpr blt::u64 CHUNK_SIZE = 32;
|
inline constexpr blt::u64 CHUNK_SIZE = 32;
|
||||||
|
inline constexpr blt::i32 IMAGE_SIZE = 64;
|
||||||
inline const blt::u64 CHUNK_MASK = static_cast<blt::u64>(std::log2(CHUNK_SIZE));
|
inline const blt::u64 CHUNK_MASK = static_cast<blt::u64>(std::log2(CHUNK_SIZE));
|
||||||
|
|
||||||
using block_id_t = blt::u64;
|
using block_id_t = blt::u64;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit c01cb757a1d19fa8e06292dcb61a5b5769979f11
|
Subproject commit c8b9879e4976d162f81f69893b95587100fcdc02
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"rdocCaptureSettings": 1,
|
||||||
|
"settings": {
|
||||||
|
"autoStart": false,
|
||||||
|
"commandLine": "",
|
||||||
|
"environment": [
|
||||||
|
],
|
||||||
|
"executable": "/home/brett/Documents/code/c++/voxel-game/cmake-build-relwithdebinfo/voxel-game",
|
||||||
|
"inject": false,
|
||||||
|
"numQueuedFrames": 0,
|
||||||
|
"options": {
|
||||||
|
"allowFullscreen": true,
|
||||||
|
"allowVSync": true,
|
||||||
|
"apiValidation": false,
|
||||||
|
"captureAllCmdLists": false,
|
||||||
|
"captureCallstacks": false,
|
||||||
|
"captureCallstacksOnlyDraws": false,
|
||||||
|
"debugOutputMute": true,
|
||||||
|
"delayForDebugger": 0,
|
||||||
|
"hookIntoChildren": false,
|
||||||
|
"refAllResources": false,
|
||||||
|
"softMemoryLimit": 0,
|
||||||
|
"verifyBufferAccess": false
|
||||||
|
},
|
||||||
|
"queuedFrameCap": 0,
|
||||||
|
"workingDir": ""
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 362 KiB |
12
src/main.cpp
12
src/main.cpp
|
@ -20,9 +20,10 @@
|
||||||
#include "blt/gfx/renderer/camera.h"
|
#include "blt/gfx/renderer/camera.h"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <voxel/chunk.h>
|
#include <voxel/chunk.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
blt::gfx::matrix_state_manager global_matrices;
|
blt::gfx::matrix_state_manager global_matrices;
|
||||||
blt::gfx::resource_manager resources;
|
blt::gfx::resource_manager resources {VOXEL_RES_DIR};
|
||||||
blt::gfx::batch_renderer_2d renderer_2d(resources, global_matrices);
|
blt::gfx::batch_renderer_2d renderer_2d(resources, global_matrices);
|
||||||
blt::gfx::first_person_camera camera;
|
blt::gfx::first_person_camera camera;
|
||||||
|
|
||||||
|
@ -30,9 +31,14 @@ void init(const blt::gfx::window_data&)
|
||||||
{
|
{
|
||||||
using namespace blt::gfx;
|
using namespace blt::gfx;
|
||||||
|
|
||||||
|
texture_array block_array{"blocks", voxel::IMAGE_SIZE, voxel::IMAGE_SIZE};
|
||||||
|
block_array.add_texture("ham.png", "ham");
|
||||||
|
|
||||||
|
resources.with(texture_info{"ham.png", "ham"}.set_desired_width(voxel::IMAGE_SIZE).set_desired_height(voxel::IMAGE_SIZE));
|
||||||
|
resources.with(std::move(block_array));
|
||||||
|
|
||||||
global_matrices.create_internals();
|
global_matrices.create_internals();
|
||||||
resources.load_resources();
|
resources.load_resources(std::thread::hardware_concurrency());
|
||||||
renderer_2d.create();
|
renderer_2d.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +50,8 @@ void update(const blt::gfx::window_data& data)
|
||||||
camera.update_view(global_matrices);
|
camera.update_view(global_matrices);
|
||||||
global_matrices.update();
|
global_matrices.update();
|
||||||
|
|
||||||
|
renderer_2d.drawRectangleInternal("ham", {50, 50, voxel::IMAGE_SIZE, voxel::IMAGE_SIZE});
|
||||||
|
|
||||||
renderer_2d.render(data.width, data.height);
|
renderer_2d.render(data.width, data.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue