git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@480 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-23 17:42:13 +00:00
parent 841ea75f37
commit 184a4eb420
6 changed files with 84 additions and 32 deletions

View File

@@ -7,7 +7,7 @@ project(
)
option(OPENGL "Compile OpenGL widget or not" ON)
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
option(VULKAN "Compile Vulkan widget or not" OFF)
else()
option(VULKAN "Compile Vulkan widget or not" ON)
@@ -102,11 +102,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
PRIVATE
USE_GDI
)
target_link_libraries(
Mw
PRIVATE
gdi32
)
list(APPEND LIBRARIES gdi32)
list(APPEND GL_LIBRARIES opengl32 glu32)
else()
find_package(PkgConfig)
pkg_check_modules(X11 REQUIRED x11)
@@ -118,35 +116,45 @@ else()
PRIVATE
src/backend/x11.c
)
target_include_directories(
Mw
PRIVATE
${X11_INCLUDE_DIRS} ${XRENDER_INCLUDE_DIRS} ${XCURSOR_INCLUDE_DIRS}
)
target_link_directories(
Mw
PRIVATE
${X11_LIBRARY_DIRS} ${XRENDER_LIBRARY_DIRS} ${XCURSOR_LIBRARY_DIRS}
)
target_link_libraries(
Mw
PRIVATE
${X11_LIBRARIES} ${XRENDER_LIBRARIES} ${XCURSOR_LIBRARIES} m
)
target_compile_definitions(
Mw
PRIVATE
USE_X11
)
list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS} ${XRENDER_INCLUDE_DIRS} ${XCURSOR_INCLUDE_DIRS})
list(APPEND LIBRARY_DIRS ${X11_LIBRARY_DIRS} ${XRENDER_LIBRARY_DIRS} ${XCURSOR_LIBRARY_DIRS})
list(APPEND LIBRARIES ${X11_LIBRARIES} ${XRENDER_LIBRARIES} ${XCURSOR_LIBRARIES} m)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(
Mw
PRIVATE
dl
)
list(APPEND LIBRARIES dl)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD" AND VULKAN)
list(APPEND INCLUDE_DIRS /usr/pkg/include)
endif()
list(APPEND GL_INCLUDE_DIRS ${INCLUDE_DIRS})
list(APPEND GL_LIBRARY_DIRS ${LIBRARY_DIRS})
list(APPEND GL_LIBRARIES GL GLU)
list(APPEND VK_INCLUDE_DIRS ${INCLUDE_DIRS})
list(APPEND VK_LIBRARY_DIRS ${LIBRARY_DIRS})
endif()
target_include_directories(
Mw
PRIVATE
${INCLUDE_DIRS}
)
target_link_directories(
Mw
PRIVATE
${LIBRARY_DIRS}
)
target_link_libraries(
Mw
PRIVATE
${LIBRARIES}
)
target_compile_definitions(
Mw
PRIVATE
@@ -155,6 +163,12 @@ target_compile_definitions(
if(BUILD_EXAMPLES)
add_subdirectory(examples/basic)
if(OPENGL)
add_subdirectory(examples/gldemos)
endif()
if(VULKAN)
add_subdirectory(examples/vkdemos)
endif()
endif()
include(GNUInstallDirs)

View File

@@ -21,6 +21,10 @@ else
CFLAGS += -O2
endif
ifeq ($(TARGET),NetBSD)
VULKAN_NO_STRING_HELPER = 1
endif
ifeq ($(VULKAN_NO_STRING_HELPER),1)
VK_STRING_HELPER_DEFINE =
else
@@ -50,6 +54,7 @@ CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include
LDFLAGS += -L/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/X11R7/lib -Wl,-R/usr/pkg/lib
UNIX = 1
OPENGL = 1
VULKAN = 1
FOUND_PLATFORM = 1
endif

View File

@@ -1,11 +1,11 @@
# $Id$
file(
GLOB
EXAMPLE_BASIC_SOURCES
EXAMPLES_BASIC_SOURCES
*.c
)
foreach(PATH IN LISTS EXAMPLE_BASIC_SOURCES)
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
get_filename_component(
TARGET
${PATH}
@@ -14,6 +14,11 @@ foreach(PATH IN LISTS EXAMPLE_BASIC_SOURCES)
add_executable(
${TARGET} ${PATH}
)
target_include_directories(
${TARGET}
PRIVATE
${CMAKE_SOURCE_DIR}/include
)
target_link_libraries(
${TARGET}
PRIVATE

View File

@@ -0,0 +1,28 @@
# $Id$
file(
GLOB
EXAMPLES_VKDEMOS_SOURCES
*.c
)
foreach(PATH IN LISTS EXAMPLES_VKDEMOS_SOURCES)
get_filename_component(
TARGET
${PATH}
NAME_WE
)
add_executable(
${TARGET} ${PATH}
)
target_include_directories(
${TARGET}
PRIVATE
${VK_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/include
)
target_link_libraries(
${TARGET}
PRIVATE
Mw
)
endforeach()

View File

@@ -12,7 +12,7 @@
#ifndef __MW_WIDGET_VULKAN_H__
#define __MW_WIDGET_VULKAN_H__
#if !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__)
#if !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
#error Vulkan is unsupported on the requested platform.
#endif

View File

@@ -11,13 +11,13 @@
#ifdef _WIN32
#define VK_USE_PLATFORM_WIN32_KHR 1
#endif
#ifdef __linux__
#ifdef __unix__
#define VK_USE_PLATFORM_XLIB_KHR 1
#endif
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>
#ifdef __linux__
#ifdef __unix__
#include <vulkan/vulkan_xlib.h>
#endif
@@ -306,7 +306,7 @@ static MwErrorEnum vulkan_surface_setup(MwWidget handle, vulkan_t* o) {
VK_CMD(_vkCreateWin32SurfaceKHR(o->vkInstance, &createInfo, NULL,
&o->vkSurface));
#endif
#ifdef __linux__
#ifdef __unix__
LOAD_VK_FUNCTION(vkCreateXlibSurfaceKHR);
VkXlibSurfaceCreateInfoKHR createInfo = {