Languages

Menu
Sites
Language
OpenGl via GLPlayer/Renderer and threads

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

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

2 Replies
muditha murthy
I think that you are trying to run game application with multi-thread application and game logic which also renders the frames runs in the seperate thread. Tizen does not guarantee the proper rendering results by rendering in separate threads except main thread, therefore, I think that you have to move all the render related codes to main thread for proper results.
Benjamin Blois
That's what I've done. Currently I have the game logic thread which is updating the data, and sleep while there is no draw (with a mutex). In my main thread, I have the GLPlayer/GLRenderer context set to update the screen at a rate of 60fps, but sleeping in the Draw loop if the image is not ready yet. It works pretty well, (some problems of GL_OUT_OF_MEMORY put aside).