diff --git a/2dGameProject/2dGameProject.vcxproj b/2dGameProject/2dGameProject.vcxproj index 44bb47e..010c549 100644 --- a/2dGameProject/2dGameProject.vcxproj +++ b/2dGameProject/2dGameProject.vcxproj @@ -130,12 +130,16 @@ + {c40453a2-a653-46a2-9ad7-f174540ef26c} + + + diff --git a/2dGameProject/2dGameProject.vcxproj.filters b/2dGameProject/2dGameProject.vcxproj.filters index ce0c35c..16353f8 100644 --- a/2dGameProject/2dGameProject.vcxproj.filters +++ b/2dGameProject/2dGameProject.vcxproj.filters @@ -18,5 +18,13 @@ Source Files + + Source Files + + + + + Header Files + \ No newline at end of file diff --git a/2dGameProject/Window.cpp b/2dGameProject/Window.cpp new file mode 100644 index 0000000..0fd0857 --- /dev/null +++ b/2dGameProject/Window.cpp @@ -0,0 +1,66 @@ +#include "Window.h" + +Window::Window(int width, int height, const char* title) { + glfw_window = glfwCreateWindow(width, height, title, NULL, NULL); + if (!glfw_window) + throw ("Failed to create GLFW Window!"); + setWidth(width); + setHeight(height); + setTitle(title); + +} + +Window::~Window() { + glfwDestroyWindow(glfw_window); +} + +void Window::setWidth(int width) { + this->width = width; + glfwSetWindowSize(glfw_window, width, height); +} + +int Window::getWidth() { + return width; +} + +void Window::setHeight(int height) { + this->height = height; + glfwSetWindowSize(glfw_window, width, height); +} + +int Window::getHeight() { + return height; +} + +void Window::setTitle(const char* title) { + this->title = title; + glfwSetWindowTitle(glfw_window, title); +} + +const char* Window::getTitle() { + return title; +} + +void Window::setFullscreen(bool fullscreen) { + is_fullscreen = fullscreen; + if (fullscreen) + glfwSetWindowMonitor(glfw_window, glfwGetPrimaryMonitor(), 0, 0, width, height, GLFW_DONT_CARE); + else + glfwSetWindowMonitor(glfw_window, NULL); +} + +bool Window::isFullscreen() { + return is_fullscreen; +} + +void Window::setResizable(bool resizable) { + is_resizable = resizable; + if (resizable) + glfwSetWindowAttrib(glfw_window, GLFW_RESIZABLE, GLFW_TRUE); + else + glfwSetWindowAttrib(glfw_window, GLFW_RESIZABLE, GLFW_FALSE); +} + +bool Window::isResizable() { + return is_resizable; +} \ No newline at end of file diff --git a/2dGameProject/Window.h b/2dGameProject/Window.h new file mode 100644 index 0000000..5c875f6 --- /dev/null +++ b/2dGameProject/Window.h @@ -0,0 +1,26 @@ +#pragma once +#include + +class Window { +private: + GLFWwindow* glfw_window; + int width, height; + const char* title; + bool is_fullscreen; + bool is_resizable; + +public: + Window(int width, int height, const char* title); + ~Window(); + int getWidth(); + int getHeight(); + void setWidth(int width); + void setHeight(int height); + const char* getTitle(); + void setTitle(const char* title); + bool isFullscreen(); + bool isResizable(); + void setFullscreen(bool fullscreen); + void setResizable(bool resizable); +}; +