Historique des modifications - Message

Message #5403

Sujet: Plantage programme à cause du récepteur d'évenement


TypeDateAuteurContenu
Dernière modification03-01-2009 07:43:52ayboangelus
Draw est utilisé comme ceci:

Voici mon coreApp.cpp, qui est la gestion graphique de mon programme.

#include "coreApp.h"

coreApp::coreApp()
{
    device = createDevice(EDT_OPENGL,dimension2d<s32>(1024,768), 32);
    //MyEvent *event = new MyEvent();
    //device->setEventReceiver(MyEvent);
    driver = device->getVideoDriver();
    env = device->getGUIEnvironment();
    scenegraph = device->getSceneManager();
    gui = scenegraph->getGUIEnvironment();

    LOGIN = new login(device);

    wchar_t titre[100];
    swprintf(titre, 100, L"Akhynia");
    device->setWindowCaption(titre);

    s32 pos = 255;//no alpha
					for (u32 i=0; i<EGDC_COUNT ; ++i)
					{
						SColor col = gui->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
						col.setAlpha(pos);
						gui->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
					}
}
coreApp::~coreApp()
{
    device->closeDevice();
}

void coreApp::draw()
{
    while(device->run() /*&& (eventReceiver.Keys[KEY_ESCAPE] == false)*/)
    {
        driver->beginScene(true, true, SColor(255,100,101,140));
        env->drawAll();
        gui->drawAll();
        scenegraph->drawAll();
        driver->endScene();
        if(LOGIN && LOGIN->draw() == 2)
        {
            delete LOGIN;
            LOGIN = false;
            Carac = new character(device);
        }
        if(LOGIN && LOGIN->draw() == 3)
        {
            env->addMessageBox(L"Erreur", L"Votre mot de passe est mauvais merci de le saisir de nouveau!");
        }
        if(Carac) { Carac->draw(); }
        if(Carac && Carac->draw() == 4)
        {
            int spouet = Carac->fonction();
            delete Carac;
            Carac = false;
            World = new world(device,spouet);
        }
        if(World) { World->draw(); }
    }
    device->drop();
}

Et pour device je l'initialise dans ma partie character.cpp que voici:

#include "character.h"
#include "eventvalidchar.h"
#include <iostream>
#include <fstream>

character::character(IrrlichtDevice* Device)
{
    device = Device;
    driver = device->getVideoDriver ();
    scenegraph = device->getSceneManager ();
    gui = scenegraph->getGUIEnvironment();
    env = device->getGUIEnvironment();

	scenegraph->addCameraSceneNode (0, core::vector3df (0,0,0), core::vector3df (50,0,0));

    IGUIImage *img = env->addImage(rect<s32>(0,0,1024,768));
    img->setImage(driver->getTexture("media/cadre.jpg"));

    int IDperso = 11;

    // Perso 1
    modele2 = scenegraph->getMesh("persos/11.x");
    Nmodele2 = scenegraph->addAnimatedMeshSceneNode(modele2);
    Nmodele2->setPosition(core::vector3df(150,-30,70));
    Nmodele2->setRotation(core::vector3df(0,80,0));
    Nmodele2->setMaterialFlag(video::EMF_LIGHTING, false);
    Nmodele2->setFrameLoop(0,0);
    Nmodele2->setMaterialTexture( 0, driver->getTexture("persos/dwarf.jpg") );

    // Perso 2
    modele = scenegraph->getMesh("persos/test/player.x");
    Nmodele = scenegraph->addAnimatedMeshSceneNode(modele);
    Nmodele->setPosition(core::vector3df(10.5,0.5,-0.5));
    Nmodele->setRotation(core::vector3df(0,-90,0));
    Nmodele->setMaterialFlag(video::EMF_LIGHTING, false);

    env->addButton(core::rect<s32>(190,600,330,650), 0, GUI_ID_VAL1, L"Selection");
    env->addButton(core::rect<s32>(460,600,600,650), 0, GUI_ID_VAL2, L"Selection");
    env->addButton(core::rect<s32>(740,600,880,650), 0, GUI_ID_VAL3, L"Selection");
    IGUIStaticText* choixperso = env->addStaticText(L"Choix du personnage",rect<s32>(380,700,670,750),false);
}
character::~character()
{
    scenegraph->clear();
    env->clear();
    gui->clear();
    driver->removeAllTextures();
}
char character::draw()
{
    cEventReceiver eventReceiver;
    device->setEventReceiver(&eventReceiver);
    return 0;
}

Merci pour tes réponses
Création du message03-01-2009 07:41:57ayboangelus
Draw est utilisé comme ceci:

