From 2b879af3e11ba7e30dbffe05cefe2f88d494fe6b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 11 Aug 2023 18:05:45 +0900 Subject: [PATCH] Fix most of the hacks for clang gcc didn't like a couple of the changes (rightly so: one was actually incorrect), and the fix for qfcc I didn't think to suggest while working with Emily. The general CFLAGS etc fixes mostly required just getting the order of operations right: check for attributes after setting the warnings flags, though those needed some care for gcc as it began warning about main wanting the const attribute. Fixing the imui link errors required moving the ui functions and setup to vulkan_lighting.c, which is really the only place they're used. --- config.d/attributes.m4 | 82 ++++++++++++++++++ config.d/compiling.m4 | 28 ++++-- config.d/typedefs_structs_compiler.m4 | 55 ------------ configure.ac | 30 ++++++- include/QF/Vulkan/render.h | 7 +- include/QF/scene/light.h | 7 -- libs/audio/test/Makemodule.am | 1 + libs/console/client.c | 4 +- libs/models/brush/leafmesh.c | 90 ++++++++++++++++++++ libs/scene/light.c | 69 --------------- libs/ui/imui.c | 4 +- libs/video/renderer/vulkan/vkgen/stddef.h | 1 + libs/video/renderer/vulkan/vulkan_lighting.c | 66 ++++++++++++++ 13 files changed, 293 insertions(+), 151 deletions(-) create mode 100644 config.d/attributes.m4 create mode 100644 libs/models/brush/leafmesh.c diff --git a/config.d/attributes.m4 b/config.d/attributes.m4 new file mode 100644 index 000000000..a26aeb7a3 --- /dev/null +++ b/config.d/attributes.m4 @@ -0,0 +1,82 @@ +dnl ================================================================== +dnl Checks for compiler attributes +dnl ================================================================== + +AC_MSG_CHECKING(for __attribute__) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[static __attribute__ ((unused)) const char *foo = "bar";]] + [[int bar(void);]], + [[return bar();]])], + [AC_DEFINE(HAVE___ATTRIBUTE__) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) +AH_VERBATIM([HAVE___ATTRIBUTE__], +[/* Define this if the GCC __attribute__ keyword is available */ +#undef HAVE___ATTRIBUTE__ +#ifndef HAVE___ATTRIBUTE__ +# define __attribute__(x) +#endif]) + +AC_MSG_CHECKING(for __attribute__ ((visibility))) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[void foo (void);]] + [[__attribute__ ((visibility ("default"))) void foo (void) {}]] + [[int bar(void);]], + [[return bar();]] + )], + [AC_DEFINE(HAVE___ATTRIBUTE__VISIBILITY) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) +AH_VERBATIM([HAVE___ATTRIBUTE__VISIBILITY], +[/* Define this if the GCC visibility __attribute__ is available */ +#undef HAVE___ATTRIBUTE__VISIBILITY +#ifdef HAVE___ATTRIBUTE__VISIBILITY +# define VISIBLE __attribute__((visibility ("default"))) +#else +# define VISIBLE +#endif]) + +AC_MSG_CHECKING(for __attribute__ ((designated_init))) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[struct x { char y; } __attribute__ ((designated_init));]] + [[int bar(void);]], + [[return bar();]] + )], + [AC_DEFINE(HAVE___ATTRIBUTE__DESIGNATED_INIT) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) +AH_VERBATIM([HAVE___ATTRIBUTE__DESIGNATED_INIT], +[/* Define this if the GCC designated_init __attribute__ is available */ +#undef HAVE___ATTRIBUTE__DESIGNATED_INIT +#ifdef HAVE___ATTRIBUTE__DESIGNATED_INIT +# define DESIGNATED_INIT __attribute__((designated_init)) +#else +# define DESIGNATED_INIT +#endif]) + +if test "x$SYSTYPE" = "xWIN32"; then + AC_MSG_CHECKING(for __attribute__ ((gcc_struct))) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[typedef struct { int foo; }]] + [[__attribute__ ((gcc_struct)) gcc_struct_test;]], + [[return gcc_struct_test.foo]])], + [AC_DEFINE(HAVE___ATTRIBUTE__GCC_STRUCT) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + ]) +fi +AH_VERBATIM([HAVE___ATTRIBUTE__GCC_STRUCT], +[/* Define this if the GCC gcc_struct __attribute__ is available */ +#undef HAVE___ATTRIBUTE__GCC_STRUCT +#ifdef HAVE___ATTRIBUTE__GCC_STRUCT +# define GCC_STRUCT __attribute__((gcc_struct)) +#else +# define GCC_STRUCT +#endif]) diff --git a/config.d/compiling.m4 b/config.d/compiling.m4 index a41d959a9..508c43775 100644 --- a/config.d/compiling.m4 +++ b/config.d/compiling.m4 @@ -6,6 +6,18 @@ else cvs_def_disabled="!= xno" fi +AC_MSG_CHECKING(for clang) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[]], + [[#ifndef __clang__], + [ choke me], + [#endif]])], + [CLANG=yes], + [CLANG=no] +) +AC_MSG_RESULT($CLANG) + AC_MSG_CHECKING(for CFLAGS pre-set) leave_cflags_alone=no if test "x$CFLAGS" != "x"; then @@ -86,7 +98,7 @@ dnl We want warnings, lots of warnings... dnl The help text should be INVERTED before release! dnl when in git, this test defaults to ENABLED. dnl In a release, this test defaults to DISABLED. -if test "x$GCC" = "xyes"; then +if test "x$GCC" = "xyes" -a "x$leave_cflags_alone" != xyes; then if test "x$enable_Werror" $cvs_def_enabled; then CFLAGS="$CFLAGS -Wall -Werror -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations" else @@ -95,6 +107,10 @@ if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -fno-common" fi +if test "x$CLANG" = xyes -a "x$leave_cflags_alone" != xyes; then + CFLAGS="$CFLAGS -Wno-misleading-indentation" +fi + AC_ARG_ENABLE(optimize, AS_HELP_STRING([--disable-optimize], [compile without optimizations (for development)]), @@ -150,8 +166,8 @@ if test "x$optimize" = xyes -a "x$leave_cflags_alone" != "xyes"; then dnl if test "$CC_MAJ" -ge 4; then dnl QF_CC_OPTION(-finline-limit=32000 -Winline) dnl fi - dnl heavy="-O2 $CFLAGS -ffast-math -fno-unsafe-math-optimizations -funroll-loops -fomit-frame-pointer" - heavy="-O2 $CFLAGS -fno-fast-math -funroll-loops -fomit-frame-pointer " + dnl heavy="-O2 -ffast-math -fno-unsafe-math-optimizations -funroll-loops -fomit-frame-pointer" + heavy="-O2 -fno-fast-math -funroll-loops -fomit-frame-pointer " CFLAGS="$saved_cflags" light="-O2" AC_ARG_ENABLE(strict-aliasing, @@ -233,7 +249,7 @@ AC_ARG_ENABLE(profile, [compile with profiling (for development)]), profile=$enable_profile ) -if test "x$profile" = xyes; then +if test "x$profile" = xyes -a "x$leave_cflags_alone" != xyes; then BUILD_TYPE="$BUILD_TYPE Profile" if test "x$GCC" = xyes; then CFLAGS="`echo $CFLAGS | sed -e 's/-fomit-frame-pointer//g'` -pg" @@ -244,7 +260,7 @@ if test "x$profile" = xyes; then fi check_pipe=no -if test "x$GCC" = xyes; then +if test "x$GCC" = xyes -a "x$leave_cflags_alone" != xyes; then dnl Check for -pipe vs -save-temps. AC_MSG_CHECKING(for -pipe vs -save-temps) AC_ARG_ENABLE(save-temps, @@ -283,7 +299,7 @@ dnl with many compilers that do not support the latest ISO standards. Well, dnl that is our cover story -- the reality is that we like them and do not want dnl to give them up. :) dnl Make the compiler swallow its pride... -if test "x$GCC" != xyes; then +if test "x$GCC" != xyes -a "x$CLANG" != xyes -a "x$leave_cflags_alone" != xyes; then AC_MSG_CHECKING(for how to deal with BCPL-style comments) case "${host}" in *-aix*) diff --git a/config.d/typedefs_structs_compiler.m4 b/config.d/typedefs_structs_compiler.m4 index b0b5792f0..645c946ff 100644 --- a/config.d/typedefs_structs_compiler.m4 +++ b/config.d/typedefs_structs_compiler.m4 @@ -14,61 +14,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int foo = _SC_PAGE ]) fi -AC_MSG_CHECKING(for __attribute__) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[static __attribute__ ((unused)) const char *foo = "bar";]], [[]])],[AC_DEFINE(HAVE___ATTRIBUTE__) - AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) -]) -AH_VERBATIM([HAVE___ATTRIBUTE__], -[/* Define this if the GCC __attribute__ keyword is available */ -#undef HAVE___ATTRIBUTE__ -#ifndef HAVE___ATTRIBUTE__ -# define __attribute__(x) -#endif]) - -AC_MSG_CHECKING(for __attribute__ ((visibility))) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void foo (void); - __attribute__ ((visibility ("default"))) void foo (void) {}]], [[]])],[AC_DEFINE(HAVE___ATTRIBUTE__VISIBILITY) - AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) -]) -AH_VERBATIM([HAVE___ATTRIBUTE__VISIBILITY], -[/* Define this if the GCC visibility __attribute__ is available */ -#undef HAVE___ATTRIBUTE__VISIBILITY -#ifdef HAVE___ATTRIBUTE__VISIBILITY -# define VISIBLE __attribute__((visibility ("default"))) -#else -# define VISIBLE -#endif]) - -AC_MSG_CHECKING(for __attribute__ ((designated_init))) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void foo (void); - struct x { char y; } __attribute__ ((designated_init));]], [[]])],[AC_DEFINE(HAVE___ATTRIBUTE__DESIGNATED_INIT) - AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) -]) -AH_VERBATIM([HAVE___ATTRIBUTE__DESIGNATED_INIT], -[/* Define this if the GCC designated_init __attribute__ is available */ -#undef HAVE___ATTRIBUTE__DESIGNATED_INIT -#ifdef HAVE___ATTRIBUTE__DESIGNATED_INIT -# define DESIGNATED_INIT __attribute__((designated_init)) -#else -# define DESIGNATED_INIT -#endif]) - -if test "x$SYSTYPE" = "xWIN32"; then - AC_MSG_CHECKING(for __attribute__ ((gcc_struct))) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[typedef struct { int foo; } - __attribute__ ((gcc_struct)) gcc_struct_test;]], [[]])],[AC_DEFINE(HAVE___ATTRIBUTE__GCC_STRUCT) - AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) - ]) -fi -AH_VERBATIM([HAVE___ATTRIBUTE__GCC_STRUCT], -[/* Define this if the GCC gcc_struct __attribute__ is available */ -#undef HAVE___ATTRIBUTE__GCC_STRUCT -#ifdef HAVE___ATTRIBUTE__GCC_STRUCT -# define GCC_STRUCT __attribute__((gcc_struct)) -#else -# define GCC_STRUCT -#endif]) - AC_MSG_CHECKING(for __builtin_expect) AC_LINK_IFELSE([AC_LANG_PROGRAM([[int x;]], [[if (__builtin_expect(!x, 1)) {}]])],[AC_DEFINE(HAVE___BUILTIN_EXPECT) AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) diff --git a/configure.ac b/configure.ac index 10adee025..41fa5270a 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,27 @@ case "$host_os" in ;; *) dnl Checks for working -lm - AC_CHECK_LIB(m, lgammaf,, AC_MSG_ERROR([math library (-lm) appears broken])) + AC_MSG_CHECKING(for pow and atan2 in standard library) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int func_ind; + double (*func[])(double, double) = {pow, atan2};]], + [[return (int)(func[func_ind])(2, 3);]])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + AC_MSG_CHECKING(for pow and atan2 in -lm) + LIBS="-lm $LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + int func_ind; + double (*func[])(double, double) = {pow, atan2};]], + [[return (int)(func[func_ind])(2, 3);]])], + [AC_MSG_RESULT(yes)], + [AC_MSG_ERROR([math library (-lm) appears broken])] + )] + ) ;; esac @@ -70,6 +90,11 @@ m4_include(config.d/sdl.m4) m4_include(config.d/curses.m4) m4_include(config.d/freetype.m4) +m4_include(config.d/networking.m4) + +m4_include(config.d/compiling.m4) +m4_include(config.d/attributes.m4) + dnl ================================================================== dnl Checks for system type dnl ================================================================== @@ -115,13 +140,10 @@ m4_include(config.d/joystick.m4) m4_include(config.d/evdev.m4) m4_include(config.d/cdrom.m4) -m4_include(config.d/networking.m4) - m4_include(config.d/paths.m4) m4_include(config.d/build_control.m4) m4_include(config.d/qfcc.m4) -m4_include(config.d/compiling.m4) AC_ARG_ENABLE(static-doc, AS_HELP_STRING([--enable-static-doc], diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index e9f15db8d..bf8c0742e 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -6,10 +6,10 @@ #endif #include -#ifndef __QFCC__ #include "QF/cexpr.h" #include "QF/simd/types.h" +#ifndef __QFCC__ #include "QF/darray.h" #include "QF/Vulkan/command.h" #endif @@ -142,13 +142,8 @@ typedef struct qfv_attachmentinfo_s { } qfv_attachmentinfo_t; typedef struct qfv_taskinfo_s { -#ifndef __QFCC__ exprfunc_t *func; const exprval_t **params; -#else - void *func; - const void **params; -#endif void *param_data; } qfv_taskinfo_t; diff --git a/include/QF/scene/light.h b/include/QF/scene/light.h index c7943c50e..5e4f04b22 100644 --- a/include/QF/scene/light.h +++ b/include/QF/scene/light.h @@ -72,11 +72,4 @@ void Light_DecayLights (lightingdata_t *ldata, float frametime, double realtime); void Light_LinkLight (lightingdata_t *ldata, uint32_t entid); -struct imui_ctx_s; -struct ecs_registry_s; -void Light_dyn_light_ui (void *l, struct imui_ctx_s *imui_ctx, - struct ecs_registry_s *reg, uint32_t ent, void *data); -void Light_light_ui (void *l, struct imui_ctx_s *imui_ctx, - struct ecs_registry_s *reg, uint32_t ent, void *data); - #endif//__QF_scene_light_h diff --git a/libs/audio/test/Makemodule.am b/libs/audio/test/Makemodule.am index e1a4800b0..6b97b2e53 100644 --- a/libs/audio/test/Makemodule.am +++ b/libs/audio/test/Makemodule.am @@ -4,6 +4,7 @@ EXTRA_PROGRAMS += libs/audio/test/testsound testaudio_libs= \ libs/audio/libQFsound.la \ + libs/scene/libQFscene.la \ libs/ruamoko/libQFruamoko.la \ libs/util/libQFutil.la diff --git a/libs/console/client.c b/libs/console/client.c index 7c987c98e..64510b40b 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -571,14 +571,14 @@ draw_input_line (inputline_t *il, draw_charbuffer_t *buffer) char *src = il->lines[il->edit_line] + il->scroll + 1; size_t i; - *dst++ = il->scroll ? '<' | 0x80U : il->lines[il->edit_line][0]; + *dst++ = il->scroll ? (char) ('<' | 0x80) : il->lines[il->edit_line][0]; for (i = 0; i < il->width - 2 && *src; i++) { *dst++ = *src++; } while (i++ < il->width - 2) { *dst++ = ' '; } - *dst++ = *src ? '>' | 0x80U : ' '; + *dst++ = *src ? (char) ('<' | 0x80) : ' '; } static void diff --git a/libs/models/brush/leafmesh.c b/libs/models/brush/leafmesh.c new file mode 100644 index 000000000..6952f1242 --- /dev/null +++ b/libs/models/brush/leafmesh.c @@ -0,0 +1,90 @@ +/* + leafmesh.c + + Generate a mesh for a leaf node. + + Copyright (C) 2023 Bill Currie + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ +// models are the only shared resource between a client and server running +// on the same machine. + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_STRING_H +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif + +#include "QF/sys.h" +#include "QF/va.h" +#include "QF/zone.h" + +#include "qfalloca.h" +#include "compat.h" +#include "mod_internal.h" +#include "r_internal.h" +#include "vid_vulkan.h" + +typedef struct { + vec3_t vel; // velocity part of Plücker coords + vec3_t mom; // moment part of Plücker coords + uint32_t verts[2]; // ~0u if not a valid vert (0 or 1 plane intersects) +} lm_edge_t; + +typedef struct { + vec4f_t p; // 1-vector plane (ax + by + cz + d = 0) +} lm_plane_t; + +typedef struct { + vec4f_t p; // trivector point +} lm_vert_t; + +void *leafmesh (const mod_brush_t *brush, uint32_t leafnum, memhunk_t *hunk); + +void * +leafmesh (const mod_brush_t *brush, uint32_t leafnum, memhunk_t *hunk) +{ + if (leafnum > brush->modleafs || leafnum < 1) { + // invalid leafnum (0 is the infinite solid leaf and doesn't actually + // exist (also, generally not convex)) + return 0; + } + if (!brush->leaf_parents[leafnum]) { + // with only one parent node, there's no way to generate a mesh for + // the leaf + return 0; + } + uint32_t num_planes = 0; + for (int32_t p = brush->leaf_parents[leafnum]; p != -1; + p = brush->leaf_parents[p]) { + num_planes++; + }; + lm_plane_t *planes = Hunk_RawAlloc (hunk, sizeof (lm_plane_t[num_planes])); + for (int32_t p = brush->leaf_parents[leafnum], i = 0; p != -1; + p = brush->leaf_parents[p], i++) { + planes[i].p = brush->nodes[p].plane; + }; +} diff --git a/libs/scene/light.c b/libs/scene/light.c index e00a2313a..d9f6e8291 100644 --- a/libs/scene/light.c +++ b/libs/scene/light.c @@ -12,9 +12,6 @@ #include "QF/scene/scene.h" #include "QF/simd/vec4f.h" -#include "QF/ui/imui.h" -#define IMUI_context imui_ctx - static void expand_pvs (set_t *pvs, mod_brush_t *brush) { @@ -210,69 +207,3 @@ Light_DecayLights (lightingdata_t *ldata, float frametime, double realtime) } } } - -#if 0 -void -Light_dyn_light_ui (void *comp, imui_ctx_t *imui_ctx, - ecs_registry_t *reg, uint32_t ent, void *data) -{ - dlight_t *dlight = comp; - UI_Horizontal { - UI_Labelf ("Origin: "); - UI_FlexibleSpace (); - UI_Labelf ("%6.1f %6.1f %6.1f %6g", VEC4_EXP (dlight->origin)); - } - UI_Horizontal { - UI_Label ("Color: "); - UI_FlexibleSpace (); - UI_Labelf ("%5.3f %5.3f %5.3f %5.3f", VEC4_EXP (dlight->color)); - } - UI_Horizontal { - UI_Labelf ("Radius: "); - UI_FlexibleSpace (); - UI_Labelf ("%6g", dlight->radius); - } - UI_Horizontal { - UI_Labelf ("Die: "); - UI_FlexibleSpace (); - UI_Labelf ("%6.2f", dlight->die); - } - UI_Horizontal { - UI_Labelf ("Decay: "); - UI_FlexibleSpace (); - UI_Labelf ("%6.2f", dlight->decay); - } - UI_Horizontal { - UI_Labelf ("Min Light: "); - UI_FlexibleSpace (); - UI_Labelf ("%6g", dlight->minlight); - } -} - -void -Light_light_ui (void *comp, imui_ctx_t *imui_ctx, - ecs_registry_t *reg, uint32_t ent, void *data) -{ - light_t *light = comp; - UI_Horizontal { - UI_Label ("Color: "); - UI_FlexibleSpace (); - UI_Labelf ("%5.3f %5.3f %5.3f %3g", VEC4_EXP (light->color)); - } - UI_Horizontal { - UI_Labelf ("Position: "); - UI_FlexibleSpace (); - UI_Labelf ("%6.1f %6.1f %6.1f %6g", VEC4_EXP (light->position)); - } - UI_Horizontal { - UI_Labelf ("Direction: "); - UI_FlexibleSpace (); - UI_Labelf ("%6.3f %6.3f %6.3f %6.3g", VEC4_EXP (light->direction)); - } - UI_Horizontal { - UI_Labelf ("Attenuation: "); - UI_FlexibleSpace (); - UI_Labelf ("%g %g %g %g", VEC4_EXP (light->attenuation)); - } -} -#endif diff --git a/libs/ui/imui.c b/libs/ui/imui.c index 916a62d8a..af94171ac 100644 --- a/libs/ui/imui.c +++ b/libs/ui/imui.c @@ -792,7 +792,7 @@ IMUI_Layout_SetXSize (imui_ctx_t *ctx, imui_size_t size, int value) auto pcont = View_Control (ctx->current_parent); uint32_t id = ctx->current_parent.id; pcont->semantic_x = size; - if (size == imui_size_percent || (bool) imui_size_expand) { + if (size == imui_size_percent || size == imui_size_expand) { *(int *) Ent_AddComponent(id, c_percent_x, ctx->csys.reg) = value; } } @@ -803,7 +803,7 @@ IMUI_Layout_SetYSize (imui_ctx_t *ctx, imui_size_t size, int value) auto pcont = View_Control (ctx->current_parent); uint32_t id = ctx->current_parent.id; pcont->semantic_y = size; - if (size == imui_size_percent || (bool) imui_size_expand) { + if (size == imui_size_percent || size == imui_size_expand) { *(int *) Ent_AddComponent(id, c_percent_y, ctx->csys.reg) = value; } } diff --git a/libs/video/renderer/vulkan/vkgen/stddef.h b/libs/video/renderer/vulkan/vkgen/stddef.h index 5252efc1d..63fd035f8 100644 --- a/libs/video/renderer/vulkan/vkgen/stddef.h +++ b/libs/video/renderer/vulkan/vkgen/stddef.h @@ -1,2 +1,3 @@ #define const #define __attribute__(x) +#define DESIGNATED_INIT diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index e2d22cdf8..5252d2930 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -1788,6 +1788,70 @@ show_leaves (vulkan_ctx_t *ctx, uint32_t leafnum, efrag_t *efrags) mark_leaves (pass, &pvs); } +static void +light_dyn_light_ui (void *comp, imui_ctx_t *imui_ctx, + ecs_registry_t *reg, uint32_t ent, void *data) +{ + dlight_t *dlight = comp; + UI_Horizontal { + UI_Labelf ("Origin: "); + UI_FlexibleSpace (); + UI_Labelf ("%6.1f %6.1f %6.1f %6g", VEC4_EXP (dlight->origin)); + } + UI_Horizontal { + UI_Label ("Color: "); + UI_FlexibleSpace (); + UI_Labelf ("%5.3f %5.3f %5.3f %5.3f", VEC4_EXP (dlight->color)); + } + UI_Horizontal { + UI_Labelf ("Radius: "); + UI_FlexibleSpace (); + UI_Labelf ("%6g", dlight->radius); + } + UI_Horizontal { + UI_Labelf ("Die: "); + UI_FlexibleSpace (); + UI_Labelf ("%6.2f", dlight->die); + } + UI_Horizontal { + UI_Labelf ("Decay: "); + UI_FlexibleSpace (); + UI_Labelf ("%6.2f", dlight->decay); + } + UI_Horizontal { + UI_Labelf ("Min Light: "); + UI_FlexibleSpace (); + UI_Labelf ("%6g", dlight->minlight); + } +} + +static void +light_light_ui (void *comp, imui_ctx_t *imui_ctx, + ecs_registry_t *reg, uint32_t ent, void *data) +{ + light_t *light = comp; + UI_Horizontal { + UI_Label ("Color: "); + UI_FlexibleSpace (); + UI_Labelf ("%5.3f %5.3f %5.3f %3g", VEC4_EXP (light->color)); + } + UI_Horizontal { + UI_Labelf ("Position: "); + UI_FlexibleSpace (); + UI_Labelf ("%6.1f %6.1f %6.1f %6g", VEC4_EXP (light->position)); + } + UI_Horizontal { + UI_Labelf ("Direction: "); + UI_FlexibleSpace (); + UI_Labelf ("%6.3f %6.3f %6.3f %6.3g", VEC4_EXP (light->direction)); + } + UI_Horizontal { + UI_Labelf ("Attenuation: "); + UI_FlexibleSpace (); + UI_Labelf ("%g %g %g %g", VEC4_EXP (light->attenuation)); + } +} + static void scene_efrags_ui (void *comp, imui_ctx_t *imui_ctx, ecs_registry_t *reg, uint32_t ent, void *data) @@ -1847,6 +1911,8 @@ Vulkan_LoadLights (scene_t *scene, vulkan_ctx_t *ctx) lctx->ldata = 0; if (lctx->scene) { auto reg = lctx->scene->reg; + reg->components.a[scene_dynlight].ui = light_dyn_light_ui; + reg->components.a[scene_light].ui = light_light_ui; reg->components.a[scene_efrags].ui = scene_efrags_ui; reg->components.a[scene_lightleaf].ui = scene_lightleaf_ui;