From 50be0ad05d491f30a77938e30062fc5792762061 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Wed, 1 May 2024 18:31:13 +0800 Subject: [PATCH] improve bgfx build on windows --- 3rd/bgfx/SConscript | 7 +++++-- 3rd/nanovg/SConscript | 2 +- src/SConscript | 5 +++-- src/vgcanvas/vgcanvas_nanovg_bgfx.inc | 4 ++-- src/vgcanvas/vgcanvas_nanovg_gl2.c | 9 ++++++++- src/vgcanvas/vgcanvas_nanovg_gl3.c | 8 ++++++++ 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/3rd/bgfx/SConscript b/3rd/bgfx/SConscript index 4de7a5f70..5485d85ff 100644 --- a/3rd/bgfx/SConscript +++ b/3rd/bgfx/SConscript @@ -22,10 +22,13 @@ BgfxSources = [ 'bimg/src/image_gnf.cpp', 'bgfx/src/amalgamated.cpp' ] +BgfxSources += Glob('bimg/3rdparty/astc-encoder/source/*.cpp') if OS_NAME == 'Windows': - CCFLAGS = CCFLAGS + ' /std:c++17 '; - BgfxCppPath = BgfxCppPath + ['bx/include/compat/msvc','bgfx/3rdparty/dxsdk/include'] + CCFLAGS = CCFLAGS + ' /std:c++17 /Zc:__cplusplus '; + BgfxCppPath = BgfxCppPath + ['bx/include/compat/msvc', + 'bgfx/3rdparty/dxsdk/include', + 'bgfx/3rdparty/directx-headers/include/directx'] elif OS_NAME == 'Darwin': CCFLAGS = CCFLAGS + ' -std=c++17 ' BgfxCppPath= BgfxCppPath + ['bx/include/compat/osx'] diff --git a/3rd/nanovg/SConscript b/3rd/nanovg/SConscript index 4e2fbb5b6..3f635fd12 100644 --- a/3rd/nanovg/SConscript +++ b/3rd/nanovg/SConscript @@ -39,7 +39,7 @@ elif NANOVG_BACKEND == 'BGFX': if OS_NAME == 'Darwin': CCFLAGS = CCFLAGS + ' -std=c++17 ' elif OS_NAME == 'Windows': - CCFLAGS = CCFLAGS + ' /std:c++17 '; + CCFLAGS = CCFLAGS + ' /std:c++17 /Zc:__cplusplus '; CPPPATH = CPPPATH + [joinPath(TK_3RD_ROOT, 'bgfx/bx/include/compat/msvc')]; CCFLAGS += ' -DBX_CONFIG_DEBUG -DBIMG_DECODE_ENABLE=0 ' diff --git a/src/SConscript b/src/SConscript index fbf1f43a7..1e5765c45 100644 --- a/src/SConscript +++ b/src/SConscript @@ -67,8 +67,9 @@ else: BASE_SOURCES += ['vgcanvas/vgcanvas_nanovg_soft.c'] else: BASE_SOURCES += ['vgcanvas/vgcanvas_nanovg_gl.c'] - BASE_SOURCES += ['vgcanvas/vgcanvas_nanovg_gl2.c'] - BASE_SOURCES += ['vgcanvas/vgcanvas_nanovg_gl3.c'] + +BASE_SOURCES += ['vgcanvas/vgcanvas_nanovg_gl2.c'] +BASE_SOURCES += ['vgcanvas/vgcanvas_nanovg_gl3.c'] if os.environ['INPUT_ENGINE'] == 'null': BASE_SOURCES += Glob('input_engines/input_engine_null.c') diff --git a/src/vgcanvas/vgcanvas_nanovg_bgfx.inc b/src/vgcanvas/vgcanvas_nanovg_bgfx.inc index fa3091106..722479867 100644 --- a/src/vgcanvas/vgcanvas_nanovg_bgfx.inc +++ b/src/vgcanvas/vgcanvas_nanovg_bgfx.inc @@ -65,9 +65,9 @@ static ret_t vgcanvas_nanovg_create_fbo(vgcanvas_t* vgcanvas, uint32_t w, uint32 static ret_t vgcanvas_nanovg_destroy_fbo(vgcanvas_t* vgcanvas, framebuffer_object_t* fbo) { struct NVGLUframebuffer* handle = (struct NVGLUframebuffer*)fbo->handle; - + uint32_t index = getBgfxFboViewId(handle); nvgluDeleteFramebufferEx(handle); - arrayViewId[getBgfxFboViewId(handle)] = false; + arrayViewId[index] = false; curViewId = 0; (void)vgcanvas; return RET_OK; diff --git a/src/vgcanvas/vgcanvas_nanovg_gl2.c b/src/vgcanvas/vgcanvas_nanovg_gl2.c index 674b06e14..989298391 100644 --- a/src/vgcanvas/vgcanvas_nanovg_gl2.c +++ b/src/vgcanvas/vgcanvas_nanovg_gl2.c @@ -26,5 +26,12 @@ #define WITH_NANOVG_GL2 1 #define VGCANVAS_CREATE_GL vgcanvas_create_gl2 +#if !defined(WITH_GPU) +#include "base/vgcanvas.h" +vgcanvas_t* VGCANVAS_CREATE_GL(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format, + void* win) { + return NULL; +} +#else #include "vgcanvas_nanovg_gl_common.inc" - +#endif/*WIN32*/ diff --git a/src/vgcanvas/vgcanvas_nanovg_gl3.c b/src/vgcanvas/vgcanvas_nanovg_gl3.c index 5b2d72c61..3f45d953e 100644 --- a/src/vgcanvas/vgcanvas_nanovg_gl3.c +++ b/src/vgcanvas/vgcanvas_nanovg_gl3.c @@ -26,5 +26,13 @@ #define WITH_NANOVG_GL3 1 #define VGCANVAS_CREATE_GL vgcanvas_create_gl3 +#if !defined(WITH_GPU) +#include "base/vgcanvas.h" +vgcanvas_t* VGCANVAS_CREATE_GL(uint32_t w, uint32_t h, uint32_t stride, bitmap_format_t format, + void* win) { + return NULL; +} +#else #include "vgcanvas_nanovg_gl_common.inc" +#endif/*WIN32*/