Voici mon coreApp.cpp, qui est la gestion graphique de mon programme.

#include "coreApp.h"

coreApp::coreApp()
{
    device = createDevice(EDT_OPENGL,dimension2d<s32>(1024,768), 32);
    //MyEvent *event = new MyEvent();
    //device->setEventReceiver(MyEvent);
    driver = device->getVideoDriver();
    env = device->getGUIEnvironment();
    scenegraph = device->getSceneManager();
    gui = scenegraph->getGUIEnvironment();

    LOGIN = new login(device);

    wchar_t titre[100];
    swprintf(titre, 100, L"Akhynia");
    device->setWindowCaption(titre);

    s32 pos = 255;//no alpha
					for (u32 i=0; i<EGDC_COUNT ; ++i)
					{
						SColor col = gui->getSkin()->getColor((EGUI_DEFAULT_COLOR)i);
						col.setAlpha(pos);
						gui->getSkin()->setColor((EGUI_DEFAULT_COLOR)i, col);
					}
}
coreApp::~coreApp()
{
    device->closeDevice();
}

void coreApp::draw()
{
    while(device->run() /*&& (eventReceiver.Keys[KEY_ESCAPE] == false)*/)
    {
        driver->beginScene(true, true, SColor(255,100,101,140));
        env->drawAll();
        gui->drawAll();
        scenegraph->drawAll();
        driver->endScene();
        if(LOGIN && LOGIN->draw() == 2)
        {
            delete LOGIN;
            LOGIN = false;
            Carac = new character(device);
        }
        if(LOGIN && LOGIN->draw() == 3)
        {
            env->addMessageBox(L"Erreur", L"Votre mot de passe est mauvais merci de le saisir de nouveau!");
        }
        if(Carac) { Carac->draw(); }
        if(Carac && Carac->draw() == 4)
        {
            int spouet = Carac->fonction();
            delete Carac;
            Carac = false;
            World = new world(device,spouet);
        }
        if(World) { World->draw(); }
    }
    device->drop();
}

Et pour device je l'initialise dans ma partie character.cpp que voici:

#include "character.h"
#include "eventvalidchar.h"
#include <iostream>
#include <fstream>

character::character(IrrlichtDevice* Device)
{
    device = Device;
    driver = device->getVideoDriver ();
    scenegraph = device->getSceneManager ();
    gui = scenegraph->getGUIEnvironment();
    env = device->getGUIEnvironment();

	scenegraph->addCameraSceneNode (0, core::vector3df (0,0,0), core::vector3df (50,0,0));

    IGUIImage *img = env->addImage(rect<s32>(0,0,1024,768));
    img->setImage(driver->getTexture("media/cadre.jpg"));

    int IDperso = 11;

    // Perso 1
    modele2 = scenegraph->getMesh("persos/11.x");
    Nmodele2 = scenegraph->addAnimatedMeshSceneNode(modele2);
    Nmodele2->setPosition(core::vector3df(150,-30,70));
    Nmodele2->setRotation(core::vector3df(0,80,0));
    Nmodele2->setMaterialFlag(video::EMF_LIGHTING, false);
    Nmodele2->setFrameLoop(0,0);
    Nmodele2->setMaterialTexture( 0, driver->getTexture("persos/dwarf.jpg") );

    // Perso 2
    modele = scenegraph->getMesh("persos/test/player.x");
    Nmodele = scenegraph->addAnimatedMeshSceneNode(modele);
    Nmodele->setPosition(core::vector3df(10.5,0.5,-0.5));
    Nmodele->setRotation(core::vector3df(0,-90,0));
    Nmodele->setMaterialFlag(video::EMF_LIGHTING, false);

    env->addButton(core::rect<s32>(190,600,330,650), 0, GUI_ID_VAL1, L"Selection");
    env->addButton(core::rect<s32>(460,600,600,650), 0, GUI_ID_VAL2, L"Selection");
    env->addButton(core::rect<s32>(740,600,880,650), 0, GUI_ID_VAL3, L"Selection");
    IGUIStaticText* choixperso = env->addStaticText(L"Choix du personnage",rect<s32>(380,700,670,750),false);
}
character::~character()
{
    scenegraph->clear();
    env->clear();
    gui->clear();
    driver->removeAllTextures();
}
char character::draw()
{
    cEventReceiver eventReceiver;
    device->setEventReceiver(&eventReceiver);
    return 0;
}

Merci pour tes réponses

Retour

OptionsLiens officielsCaractéristiquesStatistiquesCommunauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1441 sujets
11339 messages
Dernier membre inscrit: Saidov17
59 invités en ligne
membre en ligne: -
RSS Feed