Hey Guys,
Just started with IRRLICHT. I have an application that creates an OpenGL window and renders graphics using it's own 3D engine.
This application offers and SDK that allows me to do my own rendering on top of the existing 3D grpahics engine which is OpenGL based.
I want to render using IRRLICHT similar to how you would render inside of a Win32 window. I have a handle to the existing OpenGL window, is there some sample code on how to initialize IRRLICHT using an existing OpenGL window?
Cheers!
Render in Existing Window
I don't know if there could be a conflict between Irrlicht and OpenGL, but as long as you have a handle to a window you can use this handle/window to create a device that renders into this window...
This can be done with any window you got a handle from (all Windows objects like buttons etc. are derived from the class window and can be used for this as long as you got the handle of it)...
The win32-tutorial shows how to create a device inside a win32 window !!!
So you can use this tutorial and instead of the creation of the window you can use the handle directly...
Or look in the docu for createDeviceEx(...), this is used for this...
EDIT:
Yeah, here is a little demo that runs Irrlicht inside Notepad !!!
Run this program and open Notepad...
This can be done with any window you got a handle from (all Windows objects like buttons etc. are derived from the class window and can be used for this as long as you got the handle of it)...
The win32-tutorial shows how to create a device inside a win32 window !!!
So you can use this tutorial and instead of the creation of the window you can use the handle directly...
Or look in the docu for createDeviceEx(...), this is used for this...
EDIT:
Yeah, here is a little demo that runs Irrlicht inside Notepad !!!
Run this program and open Notepad...
Code: Select all
#include <windows.h>
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main(){
HWND wnd = 0;
while(!wnd){
wnd = FindWindow("Notepad", NULL);
if(wnd) wnd = GetWindow(wnd, GW_CHILD);
Sleep(10);
}
SIrrlichtCreationParameters ppp;
ppp.AntiAlias = false;
ppp.Bits = 16;
ppp.DriverType = EDT_DIRECT3D9;
ppp.EventReceiver = 0;
ppp.Fullscreen = false;
ppp.HighPrecisionFPU = false;
ppp.Stencilbuffer = false;
ppp.Vsync = false;
ppp.WindowSize = dimension2d<s32>(800, 600);
ppp.WindowId = (s32)wnd;
IrrlichtDevice *device = createDeviceEx(ppp);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
ISceneNode* node = smgr->addCubeSceneNode(10);
node->setPosition(vector3df(0, -50, 50));
ICameraSceneNode* cam = smgr->addCameraSceneNode();
cam->setTarget(vector3df(0, -50, 50));
while(device->run()){
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Last edited by Acki on Fri Jan 16, 2009 4:19 pm, edited 1 time in total.
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 2
- Joined: Sun Dec 10, 2006 8:53 pm
This plain text is called C/C++ source code !!!
Make an exe file out of it...
Make an exe file out of it...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Well, the main problem would be to find the correct window you want to use...
Especially for a internet browser, because there are many different browsers out there...
For example to use it with Mozilla's Firefox you'll have to do it this way:This will run Irrlicht inside the Firefox window (no webpage needed to load) !!!
You see there are many child windows you have to enumerate until you get to the main screen of Firefox !!!
And if someone uses MSIE it's again a different number of child windows and maybe you'll have to add for example an empty Java applet to get the HWND off...
Especially for a internet browser, because there are many different browsers out there...
For example to use it with Mozilla's Firefox you'll have to do it this way:
Code: Select all
HWND wnd = 0;
while(!wnd){
wnd = FindWindow(NULL, "Mozilla Firefox");
if(wnd){ // Firefox found
Sleep(100);
// find the main area
wnd = GetWindow(wnd, GW_CHILD);
wnd = GetWindow(wnd, GW_CHILD);
wnd = GetWindow(wnd, GW_HWNDNEXT);
wnd = GetWindow(wnd, GW_HWNDNEXT);
wnd = GetWindow(wnd, GW_CHILD);
wnd = GetWindow(wnd, GW_CHILD);
wnd = GetWindow(wnd, GW_CHILD);
wnd = GetWindow(wnd, GW_CHILD);
}
}
You see there are many child windows you have to enumerate until you get to the main screen of Firefox !!!
And if someone uses MSIE it's again a different number of child windows and maybe you'll have to add for example an empty Java applet to get the HWND off...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Thank you Acki,
I will give this to a friend to test it, because it doesn't run on my computer.
It is maybe too old. I don't have the "windows.h" file, but this is neccessary to include it.
Maybe my friend could make a browser-plugin for irrlicht engine using this code, as long as it doesn't work with jirr. There are too many errors (like security errors "access denied" for the applet or "class not found").
I'll give it up now.
Maybe I have to wait until someone will write a browser-plugin.
Sorry, I didn't expect things would become this complicated.
Greetings
Abraxas
I will give this to a friend to test it, because it doesn't run on my computer.
It is maybe too old. I don't have the "windows.h" file, but this is neccessary to include it.
Maybe my friend could make a browser-plugin for irrlicht engine using this code, as long as it doesn't work with jirr. There are too many errors (like security errors "access denied" for the applet or "class not found").
I'll give it up now.
Maybe I have to wait until someone will write a browser-plugin.
Sorry, I didn't expect things would become this complicated.
Greetings
Abraxas