Irrlicht with wxWidget, no win32

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

Irrlicht with wxWidget, no win32

Post by Guest »

Exist a tutorial example show how to use irrlicht with win32 application, there are a tutorial or an exemple with wxwidget?

Thank you.

Selles
Guest

Post by Guest »

there is not, but i asked some time ago if irrlicht can be used with wxwidgets and the answer was: if wxwidgets provides a hwnd (window handle) then it should be possible.

you could try it out by using the irrlicht tutorial for win32 and try it the same way with wxwidgets.

maybe that helps you a bit :)
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

I don't have an actual C++ example to show you, but it does work.

Code: Select all

 

//psuedo code

wxDialog *Dlg = new wxDialog(-1, "Test", wxPoint(0,0), wxSize(400,400));

SIrrlichtCreationParameters params;

params.WindowId = Dlg->GetHandle();
params.DriverType = EDT_OPENGL;
params.WindowSize = dimension2d(200,200);

device = createDeviceEx(&params);

while(device->run())
{
    Dlg->Refresh(); // <- bad ;)   It would be better to actually implement 
                           // a real messge loop, but this little trick does work
    driver->beginScene();
    smgr->drawAll();
    driver->EndScene();
}

Guest

Post by Guest »

Thanks Zenaku and GFXstyLER!!!
selles
Posts: 8
Joined: Sun Jul 03, 2005 9:21 pm

Post by selles »

other doubt..

how I do to create this in a wxPanel..O not get work in this context..

thanks.
Guest

Post by Guest »

the problem is that the event associated to the object "param"

Code: Select all

param.EventReceiver=&evento;
..doesn't work when the object that gave the handle has a parent and when the object doesn't have a parent he sees an independent frame and appears titlebar

I didn't get to do the window of the irrlicht inside of a frame without it occupies the whole window and with the event working. .

does anybody know it what it happens?

please help me.

Thank you.
juli

just curious

Post by juli »

did you get wx widget working with irrlicht, how did you do it?
Guest

Post by Guest »

look in 3rd reply in this topic, there are some errors ..

params.WindowId = Dlg->GetHandle(); //<-don´t work
params.WindowId =wx_reinterpret_cast(s32, Dlg->GetHandle()); //<-work

params.WindowSize = dimension2d(200,200); //<-don't work
params.WindowSize = dimension2d<s32>(200,200); //<-work

so, that work well, I think..

but don't wait to use events because I think that nobody get it.. :wink:
jonasrf
Posts: 25
Joined: Fri Jan 13, 2006 6:18 am
Contact:

Post by jonasrf »

Have you been able to get this to work all the way? If so could you please help me get it to work also?
KevinCain
Posts: 18
Joined: Tue Aug 15, 2006 5:00 pm
Location: San Francisco

param.WindowId

Post by KevinCain »

zenaku wrote:I don't have an actual C++ example to show you, but it does work.

Code: Select all

 

//psuedo code

wxDialog *Dlg = new wxDialog(-1, "Test", wxPoint(0,0), wxSize(400,400));

SIrrlichtCreationParameters params;

params.WindowId = Dlg->GetHandle();
params.DriverType = EDT_OPENGL;
params.WindowSize = dimension2d(200,200);

device = createDeviceEx(&params);

while(device->run())
{
    Dlg->Refresh(); // <- bad ;)   It would be better to actually implement 
                           // a real messge loop, but this little trick does work
    driver->beginScene();
    smgr->drawAll();
    driver->EndScene();
}

1. Does "params.WindowId" above require a int WINAPI WinMain method?

2. Also, in Nico's win32 Irrlicht tutorial, the usage seems to be "param.WindowId" (not params). What is the difference in usage here?

Many thanks for any helpful hints.
kornerr
Posts: 245
Joined: Thu Jul 06, 2006 9:57 am
Location: Russia, Siberia, Kemerovo
Contact:

Post by kornerr »

Can anyone provide the real C++ code to integrate Irrlicht into wxWidgets? I want to create a map editor.
Thanks.
Open Source all the way, baby ;)
OSRPG
Mobeen
Posts: 37
Joined: Sat Mar 25, 2006 9:31 am
Location: Karachi, PAKISTAN

Here you go ...

Post by Mobeen »

This is a minimalistic app based on the win32 sample. This has been tested on MS VisualStudio.Net 2003. If you find any mistake in it do let me know.
Thanks
Mobeen

Code: Select all

///////////////////////////////////////////////////////
//MyHeader.h //////////////////////////////////////////
///////////////////////////////////////////////////////
#ifndef MY_HEADER
#define MY_HEADER

#include <wx/wx.h>
#include <irrlicht.h>

using namespace irr;
using namespace irr::scene;
using namespace irr::video;

//linker input file
#pragma comment(lib, "irrlicht.lib")

//Menu id
#define ID_EXIT  1001

class MyApp: public wxApp
{	
	public:
		bool OnInit();
};

class MyFrame: public wxFrame
{
	protected:
		IrrlichtDevice* device;
		ISceneManager* smgr;
		IVideoDriver* driver;

	public:
		MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
		~MyFrame();
		void OnExit(wxCommandEvent& event);
		virtual void OnIdle(wxIdleEvent& event);
		DECLARE_EVENT_TABLE()
};
#endif
///////////////////////////////////////////////////////
//End of MyHeader.h ///////////////////////////////////
///////////////////////////////////////////////////////

///////////////////////////////////////////////////////
//Main.cpp  ///////////////////////////////////////////
///////////////////////////////////////////////////////
#include "MyHeader.h"

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(ID_EXIT,OnExit)
EVT_IDLE(OnIdle)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp) 

bool MyApp::OnInit()
{
	MyFrame *frame = new MyFrame( "Hello World in wxWidgets", wxPoint(50,50), wxSize(450,340));
	frame->Show(TRUE);
	SetTopWindow(frame);
	return TRUE;
} 

void MyFrame::OnIdle(wxIdleEvent& event)
{
	if(device->run())
	{			
		int W=0;
		int H=0;
		
		GetClientSize(&W,&H);
		driver->setViewPort(irr::core::rect<s32>(0,0,W,H)); 
		driver->beginScene(true, true, 0);
		smgr->drawAll();
		driver->endScene();			
	}		
	Refresh(false);
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
	wxMenu *menuFile = new wxMenu;
	menuFile->Append( ID_EXIT, "E&xit" );

	wxMenuBar *menuBar = new wxMenuBar;
	menuBar->Append( menuFile, "&File" );

	SetMenuBar( menuBar );
	
	//Irrlicht stuff
	irr::SIrrlichtCreationParameters param;
	param.WindowSize =   irr::core::dimension2d<s32>(size.x,size.y);
	param.WindowId = reinterpret_cast<s32>((HWND)GetHandle()); // hColorButton	
	param.DriverType = video::EDT_DIRECT3D9;

	device = irr::createDeviceEx(param);

	// setup a simple 3d scene
	smgr = device->getSceneManager();
	driver = device->getVideoDriver();

	scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
	cam->setTarget(core::vector3df(0,0,0));

	scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(core::vector3df(0,10,0), 30.0f);
	cam->addAnimator(anim);
	anim->drop();

	scene::ISceneNode* cube = smgr->addCubeSceneNode(20);

	cube->setMaterialTexture(0, driver->getTexture("media/rockwall.bmp"));
	cube->setMaterialFlag( video::EMF_LIGHTING, false );
	smgr->addSkyBoxSceneNode(
		driver->getTexture("media/irrlicht2_up.jpg"),
		driver->getTexture("media/irrlicht2_dn.jpg"),
		driver->getTexture("media/irrlicht2_lf.jpg"),
		driver->getTexture("media/irrlicht2_rt.jpg"),
		driver->getTexture("media/irrlicht2_ft.jpg"),
		driver->getTexture("media/irrlicht2_bk.jpg"));
}

void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
	Close(TRUE);	
}

MyFrame::~MyFrame()
{
	device->drop();
}
///////////////////////////////////////////////////////
//End of Main.cpp /////////////////////////////////////
///////////////////////////////////////////////////////
Proud to be a PAKISTANI
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

does this create a seperate window?

Post by juliusctw »

hello


Does this code create a seperate window? or its embedded directly in irrlicht like the other gui s ?
Mobeen
Posts: 37
Joined: Sat Mar 25, 2006 9:31 am
Location: Karachi, PAKISTAN

Re:

Post by Mobeen »

This creates a window having graphics setup in its client area not as a separate window just like in the win32 sample. Take a look here
Image
Proud to be a PAKISTANI
jonasrf
Posts: 25
Joined: Fri Jan 13, 2006 6:18 am
Contact:

Post by jonasrf »

Sweet thanks man!!! :D Your a life saver.
Post Reply