Cegui, Ogre3D and Me

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
ArKada
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Fri Jan 23, 2009 14:46

Postby ArKada » Wed Feb 04, 2009 08:12

Hello all !

Sorry for my late Reply but I was traveling with the school during last week. :D

Here is all my code:

Code: Select all

//-- Includes --//

#include <Ogre.h>

#include <CEGUI.h>

#include <OgreCEGUIRenderer.h>
#include <OgreCEGUIResourceProvider.h>

#include <OIS/OIS.h>

#include <iostream>
#include <fstream>

//-- Namespaces --//

using namespace std;
using namespace Ogre;
using namespace CEGUI;

//-- Classe Application --//

class App
{
    public:
    App();
    ~App();

    void Init(string Version);
    void Rendu();
    void SetRendu(bool ActRendu);
    void SetFrqRendu(int Valeur);
    void Menu();
    bool Retour_Rendu();
    int Retour_FrqRendu();

    private:
    Root * root;
    RenderSystem * Systeme;
    RenderWindow * Fenetre;
    OgreCEGUIRenderer * RdrGui;
    System * GuiSys;
    Camera * MenuCamera;
    Camera * MainCamera;
    SceneManager * SceneMenu;
    bool ModeRendu;
    int FrqRendu;
};

App::App()
{
    root = NULL;
    Systeme = NULL;
    Fenetre = NULL;
    RdrGui = NULL;
    SceneMenu = NULL;
    GuiSys = NULL;
    MenuCamera = NULL;
    MainCamera = NULL;
    ModeRendu = true;
    FrqRendu = 0;

};

App::~App()
{
    delete root;
    delete Systeme;
    delete Fenetre;
    delete RdrGui;
    delete SceneMenu;
    delete GuiSys;
    delete MenuCamera;
    delete MainCamera;
};

void App::Init(string Version)
{
    ifstream fichier("Configuration.txt", ios::in);

    int largeur = 0;
    int hauteur = 0;
    int mode_ecran = 0;

    if (fichier)
    {
        fichier >> largeur;
        fichier >> hauteur;
        fichier >> mode_ecran;
        fichier >> FrqRendu;

        fichier.close();
    }
    else
    {
        ofstream fichier("Configuration.txt", ios::out | ios::trunc);

        largeur = 800;
        hauteur = 600;
        mode_ecran = 0;
        FrqRendu = 60;

        fichier << largeur << endl;
        fichier << hauteur << endl;
        fichier << mode_ecran << endl;
        fichier << FrqRendu << endl;

        fichier.close();
    };

    root = new Root("","");

    #if defined(_DEBUG)
        root->loadPlugin("RenderSystem_GL_d");
    #else
        root->loadPlugin("RenderSystem_GL");
    #endif

    Systeme = root->getRenderSystemByName("OpenGL Rendering Subsystem");
    root->setRenderSystem(Systeme);

    root->initialise(false);

    if (mode_ecran == 1)
    {
    Fenetre = root->createRenderWindow(Version,largeur,hauteur,true,0);
    };

    if (mode_ecran == 0)
    {
    Fenetre = root->createRenderWindow(Version,largeur,hauteur,false,0);
    };
};

void App::Rendu()
{
    WindowEventUtilities::messagePump();
    root->renderOneFrame();
    Fenetre->update();
};

bool App::Retour_Rendu()
{
    return ModeRendu;
};

void App::SetRendu(bool ActRendu)
{
    ModeRendu = ActRendu;
};

void App::SetFrqRendu(int Valeur)
{
    FrqRendu = Valeur;
};

int App::Retour_FrqRendu()
{
    return FrqRendu;
};

void App::Menu()
{
    //-- Creation de la Scene --//
   
    SceneMenu = root->createSceneManager(ST_GENERIC,"Menu");
    MenuCamera = SceneMenu->createCamera("CameraMenu");

    //-- Activation de CEGUi --//
   
    RdrGui = new OgreCEGUIRenderer(Fenetre,RENDER_QUEUE_OVERLAY,false,3000,SceneMenu);
    GuiSys = new System(RdrGui);
    Logger::getSingleton().setLoggingLevel(Informative);

    //-- Definition des Accés datasGui --//
   
    ResourceGroupManager& Rm = ResourceGroupManager::getSingleton();

    Rm.createResourceGroup("Interface");

    Rm.addResourceLocation("Datas/Interface","FileSystem","Interface");

    Imageset::setDefaultResourceGroup("Interface");
    Scheme::setDefaultResourceGroup("Interface");
    WidgetLookManager::setDefaultResourceGroup("Interface");
    WindowManager::setDefaultResourceGroup("Interface");
    ScriptModule::setDefaultResourceGroup("Interface");
    //Font::setDefaultResourceGroup("Interface");

    Rm.initialiseAllResourceGroups();

    //-- Chargement du skin --//
   
    SchemeManager::getSingleton().loadScheme((utf8*)"TaharezLookSkin.scheme");
    MouseCursor::getSingleton().setImage((utf8*)"TaharezLook",(utf8*)"MouseArrow");
    //GuiSys->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
    //GuiSys->setDefaultFont((CEGUI::utf8*)"BlueHighway-12");


    while(ModeRendu == true)
    {
        Rendu();
    };
};


//-- Main --//

int main(int argc, char *argv[], char *env[])
{
    App * app = new App();

    app->Init("Test Cegui Application");

    app->Menu();

    delete app;
};


There is not exactly my code but it was the same thing...
It happen exactly the same thing. :wink:

Anyone Can help me ?

ArKada, end of transmission...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Feb 04, 2009 09:42

Hi,

Thanks for posting the code :)

I think you need to add a viewport to the window in order to be able to see anything. In our sample code that uses Ogre we do the following:

Code: Select all

        // Create a viewport covering whole window
        Viewport* vp = d_window->addViewport(d_camera);
        vp->setBackgroundColour(ColourValue(0,0,0));

        // Update the camera aspect ratio to that of the viewport
        d_camera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));


I image you'll probably need to do something similar (though I am no Ogre expert, by a long way). Here, 'd_window' is our Ogre::RenderWindow and 'd_camera' is our Ogre::Camera.

CE.

User avatar
ArKada
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Fri Jan 23, 2009 14:46

Postby ArKada » Wed Feb 04, 2009 11:27

Ok, thanks ! All works ! :D
But, the cegui mouse appair in the center of the window, but he doesn't ove when i move my mouse, but the default windows (Microsoft) appair and he move at the place of the cegui mouse. ^^

Here is my Mouse Code:

Code: Select all

    MouseCursor::getSingleton().setImage((utf8*)"TaharezLook",(utf8*)"MouseArrow");
    GuiSys->setDefaultMouseCursor((utf8*)"TaharezLook", (utf8*)"MouseArrow");
    CEGUI::MouseCursor::getSingleton().setConstraintArea(NULL);


I think it's a very small problem.

ArKada

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Feb 05, 2009 09:36

Hi,

Are you injecting inputs, as per: http://www.cegui.org.uk/wiki/index.php/ ... ing_Inputs.

Ogre users generally usually use OIS for this purpose.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests