Add create_surface function to create Vulkan surfaces
This commit is contained in:
parent
8a43f0000f
commit
a6895f1d5f
2 changed files with 16 additions and 6 deletions
|
@ -1,7 +1,5 @@
|
|||
#include "../compat.h"
|
||||
|
||||
#if defined(ENABLE_OPENGL)
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define FOR_WINDOWS 1
|
||||
#else
|
||||
|
@ -15,6 +13,7 @@
|
|||
#include "SDL_opengl.h"
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_vulkan.h>
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include <SDL2/SDL_opengles2.h>
|
||||
#endif
|
||||
|
@ -162,8 +161,9 @@ static void gfx_sdl_init(const char *game_name, const char* gfx_name, bool start
|
|||
char title[512];
|
||||
int len = sprintf(title, "%s (SDL - %s)", game_name, gfx_name);
|
||||
|
||||
// TODO: decide between opengl/vulkan surface c reation
|
||||
wnd = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
window_width, window_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
window_width, window_height, SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
|
||||
if (start_in_fullscreen) {
|
||||
set_fullscreen(true, false);
|
||||
|
@ -297,6 +297,15 @@ static double gfx_sdl_get_time(void) {
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
static void* gfx_sdl_create_surface(void* gfx_handle) {
|
||||
VkSurfaceKHR surface = NULL;
|
||||
SDL_Vulkan_CreateSurface(wnd, gfx_handle, &surface);
|
||||
|
||||
printf("Created vulkan surface!\n");
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
struct GfxWindowManagerAPI gfx_sdl = {
|
||||
gfx_sdl_init,
|
||||
gfx_sdl_set_keyboard_callbacks,
|
||||
|
@ -308,7 +317,6 @@ struct GfxWindowManagerAPI gfx_sdl = {
|
|||
gfx_sdl_start_frame,
|
||||
gfx_sdl_swap_buffers_begin,
|
||||
gfx_sdl_swap_buffers_end,
|
||||
gfx_sdl_get_time
|
||||
gfx_sdl_get_time,
|
||||
gfx_sdl_create_surface
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
struct GfxWindowManagerAPI {
|
||||
// FIXME: revert change for signature, gfx_name can actually be learned from gfx_get_current_rendering_api instead... oops
|
||||
void (*init)(const char *game_name, const char* gfx_name, bool start_in_fullscreen);
|
||||
void (*set_keyboard_callbacks)(bool (*on_key_down)(int scancode), bool (*on_key_up)(int scancode), void (*on_all_keys_up)(void));
|
||||
void (*set_fullscreen_changed_callback)(void (*on_fullscreen_changed)(bool is_now_fullscreen));
|
||||
|
@ -16,6 +17,7 @@ struct GfxWindowManagerAPI {
|
|||
void (*swap_buffers_begin)(void);
|
||||
void (*swap_buffers_end)(void);
|
||||
double (*get_time)(void); // For debug
|
||||
void* (*create_surface)(void* gfx_handle); // for vulkan
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue