feat(Game): re init Game class

This commit is contained in:
2025-11-19 10:10:53 +01:00
parent a7583c37f4
commit 3892d29f4e
3 changed files with 75 additions and 2 deletions

23
inc/game.hpp Normal file
View File

@@ -0,0 +1,23 @@
#ifndef GAME_HPP
#define GAME_HPP
#include "GLFW/glfw3.h"
#include <string>
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

49
src/game.cpp Normal file
View File

@@ -0,0 +1,49 @@
#include "GL/glew.h"
#include "game.hpp"
#include "GLFW/glfw3.h"
#include <iostream>
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();
}

View File

@@ -1,6 +1,7 @@
#include "game.hpp"
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h> #include "stb_image.h"
#include "game.hpp"
int main() int main()
{ {