Cucumber - AA for blenderplayer and fullscreen
authorDalai Felinto <dfelinto@gmail.com>
Wed, 11 Jan 2012 20:53:22 +0000 (20:53 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 11 Jan 2012 20:53:22 +0000 (20:53 +0000)
..............................................
svn merge ^/branches/soc-2011-cucumber -r 38968,38970,38973,39045,40845

Notes:
======
*  we replaced fullscreen by playerflag in DNA_scene.types.h. So no doversion here, I think this is a small reversion can't see any potential problem in forcuing users to re-check fullscreen. If the file is really old (<250) it will doversion though;

* (for after commit) it would be nice to gray out the width/height when desktop=True

* for a rainy day: it would be nice to have other ghost modes (e.g. screensaver) to support desktop + MSAA as well. It's not a huge deal given that I don't even know if anything else work (apart from windowed, fullscreen and embed) but it doesn't hurt to have it updated as well.

* there is something strange with outliner. I think space_outliner merge-info is not in sync with the ^/ folder. It's probably a wrong merge early in cucumber.

Commit Logs:
===========
# 40845 by dfelinto
remove desktop and fullscreen properties. They are both part of playerflag now
also I removed the fullscreen from the DNA completely. I don't think we need doversion that..

#39045 by kupoman
The Desktop option is now greyed out when fullscreen is not checked rather than disappearing from the UI completely.

#38973 by kupoman
Adding a checkbox to the UI to allow the full screen Blender Player to use the current desktop resolution instead of the resolution setting.

#38970 by kupoman
Multisampling now works in a fullscreen Blender Player.

#38968 by moguri
Committing a patch from Mitchell Stokes (Moguri) to include a setting in the UI for the Blenderplayer multisampling.

intern/ghost/GHOST_ISystem.h
intern/ghost/intern/GHOST_System.cpp
intern/ghost/intern/GHOST_System.h
release/scripts/startup/bl_ui/properties_game.py
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c
source/blender/windowmanager/intern/wm_init_exit.c
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.h
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

index d451cb16df65d7dfed6dd57749c2f445511f2729..4d2f41b48bdcabb3b2ea658c5f181e1f7fbf6fe4 100644 (file)
@@ -255,7 +255,7 @@ public:
         * @return      Indication of success.
         */
        virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
-               const bool stereoVisual) = 0;
+               const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0) = 0;
 
        /**
         * Ends full screen mode.
index b0b693e2f8f574301f38bb883b769e4c25ed934f..4efdcbc6519b590ae330752dd009c326c8b798dc 100644 (file)
@@ -139,7 +139,7 @@ bool GHOST_System::validWindow(GHOST_IWindow* window)
 
 
 GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
-                                                                                        const bool stereoVisual)
+                                                                                        const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
 {
        GHOST_TSuccess success = GHOST_kFailure;
        GHOST_ASSERT(m_windowManager, "GHOST_System::beginFullScreen(): invalid window manager")
@@ -151,7 +151,7 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting
                        success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting);
                        if (success == GHOST_kSuccess) {
                                //GHOST_PRINT("GHOST_System::beginFullScreen(): creating full-screen window\n");
-                               success = createFullScreenWindow((GHOST_Window**)window, stereoVisual);
+                               success = createFullScreenWindow((GHOST_Window**)window, stereoVisual, numOfAASamples);
                                if (success == GHOST_kSuccess) {
                                        m_windowManager->beginFullScreen(*window, stereoVisual);
                                }
@@ -333,7 +333,7 @@ GHOST_TSuccess GHOST_System::exit()
 }
 
 
-GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const bool stereoVisual)
+GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples)
 {
        GHOST_TSuccess success;
        GHOST_ASSERT(m_displayManager, "GHOST_System::createFullScreenWindow(): invalid display manager")
@@ -347,7 +347,8 @@ GHOST_TSuccess GHOST_System::createFullScreenWindow(GHOST_Window** window, const
                                        0, 0, settings.xPixels, settings.yPixels,
                                        GHOST_kWindowStateFullScreen,
                                        GHOST_kDrawingContextTypeOpenGL,
-                                       stereoVisual);
+                                       stereoVisual,
+                                       numOfAASamples);
                success = *window == 0 ? GHOST_kFailure : GHOST_kSuccess;
        }
        return success;
index 300826431184b0609ac5890d9972841cbf306b0a..6286121719d47e1be3324c551867b0cee78d561e 100644 (file)
@@ -144,7 +144,7 @@ public:
         * @return      Indication of success.
         */
        virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window,
-               const bool stereoVisual);
+               const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0);
 
        /**
         * Ends full screen mode.
@@ -308,7 +308,7 @@ protected:
         * @return Indication of success.
         */
        virtual GHOST_TSuccess createFullScreenWindow(GHOST_Window** window,
-               const bool stereoVisual);
+               const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0);
 
        /** The display manager (platform dependant). */
        GHOST_DisplayManager* m_displayManager;
