forked from bartvdbraak/blender
Patch 17508: Blender Web Plugin - XEmbed. Enable XEmbed integration of blenderplayer, using -i as input parameter to pass embedder window id. create a minimal web plugin to embed blenderplayer on web pages (using gecko/mozilla as browser). Only for *nix.
This commit is contained in:
parent
fede495c07
commit
f305bb22b7
@ -64,6 +64,7 @@ OPTION(WITH_OPENEXR "Enable OpenEXR Support (http://www.openexr.com)" ON)
|
||||
OPTION(WITH_FFMPEG "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
|
||||
OPTION(WITH_OPENAL "Enable OpenAL Support (http://www.openal.org)" ON)
|
||||
OPTION(WITH_OPENMP "Enable OpenMP (has to be supported by the compiler)" OFF)
|
||||
OPTION(WITH_WEBPLUGIN "Enable Web Plugin (Mozilla-Unix only)" OFF)
|
||||
|
||||
IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
|
||||
MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
|
||||
@ -456,6 +457,13 @@ SUBDIRS(
|
||||
# Blender Application
|
||||
SUBDIRS(source/creator)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Blender WebPlugin
|
||||
IF(WITH_WEBPLUGIN)
|
||||
SET(MOZILLA_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
|
||||
SET(WITH_PLAYER ON)
|
||||
ENDIF(WITH_WEBPLUGIN)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Blender Player
|
||||
IF(WITH_PLAYER)
|
||||
|
@ -224,13 +224,15 @@ public:
|
||||
* @param state The state of the window when opened.
|
||||
* @param type The type of drawing context installed in this window.
|
||||
* @param stereoVisual Create a stereo visual for quad buffered stereo.
|
||||
* @param parentWindow Parent (embedder) window
|
||||
* @return The new window (or 0 if creation failed).
|
||||
*/
|
||||
virtual GHOST_IWindow* createWindow(
|
||||
const STR_String& title,
|
||||
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
|
||||
GHOST_TWindowState state, GHOST_TDrawingContextType type,
|
||||
const bool stereoVisual) = 0;
|
||||
const bool stereoVisual,
|
||||
const GHOST_TEmbedderWindowID parentWindow = 0) = 0;
|
||||
|
||||
/**
|
||||
* Dispose a window.
|
||||
|
@ -100,6 +100,7 @@ typedef enum {
|
||||
GHOST_kWindowStateMaximized,
|
||||
GHOST_kWindowStateMinimized,
|
||||
GHOST_kWindowStateFullScreen,
|
||||
GHOST_kWindowStateEmbedded,
|
||||
GHOST_kWindowState8Normal = 8,
|
||||
GHOST_kWindowState8Maximized,
|
||||
GHOST_kWindowState8Minimized,
|
||||
@ -392,6 +393,15 @@ typedef struct {
|
||||
} GHOST_DisplaySetting;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef long GHOST_TEmbedderWindowID;
|
||||
#endif // _WIN32
|
||||
|
||||
#ifndef _WIN32
|
||||
// I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
|
||||
typedef int GHOST_TEmbedderWindowID;
|
||||
#endif // _WIN32
|
||||
|
||||
/**
|
||||
* A timer task callback routine.
|
||||
* @param task The timer task object.
|
||||
|
@ -402,7 +402,8 @@ GHOST_IWindow* GHOST_SystemCarbon::createWindow(
|
||||
GHOST_TUns32 height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_TDrawingContextType type,
|
||||
bool stereoVisual
|
||||
bool stereoVisual,
|
||||
const GHOST_TEmbedderWindowID parentWindow
|
||||
)
|
||||
{
|
||||
GHOST_IWindow* window = 0;
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
* @param height The height the window.
|
||||
* @param state The state of the window when opened.
|
||||
* @param type The type of drawing context installed in this window.
|
||||
* @param parentWindow Parent (embedder) window
|
||||
* @return The new window (or 0 if creation failed).
|
||||
*/
|
||||
virtual GHOST_IWindow* createWindow(
|
||||
@ -113,7 +114,8 @@ public:
|
||||
GHOST_TUns32 height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_TDrawingContextType type,
|
||||
const bool stereoVisual
|
||||
const bool stereoVisual,
|
||||
const GHOST_TEmbedderWindowID parentWindow = 0
|
||||
);
|
||||
|
||||
/***************************************************************************************
|
||||
|
@ -169,7 +169,7 @@ GHOST_IWindow* GHOST_SystemWin32::createWindow(
|
||||
const STR_String& title,
|
||||
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
|
||||
GHOST_TWindowState state, GHOST_TDrawingContextType type,
|
||||
bool stereoVisual)
|
||||
bool stereoVisual, const GHOST_TEmbedderWindowID parentWindow )
|
||||
{
|
||||
GHOST_Window* window = 0;
|
||||
window = new GHOST_WindowWin32 (title, left, top, width, height, state, type, stereoVisual);
|
||||
|
@ -109,13 +109,14 @@ public:
|
||||
* @param height The height the window.
|
||||
* @param state The state of the window when opened.
|
||||
* @param type The type of drawing context installed in this window.
|
||||
* @param parentWindow Parent (embedder) window
|
||||
* @return The new window (or 0 if creation failed).
|
||||
*/
|
||||
virtual GHOST_IWindow* createWindow(
|
||||
const STR_String& title,
|
||||
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
|
||||
GHOST_TWindowState state, GHOST_TDrawingContextType type,
|
||||
const bool stereoVisual);
|
||||
const bool stereoVisual, const GHOST_TEmbedderWindowID parentWindow = 0 );
|
||||
|
||||
/***************************************************************************************
|
||||
** Event management functionality
|
||||
|
@ -191,6 +191,7 @@ getMainDisplayDimensions(
|
||||
* @param height The height the window.
|
||||
* @param state The state of the window when opened.
|
||||
* @param type The type of drawing context installed in this window.
|
||||
* @param parentWindow Parent (embedder) window
|
||||
* @return The new window (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IWindow*
|
||||
@ -203,14 +204,18 @@ createWindow(
|
||||
GHOST_TUns32 height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_TDrawingContextType type,
|
||||
bool stereoVisual
|
||||
bool stereoVisual,
|
||||
const GHOST_TEmbedderWindowID parentWindow
|
||||
){
|
||||
GHOST_WindowX11 * window = 0;
|
||||
|
||||
if (!m_display) return 0;
|
||||
|
||||
|
||||
|
||||
|
||||
window = new GHOST_WindowX11 (
|
||||
this,m_display,title, left, top, width, height, state, type, stereoVisual
|
||||
this,m_display,title, left, top, width, height, state, parentWindow, type, stereoVisual
|
||||
);
|
||||
|
||||
if (window) {
|
||||
@ -512,6 +517,8 @@ GHOST_SystemX11::processEvent(XEvent *xe)
|
||||
break;
|
||||
}
|
||||
|
||||
case DestroyNotify:
|
||||
::exit(-1);
|
||||
// We're not interested in the following things.(yet...)
|
||||
case NoExpose :
|
||||
case GraphicsExpose :
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
* @param state The state of the window when opened.
|
||||
* @param type The type of drawing context installed in this window.
|
||||
* @param stereoVisual Create a stereo visual for quad buffered stereo.
|
||||
* @param parentWindow Parent (embedder) window
|
||||
* @return The new window (or 0 if creation failed).
|
||||
*/
|
||||
GHOST_IWindow*
|
||||
@ -119,7 +120,8 @@ public:
|
||||
GHOST_TUns32 height,
|
||||
GHOST_TWindowState state,
|
||||
GHOST_TDrawingContextType type,
|
||||
const bool stereoVisual
|
||||
const bool stereoVisual,
|
||||
const GHOST_TEmbedderWindowID parentWindow = 0
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -138,6 +138,7 @@ GHOST_WindowX11(
|
||||
GHOST_TUns32 width,
|
||||
GHOST_TUns32 height,
|
||||
GHOST_TWindowState state,
|
||||
const GHOST_TEmbedderWindowID parentWindow,
|
||||
GHOST_TDrawingContextType type,
|
||||
const bool stereoVisual
|
||||
) :
|
||||
@ -205,21 +206,57 @@ GHOST_WindowX11(
|
||||
|
||||
// create the window!
|
||||
|
||||
m_window =
|
||||
XCreateWindow(
|
||||
m_display,
|
||||
RootWindow(m_display, m_visual->screen),
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height,
|
||||
0, // no border.
|
||||
m_visual->depth,
|
||||
InputOutput,
|
||||
m_visual->visual,
|
||||
CWBorderPixel|CWColormap|CWEventMask,
|
||||
&xattributes
|
||||
);
|
||||
;
|
||||
if (parentWindow == 0) {
|
||||
m_window =
|
||||
XCreateWindow(
|
||||
m_display,
|
||||
RootWindow(m_display, m_visual->screen),
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height,
|
||||
0, // no border.
|
||||
m_visual->depth,
|
||||
InputOutput,
|
||||
m_visual->visual,
|
||||
CWBorderPixel|CWColormap|CWEventMask,
|
||||
&xattributes
|
||||
);
|
||||
} else {
|
||||
|
||||
Window root_return;
|
||||
int x_return,y_return;
|
||||
unsigned int w_return,h_return,border_w_return,depth_return;
|
||||
GHOST_TInt32 screen_x, screen_y;
|
||||
|
||||
XGetGeometry(m_display, parentWindow, &root_return, &x_return, &y_return,
|
||||
&w_return, &h_return, &border_w_return, &depth_return );
|
||||
|
||||
left = 0;
|
||||
top = 0;
|
||||
width = w_return;
|
||||
height = h_return;
|
||||
|
||||
|
||||
m_window = XCreateWindow(
|
||||
m_display,
|
||||
parentWindow, // reparent against embedder
|
||||
left,
|
||||
top,
|
||||
width,
|
||||
height,
|
||||
0, // no border.
|
||||
m_visual->depth,
|
||||
InputOutput,
|
||||
m_visual->visual,
|
||||
CWBorderPixel|CWColormap|CWEventMask,
|
||||
&xattributes
|
||||
);
|
||||
|
||||
XSelectInput(m_display , parentWindow, SubstructureNotifyMask);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Are we in fullscreen mode - then include
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
* @param width The width the window.
|
||||
* @param height The height the window.
|
||||
* @param state The state the window is initially opened with.
|
||||
* @param parentWindow Parent (embedder) window
|
||||
* @param type The type of drawing context installed in this window.
|
||||
* @param stereoVisual Stereo visual for quad buffered stereo.
|
||||
*/
|
||||
@ -76,6 +77,7 @@ public:
|
||||
GHOST_TUns32 width,
|
||||
GHOST_TUns32 height,
|
||||
GHOST_TWindowState state,
|
||||
const GHOST_TEmbedderWindowID parentWindow,
|
||||
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
|
||||
const bool stereoVisual = false
|
||||
);
|
||||
|
@ -25,3 +25,7 @@
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
SUBDIRS(common ghost)
|
||||
|
||||
IF(WITH_WEBPLUGIN)
|
||||
SUBDIRS(xembed)
|
||||
ENDIF(WITH_WEBPLUGIN)
|
||||
|
@ -129,7 +129,8 @@ GPG_Application::GPG_Application(GHOST_ISystem* system)
|
||||
m_blendermat(0),
|
||||
m_blenderglslmat(0),
|
||||
m_pyGlobalDictString(0),
|
||||
m_pyGlobalDictString_Length(0)
|
||||
m_pyGlobalDictString_Length(0),
|
||||
m_isEmbedded(false)
|
||||
{
|
||||
fSystem = system;
|
||||
}
|
||||
@ -325,6 +326,26 @@ bool GPG_Application::startWindow(STR_String& title,
|
||||
return success;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!m_mainWindow) {
|
||||
printf("error: could not create main window\n");
|
||||
exit(-1);
|
||||
}
|
||||
m_isEmbedded = true;
|
||||
|
||||
bool success = initEngine(m_mainWindow, stereoMode);
|
||||
if (success) {
|
||||
success = startEngine();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
bool GPG_Application::startFullScreen(
|
||||
@ -887,7 +908,7 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown)
|
||||
GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData);
|
||||
//no need for this test
|
||||
//if (fSystem->getFullScreen()) {
|
||||
if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc) {
|
||||
if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc && !m_isEmbedded) {
|
||||
m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
|
||||
}
|
||||
//}
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
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);
|
||||
#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);
|
||||
@ -143,6 +144,8 @@ protected:
|
||||
bool m_engineInitialized;
|
||||
/** Engine state. */
|
||||
bool m_engineRunning;
|
||||
/** Running on embedded window */
|
||||
bool m_isEmbedded;
|
||||
|
||||
/** the gameengine itself */
|
||||
KX_KetsjiEngine* m_ketsjiengine;
|
||||
|
@ -178,6 +178,9 @@ void usage(char* program)
|
||||
printf(" anaglyph (Red-Blue glasses)\n");
|
||||
printf(" vinterlace (Vertical interlace for autostereo display)\n");
|
||||
printf(" depending on the type of stereo you want\n");
|
||||
#ifndef _WIN32
|
||||
printf(" -i: parent windows ID \n");
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
printf(" -c: keep console window open\n");
|
||||
#endif
|
||||
@ -297,6 +300,9 @@ int main(int argc, char** argv)
|
||||
int fullScreenFrequency = 60;
|
||||
char* pyGlobalDictString = NULL; /* store python dict data between blend file loading */
|
||||
int pyGlobalDictString_Length = 0;
|
||||
GHOST_TEmbedderWindowID parentWindow = 0;
|
||||
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
#ifdef __alpha__
|
||||
@ -457,6 +463,16 @@ int main(int argc, char** argv)
|
||||
usage(argv[0]);
|
||||
return 0;
|
||||
break;
|
||||
#ifndef _WIN32
|
||||
case 'i':
|
||||
i++;
|
||||
if ( (i + 1) < argc )
|
||||
parentWindow = atoi(argv[i++]);
|
||||
#ifndef NDEBUG
|
||||
printf("XWindows ID = %d\n", parentWindow);
|
||||
#endif //NDEBUG
|
||||
|
||||
#endif // _WIN32
|
||||
case 'c':
|
||||
i++;
|
||||
closeConsole = false;
|
||||
@ -729,7 +745,10 @@ int main(int argc, char** argv)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
|
||||
if (parentWindow != 0)
|
||||
app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode);
|
||||
else
|
||||
app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
|
||||
stereoWindow, stereomode);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user