summaryrefslogtreecommitdiff
path: root/indra/llwindow/llwindowsdl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llwindowsdl.cpp')
-rw-r--r--indra/llwindow/llwindowsdl.cpp121
1 files changed, 29 insertions, 92 deletions
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index e901bcb1b6..ea95a5aa2e 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -37,6 +37,7 @@
#include "llstring.h"
#include "lldir.h"
#include "llfindlocale.h"
+#include "llgamecontrol.h"
#ifdef LL_GLIB
#include <glib.h>
@@ -246,8 +247,10 @@ void LLWindowSDL::tryFindFullscreenSize( int &width, int &height )
bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, bool fullscreen, bool enable_vsync)
{
- //bool glneedsinit = false;
-
+ if (width == 0)
+ width = 1024;
+ if (height == 0)
+ width = 768;
LL_INFOS() << "createContext, fullscreen=" << fullscreen <<
" size=" << width << "x" << height << LL_ENDL;
@@ -255,50 +258,6 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
mGrabbyKeyFlags = 0;
mReallyCapturedCount = 0;
- std::initializer_list<std::tuple< char const*, char const * > > hintList =
- {
- {SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR,"0"},
- {SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH,"1"},
- {SDL_HINT_IME_INTERNAL_EDITING,"1"}
- };
-
- for( auto hint: hintList )
- {
- SDL_SetHint( std::get<0>(hint), std::get<1>(hint));
- }
-
- std::initializer_list<std::tuple<uint32_t, char const*, bool>> initList=
- { {SDL_INIT_VIDEO,"SDL_INIT_VIDEO", true},
- {SDL_INIT_AUDIO,"SDL_INIT_AUDIO", false},
- {SDL_INIT_GAMECONTROLLER,"SDL_INIT_GAMECONTROLLER", false},
- {SDL_INIT_SENSOR,"SDL_INIT_SENSOR", false}
- };
-
- for( auto subSystem : initList)
- {
- if( SDL_InitSubSystem( std::get<0>(subSystem) ) < 0 )
- {
- LL_WARNS() << "SDL_InitSubSystem for " << std::get<1>(subSystem) << " failed " << SDL_GetError() << LL_ENDL;
-
- if( std::get<2>(subSystem))
- setupFailure("SDL_Init() failure", "error", OSMB_OK);
-
- }
- }
-
- SDL_version c_sdl_version;
- SDL_VERSION(&c_sdl_version);
- LL_INFOS() << "Compiled against SDL "
- << int(c_sdl_version.major) << "."
- << int(c_sdl_version.minor) << "."
- << int(c_sdl_version.patch) << LL_ENDL;
- SDL_version r_sdl_version;
- SDL_GetVersion(&r_sdl_version);
- LL_INFOS() << " Running against SDL "
- << int(r_sdl_version.major) << "."
- << int(r_sdl_version.minor) << "."
- << int(r_sdl_version.patch) << LL_ENDL;
-
if (width == 0)
width = 1024;
if (height == 0)
@@ -322,34 +281,17 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
// Setup default backing colors
GLint redBits{8}, greenBits{8}, blueBits{8}, alphaBits{8};
- GLint depthBits{(bits <= 16) ? 16 : 24}, stencilBits{8};
-
- if (getenv("LL_GL_NO_STENCIL"))
- stencilBits = 0;
+ GLint depthBits{24}, stencilBits{8};
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, redBits);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, greenBits);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, blueBits);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, alphaBits);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, depthBits);
-
- // We need stencil support for a few (minor) things.
- if (stencilBits)
- SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits);
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBits);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if (LLRender::sGLCoreProfile)
- {
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
- }
-
- // This is requesting a minimum context version
- int major_gl_version = 3;
- int minor_gl_version = 2;
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major_gl_version);
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor_gl_version);
-
U32 context_flags = 0;
if (gDebugGL)
{
@@ -364,7 +306,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
{
LL_WARNS() << "Window creation failure. SDL: " << SDL_GetError() << LL_ENDL;
setupFailure("Window creation error", "Error", OSMB_OK);
- return FALSE;
+ return false;
}
// Create the context
@@ -380,7 +322,7 @@ bool LLWindowSDL::createContext(int x, int y, int width, int height, int bits, b
{
LL_WARNS() << "Failed to make context current. SDL: " << SDL_GetError() << LL_ENDL;
setupFailure("GL Context failed to set current failure", "Error", OSMB_OK);
- return FALSE;
+ return false;
}
mSurface = SDL_GetWindowSurface(mWindow);
@@ -687,7 +629,7 @@ bool LLWindowSDL::isValid()
return (mWindow != NULL);
}
-bool LLWindowSDL::getVisible()
+bool LLWindowSDL::getVisible() const
{
bool result = false;
if (mWindow)
@@ -695,13 +637,13 @@ bool LLWindowSDL::getVisible()
Uint32 flags = SDL_GetWindowFlags(mWindow);
if (flags & SDL_WINDOW_SHOWN)
{
- result = TRUE;
+ result = true;
}
}
return result;
}
-bool LLWindowSDL::getMinimized()
+bool LLWindowSDL::getMinimized() const
{
bool result = false;
if (mWindow)
@@ -715,7 +657,7 @@ bool LLWindowSDL::getMinimized()
return result;
}
-bool LLWindowSDL::getMaximized()
+bool LLWindowSDL::getMaximized() const
{
bool result = false;
if (mWindow)
@@ -735,17 +677,12 @@ bool LLWindowSDL::maximize()
if (mWindow)
{
SDL_MaximizeWindow(mWindow);
- return TRUE;
+ return true;
}
- return FALSE;
-}
-
-bool LLWindowSDL::getFullscreen()
-{
- return mFullscreen;
+ return false;
}
-bool LLWindowSDL::getPosition(LLCoordScreen *position)
+bool LLWindowSDL::getPosition(LLCoordScreen *position) const
{
if (mWindow)
{
@@ -755,7 +692,7 @@ bool LLWindowSDL::getPosition(LLCoordScreen *position)
return false;
}
-bool LLWindowSDL::getSize(LLCoordScreen *size)
+bool LLWindowSDL::getSize(LLCoordScreen *size) const
{
if (mSurface)
{
@@ -767,7 +704,7 @@ bool LLWindowSDL::getSize(LLCoordScreen *size)
return (false);
}
-bool LLWindowSDL::getSize(LLCoordWindow *size)
+bool LLWindowSDL::getSize(LLCoordWindow *size) const
{
if (mSurface)
{
@@ -833,7 +770,7 @@ void LLWindowSDL::swapBuffers()
LL_PROFILER_GPU_COLLECT;
}
-U32 LLWindowSDL::getFSAASamples()
+U32 LLWindowSDL::getFSAASamples() const
{
return mFSAASamples;
}
@@ -843,7 +780,7 @@ void LLWindowSDL::setFSAASamples(const U32 samples)
mFSAASamples = samples;
}
-F32 LLWindowSDL::getGamma()
+F32 LLWindowSDL::getGamma() const
{
return 1.f / mGamma;
}
@@ -1142,7 +1079,7 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso
return mSupportedResolutions;
}
-bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
+bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) const
{
if (!to)
return false;
@@ -1153,7 +1090,7 @@ bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to)
return true;
}
-bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
+bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) const
{
if (!to)
return false;
@@ -1164,7 +1101,7 @@ bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to)
return true;
}
-bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to)
+bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to) const
{
if (!to)
return false;
@@ -1175,7 +1112,7 @@ bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordWindow* to)
return (true);
}
-bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to)
+bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to) const
{
if (!to)
return false;
@@ -1186,14 +1123,14 @@ bool LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordScreen *to)
return (true);
}
-bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordGL *to)
+bool LLWindowSDL::convertCoords(LLCoordScreen from, LLCoordGL *to) const
{
LLCoordWindow window_coord;
return(convertCoords(from, &window_coord) && convertCoords(window_coord, to));
}
-bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordScreen *to)
+bool LLWindowSDL::convertCoords(LLCoordGL from, LLCoordScreen *to) const
{
LLCoordWindow window_coord;
@@ -1415,7 +1352,7 @@ void LLWindowSDL::processMiscNativeEvents()
}
}
-void LLWindowSDL::gatherInput()
+void LLWindowSDL::gatherInput(bool app_has_focus)
{
SDL_Event event;
@@ -1618,7 +1555,7 @@ void LLWindowSDL::gatherInput()
}
break;
default:
- //LL_INFOS() << "Unhandled SDL event type " << event.type << LL_ENDL;
+ LLGameControl::handleEvent(event, app_has_focus);
break;
}
}
@@ -1942,7 +1879,7 @@ bool LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b)
Make the raw keyboard data available - used to poke through to LLQtWebKit so
that Qt/Webkit has access to the virtual keycodes etc. that it needs
*/
-LLSD LLWindowSDL::getNativeKeyData()
+LLSD LLWindowSDL::getNativeKeyData() const
{
LLSD result = LLSD::emptyMap();