summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--engine/xe_engine.cpp2
-rw-r--r--engine/xe_engine.hpp2
-rwxr-xr-xengine/xe_window.cpp12
-rwxr-xr-xengine/xe_window.hpp3
-rw-r--r--res/image/icon.pngbin0 -> 72310 bytes
-rwxr-xr-xsrc/first_app.cpp4
6 files changed, 17 insertions, 6 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;
diff --git a/res/image/icon.png b/res/image/icon.png
new file mode 100644
index 0000000..af0b34e
--- /dev/null
+++ b/res/image/icon.png
Binary files differ
diff --git a/src/first_app.cpp b/src/first_app.cpp
index 2319670..968f7f8 100755
--- a/src/first_app.cpp
+++ b/src/first_app.cpp
@@ -3,7 +3,7 @@
namespace app {
-FirstApp::FirstApp() : xeEngine{WIDTH, HEIGHT, "Xenon Vulkan Engine"} {};
+FirstApp::FirstApp() : xeEngine{WIDTH, HEIGHT, "Minecraft Vulkan", "res/image/icon.png"} {};
FirstApp::~FirstApp() {}
@@ -20,7 +20,7 @@ void FirstApp::run() {
sound.play();
auto viewerObject = xe::GameObject::createGameObject();
- viewerObject.transform.translation = {-7.f, 3.f, -7.f};
+ viewerObject.transform.translation = {0.f, 10.f, 0.f};
viewerObject.transform.rotation.y = glm::radians(45.f);
KeyboardMovementController cameraController{xeEngine.getInput(), viewerObject};