Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SurfaceView sample code

I need a sample tutorial for the android SurfaceView, or sample code using it that can be shared. The API demos are difficult for me to understand. Does anyone have alternatives?

like image 381
saranya krishnan Avatar asked Feb 22 '26 13:02

saranya krishnan


2 Answers

This commit of my WorldMap demo app shows you the changes necessary to convert from an android.view.View to an android.view.SurfaceView with an android.view.SurfaceHolder.Callback.

It cheats a bit by using the View's onDraw() from within the SurfaceView's DrawThread and by calling the View's onSizeChanged() from within the SurfaceView's surfaceChanged. It just makes the diff smaller and easier to understand.

like image 131
JohnnyLambada Avatar answered Feb 24 '26 02:02

JohnnyLambada


I'm not sure if you're needing a GLSurfaceView or not, but glbuffer is one of my favorite examples.

This is the java file where the action happens: GlBufferActivity

The project also relies on native methods and the NDK, so it may not be exactly what you're looking for, but it's a great starting point if you want to work with OpenGL via the normal C apis.

like image 45
Matthew Willis Avatar answered Feb 24 '26 03:02

Matthew Willis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!