bonjour tout le monde,
je continu mon programme et suite aux remarques que l'on m'a faite j'ai décidé de transformer une grosse partie de mon code en C++ pur ( il y a encore un tronçon du code qui n'est pas transformer mais à la limite celui là je m'en fiche).
Je compile mon projet mais quand je veux acceder a une de mes toolbox, le programme plante et je comprend pas pourquoi.
Voici le code:
main.cpp
#include <irrlicht.h> #include <iostream> #include "toolbox.h" using namespace irr; using namespace gui; #pragma comment(lib, "Irrlicht.lib") Toolbox* Toolbox; IrrlichtDevice *Device = 0; core::stringc StartUpModelFile; core::stringw MessageText; core::stringw Caption; scene::IAnimatedMeshSceneNode* Model = 0; scene::ISceneNode* SkyBox = 0; scene::ICameraSceneNode* Camera[2] = { 0, 0}; irr::gui::IGUICheckBox* cbCarre; irr::gui::IGUICheckBox* cbRond; irr::gui::IGUICheckBox* cbLosange; /* toggles between various cameras */ void setActiveCamera ( scene::ICameraSceneNode* newActive ) { if ( 0 == Device ) return; scene::ICameraSceneNode* active = Device->getSceneManager()->getActiveCamera (); newActive->setInputReceiverEnabled ( true ); Device->getSceneManager()->setActiveCamera ( newActive ); } void showAboutText() { // create modal message box with the text // loaded from the xml file. Device->getGUIEnvironment()->addMessageBox( Caption.c_str(), MessageText.c_str()); } void loadModel(const c8* fn) { // modify the name if it a .pk3 file core::stringc filename ( fn ); core::stringc extension; core::getFileNameExtension ( extension, filename ); extension.make_lower(); // if a texture is loaded apply it to the current model.. if ( extension == ".jpg" || extension == ".png" || extension == ".tga" || extension == ".pcx" || extension == ".psd" || extension == ".bmp" ) { video::ITexture * texture = Device->getVideoDriver()->getTexture( filename.c_str() ); if ( texture && Model ) { // always reload texture Device->getVideoDriver()->removeTexture ( texture ); texture = Device->getVideoDriver()->getTexture( filename.c_str() ); Model->setMaterialTexture ( 0, texture ); } return; } // if a archive is loaded add it to the FileSystems.. if ( extension == ".pk3" || extension == ".zip" ) { Device->getFileSystem()->addZipFileArchive( filename.c_str () ); return; } // load a model into the engine if (Model) Model->remove(); Model = 0; scene::IAnimatedMesh* m = Device->getSceneManager()->getMesh( filename.c_str() ); if (!m) { // model could not be loaded if (StartUpModelFile != filename) Device->getGUIEnvironment()->addMessageBox( Caption.c_str(), L"The model could not be loaded. " \ L"Maybe it is not a supported file format."); return; } // set default material properties Model = Device->getSceneManager()->addAnimatedMeshSceneNode(m); Model->setMaterialFlag(video::EMF_LIGHTING, false); // Model->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false); Model->setDebugDataVisible(scene::EDS_OFF); Model->setAnimationSpeed(30); } class MyEventReceiver : public IEventReceiver { public: virtual bool OnEvent(SEvent event) { // Escape swaps Camera Input if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.Key == irr::KEY_ESCAPE && event.KeyInput.PressedDown == false) { if ( Device ) { scene::ICameraSceneNode * camera = Device->getSceneManager()->getActiveCamera (); if ( camera ) { camera->setInputReceiverEnabled ( !camera->isInputReceiverEnabled() ); } return true; } } if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown) { switch(event.KeyInput.Key) { case KEY_F1: showAboutText(); return true; } if (event.KeyInput.Control) { switch(event.KeyInput.Key) { case KEY_KEY_A: Toolbox->createToolBoxForet(); return true; case KEY_KEY_C: Toolbox->createToolBoxCiel(); return true; case KEY_KEY_R: Toolbox->createToolBoxRelief(); return true; case KEY_KEY_O: Toolbox->createToolBoxEau(); return true; case KEY_KEY_I: Toolbox->createToolBoxInsertion(); return true; } } } if (event.EventType == EET_GUI_EVENT) { s32 id = event.GUIEvent.Caller->getID(); IGUIEnvironment* env = Device->getGUIEnvironment(); switch(event.GUIEvent.EventType) { case EGET_MENU_ITEM_SELECTED: { // a menu item was clicked IGUIContextMenu* menu = (IGUIContextMenu*)event.GUIEvent.Caller; s32 id = menu->getItemCommandId(menu->getSelectedItem()); switch(id) { case 100: // File -> Open Model env->addFileOpenDialog(L"Please select a model file to open"); break; case 101: // File -> Set Model Archive env->addFileOpenDialog(L"Please select your game archive/directory"); break; case 200: // File -> Quit Device->closeDevice(); break; case 300: // View -> Skybox SkyBox->setVisible(!SkyBox->isVisible()); break; case 400: // View -> Debug Information if (Model) Model->setDebugDataVisible(Model->isDebugDataVisible() ? scene::EDS_OFF : scene::EDS_FULL); break; case 401: Toolbox->createToolBoxEau(); break; case 402: Toolbox->createToolBoxRelief(); break; case 403: Toolbox->createToolBoxCiel(); break; case 410: Toolbox->createToolBoxForet(); break; case 420: Toolbox->createToolBoxInsertion(); break; case 500: // Help->About showAboutText(); break; case 610: // View -> Material -> Solid if (Model) Model->setMaterialType(video::EMT_SOLID); break; case 620: // View -> Material -> Transparent if (Model) Model->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); break; case 630: // View -> Material -> Reflection if (Model) Model->setMaterialType(video::EMT_SPHERE_MAP); break; case 1000: setActiveCamera ( Camera[0] ); break; case 1100: setActiveCamera ( Camera[1] ); break; } break; } case EGET_FILE_SELECTED: { // load the model file, selected in the file open dialog IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller; loadModel(core::stringc(dialog->getFilename()).c_str()); } case EGET_SCROLL_BAR_CHANGED: /* control skin transparency if (id == 104) { s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); for (s32 i=0; i<irr::gui::EGDC_COUNT ; ++i) { video::SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i); col.setAlpha(pos); env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col); } } break;*/ case EGET_CHECKBOX_CHANGED: { //Si une des checkBox est cochée, décocher les autres switch (id) { case 1: cbCarre->setChecked(true); cbRond->setChecked(false); cbLosange->setChecked(false); break; case 2: cbCarre->setChecked(false); cbRond->setChecked(true); cbLosange->setChecked(false); break; case 3: cbCarre->setChecked(false); cbRond->setChecked(false); cbLosange->setChecked(true); break; } } case EGET_BUTTON_CLICKED: switch(id) { /*case 1101: { // set scale gui::IGUIElement* root = env->getRootGUIElement(); core::vector3df scale; core::stringc s; s = root->getElementFromId(901, true)->getText(); scale.X = (f32)atof(s.c_str()); s = root->getElementFromId(902, true)->getText(); scale.Y = (f32)atof(s.c_str()); s = root->getElementFromId(903, true)->getText(); scale.Z = (f32)atof(s.c_str()); if (Model) Model->setScale(scale); } break;*/ case 1102: env->addFileOpenDialog(L"Please select a model file to open"); break; case 1104: Toolbox->createToolBoxEau(); break; case 1105: Toolbox->createToolBoxRelief(); break; case 1106: Toolbox->createToolBoxCiel(); break; case 1107: Toolbox->createToolBoxForet(); break; case 1108: Toolbox->createToolBoxInsertion(); break; case 1109: showAboutText(); break; } break; } } return false; } }; int main() { // ask user for driver video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; // create device and exit if creation failed MyEventReceiver receiver; Device = createDevice(driverType, core::dimension2d<s32>(800, 600), 16, false, false, false, &receiver); if (Device == 0) return 1; // could not create selected driver. Device->setResizeAble(true); Device->setWindowCaption(L"AoL_M"); video::IVideoDriver* driver = Device->getVideoDriver(); IGUIEnvironment* env = Device->getGUIEnvironment(); scene::ISceneManager* smgr = Device->getSceneManager(); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); smgr->addLightSceneNode(); smgr->addLightSceneNode(0, core::vector3df(50,-50,100), video::SColorf(1.0f,1.0f,1.0f),20000); // read configuration from xml file io::IXMLReader* xml = Device->getFileSystem()->createXMLReader( "aide.xml"); while(xml && xml->read()) { switch(xml->getNodeType()) { case io::EXN_TEXT: // in this xml file, the only text which occurs is the messageText MessageText = xml->getNodeData(); break; case io::EXN_ELEMENT: { if (core::stringw("startUpModel") == xml->getNodeName()) StartUpModelFile = xml->getAttributeValue(L"file"); else if (core::stringw("messageText") == xml->getNodeName()) Caption = xml->getAttributeValue(L"caption"); } break; } } if (xml) xml->drop(); // don't forget to delete the xml reader // set a nicer font IGUISkin* skin = env->getSkin(); IGUIFont* font = env->getFont("fonthaettenschweiler.bmp"); if (font) skin->setFont(font); // create menu gui::IGUIContextMenu* menu = env->addMenu(); menu->addItem(L"Fichier", -1, true, true); menu->addItem(L"Edition", -1, true, true); menu->addItem(L"Outils", -1, true, true); menu->addItem(L"Vues", -1, true, true); menu->addItem(L"Aide", -1, true, true); gui::IGUIContextMenu* submenu; submenu = menu->getSubMenu(0); submenu->addItem(L"Nouveau", 100); submenu->addItem(L"Ouvrir", 101); submenu->addItem(L"Enregistrer", 102); submenu->addItem(L"Enregistrer sous", 103); submenu->addItem(L"Revenir a la derniere sauvegarde", 104); submenu->addItem(L"Explorer les fichiers temporaires", 105); submenu->addSeparator(); submenu->addItem(L"Quitter", 200); submenu = menu->getSubMenu(1); submenu->addItem(L"Annuler", 300); submenu->addItem(L"Repeter", 310); submenu->addItem(L"Copier", 320 ); submenu->addItem(L"Coller", 330); submenu->addItem(L"Couper", 340); submenu->addItem(L"Generer", 350); submenu->addItem(L"Redimensionner", 360); submenu->addItem(L"Dupliquer", 370); submenu = menu->getSubMenu(2); submenu->addItem(L"Terrain",-1, true, true); submenu->addItem(L"Foret", 410); submenu->addItem(L"Insertion", 420); submenu = submenu->getSubMenu(0); submenu->addItem(L"Eau", 401); submenu->addItem(L"Relief", 402); submenu->addItem(L"Ciel", 403); submenu = menu->getSubMenu(3); submenu->addItem(L"Rendu", 500); submenu->addItem(L"Mode", -1, true, true); submenu = submenu->getSubMenu(1); submenu->addItem(L"Solide", 1000); submenu->addItem(L"Fil de fer", 1010); submenu->addItem(L"Avec texture", 1020); submenu= menu->getSubMenu(3); submenu->addItem(L"Camera", -1, true, true); submenu->addItem(L"Vue globale", 510); submenu = submenu->getSubMenu(2); submenu->addItem(L"FPS", 1100); submenu->addItem(L"Normale", 1110); submenu = menu->getSubMenu(4); submenu->addItem(L"Documentation", 600); submenu->addSeparator(); submenu->addItem(L"A propos", 610); // create toolbar gui::IGUIToolBar* bar = env->addToolBar(); video::ITexture* image = driver->getTexture("open.png"); bar->addButton(1102, 0, L"Ouvrir",image, 0, false, true); image = driver->getTexture("eau.png"); bar->addButton(1104, 0, L"Outil eau(CTRL+o)",image, 0, false, true); image = driver->getTexture("relief.png"); bar->addButton(1105, 0, L"Outil Relief(CTRL+R)",image, 0, false, true); image = driver->getTexture("ciel.png"); bar->addButton(1106, 0, L"Outil Ciel(CTRL+C)",image, 0, false, true); image = driver->getTexture("arbre.png"); bar->addButton(1107, 0, L"Outil Arbre(CTRL+A)",image, 0, false, true); image = driver->getTexture("insertion.png"); bar->addButton(1108, 0, L"Outil Insertion(CTRL+I)",image, 0, false, true); image = driver->getTexture("help.png"); bar->addButton(1109, 0, L"Aide(F1)", image, 0, false, true); //disable alpha for (s32 i=0; i<gui::EGDC_COUNT ; ++i) { video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i); col.setAlpha(255); env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col); } // add a camera scene node Camera[0] = smgr->addCameraSceneNodeMaya(); Camera[1] = smgr->addCameraSceneNodeFPS(); setActiveCamera ( Camera[0] ); // draw everything while(Device->run() && driver) { if (Device->isWindowActive()) { driver->beginScene(true, true, video::SColor(150,0,0,0)); smgr->drawAll(); env->drawAll(); driver->endScene(); } else Device->yield(); } Device->drop(); return 0; }
toolbox.cpp
#include <irrlicht.h> #include <iostream> #include "toolbox.h" using namespace irr; using namespace gui; Toolbox::Toolbox() { irr::scene::ISceneNode* node = 0; IrrlichtDevice *Device = 0; } void Toolbox::createToolBoxEau() { // enlève la toolbox si elle est déjà présente IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* e = root->getElementFromId(5000, true); if (e) e->remove(); // création de la fenêtre de la tool box wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Eau", 0, 5000); // création du controle par tab tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Format"); IGUITab* t2 = tab->addTab(L"Texture"); //Remplissage de l'onglet Format //ajout de checkbox env->addStaticText(L"Format", core::rect<s32>(10,30,100,50), false, false, t1); cbCarre = env->addCheckBox(true, core::rect<s32>(10,55,200,75), t1, 1, L"Carre"); cbRond = env->addCheckBox(false, core::rect<s32>(10,80,200,100), t1, 2, L"Rond"); cbLosange = env->addCheckBox(false, core::rect<s32>(10,105,200,125), t1, 3, L"Losange"); //Ajout d'une barre défilante env->addStaticText(L"Taille", core::rect<s32>(10,150,150,175), false, false, t1); IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,175,150,190), t1, 104); scrollbar->setMax(16); //Remplissage de l'onglet Texture env->addStaticText(L"Niveau de l'eau", core::rect<s32>(10,30,100,50),false,false, t2); env->addEditBox(L"1.0", core::rect<s32>(40,50,100,70), true, t2, 911); env->addStaticText(L"Choix de la texture", core::rect<s32>(10,100,110,120), false, false, t2); IGUIComboBox* box = env->addComboBox(core::rect<s32>(10,120,150,140), t2); box->addItem(L"Eau 1"); box->addItem(L"Eau 2"); box->addItem(L"Eau 3"); box->addItem(L"Fond marin 1"); box->addItem(L"Fond marin 2"); env->addButton(core::rect<s32>(40,200,150,250), t2, 1101, L"Valider"); std::cout<< "tb eau 100"; } void Toolbox::createToolBoxCiel() { //Atmosphère + nuage IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* a = root->getElementFromId(5100, true); if (a) a->remove(); IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Ciel", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Atmosphere"); IGUITab* t2 = tab->addTab(L"Nuage"); std::cout<< "tb ciel 100"; } void Toolbox::createToolBoxRelief() { //Altitude + sol + relief IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* b = root->getElementFromId(5200, true); if (b) b->remove(); IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Relief", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Altitude"); IGUITab* t2 = tab->addTab(L"Relief"); //Implémentation de l'onglet Altitude env->addStaticText(L"Choix de l'altitude", core::rect<s32>(10,30,105,55), false, false, t1); env->addEditBox(L"1.0", core::rect<s32>(40,50,100,70),true, t1, 912); env->addStaticText(L"Choix de la texture", core::rect<s32>(10,80,155,95), false, false, t1); IGUIComboBox* box = env->addComboBox(core::rect<s32>(10,100,150,120), t1); box->addItem(L"Herbe 1"); box->addItem(L"Herbe 2"); box->addItem(L"Herbe 3"); box->addItem(L"Sable 1"); box->addItem(L"Sable 2"); box->addItem(L"Neige 1"); box->addItem(L"Neige 2"); box->addItem(L"Roche 1"); box->addItem(L"Roche 2"); box->addItem(L"Terre 1"); box->addItem(L"Terre 2"); env->addButton(core::rect<s32>(40,150,150,200), t1, 1101, L"Valider"); //Implémentation de l'onglet Relief env->addStaticText(L"Relief max", core::rect<s32>(10,30,105,55),false,false,t2); env->addEditBox(L"1.0", core::rect<s32>(40,50,100,70),true, t2, 913); env->addStaticText(L"Coefficient de lissage", core::rect<s32>(10,80,155,95), false, false, t2); env->addEditBox(L"1.0", core::rect<s32>(40,100,100,120),true, t2, 904); env->addButton(core::rect<s32>(40,150,150,200), t2, 1101, L"Valider"); std::cout<< "tb relief 100"; } void Toolbox::createToolBoxForet() { IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* c = root->getElementFromId(5300, true); if (c) c->remove(); IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Foret", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Format"); IGUITab* t2 = tab->addTab(L"Composition"); //ajout de checkbox env->addStaticText(L"Format", core::rect<s32>(10,30,100,50), false, false, t1); cbCarre = env->addCheckBox(true, core::rect<s32>(10,55,200,75), t1, 1, L"Carre"); cbRond = env->addCheckBox(false, core::rect<s32>(10,80,200,100), t1, 2, L"Rond"); cbLosange = env->addCheckBox(false, core::rect<s32>(10,105,200,125), t1, 3, L"Losange"); //Ajout d'une barre défilante env->addStaticText(L"Taille", core::rect<s32>(10,150,150,175), false, false, t1); IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,175,150,190), t1, 104); scrollbar->setMax(16); env->addStaticText(L"Type de foret", core::rect<s32>(10,200,150,225), false, false, t1); IGUIComboBox* box = env->addComboBox(core::rect<s32>(10,225,150,245), t1); box->addItem(L"Tempere 1"); box->addItem(L"Tempere 2"); box->addItem(L"Tempere 3"); box->addItem(L"Aleatoire"); env->addButton(core::rect<s32>(40,350,150,400), t1, 1101, L"Valider"); env->addStaticText(L"Pourcentage de chene", core::rect<s32>(10,30,150,50), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,50,100,70), true, t2, 905); env->addStaticText(L"Pourcentage de hetre", core::rect<s32>(10,70,150,90), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,90,100,110), true, t2, 906); env->addStaticText(L"Pourcentage de pin", core::rect<s32>(10,110,150,130), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,130,100,150), true, t2, 907); env->addStaticText(L"Pourcentage d'erable", core::rect<s32>(10,150,150,170), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,170,100,190), true, t2, 908); env->addStaticText(L"Pourcentage de bouleau", core::rect<s32>(10,190,150,210), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,210,100,230), true, t2, 909); env->addStaticText(L"Pourcentage de chene", core::rect<s32>(10,230,150,250), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,250,100,270), true, t2, 910); env->addStaticText(L"Nom", core::rect<s32>(75,270,150,290),false, false, t2); env->addEditBox(L"", core::rect<s32>(10,290,150,310), true, t2,911); env->addButton(core::rect<s32>(40,350,150,400), t2, 1101, L"Enregistrer"); std::cout<< "100"; std::cout<< "tb foret 100"; } void Toolbox::createToolBoxInsertion() { IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* d = root->getElementFromId(5400, true); if (d) d->remove(); wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Insertion", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Insertion"); listbox = env->addListBox(core::rect<s32>(10, 20, 170, 400), t1); std::cout<< "tb insertion 100"; }
toolbox.h
#include <irrlicht.h> #include <iostream> #ifndef DEF_TOOLBOX #define DEF_TOOLBOX class Toolbox { public: Toolbox(); ~Toolbox(); void createToolBoxEau(); void createToolBoxCiel(); void createToolBoxRelief(); void createToolBoxForet(); void createToolBoxInsertion(); private: irr::gui::IGUIWindow* wnd; irr::gui::IGUITabControl* tab; irr::gui::IGUICheckBox* cbCarre; irr::gui::IGUICheckBox* cbRond; irr::gui::IGUICheckBox* cbLosange; irr::gui::IGUIListBox* listbox; irr::scene::ISceneNode* node; irr::IrrlichtDevice *Device; }; #endif
Si j'avais eu plus de temps, j'aurais résolu le problème tout seul je pense mais comme je pars lundi matin, je veux être sur de le résoudre avant ce moment.
Merci d'avance
Dernière modification par vrag (22-07-2007 10:51:02)
Hors ligne
personne n'a d'idées ?
( désolé j'avais inverser toolbox.h et toolbox.cpp)
Hors ligne
J'ai ptêt mal vu, mais je crois que t'as oublié d'initialiser ta toolbox ^^
Hors ligne
comment ça ?
j'ai créer la toolbox au début du main si c'est ça que tu veux dire
Hors ligne
Ben je vois pas en tout cas. Tu la déclare là :
Toolbox* Toolbox;
Mais dans ton main, tu dois écrire un truc comme çà
Toolbox = new Toolbox();
Sinon, ton pointeur vaut NULL, c'est donc normal que çà plante
Hors ligne
quand je fais ça la compilation ne marche pas
Hors ligne
Ben c'est qu'il y a d'autres erreurs.
Juste pour être sur, tu l'as bien mis dans la fonction main ?
int main() { // ask user for driver video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; // create device and exit if creation failed MyEventReceiver receiver; Device = createDevice(driverType, core::dimension2d<s32>(800, 600), 16, false, false, false, &receiver); if (Device == 0) return 1; // could not create selected driver. Toolbox = new Toolbox();
Sinon, j'ai regardé un peu plus le code, changes ton constructeur comme çà :
Toolbox::Toolbox(IrrlichtDevice *irrDevice) { irr::scene::ISceneNode* node = 0; Device = irrDevice; }
Sinon le device de ta classe sera NULL aussi (c'est pas la même variable que celle de ton fichier main.cpp, elle est locale à la classe toolbox). Corriges déjà çà, je jettes encore un oeil au reste.
Hors ligne
ya deux choses qu'il me dit qui vont pas avec ton code:
la première dans le main, il me dit que Toolbox n'est pas un type
la seconde, pour le constructeur il me dit:
toolbox.cpp:21: error: prototype for `Toolbox::Toolbox(irr::IrrlichtDevice*)' does not match any in class `Toolbox'
toolbox.h:20: error: candidates are: Toolbox::Toolbox(const Toolbox&)
toolbox.h:23: error: Toolbox::Toolbox()
Hors ligne
Le constructeur que je t'ai proposé doit remplacé celui d'avant.
Dans toolbox.h
Toolbox::Toolbox(IrrlichtDevice *irrDevice);
Dans toolbox.cpp
Toolbox::Toolbox(IrrlichtDevice *irrDevice) { irr::scene::ISceneNode* node = 0; Device = irrDevice; }
Dans main.cpp, tu changes (comme le constructeur a changé)
Toolbox = new Toolbox(device);
Hors ligne
pour le constructeur c'est ce que j'avais fais mais sa marche pas
Hors ligne
Dans le main, au début il faut pas effacé
Toolbox* Toolbox;
Si tu l'as fait, çà explique l'erreur de type du fichier main
Hors ligne
il y est toujours.
J'ai fais tout ce que tu m'a dit mais la compilation plante encore. Il m'affiche :
toolbox.cpp:21: error: prototype for `Toolbox::Toolbox(irr::IrrlichtDevice*)' does not match any in class `Toolbox'
toolbox.h:20: error: candidates are: Toolbox::Toolbox(const Toolbox&)
toolbox.h:23: error: Toolbox::Toolbox()
c'est pas normal puisque j'ai bien déclarer le prototype comme il faut. Je comprend pas
Hors ligne
Bon j'ai fait un projet vite fait avec c::b pour tout debugger, çà compile et çà se lance (j'ai pas tester trop).
main.cpp
#include <irrlicht.h> #include <iostream> #include "toolbox.h" using namespace irr; using namespace gui; #pragma comment(lib, "Irrlicht.lib") Toolbox* toolbox; IrrlichtDevice *Device = 0; core::stringc StartUpModelFile; core::stringw MessageText; core::stringw Caption; scene::IAnimatedMeshSceneNode* Model = 0; scene::ISceneNode* SkyBox = 0; scene::ICameraSceneNode* Camera[2] = { 0, 0}; irr::gui::IGUICheckBox* cbCarre; irr::gui::IGUICheckBox* cbRond; irr::gui::IGUICheckBox* cbLosange; /* toggles between various cameras */ void setActiveCamera ( scene::ICameraSceneNode* newActive ) { if ( 0 == Device ) return; scene::ICameraSceneNode* active = Device->getSceneManager()->getActiveCamera (); newActive->setInputReceiverEnabled ( true ); Device->getSceneManager()->setActiveCamera ( newActive ); } void showAboutText() { // create modal message box with the text // loaded from the xml file. Device->getGUIEnvironment()->addMessageBox( Caption.c_str(), MessageText.c_str()); } void loadModel(const c8* fn) { // modify the name if it a .pk3 file core::stringc filename ( fn ); core::stringc extension; core::getFileNameExtension ( extension, filename ); extension.make_lower(); // if a texture is loaded apply it to the current model.. if ( extension == ".jpg" || extension == ".png" || extension == ".tga" || extension == ".pcx" || extension == ".psd" || extension == ".bmp" ) { video::ITexture * texture = Device->getVideoDriver()->getTexture( filename.c_str() ); if ( texture && Model ) { // always reload texture Device->getVideoDriver()->removeTexture ( texture ); texture = Device->getVideoDriver()->getTexture( filename.c_str() ); Model->setMaterialTexture ( 0, texture ); } return; } // if a archive is loaded add it to the FileSystems.. if ( extension == ".pk3" || extension == ".zip" ) { Device->getFileSystem()->addZipFileArchive( filename.c_str () ); return; } // load a model into the engine if (Model) Model->remove(); Model = 0; scene::IAnimatedMesh* m = Device->getSceneManager()->getMesh( filename.c_str() ); if (!m) { // model could not be loaded if (StartUpModelFile != filename) Device->getGUIEnvironment()->addMessageBox( Caption.c_str(), L"The model could not be loaded. " \ L"Maybe it is not a supported file format."); return; } // set default material properties Model = Device->getSceneManager()->addAnimatedMeshSceneNode(m); Model->setMaterialFlag(video::EMF_LIGHTING, false); // Model->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false); Model->setDebugDataVisible(scene::EDS_OFF); Model->setAnimationSpeed(30); } class MyEventReceiver : public IEventReceiver { public: virtual bool OnEvent(SEvent event) { // Escape swaps Camera Input if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.Key == irr::KEY_ESCAPE && event.KeyInput.PressedDown == false) { if ( Device ) { scene::ICameraSceneNode * camera = Device->getSceneManager()->getActiveCamera (); if ( camera ) { camera->setInputReceiverEnabled ( !camera->isInputReceiverEnabled() ); } return true; } } if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown) { switch(event.KeyInput.Key) { case KEY_F1: showAboutText(); return true; } if (event.KeyInput.Control) { switch(event.KeyInput.Key) { case KEY_KEY_A: toolbox->createToolBoxForet(); return true; case KEY_KEY_C: toolbox->createToolBoxCiel(); return true; case KEY_KEY_R: toolbox->createToolBoxRelief(); return true; case KEY_KEY_O: toolbox->createToolBoxEau(); return true; case KEY_KEY_I: toolbox->createToolBoxInsertion(); return true; } } } if (event.EventType == EET_GUI_EVENT) { s32 id = event.GUIEvent.Caller->getID(); IGUIEnvironment* env = Device->getGUIEnvironment(); switch(event.GUIEvent.EventType) { case EGET_MENU_ITEM_SELECTED: { // a menu item was clicked IGUIContextMenu* menu = (IGUIContextMenu*)event.GUIEvent.Caller; s32 id = menu->getItemCommandId(menu->getSelectedItem()); switch(id) { case 100: // File -> Open Model env->addFileOpenDialog(L"Please select a model file to open"); break; case 101: // File -> Set Model Archive env->addFileOpenDialog(L"Please select your game archive/directory"); break; case 200: // File -> Quit Device->closeDevice(); break; case 300: // View -> Skybox SkyBox->setVisible(!SkyBox->isVisible()); break; case 400: // View -> Debug Information if (Model) Model->setDebugDataVisible(Model->isDebugDataVisible() ? scene::EDS_OFF : scene::EDS_FULL); break; case 401: toolbox->createToolBoxEau(); break; case 402: toolbox->createToolBoxRelief(); break; case 403: toolbox->createToolBoxCiel(); break; case 410: toolbox->createToolBoxForet(); break; case 420: toolbox->createToolBoxInsertion(); break; case 500: // Help->About showAboutText(); break; case 610: // View -> Material -> Solid if (Model) Model->setMaterialType(video::EMT_SOLID); break; case 620: // View -> Material -> Transparent if (Model) Model->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR); break; case 630: // View -> Material -> Reflection if (Model) Model->setMaterialType(video::EMT_SPHERE_MAP); break; case 1000: setActiveCamera ( Camera[0] ); break; case 1100: setActiveCamera ( Camera[1] ); break; } break; } case EGET_FILE_SELECTED: { // load the model file, selected in the file open dialog IGUIFileOpenDialog* dialog = (IGUIFileOpenDialog*)event.GUIEvent.Caller; loadModel(core::stringc(dialog->getFilename()).c_str()); } case EGET_SCROLL_BAR_CHANGED: /* control skin transparency if (id == 104) { s32 pos = ((IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); for (s32 i=0; i<irr::gui::EGDC_COUNT ; ++i) { video::SColor col = env->getSkin()->getColor((EGUI_DEFAULT_COLOR)i); col.setAlpha(pos); env->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col); } } break;*/ case EGET_CHECKBOX_CHANGED: { //Si une des checkBox est cochée, décocher les autres switch (id) { case 1: cbCarre->setChecked(true); cbRond->setChecked(false); cbLosange->setChecked(false); break; case 2: cbCarre->setChecked(false); cbRond->setChecked(true); cbLosange->setChecked(false); break; case 3: cbCarre->setChecked(false); cbRond->setChecked(false); cbLosange->setChecked(true); break; } } case EGET_BUTTON_CLICKED: switch(id) { /*case 1101: { // set scale gui::IGUIElement* root = env->getRootGUIElement(); core::vector3df scale; core::stringc s; s = root->getElementFromId(901, true)->getText(); scale.X = (f32)atof(s.c_str()); s = root->getElementFromId(902, true)->getText(); scale.Y = (f32)atof(s.c_str()); s = root->getElementFromId(903, true)->getText(); scale.Z = (f32)atof(s.c_str()); if (Model) Model->setScale(scale); } break;*/ case 1102: env->addFileOpenDialog(L"Please select a model file to open"); break; case 1104: toolbox->createToolBoxEau(); break; case 1105: toolbox->createToolBoxRelief(); break; case 1106: toolbox->createToolBoxCiel(); break; case 1107: toolbox->createToolBoxForet(); break; case 1108: toolbox->createToolBoxInsertion(); break; case 1109: showAboutText(); break; } break; } } return false; } }; int main() { // ask user for driver video::E_DRIVER_TYPE driverType = video::EDT_OPENGL; // create device and exit if creation failed MyEventReceiver receiver; Device = createDevice(driverType, core::dimension2d<s32>(800, 600), 16, false, false, false, &receiver); if (Device == 0) return 1; // could not create selected driver. toolbox = new Toolbox(Device); Device->setResizeAble(true); Device->setWindowCaption(L"AoL_M"); video::IVideoDriver* driver = Device->getVideoDriver(); IGUIEnvironment* env = Device->getGUIEnvironment(); scene::ISceneManager* smgr = Device->getSceneManager(); driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true); smgr->addLightSceneNode(); smgr->addLightSceneNode(0, core::vector3df(50,-50,100), video::SColorf(1.0f,1.0f,1.0f),20000); // read configuration from xml file io::IXMLReader* xml = Device->getFileSystem()->createXMLReader( "aide.xml"); while(xml && xml->read()) { switch(xml->getNodeType()) { case io::EXN_TEXT: // in this xml file, the only text which occurs is the messageText MessageText = xml->getNodeData(); break; case io::EXN_ELEMENT: { if (core::stringw("startUpModel") == xml->getNodeName()) StartUpModelFile = xml->getAttributeValue(L"file"); else if (core::stringw("messageText") == xml->getNodeName()) Caption = xml->getAttributeValue(L"caption"); } break; } } if (xml) xml->drop(); // don't forget to delete the xml reader // set a nicer font IGUISkin* skin = env->getSkin(); IGUIFont* font = env->getFont("fonthaettenschweiler.bmp"); if (font) skin->setFont(font); // create menu gui::IGUIContextMenu* menu = env->addMenu(); menu->addItem(L"Fichier", -1, true, true); menu->addItem(L"Edition", -1, true, true); menu->addItem(L"Outils", -1, true, true); menu->addItem(L"Vues", -1, true, true); menu->addItem(L"Aide", -1, true, true); gui::IGUIContextMenu* submenu; submenu = menu->getSubMenu(0); submenu->addItem(L"Nouveau", 100); submenu->addItem(L"Ouvrir", 101); submenu->addItem(L"Enregistrer", 102); submenu->addItem(L"Enregistrer sous", 103); submenu->addItem(L"Revenir a la derniere sauvegarde", 104); submenu->addItem(L"Explorer les fichiers temporaires", 105); submenu->addSeparator(); submenu->addItem(L"Quitter", 200); submenu = menu->getSubMenu(1); submenu->addItem(L"Annuler", 300); submenu->addItem(L"Repeter", 310); submenu->addItem(L"Copier", 320 ); submenu->addItem(L"Coller", 330); submenu->addItem(L"Couper", 340); submenu->addItem(L"Generer", 350); submenu->addItem(L"Redimensionner", 360); submenu->addItem(L"Dupliquer", 370); submenu = menu->getSubMenu(2); submenu->addItem(L"Terrain",-1, true, true); submenu->addItem(L"Foret", 410); submenu->addItem(L"Insertion", 420); submenu = submenu->getSubMenu(0); submenu->addItem(L"Eau", 401); submenu->addItem(L"Relief", 402); submenu->addItem(L"Ciel", 403); submenu = menu->getSubMenu(3); submenu->addItem(L"Rendu", 500); submenu->addItem(L"Mode", -1, true, true); submenu = submenu->getSubMenu(1); submenu->addItem(L"Solide", 1000); submenu->addItem(L"Fil de fer", 1010); submenu->addItem(L"Avec texture", 1020); submenu= menu->getSubMenu(3); submenu->addItem(L"Camera", -1, true, true); submenu->addItem(L"Vue globale", 510); submenu = submenu->getSubMenu(2); submenu->addItem(L"FPS", 1100); submenu->addItem(L"Normale", 1110); submenu = menu->getSubMenu(4); submenu->addItem(L"Documentation", 600); submenu->addSeparator(); submenu->addItem(L"A propos", 610); // create toolbar gui::IGUIToolBar* bar = env->addToolBar(); video::ITexture* image = driver->getTexture("open.png"); bar->addButton(1102, 0, L"Ouvrir",image, 0, false, true); image = driver->getTexture("eau.png"); bar->addButton(1104, 0, L"Outil eau(CTRL+o)",image, 0, false, true); image = driver->getTexture("relief.png"); bar->addButton(1105, 0, L"Outil Relief(CTRL+R)",image, 0, false, true); image = driver->getTexture("ciel.png"); bar->addButton(1106, 0, L"Outil Ciel(CTRL+C)",image, 0, false, true); image = driver->getTexture("arbre.png"); bar->addButton(1107, 0, L"Outil Arbre(CTRL+A)",image, 0, false, true); image = driver->getTexture("insertion.png"); bar->addButton(1108, 0, L"Outil Insertion(CTRL+I)",image, 0, false, true); image = driver->getTexture("help.png"); bar->addButton(1109, 0, L"Aide(F1)", image, 0, false, true); //disable alpha for (s32 i=0; i<gui::EGDC_COUNT ; ++i) { video::SColor col = env->getSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i); col.setAlpha(255); env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col); } // add a camera scene node Camera[0] = smgr->addCameraSceneNodeMaya(); Camera[1] = smgr->addCameraSceneNodeFPS(); setActiveCamera ( Camera[0] ); // draw everything while(Device->run() && driver) { if (Device->isWindowActive()) { driver->beginScene(true, true, video::SColor(150,0,0,0)); smgr->drawAll(); env->drawAll(); driver->endScene(); } else Device->yield(); } Device->drop(); return 0; }
toolbox.h
#include <irrlicht.h> #include <iostream> #ifndef DEF_TOOLBOX #define DEF_TOOLBOX class Toolbox { public: Toolbox(irr::IrrlichtDevice* irrdevice); ~Toolbox(); void createToolBoxEau(); void createToolBoxCiel(); void createToolBoxRelief(); void createToolBoxForet(); void createToolBoxInsertion(); private: irr::gui::IGUIWindow* wnd; irr::gui::IGUITabControl* tab; irr::gui::IGUICheckBox* cbCarre; irr::gui::IGUICheckBox* cbRond; irr::gui::IGUICheckBox* cbLosange; irr::gui::IGUIListBox* listbox; irr::scene::ISceneNode* node; irr::IrrlichtDevice *Device; }; #endif
toolbox.cpp
#include <irrlicht.h> #include <iostream> #include "toolbox.h" using namespace irr; using namespace gui; Toolbox::Toolbox(irr::IrrlichtDevice* irrdevice) { irr::scene::ISceneNode* node = 0; Device = irrdevice; } void Toolbox::createToolBoxEau() { // enlève la toolbox si elle est déjà présente IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* e = root->getElementFromId(5000, true); if (e) e->remove(); // création de la fenêtre de la tool box wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Eau", 0, 5000); // création du controle par tab tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Format"); IGUITab* t2 = tab->addTab(L"Texture"); //Remplissage de l'onglet Format //ajout de checkbox env->addStaticText(L"Format", core::rect<s32>(10,30,100,50), false, false, t1); cbCarre = env->addCheckBox(true, core::rect<s32>(10,55,200,75), t1, 1, L"Carre"); cbRond = env->addCheckBox(false, core::rect<s32>(10,80,200,100), t1, 2, L"Rond"); cbLosange = env->addCheckBox(false, core::rect<s32>(10,105,200,125), t1, 3, L"Losange"); //Ajout d'une barre défilante env->addStaticText(L"Taille", core::rect<s32>(10,150,150,175), false, false, t1); IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,175,150,190), t1, 104); scrollbar->setMax(16); //Remplissage de l'onglet Texture env->addStaticText(L"Niveau de l'eau", core::rect<s32>(10,30,100,50),false,false, t2); env->addEditBox(L"1.0", core::rect<s32>(40,50,100,70), true, t2, 911); env->addStaticText(L"Choix de la texture", core::rect<s32>(10,100,110,120), false, false, t2); IGUIComboBox* box = env->addComboBox(core::rect<s32>(10,120,150,140), t2); box->addItem(L"Eau 1"); box->addItem(L"Eau 2"); box->addItem(L"Eau 3"); box->addItem(L"Fond marin 1"); box->addItem(L"Fond marin 2"); env->addButton(core::rect<s32>(40,200,150,250), t2, 1101, L"Valider"); std::cout<< "tb eau 100"; } void Toolbox::createToolBoxCiel() { //Atmosphère + nuage IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* a = root->getElementFromId(5100, true); if (a) a->remove(); IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Ciel", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Atmosphere"); IGUITab* t2 = tab->addTab(L"Nuage"); std::cout<< "tb ciel 100"; } void Toolbox::createToolBoxRelief() { //Altitude + sol + relief IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* b = root->getElementFromId(5200, true); if (b) b->remove(); IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Relief", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Altitude"); IGUITab* t2 = tab->addTab(L"Relief"); //Implémentation de l'onglet Altitude env->addStaticText(L"Choix de l'altitude", core::rect<s32>(10,30,105,55), false, false, t1); env->addEditBox(L"1.0", core::rect<s32>(40,50,100,70),true, t1, 912); env->addStaticText(L"Choix de la texture", core::rect<s32>(10,80,155,95), false, false, t1); IGUIComboBox* box = env->addComboBox(core::rect<s32>(10,100,150,120), t1); box->addItem(L"Herbe 1"); box->addItem(L"Herbe 2"); box->addItem(L"Herbe 3"); box->addItem(L"Sable 1"); box->addItem(L"Sable 2"); box->addItem(L"Neige 1"); box->addItem(L"Neige 2"); box->addItem(L"Roche 1"); box->addItem(L"Roche 2"); box->addItem(L"Terre 1"); box->addItem(L"Terre 2"); env->addButton(core::rect<s32>(40,150,150,200), t1, 1101, L"Valider"); //Implémentation de l'onglet Relief env->addStaticText(L"Relief max", core::rect<s32>(10,30,105,55),false,false,t2); env->addEditBox(L"1.0", core::rect<s32>(40,50,100,70),true, t2, 913); env->addStaticText(L"Coefficient de lissage", core::rect<s32>(10,80,155,95), false, false, t2); env->addEditBox(L"1.0", core::rect<s32>(40,100,100,120),true, t2, 904); env->addButton(core::rect<s32>(40,150,150,200), t2, 1101, L"Valider"); std::cout<< "tb relief 100"; } void Toolbox::createToolBoxForet() { IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* c = root->getElementFromId(5300, true); if (c) c->remove(); IGUIWindow* wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Foret", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Format"); IGUITab* t2 = tab->addTab(L"Composition"); //ajout de checkbox env->addStaticText(L"Format", core::rect<s32>(10,30,100,50), false, false, t1); cbCarre = env->addCheckBox(true, core::rect<s32>(10,55,200,75), t1, 1, L"Carre"); cbRond = env->addCheckBox(false, core::rect<s32>(10,80,200,100), t1, 2, L"Rond"); cbLosange = env->addCheckBox(false, core::rect<s32>(10,105,200,125), t1, 3, L"Losange"); //Ajout d'une barre défilante env->addStaticText(L"Taille", core::rect<s32>(10,150,150,175), false, false, t1); IGUIScrollBar* scrollbar = env->addScrollBar(true, core::rect<s32>(10,175,150,190), t1, 104); scrollbar->setMax(16); env->addStaticText(L"Type de foret", core::rect<s32>(10,200,150,225), false, false, t1); IGUIComboBox* box = env->addComboBox(core::rect<s32>(10,225,150,245), t1); box->addItem(L"Tempere 1"); box->addItem(L"Tempere 2"); box->addItem(L"Tempere 3"); box->addItem(L"Aleatoire"); env->addButton(core::rect<s32>(40,350,150,400), t1, 1101, L"Valider"); env->addStaticText(L"Pourcentage de chene", core::rect<s32>(10,30,150,50), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,50,100,70), true, t2, 905); env->addStaticText(L"Pourcentage de hetre", core::rect<s32>(10,70,150,90), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,90,100,110), true, t2, 906); env->addStaticText(L"Pourcentage de pin", core::rect<s32>(10,110,150,130), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,130,100,150), true, t2, 907); env->addStaticText(L"Pourcentage d'erable", core::rect<s32>(10,150,150,170), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,170,100,190), true, t2, 908); env->addStaticText(L"Pourcentage de bouleau", core::rect<s32>(10,190,150,210), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,210,100,230), true, t2, 909); env->addStaticText(L"Pourcentage de chene", core::rect<s32>(10,230,150,250), false, false, t2); env->addEditBox(L"0", core::rect<s32>(40,250,100,270), true, t2, 910); env->addStaticText(L"Nom", core::rect<s32>(75,270,150,290),false, false, t2); env->addEditBox(L"", core::rect<s32>(10,290,150,310), true, t2,911); env->addButton(core::rect<s32>(40,350,150,400), t2, 1101, L"Enregistrer"); std::cout<< "100"; std::cout<< "tb foret 100"; } void Toolbox::createToolBoxInsertion() { IGUIEnvironment* env = Device->getGUIEnvironment(); IGUIElement* root = env->getRootGUIElement(); IGUIElement* d = root->getElementFromId(5400, true); if (d) d->remove(); wnd = env->addWindow(core::rect<s32>(600,25,800,600), false, L"Insertion", 0, 5000); IGUITabControl* tab = env->addTabControl( core::rect<s32>(2,20,800-602,600-7), wnd, true, true); IGUITab* t1 = tab->addTab(L"Insertion"); listbox = env->addListBox(core::rect<s32>(10, 20, 170, 400), t1); std::cout<< "tb insertion 100"; }
En fait, j'avais pas fait attention, mais il aime pas les variables qui portent le même nom qu'une classe
Dis moi si çà marche chez toi
Hors ligne
non il veut toujours pas compiler et m'affiche encore la même erreur (j'utilise aussi C::B)
Hors ligne
T'as bien copié les fichiers tels quels ? Parce que chez moi çà compile impec (code::block+gcc en utilisant la template fournit avec c::b)
Hors ligne
je viens de le refaire mais il veut pas
ça me gave parce qu'il a aucune raison de faire sa
Hors ligne
Bah là je vois pas. Peut être un problème avec c::b. Force le à recompiler en cliquant sur rebuild. Si çà marche toujours pas, recrées un petit projet vite fait. Si çà marche toujours pas, chui paumé
Hors ligne
j'ai une autre solution c'est de le remettre en C/C++ mais ça fait pas très "pro"
en tout cas merci pour ton aide. Si chez toi sa marche je comprend pas pourquoi ça ne marche pas chez moi.
Tu as dit que tu utilisait la template fourni avec c::b mais c'est laquelle ?
Hors ligne
File->new->project
sélectionnes Irrlicht project et suis les instructions (t'as pas à refaire toutes les chemins vers les includes et les libs)
Hors ligne
c'est bon ça marche
j'ai recréer le projet et c'est bon.
Merci beaucoup
En fait l'erreur venait de moi : j'ai marquer #include "toolbox.h" alors qu'en fait j'aurais du marquer #include "toolbox.hpp" (quelle erreur stupide ^^)
Dernière modification par vrag (22-07-2007 13:26:40)
Hors ligne
Options | Liens officiels | Caractéristiques | Statistiques | Communauté |
---|---|---|---|---|
Corrections |
|
xhtml 1.0 css 2.1 Propulsé par FluxBB Traduit par FluxBB.fr |
882 membres 1429 sujets 11119 messages |
Dernier membre inscrit: LiseBuisson96 33 invités en ligne Aucun membre connecté RSS Feed |