hello vulkan
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include <chrono>
|
||||
#include <SDL3/SDL_events.h>
|
||||
|
||||
App::App(): window_(new Window()) {
|
||||
App::App(): window_(new Window()), engine_(new Engine(window_)) {
|
||||
// smart pointers might be a good idea
|
||||
// since app will be the top level owner we can use unique ptrs for almost everything
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "Window.hpp"
|
||||
#include "Engine.hpp"
|
||||
|
||||
class App {
|
||||
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
private:
|
||||
|
||||
Window* window_;
|
||||
Engine* engine_;
|
||||
|
||||
bool rendering_ = true;
|
||||
|
||||
|
||||
51
src/Engine.cpp
Normal file
51
src/Engine.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
#include "Engine.hpp"
|
||||
|
||||
#include "vulkan/vulkan.h"
|
||||
#include <iostream>
|
||||
|
||||
Engine::Engine(Window* window): window_(window) {
|
||||
|
||||
// cleans up this constructor
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
void Engine::init() {
|
||||
|
||||
VkApplicationInfo appInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
.pApplicationName = "maiden",
|
||||
.apiVersion = VK_API_VERSION_1_4
|
||||
};
|
||||
|
||||
uint32_t instanceExtensionsCount = 0;
|
||||
char const* const* instanceExtensions{ SDL_Vulkan_GetInstanceExtensions(&instanceExtensionsCount) };
|
||||
|
||||
VkInstanceCreateInfo instanceCI {
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pApplicationInfo = &appInfo,
|
||||
.enabledExtensionCount = instanceExtensionsCount,
|
||||
.ppEnabledExtensionNames = instanceExtensions,
|
||||
};
|
||||
|
||||
VkInstance instance;
|
||||
if(vkCreateInstance(&instanceCI, nullptr, &instance) == VK_SUCCESS) {
|
||||
// TODO: need some kind of logger service
|
||||
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Vulkan instance successfully created." << std::endl;
|
||||
} else {
|
||||
std::cout << "[" << __FUNCTION__ << ": " << __LINE__ << "] Error creating Vulkan instance." << std::endl;
|
||||
}
|
||||
|
||||
// next steps:
|
||||
// device selection and setup
|
||||
// queue creation
|
||||
// vulkan memory allocator
|
||||
// create vulkan surface
|
||||
// attach surface to window
|
||||
|
||||
}
|
||||
|
||||
void Engine::draw() {
|
||||
|
||||
}
|
||||
24
src/Engine.hpp
Normal file
24
src/Engine.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Window.hpp"
|
||||
|
||||
class Engine {
|
||||
|
||||
public:
|
||||
|
||||
Engine(Window* window);
|
||||
~Engine() = default;
|
||||
|
||||
void init();
|
||||
|
||||
// draw is called every render iteration in that while loop
|
||||
void draw();
|
||||
|
||||
private:
|
||||
|
||||
// might get rid of this
|
||||
|
||||
Window* window_;
|
||||
|
||||
};
|
||||
@@ -1,12 +1,8 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "App.hpp"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
std::cout << "hi mom !" << std::endl;
|
||||
|
||||
// create app and run
|
||||
App app;
|
||||
app.run();
|
||||
|
||||
Reference in New Issue
Block a user