Danaugrs
17-09-2007 20:13:05
How can I simply display an image on the screen? Do i really need to use a GUI system just for that?
I managed to dysplay one image using CEGUI, but the code for it looks to be too much just to load and display images, specially just one!
And another thing, the image is displayed stretched horizontaly, but this probably happens because of the fact it isn't a perfect square.
If your image is a perfect square it doesn't get stretched.
If someone could show me an easier way of displaying images without a Gui system or using another one, like QuickGui, I would greatly appreciate.
The code for loading and displaying the images:
I hope someone can help me
I managed to dysplay one image using CEGUI, but the code for it looks to be too much just to load and display images, specially just one!
And another thing, the image is displayed stretched horizontaly, but this probably happens because of the fact it isn't a perfect square.
If your image is a perfect square it doesn't get stretched.
If someone could show me an easier way of displaying images without a Gui system or using another one, like QuickGui, I would greatly appreciate.
The code for loading and displaying the images:
## setup GUI system
self.GUIRenderer = CEGUI.OgreCEGUIRenderer(self.renderWindow,
ogre.RENDER_QUEUE_OVERLAY, False, 3000, self.sceneManager)
self.GUIsystem = CEGUI.System(self.GUIRenderer)
CEGUI.SchemeManager.getSingleton().loadScheme("TaharezLookSkin.scheme")
self.GUIsystem.setDefaultMouseCursor("TaharezLook", "MouseArrow")
winMgr = CEGUI.WindowManager.getSingleton()
## load an image to use as a background
CEGUI.ImagesetManager.getSingleton().createImagesetFromImageFile("BackgroundImage", "transparent.png")
## here we will use a StaticImage as the root, then we can use it to place a background image
background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd")
## set position and size
background.setPosition(CEGUI.UVector2(cegui_reldim(0), cegui_reldim( 0)))
background.setSize(CEGUI.UVector2(cegui_reldim(1), cegui_reldim( 1)))
## disable frame and standard background
background.setProperty("FrameEnabled", "false")
background.setProperty("BackgroundEnabled", "false")
## set the background image
background.setProperty("Image", "set:BackgroundImage image:full_image")
## install this as the root GUI sheet
CEGUI.System.getSingleton().setGUISheet(background)
## now we create a DefaultWindow which we will attach all the widgets to. We could
## have attached them to the background StaticImage, though we want to be a bit tricky
## since we do not wish the background to be faded by the slider - so we create this
## container window so we can affect all the other widgets, but leave the background
## unchanged.
sheet = winMgr.createWindow("DefaultWindow", "root_wnd")
## attach this to the 'real' root
background.addChildWindow(sheet)
## load an image to use as a background
CEGUI.ImagesetManager.getSingleton().createImagesetFromImageFile("pane1Image", "TBlogo.png")
pane1 = winMgr.createWindow("TaharezLook/StaticImage", "pane_wnd1")
## set position and size
pane1.setPosition(CEGUI.UVector2(cegui_reldim(0.05), cegui_reldim( 0.1)))
pane1.setSize(CEGUI.UVector2(cegui_reldim(0.3), cegui_reldim( 0.3)))
## disable frame and standard background
pane1.setProperty("FrameEnabled", "false")
pane1.setProperty("BackgroundEnabled", "false")
## set the background image
pane1.setProperty("Image", "set:pane1Image image:full_image")
## install this as the root GUI sheet
sheet.addChildWindow(pane1)
I hope someone can help me
