From 260840e202f51cf6d1f474bfe5aa9d0bab7e73b9 Mon Sep 17 00:00:00 2001 From: Hugh Sanderson Date: Tue, 24 Dec 2024 21:13:36 +0800 Subject: [PATCH] Fix compiling without opengl. Fix antialiasing flag. --- project/src/common/ManagedStage.cpp | 15 ++++++++++----- project/src/sdl2/SDL2Stage.cpp | 11 +++++++++-- tools/nme/src/project/NMEProject.hx | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/project/src/common/ManagedStage.cpp b/project/src/common/ManagedStage.cpp index 81ba23801..ed302ab87 100644 --- a/project/src/common/ManagedStage.cpp +++ b/project/src/common/ManagedStage.cpp @@ -41,11 +41,15 @@ ManagedStage::ManagedStage(int inWidth,int inHeight,int inFlags) // TODO? mHardwareRenderer = HardwareRenderer::CreateMetalNull(); #else - #error "No valid HardwareRenderer" + mHardwareRenderer = nullptr; #endif - mHardwareRenderer->IncRef(); - mHardwareSurface = new HardwareSurface(mHardwareRenderer); - mHardwareSurface->IncRef(); + + if (mHardwareRenderer) + { + mHardwareRenderer->IncRef(); + mHardwareSurface = new HardwareSurface(mHardwareRenderer); + mHardwareSurface->IncRef(); + } } ManagedStage::~ManagedStage() @@ -67,7 +71,8 @@ void ManagedStage::SetActiveSize(int inW,int inH) { mActiveWidth = inW; mActiveHeight = inH; - mHardwareRenderer->SetWindowSize(inW,inH); + if (mHardwareRenderer) + mHardwareRenderer->SetWindowSize(inW,inH); Event event(etResize,inW,inH); Stage::HandleEvent(event); diff --git a/project/src/sdl2/SDL2Stage.cpp b/project/src/sdl2/SDL2Stage.cpp index d6316a1ec..f30fbbf80 100644 --- a/project/src/sdl2/SDL2Stage.cpp +++ b/project/src/sdl2/SDL2Stage.cpp @@ -425,6 +425,7 @@ class SDLStage : public Stage if (mIsFullscreen) displayState = sdsFullscreenInteractive; + #if defined(NME_OGL) || defined(NME_METAL) if (mIsHardware) { if (sgHardwareRenderer) @@ -469,7 +470,9 @@ class SDLStage : public Stage mPrimarySurface = new HardwareSurface(mHardwareRenderer); } else + #endif { + mIsHardware = false; mHardwareRenderer = 0; mSoftwareSurface = SDL_CreateRGBSurface(0, mWidth, mHeight, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); if (!mSoftwareSurface) @@ -2612,10 +2615,10 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight, break; } - #ifdef NME_SDL3 + #if defined(NME_SDL3) { int n = SDL_GetNumRenderDrivers(); - #if !defined(NME_DYNAMIC_ANGLE) + #if !defined(NME_DYNAMIC_ANGLE) && defined(NME_OGL) bool useEgl = nmeEglMode; #else bool useEgl = false; @@ -2639,7 +2642,9 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight, #endif //printf("Using driver: %s, nmeEglMode=%d\n", rname.c_str(), nmeEglMode); + #ifdef NME_OGL InitOGLFunctions(); + #endif } #else int renderFlags = 0; @@ -2650,6 +2655,7 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight, renderer = SDL_CreateRenderer(window, -1, renderFlags); #endif + #ifdef NME_OGL if (opengl) { sgIsOGL2 = (inFlags & (wfAllowShaders | wfRequireShaders)); @@ -2658,6 +2664,7 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight, { sgIsOGL2 = nmeEglMode; } + #endif if (!renderer && (inFlags & wfHW_AA_HIRES || inFlags & wfHW_AA)) { diff --git a/tools/nme/src/project/NMEProject.hx b/tools/nme/src/project/NMEProject.hx index f5c0d62c9..6db8fffc3 100644 --- a/tools/nme/src/project/NMEProject.hx +++ b/tools/nme/src/project/NMEProject.hx @@ -1050,6 +1050,7 @@ class NMEProject context.WIN_DEPTH_BUFFER = window.depthBuffer; context.WIN_STENCIL_BUFFER = window.stencilBuffer; context.WIN_ALPHA_BUFFER = window.alphaBuffer; + context.WIN_ANTIALIASING = window.antialiasing; if (certificate != null) {