Irrlicht with wxWidget, no win32
Posted: Sat Dec 24, 2005 8:27 pm
Exist a tutorial example show how to use irrlicht with win32 application, there are a tutorial or an exemple with wxwidget?
Thank you.
Selles
Thank you.
Selles
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
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(¶ms);
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();
}
Code: Select all
param.EventReceiver=&evento;
1. Does "params.WindowId" above require a int WINAPI WinMain method?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(¶ms); 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(); }
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 /////////////////////////////////////
///////////////////////////////////////////////////////