OpenGl via GLPlayer/Renderer and threads

OpenGl via GLPlayer/Renderer and threads

BY 29 May 2013 Native Application Development

Hi,

I’m currentry working on a game, using OpenGL with the GLPlayer/Renderer wrapper.
I’m trying to get a good synchronisation between the game logic, and the renderer but no matter what I try, I can’t get it working well. Here is The differents approachs a tried :

 – Firstly, I tried to lauch the game engine infinite loop at the end of the “OnAppInitialized” method of my application, with at some points, some call for a redraw (with Invalidate), but I can’t get the context to render (not even the first frame with the clear color…).

 – I then tried with the game logic in a separate thread. It worked better, but I did not find an adequate way to request a redraw of the context :
         I tried to use the Invalidate() method of the Frame, but with in I can’t use HW Accelleration, which causes a poor framerate.
         I also tried to call directly the Redraw() method of the GLplayer, resulting in a lot of “eglMakeContext failed”

 – If I understood well, there is also a possibility to ask the Player to redraw itself on a regular basis (with the SetFPS method), but, it didn’t work ether…

 – I even tried to get rid of the player, without better results.

I’ve come to something acceptable with two threads, with the game logic calling for a redraw, and waiting for the answer with a mutex. But to claim a redraw, it uses Invalidate, and it prevents me from using the HW acceleration, and cause awfull framerate.

I would like to know is there is other ways to ask for a redraw (in a synchronuous way would be even better) in accordance with HW acceleration.
Any substitute is of course accepted.
 

Thanks by advance

Benjamin

Written by