Initial commit with the chapter-0 code working.
This commit is contained in:
commit
7298568818
19 changed files with 8380 additions and 0 deletions
60
vk_engine.cpp
Normal file
60
vk_engine.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
#include "vk_engine.h"
|
||||
#include <print>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
|
||||
#include <vk_types.h>
|
||||
#include <vk_initializers.h>
|
||||
|
||||
void VulkanEngine::init()
|
||||
{
|
||||
// We initialize SDL and create a window with it.
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN);
|
||||
|
||||
_window = SDL_CreateWindow(
|
||||
"Vulkan Engine",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
int(_windowExtent.width),
|
||||
int(_windowExtent.height),
|
||||
window_flags
|
||||
);
|
||||
|
||||
//everything went fine
|
||||
_isInitialized = true;
|
||||
}
|
||||
void VulkanEngine::cleanup()
|
||||
{
|
||||
if (_isInitialized) {
|
||||
SDL_DestroyWindow(_window);
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanEngine::draw()
|
||||
{
|
||||
//nothing yet
|
||||
}
|
||||
|
||||
void VulkanEngine::run()
|
||||
{
|
||||
SDL_Event e;
|
||||
bool bQuit = false;
|
||||
|
||||
//main loop
|
||||
while (!bQuit)
|
||||
{
|
||||
//Handle events on queue
|
||||
while (SDL_PollEvent(&e) != 0)
|
||||
{
|
||||
//close the window when user alt-f4s or clicks the X button
|
||||
if (e.type == SDL_QUIT) bQuit = true;
|
||||
}
|
||||
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue