Embed the Game Engine Application

Hi,

I create my game engine application and i want to embed it on an application like java or PyQt or in the web to use it and install it like a jeux.exe.
Can you help me to do that please?

Thanks

do you mean exporting as a exe file? or integrating your exe into another system?

theres an addon that comes with blender which can build your game into an exe, but its got alot of quirks. its called Save as Game Engine Runtime or something of the like.

until we know a bit more on how your game is structured, we cant help much. not the source code or assets, but more like folder structures, whether you have your images packed, if your using python modules or scripts, if you open other blend files during the game, and so on.

Thank you for your reply.
I would like to add my game to a Java application or PyQt where there is an identification page, form … and in the end I put everything in an .exe file.
I use a script python and bgui.

is there any solution?

You might use the BBPlayer to run a bge game in a web page.

Okey thank you, i will try it

The BlenderPlayer (the basis of any game published with the Game Engine Publishing or older Save As Runtime addons) can be embedded in another application by passing in a parent window ID using the -i argument. Using this the BlenderPlayer/BGE will draw in the parent window instead of making its own. You can then create a socket (or some other form of IPC) connection to communicate between your game and the parent application.

yes i try it but i don’t know how to embed it in the interface PyQt. something is missing in my code:

import sys
import os
from PyQt5.QtCore import QProcess
from PyQt5.QtGui import QWindow
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QPushButton

class embedBlender(QWidget):
def init(self):
QWidget.init(self)
self.setMinimumWidth(800)
self.setMinimumHeight(600)
self.window = QWindow.fromWinId(125829124)
layout = QVBoxLayout(self)
layout.addWidget(self.window)
os.system(‘blenderplayer -w 125829124 -m 16 c:\k.blend’)

if name == “main”:
app = QApplication(sys.argv)
main = embedBlender()
main.show()
sys.exit(app.exec_())

You need to get the WinId from the Qt for the window it created and pass that in as the -i parameter. The -m 16 is not needed for this example (it controls the number of samples for multisample anti-aliasing).

yes i wrote os.system(‘blenderplayer -i 125829124 -m 16 c:\k.blend’) and 125829124 is the WinId of Qt window.
The result of my code is two interfaces: the first of blenderplayer and the second of Qt
How can i embed blenderplayer in Qt window? i am not good in programming

I doubt your Window id is going to be a constant value as this is something handled by the OS or window manager (windows are usually assigned an ID when they are created). I do not have a step-by-step on getting this working, nor is it something I’ve done before, which means I’m just guessing. Do you get two windows without the os.system() call? Also, you should be using the subprocess module instead of os.system(), but you can worry about that later.

I modify my function code and i have also 2 windows:

class embedBlender(QWidget): def init(self):
QWidget.init(self)
self.setMinimumWidth(800)
self.setMinimumHeight(600)
self.frame = QFrame(self)
layout = QVBoxLayout(self)
layout.addWidget(self.frame)
layout.addWidget(QPushButton(’ blenderCore Embed ‘))
self.process = QProcess(self)
self.process.start(’’.join((‘blenderplayer -i’, str(self.frame.winId()), ‘-w 400 400 c:\k.blend’)))

in the last line, it is missing something to embed the two windows…

Without opening the blenderplayer (e.g., comment out self.process.start()), do you get two windows? Just double-checking that you haven’t messed something up and Qt is creating two windows. What kind of values do you get from self.frame.winId()? You can also clean up your self.process.start line quite a bit by using some string formating:


args = 'blenderplayer -i {} -w 400 400 c:\\k.blend'.format(self.frame.winId())
print("Starting blenderplayer process:", args)
self.process.start(args)

Also, ‘’ is an escape character, so if you want an actual backslash, you need to escape it, hence the ‘\’. I also find it useful to print out the exact string I’m passing into a function to start a process (helps finds issues with spaces, mangled strings, bad string replacement, etc.).

i replace with your code and i get 2 windows and this:
Starting blenderplayer process: blenderplayer -i <sip.voidptr object at 0x0000000000DBE418> -w 400 400 c:\V2.blend

I edit the function with this code:

    args = 'blenderplayer -i {} -w 400 400 c:\\V2.blend'.format(self.frame.winId().__int__())        print("Starting blenderplayer process:", args)
    self.process.start(args)

and i print the true command but also 2windows:
Starting blenderplayer process: blenderplayer -i 4915922 -w 400 400 c:\V2.blend

Hello,
I want to embed Game Engine Inside Pyside Qt Application. i want to do the same thing like in this question:https://blenderartists.org/forum/showthread.php?364625-Game-Engine-Inside-PySide-Qt-Application
Could you help me please?

MODERATION
Threads merged.

If you want a thread moved to a more suitable forum report it to the moderation team (triangle icon in bottom left of each post)

is there any solution?

I found this patch fix anti-aliasing for win32 platform. It gives opportunity to embed blenderplayer inside parent window. but I don’t know how to install it.
Could you help me ?