window icon
This commit is contained in:
parent
5a08c9c8e2
commit
bc2a2d08c9
6 changed files with 17 additions and 6 deletions
|
@ -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{},
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
BIN
res/image/icon.png
Normal file
BIN
res/image/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
|
@ -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};
|
||||
|
||||
|
|
Loading…
Reference in a new issue