diff --git a/res/stone.png b/res/stone.png new file mode 100755 index 0000000..5e539a4 Binary files /dev/null and b/res/stone.png differ diff --git a/src/gObserver.cpp b/src/gObserver.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/game.cpp b/src/game.cpp deleted file mode 100644 index 631f4aa..0000000 --- a/src/game.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "game.hpp" -#include "GLFW/glfw3.h" -#include - -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