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

View File

@ -1,10 +1,19 @@
# Compiler settings
CXX = g++
CXXFLAGS = -std=c++11 -I. -I/path/to/glad/include -I/path/to/imgui -I.
LDFLAGS = -lglfw -ldl -lGL
CXXFLAGS = -std=c++11 -I. -Iimgui-docking -IC:/msys64/mingw64/include
LDFLAGS = -LC:/msys64/mingw64/lib -lglfw3 -lopengl32 -lgdi32
# List source files
SRCS = main.cpp VoxelGame.cpp GreedyMesher.cpp
# List ImGui source files
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)
TARGET = voxelgame

View File

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

View File

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

View File

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