diff options
author | tylermurphy534 <tylermurphy534@gmail.com> | 2022-09-26 21:24:28 -0400 |
---|---|---|
committer | tylermurphy534 <tylermurphy534@gmail.com> | 2022-09-26 21:24:28 -0400 |
commit | bc2a2d08c9b7e5ab7b5b85bdcba77087abaed95a (patch) | |
tree | aabc135163b7569f3c339a471479963ef7eabf2f /engine | |
parent | vertex buffer is not a byte vector, multi texture loading (diff) | |
download | minecraftvulkan-bc2a2d08c9b7e5ab7b5b85bdcba77087abaed95a.tar.gz minecraftvulkan-bc2a2d08c9b7e5ab7b5b85bdcba77087abaed95a.tar.bz2 minecraftvulkan-bc2a2d08c9b7e5ab7b5b85bdcba77087abaed95a.zip |
window icon
Diffstat (limited to 'engine')
-rw-r--r-- | engine/xe_engine.cpp | 2 | ||||
-rw-r--r-- | engine/xe_engine.hpp | 2 | ||||
-rwxr-xr-x | engine/xe_window.cpp | 12 | ||||
-rwxr-xr-x | engine/xe_window.hpp | 3 |
4 files changed, 15 insertions, 4 deletions
diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp index 2044c58..56222a9 100644 --- a/engine/xe_engine.cpp +++ b/engine/xe_engine.cpp @@ -8,7 +8,7 @@ Engine* Engine::getInstance() { return _instance; } -Engine::Engine(int width, int height, std::string name) : xeWindow{width, height, name}, +Engine::Engine(int width, int height, std::string name, const char *icon) : xeWindow{width, height, name, icon}, xeDevice{xeWindow}, xeRenderer{xeWindow, xeDevice}, xeCamera{}, diff --git a/engine/xe_engine.hpp b/engine/xe_engine.hpp index 83824e2..9555574 100644 --- a/engine/xe_engine.hpp +++ b/engine/xe_engine.hpp @@ -20,7 +20,7 @@ class Engine { public: - Engine(int width, int height, std::string name); + Engine(int width, int height, std::string name, const char *icon); ~Engine(); diff --git a/engine/xe_window.cpp b/engine/xe_window.cpp index 0f9a2d1..8da1cc4 100755 --- a/engine/xe_window.cpp +++ b/engine/xe_window.cpp @@ -1,9 +1,11 @@ #include "xe_window.hpp" +#include "stb_image.h" namespace xe { - Window::Window(int w, int h, std::string name) : width{w}, height{h}, windowName{name} { + Window::Window(int w, int h, std::string name, const char *icon) : width{w}, height{h}, windowName{name} { initWindow(); + setIcon(icon); } Window::~Window() { @@ -21,6 +23,14 @@ namespace xe { glfwSetFramebufferSizeCallback(window, framebufferResizeCallback); } + void Window::setIcon(const char *icon) { + if(icon == NULL) return; + GLFWimage images[1]; + images[0].pixels = stbi_load(icon, &images[0].width, &images[0].height, 0, 4); //rgba channels + glfwSetWindowIcon(window, 1, images); + stbi_image_free(images[0].pixels); + } + void Window::createWindowSurface(VkInstance instance, VkSurfaceKHR *surface){ if (glfwCreateWindowSurface(instance, window, nullptr, surface) != VK_SUCCESS) { throw std::runtime_error("failed to create window surface"); diff --git a/engine/xe_window.hpp b/engine/xe_window.hpp index 83b7c98..bb440ad 100755 --- a/engine/xe_window.hpp +++ b/engine/xe_window.hpp @@ -12,7 +12,7 @@ namespace xe { class Window { public: - Window(int w, int h, std::string name); + Window(int w, int h, std::string name, const char *icon); ~Window(); Window(const Window &) = delete; @@ -29,6 +29,7 @@ class Window { private: static void framebufferResizeCallback(GLFWwindow *window, int width, int height); void initWindow(); + void setIcon(const char *icon); int width; int height; |