Page 1 of 1

Irrlicht with wxWidget, no win32

Posted: Sat Dec 24, 2005 8:27 pm
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

Posted: Sat Dec 24, 2005 9:24 pm
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 :)

Posted: Mon Dec 26, 2005 2:31 pm
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();
}


Posted: Thu Jan 26, 2006 7:37 am
by Guest
Thanks Zenaku and GFXstyLER!!!

Posted: Wed Mar 15, 2006 1:30 am
by selles
other doubt..

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

thanks.

Posted: Fri Mar 17, 2006 5:41 am
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.

just curious

Posted: Sat Mar 18, 2006 12:37 am
by juli
did you get wx widget working with irrlicht, how did you do it?

Posted: Sat Mar 18, 2006 1:29 am
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:

Posted: Fri Aug 11, 2006 5:16 am
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?

param.WindowId

Posted: Fri Aug 25, 2006 6:16 am
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.

Posted: Wed Aug 30, 2006 9:58 am
by kornerr
Can anyone provide the real C++ code to integrate Irrlicht into wxWidgets? I want to create a map editor.
Thanks.

Here you go ...

Posted: Wed Aug 30, 2006 5:02 pm
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 /////////////////////////////////////
///////////////////////////////////////////////////////

does this create a seperate window?

Posted: Wed Aug 30, 2006 9:06 pm
by juliusctw
hello


Does this code create a seperate window? or its embedded directly in irrlicht like the other gui s ?

Re:

Posted: Thu Aug 31, 2006 4:40 am
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

Posted: Thu Aug 31, 2006 9:44 pm
by jonasrf
Sweet thanks man!!! :D Your a life saver.