Skip to content

Commit

Permalink
Fix compiling without opengl. Fix antialiasing flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsando committed Dec 24, 2024
1 parent 472bf27 commit 260840e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
15 changes: 10 additions & 5 deletions project/src/common/ManagedStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions project/src/sdl2/SDL2Stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ class SDLStage : public Stage
if (mIsFullscreen)
displayState = sdsFullscreenInteractive;

#if defined(NME_OGL) || defined(NME_METAL)
if (mIsHardware)
{
if (sgHardwareRenderer)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -2658,6 +2664,7 @@ void CreateMainFrame(FrameCreationCallback inOnFrame, int inWidth, int inHeight,
{
sgIsOGL2 = nmeEglMode;
}
#endif

if (!renderer && (inFlags & wfHW_AA_HIRES || inFlags & wfHW_AA))
{
Expand Down
1 change: 1 addition & 0 deletions tools/nme/src/project/NMEProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 260840e

Please sign in to comment.