From a7583c37f480815b9d923db7e7645071285a05ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Sat, 15 Nov 2025 21:13:48 +0100 Subject: [PATCH] feat: add texture folder and remove old files --- res/stone.png | Bin 0 -> 429 bytes src/gObserver.cpp | 0 src/game.cpp | 15 -------- src/game.hpp | 22 ------------ src/main.cpp | 16 +++++---- src/texture.cpp | 2 +- src/visual.cpp | 87 ---------------------------------------------- src/visual.hpp | 26 -------------- 8 files changed, 10 insertions(+), 158 deletions(-) create mode 100755 res/stone.png delete mode 100644 src/gObserver.cpp delete mode 100644 src/game.cpp delete mode 100644 src/game.hpp delete mode 100644 src/visual.cpp delete mode 100644 src/visual.hpp diff --git a/res/stone.png b/res/stone.png new file mode 100755 index 0000000000000000000000000000000000000000..5e539a41e5450a7af4e03b3d0e85dca5654dce07 GIT binary patch literal 429 zcmV;e0aE^nP)Px$XGugsR5*=&Q_E_DKomU|7n3m2E`kc0Y$SeH^An~0Rf80wf{Kf1hIUp?7t=dB zvF%xj-p6@dowwI_1psZ=fRG+D2sz@v_XL*;((D8P5V!lPIXz~m`x13unnwBgr3X*} zpiozp^^s6qbMwr$n|Yyh;D$kD3W%c5ebd01hhHHvGYEqSZP%DVwB;`>rMa|$A3X>; zfyw~vzmSQA7n0Po-tILn4OHK<(4prRzrw!oFsYx#rN3M zc8#TVniK$FniM{&i>Wsf2+L!6OrW^t*1c#3kJ_06XFF3ssQVIZyFp!5h?7K{EgkJa zam^715e6|BeVqNI!aRT}qq(js>)>2!2B70&`Xb}~!3-gT0l??JiMq%yngMNYy9Q}? zvQC*ZZ - -Game::Game() : v("game", 800, 600) -{ -} - -void Game::run() -{ - while(!this->finished) - { - - } -} \ No newline at end of file diff --git a/src/game.hpp b/src/game.hpp deleted file mode 100644 index b2c0ac9..0000000 --- a/src/game.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GAME_HPP -#define GAME_HPP - -#include "visual.hpp" - -#include -#include - -class Game -{ -private: - bool finished = false; - int frame = 60; - - Visual v; -public: - Game(); - - void run(); -}; - -#endif diff --git a/src/main.cpp b/src/main.cpp index 0ab7d1e..c5c7260 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 + +int main() +{ + Game game(800, 600, "game"); + game.run(); + return 0; } \ No newline at end of file diff --git a/src/texture.cpp b/src/texture.cpp index 29a6704..ace698e 100755 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -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); diff --git a/src/visual.cpp b/src/visual.cpp deleted file mode 100644 index f7323ec..0000000 --- a/src/visual.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "visual.hpp" - -#include -#include - -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; -} \ No newline at end of file diff --git a/src/visual.hpp b/src/visual.hpp deleted file mode 100644 index 65d29f2..0000000 --- a/src/visual.hpp +++ /dev/null @@ -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