feat: add texture folder and remove old files

This commit is contained in:
2025-11-15 21:13:48 +01:00
parent cb103f4d90
commit a7583c37f4
8 changed files with 10 additions and 158 deletions

BIN
res/stone.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

View File

View File

@@ -1,15 +0,0 @@
#include "game.hpp"
#include "GLFW/glfw3.h"
#include <iostream>
Game::Game() : v("game", 800, 600)
{
}
void Game::run()
{
while(!this->finished)
{
}
}

View File

@@ -1,22 +0,0 @@
#ifndef GAME_HPP
#define GAME_HPP
#include "visual.hpp"
#include <GL/glew.h>
#include <GLFW/glfw3.h>
class Game
{
private:
bool finished = false;
int frame = 60;
Visual v;
public:
Game();
void run();
};
#endif

View File

@@ -1,8 +1,10 @@
#include "visual.hpp"
int main()
{
Visual v("game", 800, 600);
v.run();
return 0;
#include "game.hpp"
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
int main()
{
Game game(800, 600, "game");
game.run();
return 0;
}

View File

@@ -5,7 +5,7 @@ namespace fs = std::filesystem;
Texture::Texture(const std::string& filename)
{
fs::path path = fs::absolute(fs::current_path() / "res/textures" / filename);
fs::path path = fs::absolute(fs::current_path() / "res" / filename);
int maxTextureSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);

View File

@@ -1,87 +0,0 @@
#include "visual.hpp"
#include <GLFW/glfw3.h>
#include <iostream>
Visual::Visual(const char *name, int width, int height) : width(width), height(height)
{
if(!glfwInit())
{
std::cerr << "Failed to initialize GLFW";
exit(1);
}
// opengl 3.3
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
this->window = glfwCreateWindow(this->width, this->height, name, nullptr, nullptr);
if (!this->window)
{
std::cerr << "Failed to create GLFW window\n";
glfwTerminate();
exit(1);
}
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
std::cerr << "Failed to initialize GLEW\n";
glfwTerminate();
exit(EXIT_FAILURE);
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
}
Visual::~Visual()
{
if (window)
glfwDestroyWindow(window);
glfwTerminate();
std::cout << "Game finished with success." << std::endl;
}
void Visual::run()
{
while(!glfwWindowShouldClose(this->window))
{
glfwGetWindowSize(window, &this->width, &this->height);
glViewport(0, 0, this->width, this->height);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
glDisable(GL_MULTISAMPLE);
glfwPollEvents();
glfwSwapBuffers(window);
GLenum error;
if ((error = glGetError()) != GL_NO_ERROR)
std::cout << error << std::endl;
}
}
int Visual::getWidth()
{
return this->width;
}
int Visual::getHeight()
{
return this->height;
}
GLFWwindow* Visual::getWindow()
{
return this->window;
}

View File

@@ -1,26 +0,0 @@
#ifndef VISUAL_HPP
#define VISUAL_HPP
#include "GL/glew.h"
#include "GLFW/glfw3.h"
class Visual
{
private:
// window size
int width, height;
// window conf
GLFWwindow *window = nullptr;
public:
Visual(const char *name, int width, int height);
~Visual();
void run();
GLFWwindow *getWindow();
int getWidth();
int getHeight();
};
#endif