[Request] Option to Add an Update function that gets Called Before Render

View previous topic View next topic Go down

[Request] Option to Add an Update function that gets Called Before Render

Post  uprise78 on Tue May 12, 2009 10:14 am

Basically, I like to separate my updates from my renders to keep the code clean and readable. It is pretty easy to just call an update method on the first line of the render function but it seems like it would be cleaner overall if the sio2 object allowed us to add a 'templateUpdate' method that could get called just before 'templateRender'. Any thoughts?

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  Francescu on Tue May 12, 2009 10:57 am

I'm not sure what you mean by updates? You can have multiple render functions for your multiple levels and I'm assuming this is what you mean by 'renders' - how would you bind a templateUpdate to a particular templateRender - function ptr?

Cheers

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  uprise78 on Tue May 12, 2009 12:43 pm

What I mean is something similar to the _SIO2windowrender. A new function pointer on the _SIO2window object that you can set just like _SIO2windowrender.

Code:
sio2->_SIO2window->_SIO2windowupdater
sio2->_SIO2window->_SIO2windowrender

Right before sio2->_SIO2window->_SIO2windowrender gets called sio2->_SIO2window->_SIO2windowupdater would be called. The point being to separate your game logic (accelerometer smoothing, updating transforms, etc) from the actual rendering code. IMHO this keeps the code much cleaner and easier to manage.

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  oioioi on Tue May 12, 2009 12:54 pm

You can make this your self in a few minutes...
I don't think this is something which is necessary to include in sio2 because you could, as you said, just call the update function on the first line of your render function, or make it your self if you really need it which is super easy.

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  uprise78 on Tue May 12, 2009 1:11 pm

Back in the day when the sio2 file wasn't a static lib this would be easy...and it feels a bit ugly to stick an update function call on the top of my render call which then binds the render function to the update function. Obviously not a big deal in any way though. Either way works in the end.

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  sio2interactive on Tue May 12, 2009 4:11 pm

SIO2 is not a static library... all the callbacks for rendering & events are in sio2_window.cc / .h

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  uprise78 on Tue May 12, 2009 5:29 pm

Perfecto. I shall add it for my project. Thanks SIO2.

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: [Request] Option to Add an Update function that gets Called Before Render

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum