I’m currently developing a game, which only uses 2D graphics.
In the game i extensively use android’s SurfaceView to display my graphics.
I’ve heard that GLSurfaceView uses Hardware-accelerated graphics, and i can increase performance of my app using that instead of the current SurfaceView.
Currently, i have a class extending SurfaceView, which updates and renders the game state, when methods update() and render() are called by my own thread class extending Thread. The Thread basically helps me maintain a nearly constant FPS.
NOW THE PROBLEM:
How do i change from SurfaceView to GLSurfaceView, and call methods to update and render game state from the Thread, to still have control over the FPS. I read the android documentation on OpenGL ES, and i can’t quite understand how to use the GLSurfaceView.Renderer.
If someone can explain how can i easily switch from SurfaceView to GLSurfaceView, It’d be of great help! Thanks!
The Class that displays your game will extend
GLSurfaceView. Your rendering class will implementRenderer. In yourRendererclass you will need to add these unimplemented methods:onDrawFrame(),onSurfaceChanged(),and onSurfaceCreated().Hope this helps.