diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2011-05-04 05:50:17 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2011-05-04 05:50:17 +0400 |
commit | c56fe3efe6e5c739e6c24f5f57c1d52dfd3ddc68 (patch) | |
tree | 000790fa8210028b433f5cedacf5e2707285f191 /source/gameengine/GamePlayer/ghost | |
parent | 8df1a51c19483fb0a2bd2d1314173d90b268686b (diff) |
Patch [#26799] 2.5x blenderplayer (BGE) anti-aliasing & embedding by Sebastian Korczak (with some small tweaks) + adding GHOST_PRINTF
The patch can also be found in http://codereview.appspot.com/4431072/
##############
This patch fix anti-aliasing (multisampling) implementation for win32 platform. It also gives opportunity to embed blenderplayer inside parent window.
Usage:
blenderplayer.exe -i 123456 -m 16 file.blend
where:
123456 - parent window handler (integer, default: 0)
16 - multisample level (integer, default: 0, max: 16. Put there maximum level you want. If not supported, player will automatically try 15,14,13,...,3,2,1)
##############
This patch was originally created as part of the Burster (aka webplugin) project but benefit any one embedding the bge in a custom OpenGL context. By the way, to embed the BGE in a .Net application is really straightforward now =)
The Multisampling work for blenderplayer as a whole.
Missing functionalities:
- to expose the multisampling to the ui (so far it only works in console)
- window focus and keyboard messages for embedded blenderplayer (supported in their previous patch for 2.49, yet to be ported over)
- handle resizing (to be investigated, indeed the changes in getState() in GHOST_WindowWin32.cpp are going to get in the way of that if I'm not mistaken. To be addressed together.
Doxygen documentation to be added whenever I sort out how to do so. Sorry Nathan too many stuff to deal with at the same time. The sooner this patch gets in, the sooner the missing functionalities can be patched on top of that.
Diffstat (limited to 'source/gameengine/GamePlayer/ghost')
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 29 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_Application.h | 10 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 27 |
3 files changed, 38 insertions, 28 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index e00a890a1fb..6ea98e0e8cc 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -233,7 +233,8 @@ static HWND findGhostWindowHWND(GHOST_IWindow* window) bool GPG_Application::startScreenSaverPreview( HWND parentWindow, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { bool success = false; @@ -245,7 +246,7 @@ bool GPG_Application::startScreenSaverPreview( STR_String title = ""; m_mainWindow = fSystem->createWindow(title, 0, 0, windowWidth, windowHeight, GHOST_kWindowStateMinimized, - GHOST_kDrawingContextTypeOpenGL, stereoVisual); + GHOST_kDrawingContextTypeOpenGL, stereoVisual, samples); if (!m_mainWindow) { printf("error: could not create main window\n"); exit(-1); @@ -287,9 +288,10 @@ bool GPG_Application::startScreenSaverFullScreen( int height, int bpp,int frequency, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { - bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode); + bool ret = startFullScreen(width, height, bpp, frequency, stereoVisual, stereoMode, samples); if (ret) { HWND ghost_hwnd = findGhostWindowHWND(m_mainWindow); @@ -311,13 +313,14 @@ bool GPG_Application::startWindow(STR_String& title, int windowWidth, int windowHeight, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { bool success; // Create the main window //STR_String title ("Blender Player - GHOST"); m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, stereoVisual); + GHOST_kDrawingContextTypeOpenGL, stereoVisual, samples); if (!m_mainWindow) { printf("error: could not create main window\n"); exit(-1); @@ -339,10 +342,13 @@ bool GPG_Application::startWindow(STR_String& title, bool GPG_Application::startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parentWindow, const bool stereoVisual, - const int stereoMode) { - - m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, GHOST_kWindowStateNormal, - GHOST_kDrawingContextTypeOpenGL, stereoVisual, parentWindow); + const int stereoMode, + const GHOST_TUns16 samples) { + GHOST_TWindowState state = GHOST_kWindowStateNormal; + if (parentWindow != 0) + state = GHOST_kWindowStateEmbedded; + m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, state, + GHOST_kDrawingContextTypeOpenGL, stereoVisual, samples, parentWindow); if (!m_mainWindow) { printf("error: could not create main window\n"); @@ -363,7 +369,8 @@ bool GPG_Application::startFullScreen( int height, int bpp,int frequency, const bool stereoVisual, - const int stereoMode) + const int stereoMode, + const GHOST_TUns16 samples) { bool success; // Create the main window diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 850b34d5b69..c0638517657 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -63,12 +63,12 @@ public: bool SetGameEngineData(struct Main* maggie, struct Scene* scene, int argc, char** argv); bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight, - const bool stereoVisual, const int stereoMode); - bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); - bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, const bool stereoVisual, const int stereoMode); + 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 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); - bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode); + bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); + bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode, const GHOST_TUns16 samples=0); #endif virtual bool processEvent(GHOST_IEvent* event); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 968d6caeb1c..0ab6da240ce 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -199,7 +199,7 @@ void usage(const char* program, bool isBlenderPlayer) } printf("usage: %s [-w [w h l t]] [-f [fw fh fb ff]] %s[-g gamengineoptions] " - "[-s stereomode] %s\n", program, consoleoption, filename); + "[-s stereomode] [-m aasamples] %s\n", program, consoleoption, filename); printf(" -h: Prints this command summary\n\n"); printf(" -w: display in a window\n"); printf(" --Optional parameters--\n"); @@ -235,9 +235,8 @@ void usage(const char* program, bool isBlenderPlayer) printf(" cubemap (Cube Map)\n"); printf(" sphericalpanoramic (Spherical Panoramic)\n"); printf(" depending on the type of dome you are using\n\n"); -#ifndef _WIN32 + printf(" -m: maximum anti-aliasing (eg. 2,4,8,16)\n\n"); printf(" -i: parent windows ID \n\n"); -#endif #ifdef _WIN32 printf(" -c: keep console window open\n\n"); #endif @@ -257,6 +256,7 @@ void usage(const char* program, bool isBlenderPlayer) printf("\n"); printf("example: %s -w 320 200 10 10 -g noaudio%s%s\n", program, pathname, filename); printf("example: %s -g show_framerate = 0 %s%s\n", program, pathname, filename); + printf("example: %s -i 232421 -m 16 %s%s\n\n", program, pathname, filename); } static void get_filename(int argc, char **argv, char *filename) @@ -367,6 +367,7 @@ int main(int argc, char** argv) GHOST_TEmbedderWindowID parentWindow = 0; bool isBlenderPlayer = false; int validArguments=0; + GHOST_TUns16 aasamples = 0; #ifdef __linux__ #ifdef __alpha__ @@ -553,7 +554,6 @@ int main(int argc, char** argv) usage(argv[0], isBlenderPlayer); return 0; break; -#ifndef _WIN32 case 'i': i++; if ( (i + 1) <= validArguments ) @@ -562,12 +562,15 @@ int main(int argc, char** argv) error = true; printf("error: too few options for parent window argument.\n"); } - #if defined(DEBUG) printf("XWindows ID = %d\n", parentWindow); #endif // defined(DEBUG) - -#endif // _WIN32 + break; + case 'm': + i++; + if ((i+1) <= validArguments ) + aasamples = atoi(argv[i++]); + break; case 'c': i++; closeConsole = false; @@ -857,13 +860,13 @@ int main(int argc, char** argv) if (scr_saver_mode == SCREEN_SAVER_MODE_SAVER) { app.startScreenSaverFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency, - stereoWindow, stereomode); + stereoWindow, stereomode, aasamples); } else #endif { app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency, - stereoWindow, stereomode); + stereoWindow, stereomode, aasamples); } } else @@ -903,16 +906,16 @@ int main(int argc, char** argv) #ifdef WIN32 if (scr_saver_mode == SCREEN_SAVER_MODE_PREVIEW) { - app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode); + app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode, aasamples); } else #endif { if (parentWindow != 0) - app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode); + app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode, aasamples); else app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, - stereoWindow, stereomode); + stereoWindow, stereomode, aasamples); } } } |