diff --git a/examples/kanban_app.php b/examples/kanban_app.php index 701e332..82984a9 100644 --- a/examples/kanban_app.php +++ b/examples/kanban_app.php @@ -357,6 +357,30 @@ if (function_exists('sdl_get_window_display_scale')) { $scale = sdl_get_window_display_scale($window->getWindowResource()); $densityText .= ($densityText !== '' ? ' | ' : '') . sprintf('DisplayScale: %.2f', $scale); } +if (function_exists('sdl_get_display_content_scale')) { + $contentScale = sdl_get_display_content_scale($window->getWindowResource()); + $densityText .= ($densityText !== '' ? ' | ' : '') . sprintf('ContentScale: %.2f', $contentScale); +} +// Fallback: effektiven Scale aus WindowSize vs. WindowSizeInPixels berechnen +if ( + function_exists('sdl_get_window_size') && + function_exists('sdl_get_window_size_in_pixels') +) { + $logical = sdl_get_window_size($window->getWindowResource()); + $pixels = sdl_get_window_size_in_pixels($window->getWindowResource()); + if (is_array($logical) && is_array($pixels) && $logical[0] > 0 && $logical[1] > 0) { + $scaleX = $pixels[0] / $logical[0]; + $scaleY = $pixels[1] / $logical[1]; + $densityText .= ($densityText !== '' ? ' | ' : '') . + sprintf('EffectiveScale: %.2f x %.2f', $scaleX, $scaleY); + } +} +if (function_exists('sdl_get_current_video_driver')) { + $driver = sdl_get_current_video_driver(); + if ($driver !== false) { + $densityText .= ($densityText !== '' ? ' | ' : '') . 'VideoDriver: ' . $driver; + } +} if ($densityText !== '') { $statusLabel->setText('Bereit. ' . $densityText); } diff --git a/php-sdl3/.libs/sdl3.o b/php-sdl3/.libs/sdl3.o index 7062c30..c70678f 100644 Binary files a/php-sdl3/.libs/sdl3.o and b/php-sdl3/.libs/sdl3.o differ diff --git a/php-sdl3/.libs/sdl3.so b/php-sdl3/.libs/sdl3.so index 936d612..862d6ca 100755 Binary files a/php-sdl3/.libs/sdl3.so and b/php-sdl3/.libs/sdl3.so differ diff --git a/php-sdl3/.libs/sdl3_events.o b/php-sdl3/.libs/sdl3_events.o index d501645..0a2b99c 100644 Binary files a/php-sdl3/.libs/sdl3_events.o and b/php-sdl3/.libs/sdl3_events.o differ diff --git a/php-sdl3/.libs/sdl3_image.o b/php-sdl3/.libs/sdl3_image.o index c337a46..9ab5840 100644 Binary files a/php-sdl3/.libs/sdl3_image.o and b/php-sdl3/.libs/sdl3_image.o differ diff --git a/php-sdl3/.libs/sdl3_ttf.o b/php-sdl3/.libs/sdl3_ttf.o index 04225ea..5241d98 100644 Binary files a/php-sdl3/.libs/sdl3_ttf.o and b/php-sdl3/.libs/sdl3_ttf.o differ diff --git a/php-sdl3/Makefile b/php-sdl3/Makefile index 6c0d65b..d689883 100644 --- a/php-sdl3/Makefile +++ b/php-sdl3/Makefile @@ -18,7 +18,7 @@ exec_prefix = $(prefix) libdir = ${exec_prefix}/lib phpincludedir = /usr/local/include/php CC = cc -CFLAGS = -g -O2 -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/local/include -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/webp -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread +CFLAGS = -g -O2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread CFLAGS_CLEAN = $(CFLAGS) -D_GNU_SOURCE CPP = cc -E CPPFLAGS = -DHAVE_CONFIG_H @@ -30,7 +30,7 @@ PHP_EXECUTABLE = /usr/local/bin/php EXTRA_LDFLAGS = EXTRA_LIBS = INCLUDES = -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -LDFLAGS = -lSDL3 -L/usr/local/lib -lSDL3_gfx -lSDL3 -lSDL3_image -lSDL3 -lSDL3_ttf -lSDL3 +LDFLAGS = -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -L/usr/local/lib -lSDL3_gfx -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -L/usr/local/lib -lSDL3_image -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 -L/usr/local/lib -lSDL3_ttf -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL3 LIBTOOL = $(SHELL) $(top_builddir)/libtool SHELL = /bin/bash INSTALL_HEADERS = diff --git a/php-sdl3/config.nice b/php-sdl3/config.nice index 855d245..52d739d 100755 --- a/php-sdl3/config.nice +++ b/php-sdl3/config.nice @@ -3,8 +3,4 @@ # Created by configure './configure' \ -'--with-sdl3=/usr/local' \ -'--with-sdl3-gfx=/usr/local' \ -'--with-sdl3-image=/usr/local' \ -'--with-sdl3-ttf=/usr/local' \ "$@" diff --git a/php-sdl3/config.status b/php-sdl3/config.status index 4c8b12a..801a253 100755 --- a/php-sdl3/config.status +++ b/php-sdl3/config.status @@ -413,7 +413,7 @@ $config_headers Report bugs to the package provider." -ac_cs_config='--with-sdl3=/usr/local --with-sdl3-gfx=/usr/local --with-sdl3-image=/usr/local --with-sdl3-ttf=/usr/local' +ac_cs_config='' ac_cs_version="\ config.status configured by ./configure, generated by GNU Autoconf 2.72, @@ -494,7 +494,7 @@ if $ac_cs_silent; then fi if $ac_cs_recheck; then - set X /bin/bash './configure' '--with-sdl3=/usr/local' '--with-sdl3-gfx=/usr/local' '--with-sdl3-image=/usr/local' '--with-sdl3-ttf=/usr/local' $ac_configure_extra_args --no-create --no-recursion + set X /bin/bash './configure' $ac_configure_extra_args --no-create --no-recursion shift \printf "%s\n" "running CONFIG_SHELL=/bin/bash $*" >&6 CONFIG_SHELL='/bin/bash' diff --git a/php-sdl3/libtool b/php-sdl3/libtool index 1e0e0e4..c22ceaf 100755 --- a/php-sdl3/libtool +++ b/php-sdl3/libtool @@ -85,7 +85,7 @@ AR_FLAGS="cru" LTCC="cc" # LTCC compiler flags. -LTCFLAGS="-g -O2 -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/local/include -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/include/libpng16 -I/usr/include/x86_64-linux-gnu -I/usr/include/webp -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2 -D_REENTRANT -I/usr/include/libdrm -I/usr/include/libdecor-0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread " +LTCFLAGS="-g -O2 -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/local/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -pthread " # A language-specific compiler. CC="cc" diff --git a/php-sdl3/modules/sdl3.so b/php-sdl3/modules/sdl3.so index 936d612..862d6ca 100755 Binary files a/php-sdl3/modules/sdl3.so and b/php-sdl3/modules/sdl3.so differ diff --git a/php-sdl3/sdl3.c b/php-sdl3/sdl3.c index fd17760..2763acb 100644 --- a/php-sdl3/sdl3.c +++ b/php-sdl3/sdl3.c @@ -827,6 +827,36 @@ PHP_FUNCTION(sdl_get_window_display_scale) { RETURN_DOUBLE(scale); } +PHP_FUNCTION(sdl_get_display_content_scale) { + zval *win_res; + SDL_Window *win; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &win_res) == FAILURE) { + RETURN_THROWS(); + } + + win = (SDL_Window *)zend_fetch_resource(Z_RES_P(win_res), "SDL_Window", le_sdl_window); + if (!win) { + RETURN_FALSE; + } + + SDL_DisplayID display = SDL_GetDisplayForWindow(win); + if (!display) { + RETURN_FALSE; + } + + float scale = SDL_GetDisplayContentScale(display); + RETURN_DOUBLE(scale); +} + +PHP_FUNCTION(sdl_get_current_video_driver) { + const char *drv = SDL_GetCurrentVideoDriver(); + if (!drv) { + RETURN_FALSE; + } + RETURN_STRING(drv); +} + PHP_FUNCTION(sdl_start_text_input) { zval *win_res; SDL_Window *win; @@ -1029,6 +1059,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_sdl_get_window_display_scale, 0, 0, 1) ZEND_ARG_INFO(0, window) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_sdl_get_display_content_scale, 0, 0, 1) + ZEND_ARG_INFO(0, window) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_sdl_get_current_video_driver, 0, 0, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_sdl_get_renderer_output_size, 0, 0, 1) ZEND_ARG_INFO(0, renderer) ZEND_END_ARG_INFO() @@ -1074,6 +1110,8 @@ const zend_function_entry sdl3_functions[] = { PHP_FE(sdl_get_window_size_in_pixels, arginfo_sdl_get_window_size_in_pixels) PHP_FE(sdl_get_window_pixel_density, arginfo_sdl_get_window_pixel_density) PHP_FE(sdl_get_window_display_scale, arginfo_sdl_get_window_display_scale) + PHP_FE(sdl_get_display_content_scale, arginfo_sdl_get_display_content_scale) + PHP_FE(sdl_get_current_video_driver, arginfo_sdl_get_current_video_driver) PHP_FE(sdl_get_renderer_output_size, arginfo_sdl_get_renderer_output_size) PHP_FE(sdl_start_text_input, arginfo_sdl_start_text_input) PHP_FE(sdl_stop_text_input, arginfo_sdl_stop_text_input)