Question to App.RequestRender()

About Monkey 2 Forums Monkey 2 Programming Help Question to App.RequestRender()

This topic contains 11 replies, has 5 voices, and was last updated by  c0d3r9 4 months, 3 weeks ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #15065

    c0d3r9
    Participant

    App.RequestRender() renders the scene, right?
    Canvas things are called after that.
    Lights too?
    Why?

    Here is the code from the simplelightning example and App.RequestRender() is in the middle of that.
    Maybe anybody can say me why?

    Or is it all rendering after RequestRender()
    Sorry but we need more tutorials 😉

    #15066

    Hezkore
    Participant

    As I understand it; rendering happens automatically after OnRender, which means it always happens after you’ve drawn all your stuff.
    App.RequestRender() only tells the application that you want another frame to be rendered as soon as possible, and since you’ll want that to happen continuously in a game App.RequestRender() is called in the OnRender method itself.
    So it won’t matter where or when you call App.RequestRender() really, rendering still occurs after OnRender.

    If you were making an app instead of a game — which only needs to render when things change e.g.; you press a button, move a slider etc. — you could use App.RequestRender() specifically when a button event happens for example.

    #15067

    abakobo
    Participant

    It doesn’t change anything if App.RequestRender() is at the beggining or at the end of OnRender(). It just means that OnRender must be called the next time.
    But you can set SwapInterval=0 so there is no Vsync, it will redraw as fast as it can.

    To control the framerate (for screen with a vsync different from 60fps e.g.) you can use a timer and SwapInterval=0, calling App.RequestRender() thru the timer.

    See spacechimps banana for an example. It uses a lot of OnBlah stuff but is readable.

    #15068

    c0d3r9
    Participant

    okay but all code that comes after App.RequestRender() would be render on the next App.RequestRender().
    Is SwapInterval = 1 set by default?

    Btw. what timer commands can i use? (sorry but the language reference freezes often my Firefox)

    #15071

    nerobot
    Participant

    but all code that comes after App.RequestRender() would be render on the next App.RequestRender().

    No, in current frame. There could be another Game template that hides such kind of stuff..

    what timer commands can i use?

    Timer for 50fps:

    New Timer( 50,Lambda()

    ‘ your code here

    End )

    #15072

    c0d3r9
    Participant

    I found timer 😉 i forget that the online help is not state of builds.
    And timer is going another way like i thought…but very useful.

     

    App.RequestRender: in short all code in the onupdate methode was rendered with the call of App.RequestRender.Right?

    Independend where RequestRender stays in the code.

    #15076

    nerobot
    Participant

    What is onupdate in your case?

    You can have timer with 120fps rate but call render each second ‘frame’, for example.

    In timer func:

    If counter mod 2=1 App.RequestRender()

    counter+=1

    In that case you have twice more updates than renders.

    #15078

    c0d3r9
    Participant

    I thought in another direction.
    I thought all what is inside onrender object was send automatic to the rendertarget.

    Now i´m a little bit confused.
    I thought in onupdate i handle some things i.e. keyboard input and so on.
    And then in onrender all inside that object was send to the render target via RequestRender.

    onrender and onupdate are only a shell.

    Theoretical i can do that all in onupdate or onrender?
    Or are there differences between these both classes?

    edit: i see “override” so i have to look inside these both classes.

    edit2: after a few hours of reading the reference maze 😉 i understand the internal of M2 a little bit more.
    onrender is a view methode.onupdate was a user created class for better code reading and handling.

    #15084

    abakobo
    Participant

    yes onupdate was user created and could have another name.

    Drawings are always made in Onrender because it’s the only place where you receive the canvas.

    #15123

    nerobot
    Participant

    I thought all what is inside onrender object was send automatic to the rendertarget.

    Now i´m a little bit confused.

    RequestRender – it’s just Request, not actually *Do*Render.

    So you just ask app to call window.OnRender (all windows if there few) when next step of game loop occured.

    I thought in onupdate i handle some things i.e. keyboard input and so on.
    And then in onrender all inside that object was send to the render target via RequestRender.

    There is no OnUpdate but it’s easy to split OnRender to Update and Render

    #15124

    skaven
    Participant

    @hezkore ah okay thank you i was wondering how it worked as well

    did you not read hezkores reply? it answers most questions

    #15126

    c0d3r9
    Participant

    I wrote “i thought”. I understand it now.

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.