Button image with LUA?

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

hkroger
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 20, 2006 01:39

Button image with LUA?

Postby hkroger » Wed Mar 08, 2006 00:31

Hi,

I wanted to change button image with LUA. This is the code so far:

Code: Select all

   local button = wmgr:createWindow("WindowsLook/Button","toolbartestbutton");
   button:setText( "Test" )
   button:setSize( CEGUI.Size:new_local(0.5,0.1) )
   button:setPosition( CEGUI.Point:new_local(0.0,0.8) )
   
   local imagesetman = CEGUI.ImagesetManager:getSingleton()
   local imageset = imagesetman:getImageset("Editor")
   local image = imageset:getImage("ToolbarIcon1")
   
   button:setProperty( "NormalImage", image );


As you might guess, it does not work as property gets always a string a parameter. How can I make this work?

I really would like to see more LUA+CEGUI source code online. Good documentation would not hurt either.

User avatar
Trentin
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Tue Nov 22, 2005 21:25
Contact:

Postby Trentin » Wed Mar 08, 2006 15:40

Try this:

Code: Select all

local button = wmgr:createWindow("WindowsLook/Button","toolbartestbutton");
button:setText( "Test" )
button:setSize( CEGUI.Size:new_local(0.5,0.1) )
button:setPosition( CEGUI.Point:new_local(0.0,0.8) )

button:setProperty( "NormalImage", "set:Editor image:ToolbarIcon1");


Hope that works, haven't actually tried it :)

hkroger
Just popping in
Just popping in
Posts: 12
Joined: Mon Feb 20, 2006 01:39

Postby hkroger » Wed Mar 08, 2006 21:00

Trentin wrote:Try this:

Code: Select all

local button = wmgr:createWindow("WindowsLook/Button","toolbartestbutton");
button:setText( "Test" )
button:setSize( CEGUI.Size:new_local(0.5,0.1) )
button:setPosition( CEGUI.Point:new_local(0.0,0.8) )

button:setProperty( "NormalImage", "set:Editor image:ToolbarIcon1");


Hope that works, haven't actually tried it :)


Seems to work, thanks. I noticed that if the image of an imageset is not 128x128 or 256x256 then coordinates given in imageset xml-file don't really match. Is it a feature?

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Wed Mar 08, 2006 21:47

3D hardware requires that texture have dimensions in powers of two

64x64, 128x128, 128x256, 256x256, 256x512 as so on...

The texture does'nt have to be square but both width and height must be a power of two.

If the image is'nt dimensioned like this it is scaled up to the nearest power of two on each axis. CEGUI does not currently take this scaling into account and "thinks" that the original pixel corrdinates still are valid.

I guess this should be considered a bug, but.. I would make sure that your texture just use 2^n dimensions as the auto scaling can make your texture look bad as well.

User avatar
baxissimo
Quite a regular
Quite a regular
Posts: 60
Joined: Tue Feb 22, 2005 08:04
Location: Tokyo, JAPAN
Contact:

Postby baxissimo » Thu Mar 09, 2006 00:32

lindquist wrote:3D hardware requires that texture have dimensions in powers of two

64x64, 128x128, 128x256, 256x256, 256x512 as so on...

The texture does'nt have to be square but both width and height must be a power of two.


Any semi-recent NVIDIA card has support for the NV_texture_rectangle GL extension that allows for NPOT (non-power-of-two) textures. Is this supported by recent ATI cards also? [edit]It seems they do have something called EXT_texture_rectangle, which I'm guessing has the same functionality, and probably same API[/edit] It might be nice if CEGUI's GL renderer could use it when available when someone tries to use a non-power-of-two texture.

On second thought. Nevermind. It would be annoying to develop your whole app on your fancy NVIDIA card only to find out that all of your 260x260 textures are suddenly taking up 512x512 of texture memory when you run your app on Joe Consumer's ancient hardware.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 28 guests