From b82e13cb2e4ba772e342c68cbe30bb3ac210120f Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 16 Apr 2026 23:53:29 +0900 Subject: [PATCH] define opengl/vulkan symbols anyways --- CMakeLists.txt | 10 +++++----- pl/rules.pl | 6 ++++-- src/widget/opengl.c | 7 +++++++ src/widget/vulkan.c | 11 ++++++++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0c7f0b..a4f4eb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,9 +45,6 @@ file( external/libz/src/*.c src/*.c src/cursor/*.c src/icon/*.c src/widget/*.c src/text/*.c src/text/font/*.c src/dialog/*.c src/abstract/*.c external/*.c ) -list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c") -list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c") - if(NOT MW_USE_STB_IMAGE) list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_image.c") endif() @@ -65,7 +62,11 @@ if(MW_TRY_OPENGL) find_package(OpenGL) if(OpenGL_FOUND) set(MW_BUILD_OPENGL ON) - list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c") + target_compile_definitions( + Mw + PRIVATE + MW_OPENGL + ) if(APPLE) list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl_cocoa.m") endif() @@ -79,7 +80,6 @@ if(MW_TRY_VULKAN) check_include_files(vulkan/vulkan.h HAVE_VULKAN_VULKAN_H) if(HAVE_VULKAN_VULKAN_H) set(MW_BUILD_VULKAN ON) - list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c") target_compile_definitions( Mw PRIVATE diff --git a/pl/rules.pl b/pl/rules.pl index 6f64a17..7ad414d 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -139,12 +139,14 @@ new_object("src/widget/treeview.c"); new_object("src/widget/viewport.c"); new_object("src/widget/window.c"); +new_object("src/widget/opengl.c"); +new_object("src/widget/vulkan.c"); + if (param_get("opengl")) { - new_object("src/widget/opengl.c"); + add_cflags("-DMW_OPENGL"); } if (param_get("vulkan")) { add_cflags("-DMW_VULKAN"); - new_object("src/widget/vulkan.c"); } new_object("src/dialog/*.c"); diff --git a/src/widget/opengl.c b/src/widget/opengl.c index 39b5510..e8b222c 100644 --- a/src/widget/opengl.c +++ b/src/widget/opengl.c @@ -1,6 +1,8 @@ #ifndef __APPLE__ #include + +#ifdef MW_OPENGL #include #ifdef USE_GDI @@ -516,5 +518,10 @@ MwClassRec MwOpenGLClassRec = {wcreate, /* create */ NULL, /* clipboard */ NULL, NULL, NULL, NULL}; MwClass MwOpenGLClass = &MwOpenGLClassRec; +#else +MWDECL MwClass MwOpenGLClass; + +MwClass MwOpenGLClass = NULL; +#endif #endif diff --git a/src/widget/vulkan.c b/src/widget/vulkan.c index 7cb3312..394c9e5 100644 --- a/src/widget/vulkan.c +++ b/src/widget/vulkan.c @@ -1,10 +1,12 @@ #include -#include /** * ioixd maintains this file. nishi doesn't know vulkan at all */ +#ifdef MW_VULKAN +#include + #ifdef USE_GDI #define VK_USE_PLATFORM_WIN32_KHR 1 #endif @@ -165,6 +167,8 @@ static int _destroy(MwWidget handle) { static void destroy(MwWidget handle) { int err = _destroy(handle); + + (void)err; } static void* vulkan_lib_load() { @@ -577,3 +581,8 @@ MwClassRec MwVulkanClassRec = { NULL, NULL}; MwClass MwVulkanClass = &MwVulkanClassRec; +#else +MWDECL MwClass MwVulkanClass; + +MwClass MwVulkanClass = NULL; +#endif