Topic: Renderable behaviours

What is the best way to be able to add renderable behaviours? I assume during update() the GL state is unlikely to be set up correctly. There is a runEvent call with parameters, but I can't find where that would be called from, so I have no idea if there would be a "draw" event. Ideally, a late-/post-render event would be amazing too, as I could do debug drawing in that, but I guess that's asking too much tongue

Re: Renderable behaviours

at some point I had made a draw function in behavior, but I removed it for a simple reason, there is now a renderer system in Maratis (it was not like that before), there is now a standard renderer (shaders) and a fixed renderer, so it's not completely safe to let a general draw behavior function.

I preferred leaving the choice of drawing only non-general using the MGame class, the runEvent was done to be called from MGame, for example from MGame::draw you can call beavior->runEvent with a code.

But, yes it's not completely generic. But for this quind of thing to be allowed, a solution need to be find first to know how to deal with different renderers.

Re: Renderable behaviours

Hmmm, thanks, I'm not entirely sure what I can do with that, as I'm working on plugins which can't really have a game. I might try and add extra function pointers to MPlugin which can call update and draw if they're present.

I'm not sure I quite understand what's unsafe, considering that it's already abstracted to MRenderingContext... but I will admit a serious lack of knowledge here, so I do believe you tongue I will try and have a closer look later and see if I can think of anything smile

Re: Renderable behaviours

In fact, I taught about it and there is a simple way to make it safe without coding anything,
the behavior can just check what is the current renderer to draw with or without shader.

What is unsafe is if a generic behavior try to draw something in 3d using shaders if the renderer is a fixed renderer (without shader).

Re: Renderable behaviours

I can make a quick fix and add a draw function in MBehavior at lunch if you want.

Re: Renderable behaviours

That would be great. I don't know if I'm going to have much time to work on stuff myself any time soon, so it's no rush though smile No need at lunch time if you don't have time smile

Re: Renderable behaviours

It's ok, I added it on svn, that was really nothing complicated, just added a virtual function to MBehavior and a standard call to it in MGame::draw.

So there is a draw function that is called by default at the end (but the order can be changed with a custom game).
Just be sure to check the current renderer in case you are using shaders, if you want the behavior to be really generic.

Re: Renderable behaviours

That's awesome! thanks smile I Hope I'll have time to play with it now tongue

Re: Renderable behaviours

Haha. I had an issue with it last night, that it didn't draw, so I gave up and went to bed. Now I took a look at it again and it was because I was trying to test it in my game scene, which had the custom MGame class to handle the post processing shader. Guess what I forgot to do...

I called MGame::draw and... well, it crashes now. That's more like what I was expecting tongue I made a guess at how to translate OpenGL array calls to MRenderingContext calls. I guess I got them wrong

EDIT: removed some of the smileys, they were annoying me

Last edited by Nistur (2012-03-20 20:18:49)