Button scale/position wrong

Akumax

22-10-2009 23:10:13

Hi,

I'm new to QuickGUI, I only discovered it a few days ago. It seems easy to use and to integrate but I'm running into some problems while I'm following the tutorials.

First, in this tutorial : Beginner Tutorial 2, it's said that GUIManager creates a default sheet ready to use. But when I'm calling the "getActiveSheet" function and try to use the sheet, my program crashes.

Second, I create a sheet with this code :


QuickGUI::SheetDesc* sd = QuickGUI::DescManager::getSingleton().getDefaultSheetDesc();
sd->resetToDefault();
sd->widget_dimensions.size = QuickGUI::Size(mRenderWindow->getWidth(), mRenderWindow->getHeight());
QuickGUI::Sheet* defaultSheet = QuickGUI::SheetManager::getSingleton().createSheet(sd);
mGUIManager->setActiveSheet(defaultSheet);


Then I create a button with this code :


QuickGUI::ButtonDesc* bd = QuickGUI::DescManager::getSingleton().getDefaultButtonDesc();
bd->resetToDefault();
bd->widget_name = "MyButton";
bd->widget_dimensions.position = QuickGUI::Point(0,0);
bd->widget_dimensions.size = QuickGUI::Size(100,25);
QuickGUI::Button* myButton = defaultSheet->createButton(bd);


Then my button is well placed at 0,0 but it's seems the scale is wrong because I can click out of the button. And, another weird thing, another button (the same as mine but reversed) is appearing when I click on the button, as in this picture.



You can see that I click out of the button but it still work and another button is appearing at the bottom of the screen.

I'm using QuickGUI 9.10 (I tried with the 9.09 version too) and Ogre 1.6 (svn version, but I tried with the 1.6.4 version too).

Any ideas ? Any more information I should give ?

Thank you

kungfoomasta

23-10-2009 20:40:11

Akumax,

Are you using a custom skin for your button? If so can you post up your definition?

Also how are you creating the viewport?

Akumax

24-10-2009 11:54:07

This is the creation of the RenderWindow, the config of Ogre is done by the Dialog Config :


mRenderWindow = mRoot->initialise(true, "Tutorial Render Window");


For the creation of the viewport (and of the scene):


mSceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
mCamera = mSceneMgr->createCamera("Camera");
mViewPort = mRenderWindow->addViewport(mCamera);
mCamera->setAspectRatio(Ogre::Real(mViewPort->getActualWidth()) / Ogre::Real(mViewPort->getActualHeight()));


I'm using the default skin for the button, but the button is blue because I set the color of the sheet as blue (for some test). Otherwise the skin of the button is like the one of the button displayed at the bottom of the window.
This is the code for setting QuickGUI (I'm doing QuickGUI::resgisterScriptReader() before initializeResourceGroups):


new QuickGUI::Root();
QuickGUI::SkinTypeManager::getSingleton().loadTypes();
QuickGUI::GUIManagerDesc d;
d.sceneManager = mSceneMgr;
d.viewport = mViewPort;
d.queueID = Ogre::RENDER_QUEUE_OVERLAY;
d.name = "GUIManager";

QuickGUI::GUIManager* mGUIManager = QuickGUI::Root::getSingletonPtr()->createGUIManager(d);

QuickGUI::SheetDesc* sd = QuickGUI::DescManager::getSingleton().getDefaultSheetDesc();
sd->resetToDefault();
sd->widget_dimensions.size = QuickGUI::Size(mRenderWindow->getWidth(), mRenderWindow->getHeight());
QuickGUI::Sheet* defaultSheet = QuickGUI::SheetManager::getSingleton().createSheet(sd);
mGUIManager->setActiveSheet(defaultSheet);

QuickGUI::ButtonDesc* bd = QuickGUI::DescManager::getSingleton().getDefaultButtonDesc();
bd->widget_name = "MyButton";
bd->widget_dimensions.position = QuickGUI::Point(0,0);
bd->widget_dimensions.size = QuickGUI::Size(100,25);
QuickGUI::Button* myButton = defaultSheet->createButton(bd);

kungfoomasta

24-10-2009 19:34:41

Sorry for the delay in my response, work has been taking all my time recently. :(

The problem you have seems very odd. Can you verify what mRenderWindow->getWidth() and mRenderWindow->getHeight() return? I remember there being some function like "getActualWidth/Height()".

Are you able to build and run the PlayPen, Editor, or AnimationViewer projects? If that looks good we can limit the error to something in your setup.

Akumax

24-10-2009 23:37:34

No problem for the delay. :wink:

The mViewport->getActualWidth/Height returns good values.

I can run the PlayPen sample but I have the same kind of problem.

It seems really odd, I can't find anyone else who is running into this problem :(
Oh, and I forgot to say that I'm running under Linux, maybe that helps.

kungfoomasta

27-10-2009 18:21:26

Akumax, are you able to run the Ogre demos fine? It sounds like maybe some driver issue. I'm not doing anything fancy for rendering, I just draw quads in screen space. Its odd the mouse draws fine yet the Sheet texture seems to be flipped, and then there is some blue box..

Are you using an ATI card? I heard a lot of people have issues with Linux and ATI cards.

Akumax

28-10-2009 08:15:19

I can run the Ogre demos fine

Well, I'm using an ATI card. I'll try my code on another PC to see if it's running fine elsewhere.

Akumax

28-10-2009 09:41:55

I tried my code on windows on another PC.

Well, it seems it's a problem with OpenGL. When I choose Direct3D for the rendering there is no problem, but when I choose OpenGL I have the same problem I have on my PC.