Max2D in CEGUI Control

BlitzMax Forums/Brucey's Modules/Max2D in CEGUI Control

Retimer(Posted 2009) [#1]
How would I go about drawing within a control?

I have tried subscribing events to TCEFrameWindow:: EventRenderingEnded and EventRenderingStarted, where I would attempt drawing a red square, but that was no good.

I assume there is a way to do this, and that i'm trying it the wrong way.

I understand I could call draw commands after calling TCESystem.renderGUI(), but then render ordering and advanced partial rendering would have to come into place with windows/controls overtop, which would kind of require more work than I think necessary.

I'm basically looking for an event that is called 'right' after it renders the control (not including the controls within that control) so I can draw stuff ontop of it, so controls within it will render over what I draw.

Hoping you understand what i'm getting at.

*bashes head on wall for having a speech impediment when it comes to technical terms*


Armitage 1982(Posted 2009) [#2]
I know one of my level editor feature (the tile selector) need to update a staticImage CEGUI object.

It's a bit related to this problem.
I know that CEGUI is using accelerated image to draw everything.
So as my driver is openGL I'm wondering if it's possible to get direct access to one of the memory staticImage used by CEGUI in order to draw inside.

I will probably ask this in the CEGUI forum too but there is clearly a BlitzMax step to achieve this.

You'll probably have to play with ImagesetManager class
http://www.cegui.org.uk/api_reference/classCEGUI_1_1ImagesetManager.html

And the imageSet Class
http://www.cegui.org.uk/api_reference/classCEGUI_1_1Imageset.html

Could you help us on this Brucey ??


Brucey(Posted 2009) [#3]
I know that CEGUI is using accelerated image to draw everything.

Isn't everything cached, so that it only "redraws" when required?


Brucey(Posted 2009) [#4]
You can access a Texture directly... but I don't know if this is what you really want to be doing ;-)


Armitage 1982(Posted 2009) [#5]
In fact I would like to be able to draw a BlitzMax TImage onto a CEGUI Window (more precisely a StaticImage).

This TImage will be created at runtime so maybe it's possible to create a runtime StaticImage from my TImage but I'll rather prefer to simply draw onto the CEGUI Window.


Brucey(Posted 2009) [#6]
I know what you mean, but I'm not entirely sure if it's possible.

But I'll look into it.


Armitage 1982(Posted 2009) [#7]
Thanks :D


Armitage 1982(Posted 2009) [#8]
Think I would go in that direction :
http://www.cegui.org.uk/phpBB2/viewtopic.php?t=3362&highlight=draw+onto

* Render / otherwise copy content to a texture
* Create a CEGUI::Texture from the underlying engine / API texture
* Create an Imageset from the CEGUI::Texture
* Define an Image for the Imageset
* Draw the image from your window / skin / or use a StaticImage.

The only missing part is the passing a blitzmax texture to a CEGUI::Texture


Brucey(Posted 2009) [#9]
The only missing part is the passing a blitzmax texture to a CEGUI::Texture

Indeed :-)

I hope you don't mean an actual hidden-away from us TImage texture reference? :-p


Armitage 1982(Posted 2009) [#10]
Humm Sad... (put his research on hold) ^^

I was already playing with this lol :
	Local texture:TCETexture = TCEImagesetManager.getImageset("ToolBarLook").GetTexture()
	texture.loadFromMemory(****magical texture reference pointer****, 48, 48, PF_RGBA)
	TCEImagesetManager.createImagesetFromTexture("TEST", texture)
	TCEWindowManager.getWindow("tileSelected").setProperty("Image", "set:TEST image:NormalPaint")


Note that I could go with saving the small texture to the drive and reload it with CEGUI since it's not realtime stuff... But it's a dirty solution.


Brucey(Posted 2009) [#11]
magical texture reference pointer

Couldn't that simply be the pixmap data? (pixelptr)


Armitage 1982(Posted 2009) [#12]
I can't try.

The CEGUI::Imageset:GetTexture() seems to be missing from the current SVN of Max CEGUI.
And the loadFromMemory() doesn't return any TCETexture object curiously.

So new object ? ( http://www.cegui.org.uk/api_reference/classCEGUI_1_1Texture.html )

I doubt it would be so simple, but worth to try :D


Armitage 1982(Posted 2009) [#13]
Oh I see that TCETexture extend blitzmax Object so I know I could use New to create a new Texture (Well I think).

PixmapPixelPtr my pixmaps result in a Unhandled Memory Exception Error through :(


Armitage 1982(Posted 2009) [#14]
I'm perplex :
http://www.cegui.org.uk/phpBB2/viewtopic.php?t=3782&highlight=texture
I suppose it's the same thing for OpenGL texture :s

Note that in regard to creating the Imageset from the texture, you usually would create a CEGUI::Texture from the underlying engine / API texture for use by the Imageset, however if you're using OpenGL, we are missing a means of doing this directly, so you'd create the CEGUI::Texture first, extract the OpenGL texture name from this and then either the data into it (or use it when setting up a frame buffer, or whatever).



Armitage 1982(Posted 2009) [#15]
Well until any better solution I will use that trick :
	SavePixmapPNG(TileSetImage.pixmaps[tileNumber], AppDir + "/TMPSelection.png")
	If TCEImagesetManager.isImagesetPresent("TMPSelection") Then TCEImagesetManager.destroyImageSet("TMPSelection")
	TCEImagesetManager.createImagesetFromImageFile("TMPSelection", AppDir + "/TMPSelection.png").setAutoScalingEnabled(False)
	TCEWindowManager.getWindow("tileSelected").setProperty("Image", "set:TMPSelection image:full_image")
	If FileType(AppDir + "/TMPSelection.png") = 1 Then DeleteFile(AppDir + "/TMPSelection.png")


A bit ugly but work like a charm since my tile are only a few pixels width and depth.
Alpha Borders of staticImage are a bit strange because of the scaling smooth through.
I wonder if there is a way to uncheck this ?

Ho !
I found this lately and that was very useful :
http://www.cegui.org.uk/wiki/index.php/SetProperty