From 8529b2f925c2a0f0cfa3ffe9218519b55223107e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 9 Jun 2016 21:07:58 +0200 Subject: 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. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/gameengine/GamePlayer/ghost/GPG_ghost.cpp') 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); -- cgit v1.2.3