Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 3.22)

project(ft_vox LANGUAGES C CXX)
project(ft_minecraft LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(FT_VOX_FETCH_DEPS "Fetch third-party dependencies into the build tree" ON)
option(FT_MINECRAFT_FETCH_DEPS "Fetch third-party dependencies into the build tree" ON)

set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
Expand All @@ -20,7 +20,7 @@ include(FetchContent)
find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)

if(FT_VOX_FETCH_DEPS)
if(FT_MINECRAFT_FETCH_DEPS)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw.git
Expand Down Expand Up @@ -49,20 +49,20 @@ if(FT_VOX_FETCH_DEPS)
FetchContent_Populate(fastnoiselite)
endif()

add_library(ft_vox_fastnoise INTERFACE)
add_library(ft_minecraft_fastnoise INTERFACE)
target_include_directories(
ft_vox_fastnoise
ft_minecraft_fastnoise
INTERFACE
${fastnoiselite_SOURCE_DIR}/Cpp
)
else()
find_package(glfw3 REQUIRED)
find_package(glm CONFIG REQUIRED)
message(FATAL_ERROR "FT_VOX_FETCH_DEPS=OFF is not fully wired yet. Reconfigure with -DFT_VOX_FETCH_DEPS=ON.")
message(FATAL_ERROR "FT_MINECRAFT_FETCH_DEPS=OFF is not fully wired yet. Reconfigure with -DFT_MINECRAFT_FETCH_DEPS=ON.")
endif()

add_executable(
ft_vox
ft_minecraft
srcs/main.cpp
srcs/player/input_handler.cpp
srcs/player/camera.cpp
Expand Down Expand Up @@ -91,27 +91,27 @@ add_executable(
)

target_include_directories(
ft_vox
ft_minecraft
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/srcs
${glfw_SOURCE_DIR}/deps
)

target_compile_definitions(ft_vox PRIVATE GLFW_INCLUDE_NONE)
target_compile_definitions(ft_minecraft PRIVATE GLFW_INCLUDE_NONE)

target_link_libraries(
ft_vox
ft_minecraft
PRIVATE
OpenGL::GL
glfw
glm::glm
ft_vox_fastnoise
ft_minecraft_fastnoise
Threads::Threads
)

set_target_properties(
ft_vox
ft_minecraft
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}
)
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ configure:
$(CONFIGURE)

run: all
./ft_vox $(RUN_ARGS)
./ft_minecraft $(RUN_ARGS)

clean:
if [ -d $(BUILD_DIR) ]; then rm -rf $(BUILD_DIR); fi

fclean: clean
rm -f ft_vox
rm -f ft_minecraft

re: fclean all

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ft_vox
# ft_minecraft

42Tokyoの課題として制作した、C++17 / OpenGL 4.1 製のMinecraft風ボクセルエンジンです。

Expand Down
2 changes: 1 addition & 1 deletion srcs/core/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ bool Engine::init(uint32_t seed, int width, int height) {
width_ = mode->width;
height_ = mode->height;

window_ = glfwCreateWindow(width_, height_, "ft_vox", monitor, nullptr);
window_ = glfwCreateWindow(width_, height_, "ft_minecraft", monitor, nullptr);
if (!window_) {
fprintf(stderr, "[Engine] glfwCreateWindow failed\n");
glfwTerminate();
Expand Down
8 changes: 4 additions & 4 deletions srcs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include <cstring>

// Usage:
// ./ft_vox [seed] — single-player
// ./ft_vox --server [port] [seed] — headless server
// ./ft_vox --connect <ip> [port] [seed] — multiplayer client
// ./ft_minecraft [seed] — single-player
// ./ft_minecraft --server [port] [seed] — headless server
// ./ft_minecraft --connect <ip> [port] [seed] — multiplayer client

int main(int argc, char** argv) {
// ── ヘッドレスサーバーモード ─────────────────────────────────────────────
Expand All @@ -38,7 +38,7 @@ int main(int argc, char** argv) {
uint32_t seed = 42;

if (argc >= 2 && std::strcmp(argv[1], "--connect") == 0) {
if (argc < 3) { fprintf(stderr, "Usage: ft_vox --connect <ip> [port] [seed]\n"); return 1; }
if (argc < 3) { fprintf(stderr, "Usage: ft_minecraft --connect <ip> [port] [seed]\n"); return 1; }
connect_host = argv[2];
if (argc >= 4) connect_port = (uint16_t)std::atoi(argv[3]);
if (argc >= 5) seed = (uint32_t)std::atol(argv[4]);
Expand Down
28 changes: 22 additions & 6 deletions srcs/renderer/title_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ static const struct { char c; Glyph g; } kGlyphs[] = {
{kL, kT, kR, kT}, // top bar
{0.5f,kB, 0.5f,kT}, // center vert
}}},
{'M', {4, {
{kL,kB,kL,kT}, // left vert
{kR,kB,kR,kT}, // right vert
{kL,kT,0.5f,kM}, // left diagonal
{0.5f,kM,kR,kT}, // right diagonal
}}},
{'I', {3, {
{kL,kT,kR,kT}, // top
{0.5f,kB,0.5f,kT}, // center vert
{kL,kB,kR,kB}, // bottom
}}},
{'N', {3, {
{kL,kB,kL,kT}, // left vert
{kR,kB,kR,kT}, // right vert
{kL,kT,kR,kB}, // diagonal
}}},
{'_', {1, {
{kL,0.08f,kR,0.08f}, // underscore
}}},
Expand Down Expand Up @@ -225,17 +241,17 @@ void TitleScreen::buildTextBuffers() {
float prompt_v[kBufSize] = {};
int tc = 0, pc = 0;

// ── Title "FT_VOX" ────────────────────────────────────────────────────────
const char* title = "FT_VOX";
const float t_cw = 0.115f;
const float t_ch = 0.175f;
const float t_gap = 0.028f;
// ── Title "FT_MINECRAFT" ──────────────────────────────────────────────────
const char* title = "FT_MINECRAFT";
const float t_cw = 0.072f;
const float t_ch = 0.125f;
const float t_gap = 0.016f;
float t_w = textWidth(title, t_cw, t_gap);
appendText(title_v, tc, title,
-t_w * 0.5f, 0.58f, t_cw, t_ch, t_gap);

// Thin separator line below title
appendSeg(title_v, tc, -0.32f, 0.54f, 0.32f, 0.54f);
appendSeg(title_v, tc, -t_w * 0.5f, 0.54f, t_w * 0.5f, 0.54f);

title_cnt_ = tc / 2;

Expand Down