This commit is contained in:
OusmBlueNinja 2025-04-05 21:09:28 -05:00
parent 9a55f34dd6
commit 4dcf88380b
5 changed files with 30 additions and 18 deletions

View File

@ -3,7 +3,9 @@
{ {
"name": "Win32", "name": "Win32",
"includePath": [ "includePath": [
"${default}" "${default}",
"${workspaceFolder}/**",
"C:\\msys64\\mingw64\\include\\**"
], ],
"defines": [ "defines": [
"_DEBUG", "_DEBUG",
@ -11,10 +13,10 @@
"_UNICODE" "_UNICODE"
], ],
"windowsSdkVersion": "10.0.22621.0", "windowsSdkVersion": "10.0.22621.0",
"compilerPath": "cl.exe", "compilerPath": "C:/msys64/mingw64/bin/g++.exe",
"cStandard": "c17", "cStandard": "c17",
"cppStandard": "c++17", "cppStandard": "c++20",
"intelliSenseMode": "windows-msvc-x64" "intelliSenseMode": "linux-gcc-x64"
} }
], ],
"version": 4 "version": 4

View File

@ -1,10 +1,19 @@
# Compiler settings # Compiler settings
CXX = g++ CXX = g++
CXXFLAGS = -std=c++11 -I. -I/path/to/glad/include -I/path/to/imgui -I. CXXFLAGS = -std=c++11 -I. -Iimgui-docking -IC:/msys64/mingw64/include
LDFLAGS = -lglfw -ldl -lGL LDFLAGS = -LC:/msys64/mingw64/lib -lglfw3 -lopengl32 -lgdi32
# List source files # List ImGui source files
SRCS = main.cpp VoxelGame.cpp GreedyMesher.cpp IMGUISRCS = imgui-docking/imgui.cpp \
imgui-docking/imgui_demo.cpp \
imgui-docking/imgui_draw.cpp \
imgui-docking/imgui_tables.cpp \
imgui-docking/imgui_widgets.cpp \
imgui-docking/imgui_impl_glfw.cpp \
imgui-docking/imgui_impl_opengl3.cpp
# List all source files
SRCS = main.cpp VoxelGame.cpp GreedyMesher.cpp $(IMGUISRCS)
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)
TARGET = voxelgame TARGET = voxelgame

View File

@ -1,6 +1,6 @@
#include "VoxelGame.h" #include "VoxelGame.h"
#include <iostream> #include <iostream>
#include <glad/glad.h> #include <GL/glew.h>
// Include stb_image implementation (ensure stb_image.h is in your include path) // Include stb_image implementation (ensure stb_image.h is in your include path)
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
@ -32,7 +32,7 @@ bool VoxelGame::loadTextures() {
unsigned char *data; unsigned char *data;
// Load grass texture // Load grass texture
data = stbi_load("grass.png", &width, &height, &nrChannels, 0); data = stbi_load("grass.jpg", &width, &height, &nrChannels, 0);
if (data) { if (data) {
glGenTextures(1, &textureGrass); glGenTextures(1, &textureGrass);
glBindTexture(GL_TEXTURE_2D, textureGrass); glBindTexture(GL_TEXTURE_2D, textureGrass);
@ -50,7 +50,7 @@ bool VoxelGame::loadTextures() {
} }
// Load dirt texture // Load dirt texture
data = stbi_load("dirt.png", &width, &height, &nrChannels, 0); data = stbi_load("dirt.jpg", &width, &height, &nrChannels, 0);
if (data) { if (data) {
glGenTextures(1, &textureDirt); glGenTextures(1, &textureDirt);
glBindTexture(GL_TEXTURE_2D, textureDirt); glBindTexture(GL_TEXTURE_2D, textureDirt);
@ -122,7 +122,7 @@ void VoxelGame::render() {
} }
void VoxelGame::debugUI() { void VoxelGame::debugUI() {
// Display a debug window using ImGui
ImGui::Begin("Debug"); ImGui::Begin("Debug");
ImGui::Text("Voxel Game Debug Window"); ImGui::Text("Voxel Game Debug Window");
ImGui::Text("Mesh quads count: %d", (int)meshQuads.size()); ImGui::Text("Mesh quads count: %d", (int)meshQuads.size());

View File

@ -4,6 +4,11 @@
#include <vector> #include <vector>
#include "GreedyMesher.h" #include "GreedyMesher.h"
#include "imgui.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
class VoxelGame { class VoxelGame {
public: public:
VoxelGame(); VoxelGame();

View File

@ -1,5 +1,5 @@
#include <iostream> #include <iostream>
#include <glad/glad.h> #include <GL/glew.h>
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "VoxelGame.h" #include "VoxelGame.h"
@ -27,11 +27,7 @@ GLFWwindow* initWindow(int width, int height, const char* title) {
} }
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
// Initialize GLAD to load OpenGL function pointers
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cerr << "Failed to initialize GLAD\n";
return nullptr;
}
return window; return window;
} }