From 3892d29f4e7846696a2239e2d1c07ff3babda7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Wed, 19 Nov 2025 10:10:53 +0100 Subject: [PATCH] feat(Game): re init Game class --- inc/game.hpp | 23 +++++++++++++++++++++++ src/game.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/main.cpp | 5 +++-- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 inc/game.hpp create mode 100644 src/game.cpp diff --git a/inc/game.hpp b/inc/game.hpp new file mode 100644 index 0000000..5b37d5d --- /dev/null +++ b/inc/game.hpp @@ -0,0 +1,23 @@ +#ifndef GAME_HPP +#define GAME_HPP + +#include "GLFW/glfw3.h" +#include + +using namespace std; + +class Game +{ +private: + int width; + int height; + const char *name; + GLFWwindow *window; + +public: + Game(int width, int height, string name); + ~Game(); + void run(); +}; + +#endif \ No newline at end of file diff --git a/src/game.cpp b/src/game.cpp new file mode 100644 index 0000000..6e919b5 --- /dev/null +++ b/src/game.cpp @@ -0,0 +1,49 @@ +#include "GL/glew.h" +#include "game.hpp" +#include "GLFW/glfw3.h" +#include + + +Game::Game(int width, int height, string name) : + width(width), + height(height), + name(name.c_str()) +{ + if(glfwInit() == GLFW_FALSE) + std::cerr << "error glfw" << std::endl; + + this->window = glfwCreateWindow( + this->width, + this->height, + this->name, + nullptr, + nullptr + ); + + // OpenGL 3.3 + glfwWindowHint(GLFW_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_VERSION_MINOR, 3); + + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + + glfwWindowHint(GLFW_DEPTH_BITS, 24); + glfwWindowHint(GLFW_STENCIL_BITS, 8); + + glfwWindowHint(GLFW_SAMPLES, 4); + glfwMakeContextCurrent(this->window); + + glewInit(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_MULTISAMPLE); +} + +void Game::run() +{ + +} + +Game::~Game() +{ + glfwTerminate(); +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index c5c7260..5a11d63 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ -#include "game.hpp" #define STB_IMAGE_IMPLEMENTATION -#include +#include "stb_image.h" + +#include "game.hpp" int main() {