index b7b2acc6b0863c1033624964b9bb108f479ad8d9..f0f964f9a3134a46a9a300a18da98378fc68ab53 100644 (file)
@@ -274,16 +274,23 @@ class RENDER_PT_game_player(RenderButtonsPanel, Panel):
 
         row = layout.row()
         row.operator("wm.blenderplayer_start", text="Start")
-        row.prop(gs, "show_fullscreen")
+        row.label()
 
         row = layout.row()
         row.label(text="Resolution:")
         row = layout.row(align=True)
         row.prop(gs, "resolution_x", slider=False, text="X")
         row.prop(gs, "resolution_y", slider=False, text="Y")
-
+        row = layout.row()
+        col = row.column()
+        col.prop(gs, "show_fullscreen")
+        col = row.column()
+        col.prop(gs, "use_desktop")
+        col.active = gs.show_fullscreen
+        
         col = layout.column()
         col.label(text="Quality:")
+        col.prop(gs, "samples")
         col = layout.column(align=True)
         col.prop(gs, "depth", text="Bit Depth", slider=False)
         col.prop(gs, "frequency", text="Refresh Rate", slider=False)
index 82b934d52e60ad1b0051b4ca70428124d99f9c43..a1d583624cd0905dbde1fa897d68f8f9ac45ae88 100644 (file)
@@ -10904,7 +10904,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        sce->gm.dome.warptext = sce->r.dometext;
 
                        //Stand Alone
-                       sce->gm.fullscreen = sce->r.fullscreen;
+                       sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0);
                        sce->gm.xplay = sce->r.xplay;
                        sce->gm.yplay = sce->r.yplay;
                        sce->gm.freqplay = sce->r.freqplay;
index d3eb4f12b2ac41c95bee32a2294d7c26c0b92833..7a87ca8c6806b96346dc056d65b5016bebf5be1b 100644 (file)
@@ -583,8 +583,9 @@ typedef struct GameData {
 
        /*  standalone player */
        struct GameFraming framing;
-       short fullscreen, xplay, yplay, freqplay;
+       short playerflag, xplay, yplay, freqplay;
        short depth, attrib, rt1, rt2;
+       short aasamples, pad4[3];
 
        /* stereo/dome mode */
        struct GameDome dome;
@@ -661,6 +662,10 @@ typedef struct GameData {
 #define GAME_SHOW_OBSTACLE_SIMULATION          (1 << 16)
 /* Note: GameData.flag is now an int (max 32 flags). A short could only take 16 flags */
 
+/* GameData.playerflag */
+#define GAME_PLAYER_FULLSCREEN                         (1 << 0)
+#define GAME_PLAYER_DESKTOP_RESOLUTION         (1 << 1)
+
 /* GameData.matmode */
 #define GAME_MAT_TEXFACE       0
 #define GAME_MAT_MULTITEX      1
index 84cf50a3755d33f892df94e4db32e3220ea5b65e..e1bf4d73fffd07275886827548576ec69afc8474 100644 (file)
@@ -2036,6 +2036,14 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
+       static EnumPropertyItem aasamples_items[]  ={
+               {0, "SAMPLES_0", 0, "Off", ""},
+               {2, "SAMPLES_2", 0, "2x", ""},
+               {4, "SAMPLES_4", 0, "4x", ""},
+               {8, "SAMPLES_8", 0, "8x", ""},
+               {16, "SAMPLES_16", 0, "16x", ""},
+               {0, NULL, 0, NULL, NULL}};
+
        static EnumPropertyItem framing_types_items[] ={
                {SCE_GAMEFRAMING_BARS, "LETTERBOX", 0, "Letterbox",
                                       "Show the entire viewport in the display window, using bar horizontally or vertically"},
@@ -2105,6 +2113,11 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the screen");
        RNA_def_property_update(prop, NC_SCENE, NULL);
        
+       prop= RNA_def_property(srna, "samples", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "aasamples");
+       RNA_def_property_enum_items(prop, aasamples_items);
+       RNA_def_property_ui_text(prop, "AA Samples", "The number of AA Samples to use for MSAA");
+       
        prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_int_sdna(prop, NULL, "depth");
        RNA_def_property_range(prop, 8, 32);
@@ -2126,10 +2139,15 @@ static void rna_def_scene_game_data(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_SCENE, NULL);
        
        prop= RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "fullscreen", 1.0);
+       RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_FULLSCREEN);
        RNA_def_property_ui_text(prop, "Fullscreen", "Start player in a new fullscreen display");
        RNA_def_property_update(prop, NC_SCENE, NULL);
 
+       prop= RNA_def_property(srna, "use_desktop", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "playerflag", GAME_PLAYER_DESKTOP_RESOLUTION);
+       RNA_def_property_ui_text(prop, "Desktop", "Uses the current desktop resultion in fullscreen mode");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
+
        /* Framing */
        prop= RNA_def_property(srna, "frame_type", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "framing.type");
index 8abc12b8bec970f2002c09deed98af2c204080ab..e36d9c0b0ab70c8aadad094e92beb97888219c65 100644 (file)
@@ -264,7 +264,7 @@ int WM_init_game(bContext *C)
                }
 
                /* Fullscreen */
