summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llwindow.cpp9
-rw-r--r--indra/llwindow/llwindow.h5
-rw-r--r--indra/llwindow/llwindowheadless.h2
-rw-r--r--indra/llwindow/llwindowmacosx.cpp26
-rw-r--r--indra/llwindow/llwindowmacosx.h11
-rw-r--r--indra/llwindow/llwindowmesaheadless.h2
-rw-r--r--indra/llwindow/llwindowsdl.cpp40
-rw-r--r--indra/llwindow/llwindowsdl.h5
-rw-r--r--indra/llwindow/llwindowwin32.cpp456
-rw-r--r--indra/llwindow/llwindowwin32.h5
10 files changed, 154 insertions, 407 deletions
diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp
index 43f3081321..37f089e8be 100644
--- a/indra/llwindow/llwindow.cpp
+++ b/indra/llwindow/llwindow.cpp
@@ -440,7 +440,8 @@ LLWindow* LLWindowManager::createWindow(
BOOL clearBg,
BOOL disable_vsync,
BOOL use_gl,
- BOOL ignore_pixel_depth)
+ BOOL ignore_pixel_depth,
+ U32 fsaa_samples)
{
LLWindow* new_window;
@@ -453,15 +454,15 @@ LLWindow* LLWindowManager::createWindow(
#elif LL_SDL
new_window = new LLWindowSDL(
title, x, y, width, height, flags,
- fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth);
+ fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples);
#elif LL_WINDOWS
new_window = new LLWindowWin32(
title, name, x, y, width, height, flags,
- fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth);
+ fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples);
#elif LL_DARWIN
new_window = new LLWindowMacOSX(
title, name, x, y, width, height, flags,
- fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth);
+ fullscreen, clearBg, disable_vsync, use_gl, ignore_pixel_depth, fsaa_samples);
#elif LL_LINUX
new_window = new LLWindowLinux(
title, name, x, y, width, height, flags,
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index bc444ae811..b2e9c5b51d 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -184,6 +184,8 @@ public:
virtual void flashIcon(F32 seconds) = 0;
virtual F32 getGamma() = 0;
virtual BOOL setGamma(const F32 gamma) = 0; // Set the gamma
+ virtual void setFSAASamples(const U32 fsaa_samples) = 0; //set number of FSAA samples
+ virtual U32 getFSAASamples() = 0;
virtual BOOL restoreGamma() = 0; // Restore original gamma table (before updating gamma)
virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
virtual void gatherInput() = 0;
@@ -340,7 +342,8 @@ public:
BOOL clearBg = FALSE,
BOOL disable_vsync = TRUE,
BOOL use_gl = TRUE,
- BOOL ignore_pixel_depth = FALSE);
+ BOOL ignore_pixel_depth = FALSE,
+ U32 fsaa_samples = 0);
static BOOL destroyWindow(LLWindow* window);
static BOOL isWindowValid(LLWindow *window);
};
diff --git a/indra/llwindow/llwindowheadless.h b/indra/llwindow/llwindowheadless.h
index 4962cf7bf7..b7e6644674 100644
--- a/indra/llwindow/llwindowheadless.h
+++ b/indra/llwindow/llwindowheadless.h
@@ -69,6 +69,8 @@ public:
/*virtual*/ void flashIcon(F32 seconds) {};
/*virtual*/ F32 getGamma() {return 1.0f; };
/*virtual*/ BOOL setGamma(const F32 gamma) {return FALSE; }; // Set the gamma
+ /*virtual*/ void setFSAASamples(const U32 fsaa_samples) { }
+ /*virtual*/ U32 getFSAASamples() { return 0; }
/*virtual*/ BOOL restoreGamma() {return FALSE; }; // Restore original gamma table (before updating gamma)
//virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput() {};
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index a1d97429e1..aa4c2c86f7 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -246,7 +246,8 @@ LLWindowMacOSX::LLWindowMacOSX(char *title, char *name, S32 x, S32 y, S32 width,
S32 height, U32 flags,
BOOL fullscreen, BOOL clearBg,
BOOL disable_vsync, BOOL use_gl,
- BOOL ignore_pixel_depth)
+ BOOL ignore_pixel_depth,
+ U32 fsaa_samples)
: LLWindow(fullscreen, flags)
{
// Voodoo for calling cocoa from carbon (see llwindowmacosx-objc.mm).
@@ -277,6 +278,8 @@ LLWindowMacOSX::LLWindowMacOSX(char *title, char *name, S32 x, S32 y, S32 width,
mTSMScriptCode = 0;
mTSMLangCode = 0;
mPreeditor = NULL;
+ mFSAASamples = fsaa_samples;
+ mForceRebuild = FALSE;
// For reasons that aren't clear to me, LLTimers seem to be created in the "started" state.
// Since the started state of this one is used to track whether the NMRec has been installed, it wants to start out in the "stopped" state.
@@ -558,6 +561,8 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
AGL_RGBA,
AGL_FULLSCREEN,
// AGL_NO_RECOVERY, // MBW -- XXX -- Not sure if we want this attribute
+ AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0,
+ AGL_SAMPLES_ARB, mFSAASamples,
AGL_DOUBLEBUFFER,
AGL_CLOSEST_POLICY,
AGL_ACCELERATED,
@@ -586,6 +591,8 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
AGL_DOUBLEBUFFER,
AGL_CLOSEST_POLICY,
AGL_ACCELERATED,
+ AGL_SAMPLE_BUFFERS_ARB, mFSAASamples > 0 ? 1 : 0,
+ AGL_SAMPLES_ARB, mFSAASamples,
AGL_RED_SIZE, 8,
AGL_GREEN_SIZE, 8,
AGL_BLUE_SIZE, 8,
@@ -819,6 +826,9 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
}
}
+ //make sure multisample starts off disabled
+ glDisable(GL_MULTISAMPLE_ARB);
+
// Don't need to get the current gamma, since there's a call that restores it to the system defaults.
return TRUE;
}
@@ -897,8 +907,9 @@ BOOL LLWindowMacOSX::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL dis
}
stop_glerror();
- if(needsRebuild)
+ if(needsRebuild || mForceRebuild)
{
+ mForceRebuild = FALSE;
destroyContext();
result = createContext(0, 0, size.mX, size.mY, 0, fullscreen, disable_vsync);
if (result)
@@ -1318,6 +1329,17 @@ F32 LLWindowMacOSX::getGamma()
return result;
}
+U32 LLWindowMacOSX::getFSAASamples()
+{
+ return mFSAASamples;
+}
+
+void LLWindowMacOSX::setFSAASamples(const U32 samples)
+{
+ mFSAASamples = samples;
+ mForceRebuild = TRUE;
+}
+
BOOL LLWindowMacOSX::restoreGamma()
{
CGDisplayRestoreColorSyncSettings();
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index 2fdf80ee82..86b88daa3c 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -78,6 +78,8 @@ public:
/*virtual*/ void flashIcon(F32 seconds);
/*virtual*/ F32 getGamma();
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
+ /*virtual*/ U32 getFSAASamples();
+ /*virtual*/ void setFSAASamples(const U32 fsaa_samples);
/*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput();
@@ -119,7 +121,8 @@ protected:
LLWindowMacOSX(
char *title, char *name, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
- BOOL ignore_pixel_depth);
+ BOOL ignore_pixel_depth,
+ U32 fsaa_samples);
~LLWindowMacOSX();
void initCursors();
@@ -185,7 +188,9 @@ protected:
LLCoordScreen mNeedsResizeSize;
F32 mOverrideAspectRatio;
BOOL mMinimized;
-
+ U32 mFSAASamples;
+ BOOL mForceRebuild;
+
F32 mBounceTime;
NMRec mBounceRec;
LLTimer mBounceTimer;
@@ -196,7 +201,7 @@ protected:
ScriptCode mTSMScriptCode;
LangCode mTSMLangCode;
LLPreeditor* mPreeditor;
-
+
friend class LLWindowManager;
};
diff --git a/indra/llwindow/llwindowmesaheadless.h b/indra/llwindow/llwindowmesaheadless.h
index fe91a2d2a0..8de92bbe0e 100644
--- a/indra/llwindow/llwindowmesaheadless.h
+++ b/indra/llwindow/llwindowmesaheadless.h
@@ -74,6 +74,8 @@ public:
/*virtual*/ F32 getGamma() {return 1.0f; };
/*virtual*/ BOOL setGamma(const F32 gamma) {return FALSE; }; // Set the gamma
/*virtual*/ BOOL restoreGamma() {return FALSE; }; // Restore original gamma table (before updating gamma)
+ /*virtual*/ void setFSAASamples(const U32 fsaa_samples) { /* FSAA not supported yet on Mesa headless.*/ }
+ /*virtual*/ U32 getFSAASamples() { return 0; }
//virtual ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput() {};
/*virtual*/ void delayInputProcessing() {};
diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp
index 686be3385e..122b57a497 100644
--- a/indra/llwindow/llwindowsdl.cpp
+++ b/indra/llwindow/llwindowsdl.cpp
@@ -81,7 +81,7 @@ static BOOL was_fullscreen = FALSE;
void maybe_lock_display(void)
{
- if (gWindowImplementation) {
+ if (gWindowImplementation && gWindowImplementation->Lock_Display) {
gWindowImplementation->Lock_Display();
}
}
@@ -89,7 +89,7 @@ void maybe_lock_display(void)
void maybe_unlock_display(void)
{
- if (gWindowImplementation) {
+ if (gWindowImplementation && gWindowImplementation->Unlock_Display) {
gWindowImplementation->Unlock_Display();
}
}
@@ -217,7 +217,7 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width,
S32 height, U32 flags,
BOOL fullscreen, BOOL clearBg,
BOOL disable_vsync, BOOL use_gl,
- BOOL ignore_pixel_depth)
+ BOOL ignore_pixel_depth, U32 fsaa_samples)
: LLWindow(fullscreen, flags), mGamma(1.0f)
{
// Initialize the keyboard
@@ -236,6 +236,7 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width,
mReallyCapturedCount = 0;
mHaveInputFocus = -1;
mIsMinimized = -1;
+ mFSAASamples = fsaa_samples;
#if LL_X11
mSDL_XWindowID = None;
@@ -260,7 +261,7 @@ LLWindowSDL::LLWindowSDL(char *title, S32 x, S32 y, S32 width,
mWindowTitle = new char[strlen(title) + 1]; /* Flawfinder: ignore */
if(mWindowTitle == NULL)
{
- llerrs << "Memory allocation failure" << llendl;
+ llwarns << "Memory allocation failure" << llendl;
return;
}
@@ -535,6 +536,12 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+ if (mFSAASamples > 0)
+ {
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, mFSAASamples);
+ }
+
mSDLFlags = sdlflags;
if (mFullscreen)
@@ -796,7 +803,6 @@ void LLWindowSDL::destroyContext()
gGLManager.shutdownGL();
llinfos << "SDL_QuitSS/VID begins" << llendl;
SDL_QuitSubSystem(SDL_INIT_VIDEO); // *FIX: this might be risky...
- //unload_all_glsyms();
mWindow = NULL;
}
@@ -922,10 +928,10 @@ BOOL LLWindowSDL::getSize(LLCoordScreen *size)
{
size->mX = mWindow->w;
size->mY = mWindow->h;
- return (TRUE);
+ return (TRUE);
}
- llerrs << "LLWindowSDL::getPosition(): no window and not fullscreen!" << llendl;
+ llwarns << "LLWindowSDL::getPosition(): no window and not fullscreen!" << llendl;
return (FALSE);
}
@@ -935,10 +941,10 @@ BOOL LLWindowSDL::getSize(LLCoordWindow *size)
{
size->mX = mWindow->w;
size->mY = mWindow->h;
- return (TRUE);
+ return (TRUE);
}
- llerrs << "LLWindowSDL::getPosition(): no window and not fullscreen!" << llendl;
+ llwarns << "LLWindowSDL::getPosition(): no window and not fullscreen!" << llendl;
return (FALSE);
}
@@ -970,6 +976,16 @@ void LLWindowSDL::swapBuffers()
SDL_GL_SwapBuffers();
}
+U32 LLWindowSDL::getFSAASamples()
+{
+ return mFSAASamples;
+}
+
+void LLWindowSDL::setFSAASamples(const U32 samples)
+{
+ mFSAASamples = samples;
+}
+
F32 LLWindowSDL::getGamma()
{
return 1/mGamma;
@@ -1116,8 +1132,10 @@ F32 LLWindowSDL::getPixelAspectRatio()
if (getFullscreen())
{
LLCoordScreen screen_size;
- getSize(&screen_size);
- pixel_aspect = getNativeAspectRatio() * (F32)screen_size.mY / (F32)screen_size.mX;
+ if (getSize(&screen_size))
+ {
+ pixel_aspect = getNativeAspectRatio() * (F32)screen_size.mY / (F32)screen_size.mX;
+ }
}
return pixel_aspect;
diff --git a/indra/llwindow/llwindowsdl.h b/indra/llwindow/llwindowsdl.h
index 2c411e03fd..4d4d36e30a 100644
--- a/indra/llwindow/llwindowsdl.h
+++ b/indra/llwindow/llwindowsdl.h
@@ -85,6 +85,8 @@ public:
/*virtual*/ void flashIcon(F32 seconds);
/*virtual*/ F32 getGamma();
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
+ /*virtual*/ U32 getFSAASamples();
+ /*virtual*/ void setFSAASamples(const U32 samples);
/*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput();
@@ -132,7 +134,7 @@ protected:
LLWindowSDL(
char *title, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
- BOOL ignore_pixel_depth);
+ BOOL ignore_pixel_depth, U32 fsaa_samples);
~LLWindowSDL();
void initCursors();
@@ -183,6 +185,7 @@ protected:
LLCoordScreen mNeedsResizeSize;
F32 mOverrideAspectRatio;
F32 mGamma;
+ U32 mFSAASamples;
int mSDLFlags;
diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index a5367aac8a..bcbd2d9cc3 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -371,10 +371,11 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
S32 height, U32 flags,
BOOL fullscreen, BOOL clearBg,
BOOL disable_vsync, BOOL use_gl,
- BOOL ignore_pixel_depth)
+ BOOL ignore_pixel_depth,
+ U32 fsaa_samples)
: LLWindow(fullscreen, flags)
{
- S32 i = 0;
+ mFSAASamples = fsaa_samples;
mIconResource = gIconResource;
mOverrideAspectRatio = 0.f;
mNativeAspectRatio = 0.f;
@@ -389,7 +390,6 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
// based on the system's (user's) default settings.
allowLanguageTextInput(mPreeditor, FALSE);
- GLuint pixel_format;
WNDCLASS wc;
DWORD dw_ex_style;
DWORD dw_style;
@@ -651,366 +651,13 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
//-----------------------------------------------------------------------
// Create GL drawing context
//-----------------------------------------------------------------------
- PIXELFORMATDESCRIPTOR pfd =
+ if (!switchContext(mFullscreen, LLCoordScreen(window_rect.right - window_rect.left, // width
+ window_rect.bottom - window_rect.top), // height
+ TRUE))
{
- sizeof(PIXELFORMATDESCRIPTOR),
- 1,
- pfdflags,
- PFD_TYPE_RGBA,
- BITS_PER_PIXEL,
- 0, 0, 0, 0, 0, 0, // RGB bits and shift, unused
- 8, // alpha bits
- 0, // alpha shift
- 0, // accum bits
- 0, 0, 0, 0, // accum RGBA
- 24, // depth bits
- 8, // stencil bits, avi added for stencil test
- 0,
- PFD_MAIN_PLANE,
- 0,
- 0, 0, 0
- };
-
- if (!(mhDC = GetDC(mWindowHandle)))
- {
- close();
- OSMessageBox("Can't make GL device context", "Error", OSMB_OK);
- return;
- }
-
- if (!(pixel_format = ChoosePixelFormat(mhDC, &pfd)))
- {
- close();
- OSMessageBox("Can't find suitable pixel format", "Error", OSMB_OK);
- return;
- }
-
- // Verify what pixel format we actually received.
- if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR),
- &pfd))
- {
- close();
- OSMessageBox("Can't get pixel format description", "Error", OSMB_OK);
return;
}
-
- // sanity check pfd returned by Windows
- if (!ignore_pixel_depth && (pfd.cColorBits < 32))
- {
- close();
- OSMessageBox(
- "Second Life requires True Color (32-bit) to run in a window.\n"
- "Please go to Control Panels -> Display -> Settings and\n"
- "set the screen to 32-bit color.\n"
- "Alternately, if you choose to run fullscreen, Second Life\n"
- "will automatically adjust the screen each time it runs.",
- "Error",
- OSMB_OK);
- return;
- }
-
- if (!ignore_pixel_depth && (pfd.cAlphaBits < 8))
- {
- close();
- OSMessageBox(
- "Second Life is unable to run because it can't get an 8 bit alpha\n"
- "channel. Usually this is due to video card driver issues.\n"
- "Please make sure you have the latest video card drivers installed.\n"
- "Also be sure your monitor is set to True Color (32-bit) in\n"
- "Control Panels -> Display -> Settings.\n"
- "If you continue to receive this message, contact customer service.",
- "Error",
- OSMB_OK);
- return;
- }
-
- if (!SetPixelFormat(mhDC, pixel_format, &pfd))
- {
- close();
- OSMessageBox("Can't set pixel format", "Error", OSMB_OK);
- return;
- }
-
- if (use_gl)
- {
- if (!(mhRC = wglCreateContext(mhDC)))
- {
- close();
- OSMessageBox("Can't create GL rendering context", "Error", OSMB_OK);
- return;
- }
-
- if (!wglMakeCurrent(mhDC, mhRC))
- {
- close();
- OSMessageBox("Can't activate GL rendering context", "Error", OSMB_OK);
- return;
- }
-
- gGLManager.initWGL();
-
- if (gGLManager.mHasWGLARBPixelFormat && (wglChoosePixelFormatARB != NULL))
- {
- // OK, at this point, use the ARB wglChoosePixelFormatsARB function to see if we
- // can get exactly what we want.
- GLint attrib_list[256];
- S32 cur_attrib = 0;
-
- attrib_list[cur_attrib++] = WGL_DEPTH_BITS_ARB;
- attrib_list[cur_attrib++] = 24;
-
- attrib_list[cur_attrib++] = WGL_STENCIL_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
-
- attrib_list[cur_attrib++] = WGL_DRAW_TO_WINDOW_ARB;
- attrib_list[cur_attrib++] = GL_TRUE;
-
- attrib_list[cur_attrib++] = WGL_ACCELERATION_ARB;
- attrib_list[cur_attrib++] = WGL_FULL_ACCELERATION_ARB;
-
- attrib_list[cur_attrib++] = WGL_SUPPORT_OPENGL_ARB;
- attrib_list[cur_attrib++] = GL_TRUE;
-
- attrib_list[cur_attrib++] = WGL_DOUBLE_BUFFER_ARB;
- attrib_list[cur_attrib++] = GL_TRUE;
-
- attrib_list[cur_attrib++] = WGL_COLOR_BITS_ARB;
- attrib_list[cur_attrib++] = 32;
-
- attrib_list[cur_attrib++] = WGL_RED_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
-
- attrib_list[cur_attrib++] = WGL_GREEN_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
-
- attrib_list[cur_attrib++] = WGL_BLUE_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
-
- attrib_list[cur_attrib++] = WGL_ALPHA_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
-
- // End the list
- attrib_list[cur_attrib++] = 0;
-
- GLint pixel_formats[256];
- U32 num_formats = 0;
-
- // First we try and get a 32 bit depth pixel format
- BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
- if (!result)
- {
- close();
- show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit");
- return;
- }
-
- if (!num_formats)
- {
- llinfos << "No 32 bit z-buffer, trying 24 bits instead" << llendl;
- // Try 24-bit format
- attrib_list[1] = 24;
- BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
- if (!result)
- {
- close();
- show_window_creation_error("Error after wglChoosePixelFormatARB 24-bit");
- return;
- }
-
- if (!num_formats)
- {
- llwarns << "Couldn't get 24 bit z-buffer,trying 16 bits instead!" << llendl;
- attrib_list[1] = 16;
- BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
- if (!result || !num_formats)
- {
- close();
- show_window_creation_error("Error after wglChoosePixelFormatARB 16-bit");
- return;
- }
- }
-
- llinfos << "Choosing pixel formats: " << num_formats << " pixel formats returned" << llendl;
-
- pixel_format = pixel_formats[0];
- }
-
- DestroyWindow(mWindowHandle);
-
- mWindowHandle = CreateWindowEx(dw_ex_style,
- mWindowClassName,
- mWindowTitle,
- WS_CLIPSIBLINGS | WS_CLIPCHILDREN | dw_style,
- x, // x pos
- y, // y pos
- window_rect.right - window_rect.left, // width
- window_rect.bottom - window_rect.top, // height
- NULL,
- NULL,
- mhInstance,
- NULL);
-
- if (!(mhDC = GetDC(mWindowHandle)))
- {
- close();
- OSMessageBox("Can't make GL device context", "Error", OSMB_OK);
- return;
- }
-
- if (!SetPixelFormat(mhDC, pixel_format, &pfd))
- {
- close();
- OSMessageBox("Can't set pixel format", "Error", OSMB_OK);
- return;
- }
-
- int swap_method = 0;
- GLint swap_query = WGL_SWAP_METHOD_ARB;
-
- if (wglGetPixelFormatAttribivARB(mhDC, pixel_format, 0, 1, &swap_query, &swap_method))
- {
- switch (swap_method)
- {
- case WGL_SWAP_EXCHANGE_ARB:
- mSwapMethod = SWAP_METHOD_EXCHANGE;
- llinfos << "Swap Method: Exchange" << llendl;
- break;
- case WGL_SWAP_COPY_ARB:
- mSwapMethod = SWAP_METHOD_COPY;
- llinfos << "Swap Method: Copy" << llendl;
- break;
- case WGL_SWAP_UNDEFINED_ARB:
- mSwapMethod = SWAP_METHOD_UNDEFINED;
- llinfos << "Swap Method: Undefined" << llendl;
- break;
- default:
- mSwapMethod = SWAP_METHOD_UNDEFINED;
- llinfos << "Swap Method: Unknown" << llendl;
- break;
- }
- }
- }
- else
- {
- llwarns << "No wgl_ARB_pixel_format extension, using default ChoosePixelFormat!" << llendl;
- }
-
- // Verify what pixel format we actually received.
- if (!DescribePixelFormat(mhDC, pixel_format, sizeof(PIXELFORMATDESCRIPTOR),
- &pfd))
- {
- close();
- OSMessageBox("Can't get pixel format description", "Error", OSMB_OK);
- return;
- }
- llinfos << "GL buffer: Color Bits " << S32(pfd.cColorBits)
- << " Alpha Bits " << S32(pfd.cAlphaBits)
- << " Depth Bits " << S32(pfd.cDepthBits)
- << llendl;
-
- if (pfd.cColorBits < 32)
- {
- close();
- OSMessageBox(
- "Second Life requires True Color (32-bit) to run in a window.\n"
- "Please go to Control Panels -> Display -> Settings and\n"
- "set the screen to 32-bit color.\n"
- "Alternately, if you choose to run fullscreen, Second Life\n"
- "will automatically adjust the screen each time it runs.",
- "Error",
- OSMB_OK);
- return;
- }
-
- if (pfd.cAlphaBits < 8)
- {
- close();
- OSMessageBox(
- "Second Life is unable to run because it can't get an 8 bit alpha\n"
- "channel. Usually this is due to video card driver issues.\n"
- "Please make sure you have the latest video card drivers installed.\n"
- "Also be sure your monitor is set to True Color (32-bit) in\n"
- "Control Panels -> Display -> Settings.\n"
- "If you continue to receive this message, contact customer service.",
- "Error",
- OSMB_OK);
- return;
- }
-
- if (!(mhRC = wglCreateContext(mhDC)))
- {
- close();
- OSMessageBox("Can't create GL rendering context", "Error", OSMB_OK);
- return;
- }
-
- if (!wglMakeCurrent(mhDC, mhRC))
- {
- close();
- OSMessageBox("Can't activate GL rendering context", "Error", OSMB_OK);
- return;
- }
-
- if (!gGLManager.initGL())
- {
- close();
- OSMessageBox(
- "Second Life is unable to run because your video card drivers\n"
- "are out of date or unsupported. Please make sure you have\n"
- "the latest video card drivers installed.\n\n"
- "If you continue to receive this message, contact customer service.",
- "Error",
- OSMB_OK);
- return;
- }
-
- // Disable vertical sync for swap
- if (disable_vsync && wglSwapIntervalEXT)
- {
- llinfos << "Disabling vertical sync" << llendl;
- wglSwapIntervalEXT(0);
- }
- else
- {
- llinfos << "Keeping vertical sync" << llendl;
- }
-
-
- // OK, let's get the current gamma information and store it off.
- mCurrentGamma = 0.f; // Not set, default;
- if (!GetDeviceGammaRamp(mhDC, mPrevGammaRamp))
- {
- llwarns << "Unable to get device gamma ramp" << llendl;
- }
-
- // Calculate what the current gamma is. From a posting by Garrett T. Bass, Get/SetDeviceGammaRamp Demystified
- // http://apollo.iwt.uni-bielefeld.de/~ml_robot/OpenGL-04-2000/0058.html
-
- // We're going to assume that gamma's the same for all 3 channels, because I don't feel like doing it otherwise.
- // Using the red channel.
-
- F32 Csum = 0.0;
- S32 Ccount = 0;
- for (i = 0; i < 256; i++)
- {
- if (i != 0 && mPrevGammaRamp[i] != 0 && mPrevGammaRamp[i] != 65536)
- {
- F64 B = (i % 256) / 256.0;
- F64 A = mPrevGammaRamp[i] / 65536.0;
- F32 C = (F32) ( log(A) / log(B) );
- Csum += C;
- Ccount++;
- }
- }
- mCurrentGamma = Csum / Ccount;
-
- llinfos << "Previous gamma: " << mCurrentGamma << llendl;
- }
-
-
- //store this pointer for wndProc callback
- SetWindowLong(mWindowHandle, GWL_USERDATA, (U32)this);
-
+
//start with arrow cursor
initCursors();
setCursor( UI_CURSOR_ARROW );
@@ -1018,8 +665,6 @@ LLWindowWin32::LLWindowWin32(char *title, char *name, S32 x, S32 y, S32 width,
// Initialize (boot strap) the Language text input management,
// based on the system's (or user's) default settings.
allowLanguageTextInput(NULL, FALSE);
-
- initInputDevices();
}
void LLWindowWin32::initInputDevices()
@@ -1558,17 +1203,19 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disa
attrib_list[cur_attrib++] = WGL_COLOR_BITS_ARB;
attrib_list[cur_attrib++] = 24;
- attrib_list[cur_attrib++] = WGL_RED_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
-
- attrib_list[cur_attrib++] = WGL_GREEN_BITS_ARB;
+ attrib_list[cur_attrib++] = WGL_ALPHA_BITS_ARB;
attrib_list[cur_attrib++] = 8;
- attrib_list[cur_attrib++] = WGL_BLUE_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
+ U32 end_attrib = 0;
+ if (mFSAASamples > 0)
+ {
+ end_attrib = cur_attrib;
+ attrib_list[cur_attrib++] = WGL_SAMPLE_BUFFERS_ARB;
+ attrib_list[cur_attrib++] = GL_TRUE;
- attrib_list[cur_attrib++] = WGL_ALPHA_BITS_ARB;
- attrib_list[cur_attrib++] = 8;
+ attrib_list[cur_attrib++] = WGL_SAMPLES_ARB;
+ attrib_list[cur_attrib++] = mFSAASamples;
+ }
// End the list
attrib_list[cur_attrib++] = 0;
@@ -1587,36 +1234,67 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, LLCoordScreen size, BOOL disa
if (!num_formats)
{
- llinfos << "No 32 bit z-buffer, trying 24 bits instead" << llendl;
- // Try 24-bit format
- attrib_list[1] = 24;
- BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
- if (!result)
+ if (end_attrib > 0)
{
- close();
- show_window_creation_error("Error after wglChoosePixelFormatARB 24-bit");
- return FALSE;
+ llinfos << "No valid pixel format for " << mFSAASamples << "x anti-aliasing." << llendl;
+ attrib_list[end_attrib] = 0;
+
+ BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
+ if (!result)
+ {
+ close();
+ show_window_creation_error("Error after wglChoosePixelFormatARB 32-bit no AA");
+ return FALSE;
+ }
}
if (!num_formats)
{
- llwarns << "Couldn't get 24 bit z-buffer,trying 16 bits instead!" << llendl;
- attrib_list[1] = 16;
+ llinfos << "No 32 bit z-buffer, trying 24 bits instead" << llendl;
+ // Try 24-bit format
+ attrib_list[1] = 24;
BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
- if (!result || !num_formats)
+ if (!result)
{
close();
- show_window_creation_error("Error after wglChoosePixelFormatARB 16-bit");
+ show_window_creation_error("Error after wglChoosePixelFormatARB 24-bit");
return FALSE;
}
+
+ if (!num_formats)
+ {
+ llwarns << "Couldn't get 24 bit z-buffer,trying 16 bits instead!" << llendl;
+ attrib_list[1] = 16;
+ BOOL result = wglChoosePixelFormatARB(mhDC, attrib_list, NULL, 256, pixel_formats, &num_formats);
+ if (!result || !num_formats)
+ {
+ close();
+ show_window_creation_error("Error after wglChoosePixelFormatARB 16-bit");
+ return FALSE;
+ }
+ }
}
llinfos << "Choosing pixel formats: " << num_formats << " pixel formats returned" << llendl;
+ }
+
+ pixel_format = pixel_formats[0];
+
+ if (mhDC != 0) // Does The Window Have A Device Context?
+ {
+ wglMakeCurrent(mhDC, 0); // Set The Current Active Rendering Context To Zero
+ if (mhRC != 0) // Does The Window Have A Rendering Context?
+ {
+ wglDeleteContext (mhRC); // Release The Rendering Context
+ mhRC = 0; // Zero The Rendering Context
- pixel_format = pixel_formats[0];
+ }
+ ReleaseDC (mWindowHandle, mhDC); // Release The Device Context
+ mhDC = 0; // Zero The Device Context
}
+ DestroyWindow (mWindowHandle); // Destroy The Window
+
- DestroyWindow(mWindowHandle);
mWindowHandle = CreateWindowEx(dw_ex_style,
mWindowClassName,
mWindowTitle,
@@ -2985,6 +2663,16 @@ BOOL LLWindowWin32::setGamma(const F32 gamma)
return SetDeviceGammaRamp ( mhDC, mCurrentGammaRamp );
}
+void LLWindowWin32::setFSAASamples(const U32 fsaa_samples)
+{
+ mFSAASamples = fsaa_samples;
+}
+
+U32 LLWindowWin32::getFSAASamples()
+{
+ return mFSAASamples;
+}
+
LLWindow::LLWindowResolution* LLWindowWin32::getSupportedResolutions(S32 &num_resolutions)
{
if (!mSupportedResolutions)
diff --git a/indra/llwindow/llwindowwin32.h b/indra/llwindow/llwindowwin32.h
index b21df8981e..e8eed55aee 100644
--- a/indra/llwindow/llwindowwin32.h
+++ b/indra/llwindow/llwindowwin32.h
@@ -78,6 +78,8 @@ public:
/*virtual*/ void flashIcon(F32 seconds);
/*virtual*/ F32 getGamma();
/*virtual*/ BOOL setGamma(const F32 gamma); // Set the gamma
+ /*virtual*/ void setFSAASamples(const U32 fsaa_samples);
+ /*virtual*/ U32 getFSAASamples();
/*virtual*/ BOOL restoreGamma(); // Restore original gamma table (before updating gamma)
/*virtual*/ ESwapMethod getSwapMethod() { return mSwapMethod; }
/*virtual*/ void gatherInput();
@@ -118,7 +120,7 @@ protected:
LLWindowWin32(
char *title, char *name, int x, int y, int width, int height, U32 flags,
BOOL fullscreen, BOOL clearBg, BOOL disable_vsync, BOOL use_gl,
- BOOL ignore_pixel_depth);
+ BOOL ignore_pixel_depth, U32 fsaa_samples);
~LLWindowWin32();
void initCursors();
@@ -184,6 +186,7 @@ protected:
static BOOL sIsClassRegistered; // has the window class been registered?
F32 mCurrentGamma;
+ U32 mFSAASamples;
WORD mPrevGammaRamp[256*3];
WORD mCurrentGammaRamp[256*3];