2

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?

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
saranya krishnan
  • 965
  • 4
  • 11
  • 16
  • 1
    try this http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html – Ahmed Aswani Jan 17 '12 at 12:08
  • read the documentations on android dev, there is a tutorial on what your looking for; if you can't understand that then u got to do your java basics – tom91136 Jan 30 '12 at 14:36
  • 3
    I agree that the samples aren't the best source of information on SurfaceView for all cases. I am looking for the *simplest* implementation(s) of a functional SurfaceView, and am having trouble understanding what the minimum requirements are for a skeleton framework of drawing on a surface view. I've been looking at the Lunar Lander sample, but can't work out what's specific to the game, and what's required for using a SurfaceView. – BlueMonkMN Mar 04 '12 at 14:54
  • Download the LunarLander demo. There are tons of websites discussing it. – user432209 Mar 08 '11 at 16:48
  • 1
    do u have any easy samples??? i'm new to android.. – saranya krishnan Mar 08 '11 at 16:55
  • It doesn't get a whole lot easier when it comes to a full game application. You have to devote the time and a game application is by far _not_ the easiest thing to learn. – user432209 Mar 11 '11 at 00:11

2 Answers2

7

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.

JohnnyLambada
  • 12,700
  • 11
  • 57
  • 61
2

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.

Matthew
  • 44,826
  • 10
  • 98
  • 87