diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2016-06-09 22:07:58 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2016-06-09 23:15:13 +0300 |
commit | 8529b2f925c2a0f0cfa3ffe9218519b55223107e (patch) | |
tree | 2d8b7cbe6d9e813e96870a0594b32f282ea55cce /source/gameengine | |
parent | 5da02ab9e249487081afe3ee459f1e8d15a7f674 (diff) |
BGE: alpha on frame buffer and precedence of MSAA over swap.
A new option '-a' can be passed to the blenderplayer. It forces the
framebuffer to have an alpha channel.
This can be used in VideoTexture to return a image with alpha channel
with ImageViewport (provided alpha is set to True on the ImageViewport
object and that the background color alpha channel is 0, which is the
default).
Without the -a option, the frame buffer has no alpha channel and
ImageViewport always returns an opaque image, no matter what.
In Linux, the player window will be rendered transparently over
the desktop.
In Windows, the player window is still rendered opaque because
transparency of the window is only possible using the 'compositing'
functions of Windows. The code is there but not enabled (look for
WIN32_COMPOSITING) because 1) it doesn't work so well 2) it requires
a DLL that is only available on Vista and up.
give precedence to AA over Swap copy:
Certain GPU (intel) will not allow MSAA together with swap copy.
Previously, swap copy had priority over MSAA: fewer AA samples would be
chosen if it was the condition to get swap copy. This patch reverse the
logic: swap copy will be abandonned if another swap method (undefined or
exchange) will provide the number of AA samples requested. If no AA
samples is requested, swap copy still has the priority of course.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 11 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.h | 6 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 11 |
3 files changed, 21 insertions, 7 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index f0a7bd47ca3..19eef82439e 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -301,7 +301,7 @@ bool GPG_Application::startScreenSaverFullScreen( const int stereoMode, const GHOST_TUns16 samples) { - bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode, samples); + bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode, 0, samples); if (ret) { HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow); @@ -325,6 +325,7 @@ bool GPG_Application::startWindow( int windowHeight, const bool stereoVisual, const int stereoMode, + const int alphaBackground, const GHOST_TUns16 samples) { GHOST_GLSettings glSettings = {0}; @@ -333,6 +334,8 @@ bool GPG_Application::startWindow( //STR_String title ("Blender Player - GHOST"); if (stereoVisual) glSettings.flags |= GHOST_glStereoVisual; + if (alphaBackground) + glSettings.flags |= GHOST_glAlphaBackground; glSettings.numOfAASamples = samples; m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal, @@ -360,6 +363,7 @@ bool GPG_Application::startEmbeddedWindow( const GHOST_TEmbedderWindowID parentWindow, const bool stereoVisual, const int stereoMode, + const int alphaBackground, const GHOST_TUns16 samples) { GHOST_TWindowState state = GHOST_kWindowStateNormal; @@ -367,6 +371,8 @@ bool GPG_Application::startEmbeddedWindow( if (stereoVisual) glSettings.flags |= GHOST_glStereoVisual; + if (alphaBackground) + glSettings.flags |= GHOST_glAlphaBackground; glSettings.numOfAASamples = samples; if (parentWindow != 0) @@ -394,6 +400,7 @@ bool GPG_Application::startFullScreen( int bpp,int frequency, const bool stereoVisual, const int stereoMode, + const int alphaBackground, const GHOST_TUns16 samples, bool useDesktop) { @@ -407,7 +414,7 @@ bool GPG_Application::startFullScreen( setting.bpp = bpp; setting.frequency = frequency; - fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual, samples); + fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual, alphaBackground, samples); m_mainWindow->setCursorVisibility(false); /* note that X11 ignores this (it uses a window internally for fullscreen) */ m_mainWindow->setState(GHOST_kWindowStateFullScreen); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index b6f545c2de8..e757cc10e32 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -65,13 +65,13 @@ public: bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight, - const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); + const bool stereoVisual, const int stereoMode, const int alphaBackground=0, const GHOST_TUns16 samples=0); bool startFullScreen(int width, int height, int bpp, int frequency, - const bool stereoVisual, const int stereoMode, + const bool stereoVisual, const int stereoMode, const int alphaBackground = 0, const GHOST_TUns16 samples=0, bool useDesktop=false); bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, - const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); + const bool stereoVisual, const int stereoMode, const int alphaBackground=0, const GHOST_TUns16 samples=0); #ifdef WIN32 bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index ac2e4dfa563..30ad5b37777 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -444,6 +444,7 @@ int main( int validArguments=0; bool samplesParFound = false; GHOST_TUns16 aasamples = 0; + int alphaBackground = 0; #ifdef WIN32 char **argv; @@ -838,6 +839,12 @@ int main( } break; } + case 'a': // allow window to blend with display background + { + i++; + alphaBackground = 1; + break; + } default: //not recognized { printf("Unknown argument: %s\n", argv[i++]); @@ -1041,7 +1048,7 @@ int main( #endif { app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency, - stereoWindow, stereomode, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION)); + stereoWindow, stereomode, alphaBackground, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION)); } } else @@ -1088,7 +1095,7 @@ int main( app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode, aasamples); else app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, - stereoWindow, stereomode, aasamples); + stereoWindow, stereomode, alphaBackground, aasamples); if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) { GPU_set_mipmap(0); |