Red screen on Linux
Oddly no validation error
This commit is contained in:
@@ -68,6 +68,8 @@
|
||||
#if OS_WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#elif OS_LINUX
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#endif // LD_CORE_PLATFORM_H_
|
||||
|
||||
@@ -23,6 +23,46 @@ static void Vk_CreateSurface(SDL_Window *window) {
|
||||
vk.err = vk.CreateWin32SurfaceKHR(vk.instance, &create_info, 0, &vk.surface);
|
||||
}
|
||||
|
||||
#elif OS_LINUX
|
||||
|
||||
#define VK_PLATFORM_SURFACE_EXTENSION \
|
||||
VK_KHR_XLIB_SURFACE_EXTENSION_NAME, \
|
||||
VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME
|
||||
|
||||
static void *Vk_LoadLibrary() {
|
||||
void *result = dlopen("libvulkan.so", RTLD_LAZY);
|
||||
|
||||
if (result != 0) {
|
||||
vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) dlsym(result, "vkGetInstanceProcAddr");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void Vk_CreateSurface(SDL_Window *window) {
|
||||
SDL_PropertiesID prop_id = SDL_GetWindowProperties(window);
|
||||
|
||||
struct wl_display *wl_display = SDL_GetPointerProperty(prop_id, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, 0);
|
||||
if (wl_display == 0) {
|
||||
// Assume we are running via X11 if there isn't a vaild Wayland display
|
||||
//
|
||||
VkXlibSurfaceCreateInfoKHR create_info = { 0 };
|
||||
create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.dpy = SDL_GetPointerProperty(prop_id, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, 0);
|
||||
create_info.window = SDL_GetNumberProperty(prop_id, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
|
||||
vk.err = vk.CreateXlibSurfaceKHR(vk.instance, &create_info, 0, &vk.surface);
|
||||
}
|
||||
else {
|
||||
VkWaylandSurfaceCreateInfoKHR create_info = { 0 };
|
||||
create_info.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
|
||||
create_info.display = wl_display;
|
||||
create_info.surface = SDL_GetPointerProperty(prop_id, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, 0);
|
||||
|
||||
vk.err = vk.CreateWaylandSurfaceKHR(vk.instance, &create_info, 0, &vk.surface);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Vk_Context vk;
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
#if defined(VK_USE_PLATFORM_WIN32_KHR)
|
||||
VK_FUNC(CreateWin32SurfaceKHR);
|
||||
#endif
|
||||
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
VK_FUNC(CreateWaylandSurfaceKHR);
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_XLIB_KHR)
|
||||
VK_FUNC(CreateXlibSurfaceKHR);
|
||||
#endif
|
||||
|
||||
#undef VK_INSTANCE_FUNCTIONS
|
||||
#endif
|
||||
|
||||
|
||||
50
linux
Executable file
50
linux
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
pushd "$(dirname $0)" > /dev/null
|
||||
|
||||
if [[ ! -d "build" ]];
|
||||
then
|
||||
mkdir "build"
|
||||
fi
|
||||
|
||||
pushd "build" > /dev/null
|
||||
|
||||
release=0
|
||||
deps=0
|
||||
|
||||
for a in $*
|
||||
do
|
||||
let $a=1
|
||||
done
|
||||
|
||||
if [[ ! -d "deps" ]]
|
||||
then
|
||||
deps=1
|
||||
fi
|
||||
|
||||
if [[ $deps == 1 ]]
|
||||
then
|
||||
# We don't build SDL3 like on windows, this assumes you have it installed instead. We can't
|
||||
# just ship with the version of SDL3 we want because the shared object system is bad
|
||||
echo "[Building dependencies]"
|
||||
|
||||
rm -rf "deps"
|
||||
mkdir -p "deps/stb"
|
||||
|
||||
cp ../thirdparty/stb/*.h deps/stb
|
||||
fi
|
||||
|
||||
echo "[Building source]"
|
||||
|
||||
COMPILER_OPTS="-Wall -Wno-missing-braces -I'deps/stb'"
|
||||
LINKER_OPTS="-lSDL3"
|
||||
|
||||
if [[ $release == 1 ]]
|
||||
then
|
||||
echo "[Release build]"
|
||||
gcc -O2 -Werror $COMPILER_OPTS -DLD_RELEASE=1 $(realpath "../code/first.c") -o "ludum" $LINKER_OPTS
|
||||
else
|
||||
echo "[Debug build]"
|
||||
gcc -O0 -g -ggdb $COMPILER_OPTS $(realpath "../code/first.c") -o "ldebug" $LINKER_OPTS
|
||||
fi
|
||||
Reference in New Issue
Block a user