[Solved] Buttons not rendering in the correct size

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

sirbabyface
Just popping in
Just popping in
Posts: 8
Joined: Tue Jun 07, 2011 09:39
Location: Coimbra, Portugal

[Solved] Buttons not rendering in the correct size

Postby sirbabyface » Thu Jun 09, 2011 09:56

Hi,

I've some CEGUI buttons created in C++ to use in an application Qt + Ogre + CEGUI.

I just use a single image for each button, instead of creating a big atlas Png, since currently we are still chaning images and it is easier for us to have single images that we can quickly replace.

I've tested in different brand computers that have Intel GMA 950 drivers, and I get some buttons with the wrong dimension. This happen to all buttons I create that have 128x128 pixels.
In the computers with Nvidia (Quadro FX 1600M, GeForce GTS 450) and ATI ( X700 Mobile) the buttons appear just fine. I would say it is a bug with Intel GM 950 drivers. But the application we are creating, we believe that many of your users, have this type of graphics drivers.
We have tested in both OpenGL and DirectX.

Any ideias, what the problem could be?

Image

sirbabyface
Just popping in
Just popping in
Posts: 8
Joined: Tue Jun 07, 2011 09:39
Location: Coimbra, Portugal

Re: [Solved] Buttons not rendering in the correct size

Postby sirbabyface » Thu Jun 09, 2011 09:57

The problem has that the original image had 129x128 pixels instead of 128x128.

since the image it is not power of 2, in some graphics cards, there are problems. so this is solved now.

I decided to post this, since others might have similar problems.

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: [Solved] Buttons not rendering in the correct size

Postby Jamarr » Thu Jun 09, 2011 21:51

Thanks for posting the solution. I do not think I would have ever guessed that was the issue.

I have myself had numerous issues with Intel graphics where the code ran fine on Nvidia/Ati...but then I have also had issues with Nvidia/Ati as well. in once case I had two identical systems (hardware&software) and the Nvidia card in one failed on an opengl call and not the other; had to replace the call with a round-about way of achieving the same purpose as the original function and that fixed it.

Anyway, I noticed the button-area on the Intel screenshot appear to have been stretched to accommodate the size of the texture as opposed to the texture being downsampled to accommodate the size of the button. Do you dynamically set the size of the button to match the texture size? I am fairly certain that CEGUI does not (normally) do this. Normally I would have expected the texture to resample (shrink/expand/wrap) to fill the (fixed) button-area, in which case it would have been more obvious (to me) that the size of the texture was the issue.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

sirbabyface
Just popping in
Just popping in
Posts: 8
Joined: Tue Jun 07, 2011 09:39
Location: Coimbra, Portugal

Re: [Solved] Buttons not rendering in the correct size

Postby sirbabyface » Wed Jun 15, 2011 08:40

Do you dynamically set the size of the button to match the texture size? I am fairly certain that CEGUI does not (normally) do this.


We do dynamically set the size of the button, depending on the size of the image. For each button we create a new Imageset.
Below is the code we use (more or less, since we use several own functions and I simplified the code for example)

Code: Select all

CEGUI::Imageset *btImageset;
CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
CEGUI::PushButton* _ceguiButton = (CEGUI::PushButton*)winMgr.createWindow("AquaLook/ImageButton");

try
{
   btImageset = CEGUI::ImagesetManager::getSingleton().createFromImageFile("button.png", "button.png", "", CEGUI::XREA_RETURN);
   CEGUI::Size s = btImageset->getNativeResolution();
   _ceguiButton->setSize(CEGUI::UVector2(cegui_absdim(s.d_width), cegui_absdim(s.d_height)));
   _ceguiButton->setProperty("NormalImage", "set:button.png image:full_image");
}
catch (CEGUI::FileIOException)
{
   // File not found usually
}


You should do extra checks, when files are not found, or using some function returns unexpected results.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 8 guests