learn-vulkan/vk_gui.cpp
2026-02-12 23:24:24 -05:00

48 lines
1 KiB
C++

#include "vk_gui.h"
#include "vk_initializers.h"
#include <SDL.h>
#include <SDL_vulkan.h>
#include "vk_engine.h"
struct SDL_Window* VkGUI::init_window(VkExtent2D windowExtent)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN);
return SDL_CreateWindow(
"Vulkan Engine",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
int(windowExtent.width),
int(windowExtent.height),
window_flags);
}
void VkGUI::destroy(struct SDL_Window* _window)
{
SDL_DestroyWindow(_window);
}
void VkGUI::poll_event() {
SDL_Event event;
while(SDL_PollEvent(&event) != 0) {
//close the window when user alt-f4s or clicks the X button
if(event.type == SDL_QUIT) {
should_quit = true;
}
if(event.type == SDL_WINDOWEVENT) {
if(event.window.event == SDL_WINDOWEVENT_MINIMIZED) {
stop_rendering = true;
}
if(event.window.event == SDL_WINDOWEVENT_RESTORED) {
stop_rendering = false;
}
}
}
}