Why extend GLSurfaceView?

Problems with Canvas, OpenGL, etc...

Why extend GLSurfaceView?

Postby James Coote » Fri Dec 16, 2011 12:19 pm

This is more a best-practice / wanting deeper understanding question than an "I'm stuck" question

I wrote a 3D game android app completely in Java (no NDK), and it works fine, runs great, I've solved all the threading problems and I can see how if I wanted to make it even more efficient, I could use the NDK in certain sections. This is all in android 2.1 / openGL-ES 1.1

However I don't extend GLSurfaceView at all in my app

I can see that the official site tells you

a). Inter-thread communication is easiest with queueEvent(Runnable) (see Handling events section)

b). You have to extend GLSurfaceView to register touch events on GLSurfaceView (see The Basics -> GLSurfaceView section)

Point a) leads lots of people down the path of implementing threading in their apps with runnable, whilst everywhere else in the android documentation it recommends using AsyncTask and/or Handler

Point b) is just plain wrong (at least for api lvl 7 / 2.1, not tried other versions). You can just implement your own bog-standard onTounchListener and attach it to a GLSurfaceView just as you might do with any other view

I keep coming across people on StackOverflow asking questions about android and openGL-ES and they are all extending GLSurfaceView and I'm thinking "why? You don't need to..."

Am I missing something fundamental or is there some really smart reason for extending GLSurfaceView aside from doing your own crazy custom openGL rendering code?
James Coote
Once Poster
Once Poster
Posts: 1
Joined: Fri Dec 16, 2011 11:58 am


Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests