#2 - Static linking & dependency reduction
This commit is contained in:
+23
-19
@@ -1,10 +1,12 @@
|
||||
#include <SDL2/SDL_error.h>
|
||||
#include <SDL_video.h>
|
||||
#include "SDLWindow.h"
|
||||
|
||||
#include <SDL3/SDL_error.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <volk.h>
|
||||
#include <stdexcept>
|
||||
#include "SDLWindow.h"
|
||||
|
||||
#include "LoftException.hpp"
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
#include <SDL3/SDL_vulkan.h>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
@@ -27,16 +29,16 @@ VkExtent2D SDLWindow::get_size() const {
|
||||
SDLWindow::SDLWindow(std::string name, VkRect2D rect) :
|
||||
m_extent{rect.extent}
|
||||
{
|
||||
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVERYTHING) < 0) {
|
||||
if(!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
throw std::runtime_error("Failed to initialize sdl");
|
||||
}
|
||||
|
||||
m_pWindow = SDL_CreateWindow(name.c_str(),
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
// SDL_WINDOWPOS_CENTERED,
|
||||
// SDL_WINDOWPOS_CENTERED,
|
||||
rect.extent.width,
|
||||
rect.extent.height,
|
||||
SDL_WINDOW_VULKAN | SDL_WINDOW_ALLOW_HIGHDPI |
|
||||
SDL_WINDOW_VULKAN | SDL_WINDOW_HIGH_PIXEL_DENSITY |
|
||||
SDL_WINDOW_RESIZABLE);
|
||||
|
||||
if(m_pWindow == nullptr) {
|
||||
@@ -46,7 +48,7 @@ m_extent{rect.extent}
|
||||
|
||||
Surface SDLWindow::create_surface(const Instance* instance) const {
|
||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||
SDL_Vulkan_CreateSurface(m_pWindow, instance->instance(), &surface);
|
||||
SDL_Vulkan_CreateSurface(m_pWindow, instance->instance(), NULL, &surface);
|
||||
return Surface(instance, surface);
|
||||
}
|
||||
|
||||
@@ -60,19 +62,21 @@ int32_t SDLWindow::poll_event(SDL_Event *pOutEvent) const {
|
||||
|
||||
std::vector<std::string> SDLWindow::get_required_extensions() const {
|
||||
uint32_t count = 0;
|
||||
SDL_Vulkan_GetInstanceExtensions(m_pWindow, &count, nullptr);
|
||||
const char* const *instance_extensions = SDL_Vulkan_GetInstanceExtensions(&count);
|
||||
|
||||
std::vector<const char*> extensions(count);
|
||||
SDL_Vulkan_GetInstanceExtensions(m_pWindow, &count, extensions.data());
|
||||
std::vector<std::string> extensions(count);
|
||||
for(int i = 0; i < count; i++) {
|
||||
extensions[i] = std::string(instance_extensions[i]);
|
||||
}
|
||||
|
||||
std::vector<std::string> extension_strings(count);
|
||||
std::transform(extensions.begin(), extensions.end(),
|
||||
extension_strings.begin(),
|
||||
[](const char* str) {
|
||||
return std::string(str);
|
||||
});
|
||||
// std::vector<std::string> extension_strings(count);
|
||||
// std::transform(extensions.begin(), extensions.end(),
|
||||
// extension_strings.begin(),
|
||||
// [](const char* str) {
|
||||
// return std::string(str);
|
||||
// });
|
||||
|
||||
return extension_strings;
|
||||
return extensions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user