-               if(scene->gm.fullscreen) {
+               if((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
                        WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
                        wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
                        ar->winx = ar->winrct.xmax + 1;
index f249510ecc7a00f9293c6e7a061e7224e0c52d92..f7c366599ef676f2103b48f4767226f476e1e8ce 100644 (file)
@@ -372,17 +372,20 @@ bool GPG_Application::startFullScreen(
                int bpp,int frequency,
                const bool stereoVisual,
                const int stereoMode,
-               const GHOST_TUns16 samples)
+               const GHOST_TUns16 samples,
+               bool useDesktop)
 {
        bool success;
+       GHOST_TUns32 sysWidth=0, sysHeight=0;
+       fSystem->getMainDisplayDimensions(sysWidth, sysHeight);
        // Create the main window
        GHOST_DisplaySetting setting;
-       setting.xPixels = width;
-       setting.yPixels = height;
+       setting.xPixels = (useDesktop) ? sysWidth : width;
+       setting.yPixels = (useDesktop) ? sysHeight : height;
        setting.bpp = bpp;
        setting.frequency = frequency;
 
-       fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual);
+       fSystem->beginFullScreen(setting, &m_mainWindow, stereoVisual, samples);
        m_mainWindow->setCursorVisibility(false);
        m_mainWindow->setState(GHOST_kWindowStateFullScreen);
 
index 37625dc8998b99f7213bcc841c2bd3b988361057..51dac5cb3f3985ceccaa08f59e1ec12f0f372547 100644 (file)
@@ -64,7 +64,7 @@ public:
                        bool SetGameEngineData(struct Main* maggie, struct Scene* scene, GlobalSettings* gs, int argc, char** argv);
                        bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight,
                        const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0);
-                       bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0);
+                       bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode, 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);
 #ifdef WIN32
                        bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0);
index e84df921fd5c6c5cf2efdb56f8c2bc3d200360d2..c725847037ae971f8a4d4c91676a33d236ad5cbb 100644 (file)
@@ -365,6 +365,7 @@ int main(int argc, char** argv)
        GHOST_TEmbedderWindowID parentWindow = 0;
        bool isBlenderPlayer = false;
        int validArguments=0;
+       bool samplesParFound = false;
        GHOST_TUns16 aasamples = 0;
        
 #ifdef __linux__
@@ -582,8 +583,14 @@ int main(int argc, char** argv)
                                break;
                        case 'm':
                                i++;
+                               samplesParFound = true;
                                if ((i+1) <= validArguments )
-                               aasamples = atoi(argv[i++]);
+                                       aasamples = atoi(argv[i++]);
+                               else
+                               {
+                                       error = true;
+                                       printf("error: No argument supplied for -m");
+                               }
                                break;
                        case 'c':
                                i++;
@@ -819,7 +826,7 @@ int main(int argc, char** argv)
                                                if ((!fullScreenParFound) && (!windowParFound))
                                                {
                                                        // Only use file settings when command line did not override
-                                                       if (scene->gm.fullscreen) {
+                                                       if ((scene->gm.playerflag & GAME_PLAYER_FULLSCREEN)) {
                                                                //printf("fullscreen option found in Blender file\n");
                                                                fullScreen = true;
                                                                fullScreenWidth= scene->gm.xplay;
@@ -848,6 +855,9 @@ int main(int argc, char** argv)
                                                else
                                                        scene->gm.stereoflag = STEREO_ENABLED;
 
+                                               if (!samplesParFound)
+                                                       aasamples = scene->gm.aasamples;
+
                                                if (stereoFlag == STEREO_DOME){
                                                        stereomode = RAS_IRasterizer::RAS_STEREO_DOME;
                                                        scene->gm.stereoflag = STEREO_DOME;
@@ -893,7 +903,7 @@ int main(int argc, char** argv)
 #endif
                                                                {
                                                                        app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
-                                                                               stereoWindow, stereomode, aasamples);
+                                                                               stereoWindow, stereomode, aasamples, (scene->gm.playerflag & GAME_PLAYER_DESKTOP_RESOLUTION));
                                                                }
                                                        }
                                                        else