In first, MVSCPP 2003 is new for me. Iam a msvcpp2003-Beginner - and iam german lol.
There is a small programmers language named XProfan (http://xprofan.com(only.german.sorry)) - its an interpreter - picoCompiler (notNative).
I tried to use Irrlicht with this language (Xprofan) - but its still impossible.
Then - some evening - i opened the Terrainexample in msvcpp2003 - i simply modified the compileroptions to export this terrainexample as dll.
And - it works!
I can load and call DLL-Funktions with XProfan.
This is the old main{}:
Code: Select all
;extern "C" __declspec(dllexport) __stdcall initor() {
;video::E_DRIVER_TYPE driverType = video::EDT_DIRECTX9;
driverType = video::EDT_OPENGL;
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(640,480));
if (device == 0) return 11; // could not create selected driver
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
//env->addImage(driver->getTexture("../../media/irrlichtlogoalpha.tga"),
// core::position2d<s32>(10,10));
//gui::IGUIStaticText* text = env->addStaticText(
// L"Press 'W' to change wireframe mode",
// core::rect<s32>(10,465,200,475), true);
//text->setOverrideColor(video::SColor(100,255,255,255));
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f);
camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
camera->setFarValue(12000.0f);
// disable mouse cursor
device->getCursorControl()->setVisible(false);
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40, 9.4f, 40));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("terrain-heightmap.bmp"));
//terrain->scaleTexture(1.0f);
scene::ITriangleSelector* selector
= smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
MyEventReceiver receiver(terrain);
//device->setEventReceiver(&receiver);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, 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"));
*/
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
while( (device->run()) & (msg_drop==0) ) {
// ;if (device->isWindowActive()) {
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
// }
}
device->drop();
return 55;
}
Simply - what can i do? This "prinzip" is working - but i dunno whats wrong because the first run of smgr->drawAll() works fine - but not the second.
Plz help me.
Thank you, iF.
________________________
And here the complete Codes if someone needs:
The XProfan-Code:
Code: Select all
{$cleq}
$U thread.pcu = thread.
Def gsk(1) !"USER32","GetAsyncKeyState"
Declare tdll&
Def hi(0) !"12.TerrainRendering.dll", "_hi@0"
Def initor(0) !"12.TerrainRendering.dll", "_initor@0"
Def exitor(0) !"12.TerrainRendering.dll", "_exitor@0"
Proc TerrainRenderingUseDLL
tdll& = UseDLL("12.TerrainRendering.dll")
EndProc
Proc TerrainRenderingFreeDLL
FreeDLL tdll&
EndProc
cls
print "hallo welt"
TerrainRenderingUseDLL
print hi()
thread.start 1
print initor()
thread.stop 1
//TerrainRenderingFreeDLL
print "done"
sleep 1000
end
proc thread.do
settext %hwnd,str$(&gettickcount)
if gsk(32)<0
print "exitor:",exitor()
endif
sleep 0
endproc
Code: Select all
/*
This tutorial will briefly show how to use the terrain renderer of Irrlicht. It will also
show the terrain renderer triangle selector to be able to do collision detection with
terrain.
Note that the Terrain Renderer in Irrlicht is based on Spintz' GeoMipMapSceneNode, lots
of thanks go to him.
In the beginning there is nothing special. We include the needed header files and create
an event listener to listen if the user presses the 'W' key so we can switch to wireframe
mode.
*/
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
class MyEventReceiver : public IEventReceiver
{
public:
MyEventReceiver(scene::ISceneNode* terrain)
{
// store pointer to terrain so we can change its drawing mode
//Terrain = terrain;
}
bool OnEvent(SEvent event)
{
// check if user presses the key 'W'
/*if (event.EventType == irr::EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == irr::KEY_KEY_W && !event.KeyInput.PressedDown)
{
// switch wire frame mode
Terrain->setMaterialFlag(video::EMF_WIREFRAME, !Terrain->getMaterial(0).Wireframe);
return true;
}
*/
return false;
}
private:
scene::ISceneNode* Terrain;
};
/*
The start of the main function starts like in most other example. We ask the user
for the desired renderer and start it up.
*/
int main()
{
// let user select driver type
}
;extern "C" __declspec(dllexport) __stdcall hi() {
;return 1
;}
;extern int msg_drop =0
;extern "C" __declspec(dllexport) __stdcall exitor() {
msg_drop=1;
return 1;
;}
;extern "C" __declspec(dllexport) __stdcall initor() {
;video::E_DRIVER_TYPE driverType = video::EDT_DIRECTX9;
driverType = video::EDT_OPENGL;
IrrlichtDevice* device = createDevice(driverType, core::dimension2d<s32>(640,480));
if (device == 0) return 11; // could not create selected driver
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* env = device->getGUIEnvironment();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
//env->addImage(driver->getTexture("../../media/irrlichtlogoalpha.tga"),
// core::position2d<s32>(10,10));
//gui::IGUIStaticText* text = env->addStaticText(
// L"Press 'W' to change wireframe mode",
// core::rect<s32>(10,465,200,475), true);
//text->setOverrideColor(video::SColor(100,255,255,255));
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,1200.0f);
camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
camera->setTarget(core::vector3df(2397*2,343*2,2700*2));
camera->setFarValue(12000.0f);
// disable mouse cursor
device->getCursorControl()->setVisible(false);
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40, 9.4f, 40));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("terrain-heightmap.bmp"));
//terrain->scaleTexture(1.0f);
scene::ITriangleSelector* selector
= smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop();
MyEventReceiver receiver(terrain);
//device->setEventReceiver(&receiver);
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, 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"));
*/
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
while( (device->run()) & (msg_drop==0) ) {
// ;if (device->isWindowActive()) {
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
// }
}
device->drop();
return 55;
}