diff options
author | Erik Kundiman <erik@megapahit.org> | 2024-06-22 14:26:04 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2024-07-01 13:25:00 +0800 |
commit | 9b4cbc5a9cbbe9ecbd8366f079a5a44885750095 (patch) | |
tree | 47989d94b08e56f464670ed43bc370f9edb5eb12 | |
parent | cadf6842074bed0ece498f53ed17abf75861c7da (diff) |
Fix core profile set not taking effect on SDL2
From https://wiki.libsdl.org/SDL2/MigrationGuide
"So now that your window is back on the screen, let's talk strategy.
SDL2 still has SDL_Surface, but what you want, if possible, is the new
SDL_Texture. Surfaces are always in system RAM now, and are always
operated on by the CPU, so we want to get away from there. SDL2 has a
new rendering API. It's meant for use by simple 2D games, but most
notably, it's meant to get all that software rendering into video RAM
and onto the GPU. And even if you just want to use it to get your
software renderer's work to the screen, it brings some very nice
benefits: if possible, it will use OpenGL or Direct3D behind the scenes,
which means you'll get faster blits, a working Steam Overlay, and
scaling for free."
-rw-r--r-- | indra/llwindow/llwindowsdl.cpp | 35 | ||||
-rw-r--r-- | indra/llwindow/llwindowsdl.h | 1 |
2 files changed, 16 insertions, 20 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index e592815f4f..eb689dc48c 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -797,18 +797,20 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B return FALSE; } // SDL_GL_SetSwapInterval(1); - mSurface = SDL_GetWindowSurface( mWindow ); } if( mFullscreen ) { - if (mSurface) + if (mWindow) { mFullscreen = TRUE; + /* mFullscreenWidth = mSurface->w; mFullscreenHeight = mSurface->h; mFullscreenBits = mSurface->format->BitsPerPixel; + */ + SDL_GetWindowSize(mWindow, &mFullscreenWidth, &mFullscreenHeight); mFullscreenRefresh = -1; LL_INFOS() << "Running at " << mFullscreenWidth @@ -1171,18 +1173,14 @@ BOOL LLWindowSDL::getPosition(LLCoordScreen *position) BOOL LLWindowSDL::getSize(LLCoordScreen *size) { - if (mSurface) + if (mWindow) { /* if(hasHIDPI) - { SDL_GL_GetDrawableSize(mWindow, &size->mX, &size->mY); - return (TRUE); - } + else */ - - size->mX = mSurface->w; - size->mY = mSurface->h; + SDL_GetWindowSize(mWindow, &size->mX, &size->mY); return (TRUE); } @@ -1191,16 +1189,12 @@ BOOL LLWindowSDL::getSize(LLCoordScreen *size) BOOL LLWindowSDL::getSize(LLCoordWindow *size) { - if (mSurface) + if (mWindow) { if(hasHIDPI) - { SDL_GL_GetDrawableSize(mWindow, &size->mX, &size->mY); - return (TRUE); - } - - size->mX = mSurface->w; - size->mY = mSurface->h; + else + SDL_GetWindowSize(mWindow, &size->mX, &size->mY); return (TRUE); } @@ -1643,7 +1637,9 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) return FALSE; to->mX = from.mX; - to->mY = mSurface->h - from.mY - 1; + int h; + SDL_GetWindowSize(mWindow, nullptr, &h); + to->mY = h - from.mY - 1; return TRUE; } @@ -1654,7 +1650,9 @@ BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) return FALSE; to->mX = from.mX; - to->mY = mSurface->h - from.mY - 1; + int h; + SDL_GetWindowSize(mWindow, nullptr, &h); + to->mY = h - from.mY - 1; return TRUE; } @@ -2133,7 +2131,6 @@ void LLWindowSDL::gatherInput() S32 width = llmax(event.window.data1, (S32)mMinWindowWidth); S32 height = llmax(event.window.data2, (S32)mMinWindowHeight); - mSurface = SDL_GetWindowSurface( mWindow ); // *FIX: I'm not sure this is necessary! // <FS:ND> I think is is not diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h index 33dd794501..87a3e15731 100644 --- a/indra/llwindow/llwindowsdl.h +++ b/indra/llwindow/llwindowsdl.h @@ -272,7 +272,6 @@ protected: int mReallyCapturedCount; SDL_Window *mWindow; - SDL_Surface *mSurface; SDL_GLContext mContext; SDL_Cursor *mSDLCursors[UI_CURSOR_COUNT]; |