[Solved] Custom Rendering

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

skyforger
Just popping in
Just popping in
Posts: 12
Joined: Mon Jan 02, 2012 19:21

[Solved] Custom Rendering

Postby skyforger » Sat Jan 07, 2012 17:23

Hello,

I've followed the tutorial here http://www.cegui.org.uk/wiki/index.php/ ... right_time on custom rendering. I'm using the Ogre renderer so I've created an OgreGeometryBuffer like so:

Code: Select all

mDragSeparatorGB = (OgreGeometryBuffer*)(&System::getSingletonPtr()->getRenderer()->createGeometryBuffer());

And then drawn a rectangle in it with the generic brush:

Code: Select all

Image brush = ImagesetManager::getSingleton().get( "BlenderTheme" ).getImage( "ClientBrush" );
brush.draw( *mDragSeparatorGB, Vector2( 0, 0 ), Size( 100, 100 ), new Rect(0, 0, 100, 100),  0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF );

After that, I added the geometry buffer to the surface and called the superclass drawSelf() method:

Code: Select all

surface->addGeometryBuffer( ctx.queue, *mDragSeparatorGB );
MultiColumnList::drawSelf( ctx );

Unfortunately, I can't get anything rendered. Does anyone have any ideas what I'm doing wrong?

Thanks
Last edited by skyforger on Sun Jan 08, 2012 01:06, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Custom Rendering

Postby CrazyEddie » Sat Jan 07, 2012 18:27

It is possible (likely?) that the default implementation rendering is overdrawing the custom content. Does anything change if you add the buffer containing the custom content after calling the superclass?

Also, you're probably aware, but the "new Rect" in the Image::draw call is a horrible memory leak ;)

CE.

skyforger
Just popping in
Just popping in
Posts: 12
Joined: Mon Jan 02, 2012 19:21

Re: Custom Rendering

Postby skyforger » Sat Jan 07, 2012 19:10

Thanks for the response. I did have a few leaks from the hastily written code and I was aware of most of them. They got cleared as soon as the approach didn't work, but it seems this one slipped. Here's what I've tried ( and didn't work ):

  • Adding the geometry buffer after calling the superclass ( like you suggested ).
  • Removing the super class call all together but nothing happened ( except for the window not being drawn, that is ).
  • Using the brush from another widget and using a different brush from the imageset to make sure the image wasn't the problem.
  • I've checked the buffer's vertex array. It holds the 6 vertices added by the brush forming the right quad as expected.
  • Setting the clipping region with mDragSeparatorGB->setClippingRegion( Rect( 0, 0, 100, 100 ) );
  • Adding the geometry buffer to another render queue ( overlay ) with surface->addGeometryBuffer( RQ_OVERLAY, *mDragSeparatorGB );
Any ideas what else I could try?

skyforger
Just popping in
Just popping in
Posts: 12
Joined: Mon Jan 02, 2012 19:21

Re: Custom Rendering

Postby skyforger » Sun Jan 08, 2012 00:14

I've managed to catch a glimpse of the rectangle. It's being draw for just one frame, and then it disappears. Also, not every draw call of the window causes the rectangle to briefly appear. I'm not sure what could be causing this.
Last edited by skyforger on Sun Jan 08, 2012 01:04, edited 2 times in total.

skyforger
Just popping in
Just popping in
Posts: 12
Joined: Mon Jan 02, 2012 19:21

Re: Custom Rendering

Postby skyforger » Sun Jan 08, 2012 01:04

I've solved it! Looking at the CEGUI::Window implementation I found this:

Code: Select all

void Window::queueGeometry(const RenderingContext& ctx)
{
    // add geometry so that it gets drawn to the target surface.
    ctx.surface->addGeometryBuffer(ctx.queue, *d_geometry);
}

However, the tutorial code for this was:

Code: Select all

if (ctx.surface->isRenderingWindow())
    surface = &static_cast<RenderingWindow*>(ctx.surface)->getOwner();
else
    surface = ctx.surface;

Adding the geometry buffer to the context surface and not the owner did the trick.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: [Solved] Custom Rendering

Postby CrazyEddie » Mon Jan 09, 2012 07:58

Ah, right... cool :)

I should likely add / reiterate why the tutorial has that...

Basically what is developed in that tutorial performs rendering of lines/arrows that emanate from the edge of one FrameWindow and point towards the edge of another. In order that this rendering be successful when the FrameWindow objects have their own rendering surface, we must render to the parent surface - otherwise the custom rendering is clipped to the edges of the child surface and nothing would show up (or to put it another way, the tutorial code needs to render outside of the window's surface area, so draws on the parent surface).

CE.

skyforger
Just popping in
Just popping in
Posts: 12
Joined: Mon Jan 02, 2012 19:21

Re: [Solved] Custom Rendering

Postby skyforger » Mon Jan 09, 2012 09:09

Yes, I understand what the tutorial was supposed to do, I read the forum post about the node editor ( rendering the linking lines between the windows ) so It would make sense to draw on the parent surface. Initially, I was drawing outside the window as well, but that brief flicker was happening.

Thanks for the feedback.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests