Skip to content

Commit

Permalink
Allow command-line specification of metal renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sanderson committed Sep 16, 2024
1 parent 6311d36 commit f1030f6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 83 deletions.
1 change: 1 addition & 0 deletions project/ToolkitBuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<set name="NME_NO_OGL" value="1" if="nme_no_ogl" />
<set name="NME_NO_OGL" value="1" if="nme_metal" unless="mac" />
<set name="NME_ANGLE" value="1" if="windows||winrt" unless="NME_NO_ANGLE || NME_LOCAL_TOOLKIT" />
<set name="NME_NO_ANGLE" value="1" unless="windows" />
<set name="NME_DYNAMIC_ANGLE" value="1" if="NME_LOCAL_TOOLKIT" unless="NME_NO_ANGLE" />
<set name="NATIVE_TOOLKIT_SDL_ANGLE" value="1" if="NME_ANGLE" />
<set name="NATIVE_TOOLKIT_STATIC_ANGLE" value="1" if="NME_ANGLE" />
Expand Down
4 changes: 4 additions & 0 deletions project/src/common/ExternalInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,10 @@ void nme_set_renderer(HxString inRenderer)
if (std::string(inRenderer.c_str())=="opengl")
nmeEglMode = false;
#endif
#ifdef NME_SDL3
extern std::string nmeRenderer;
nmeRenderer = inRenderer.c_str();
#endif
}
DEFINE_PRIME1v(nme_set_renderer);

Expand Down
15 changes: 15 additions & 0 deletions project/src/sdl2/SDL2Stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth
}

typedef float MousePosType;

std::string nmeRenderer;

#else
typedef int MousePosType;
#endif
Expand Down Expand Up @@ -2258,6 +2261,18 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight,
#if defined(NME_OGL) && defined(NME_METAL)
nmeOpenglRenderer = !(inFlags & wfHardwareMetal);
bool hw = (inFlags & wfHardware) != 0;
#ifdef NME_SDL3
if (nmeRenderer=="opengl")
{
hw = true;
nmeOpenglRenderer = true;
}
else if (nmeRenderer=="metal")
{
hw = true;
nmeOpenglRenderer = false;
}
#endif
bool opengl = hw && nmeOpenglRenderer;
bool metal = hw && !nmeOpenglRenderer;
#elif defined(NME_OGL)
Expand Down
84 changes: 1 addition & 83 deletions project/toolkit/sdl/files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,89 +16,7 @@
<depend name="${SDL_CONFIG_PATH}/SDL_config.h" if="SDL_CONFIG_PATH" />

<!--
<depend name="${NME_LIBSDL}include/SDL3/SDL_config_android.h"/>
<depend name="${NME_LIBSDL}include/SDL3/begin_code.h"/>
<depend name="${NME_LIBSDL}include/SDL3/close_code.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_test_random.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_thread.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_timer.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_touch.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_types.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_version.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_video.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_surface.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_system.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_syswm.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_test.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_test_assert.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_test_common.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_render.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_revision.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_scancode.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_shape.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_stdinc.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengles2_gl2platform.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengles2_khrplatform.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_pixels.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_platform.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_power.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_quit.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_rect.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengl_glext.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengles.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengles2.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengles2_gl2.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengles2_gl2ext.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_mouse.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_mutex.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_name.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_opengl.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_hints.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_joystick.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_keyboard.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_keycode.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_loadso.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_log.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_main.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_messagebox.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_error.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_events.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_filesystem.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_gamecontroller.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_gesture.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_haptic.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_copying.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_cpuinfo.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_egl.h"/>
<depend name="${NME_LIBSDL}include/SDL3/SDL_endian.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_winrt.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_wiz.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_iphoneos.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_macosx.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_minimal.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_pandora.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_psp.h"/>
<depend name="${NME_LIBSDL}include/SDL_config_windows.h" unless="winrt"/>
<depend name="${NME_LIBSDL}include/SDL_assert.h"/>
<depend name="${NME_LIBSDL}include/SDL_atomic.h"/>
<depend name="${NME_LIBSDL}include/SDL_audio.h"/>
<depend name="${NME_LIBSDL}include/SDL_bits.h"/>
<depend name="${NME_LIBSDL}include/SDL_blendmode.h"/>
<depend name="${NME_LIBSDL}include/SDL_clipboard.h"/>
<depend name="${NME_LIBSDL}include/SDL.h"/>
<depend name="${NME_LIBSDL}include/SDL_gamecontrollerdb.h" if="winrt"/>
<depend name="${NME_LIBSDL}include/SDL_windows.h" if="winrt"/>
<depend name="${NME_LIBSDL}include/SDL_xinput.h" if="winrt"/>
<depend name="${NME_LIBSDL}src/core/winrt/SDL_winrtapp_common.h" if="winrt"/>
<depend name="${NME_LIBSDL}src/core/winrt/SDL_winrtapp_direct3d.h" if="winrt"/>
<depend name="${NME_LIBSDL}src/core/winrt/SDL_winrtapp_xaml.h" if="winrt"/>
<depend name="${NME_LIBSDL}src/dynapi/SDL_dynapi.h" if="winrt"/>
<depend name="${NME_LIBSDL}src/dynapi/SDL_dynapi_overrides.h" if="winrt"/>
<depend name="${NME_LIBSDL}src/dynapi/SDL_dynapi_procs.h" if="winrt"/>
-->
-->

</files>

Expand Down

0 comments on commit f1030f6

Please sign in to comment.