GLSurfaceView and the Game Thread

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

GLSurfaceView and the Game Thread

Postby netvampire » Sat Jun 06, 2009 2:03 am

Hello,
Can someone PLEASE help me with this issue. I am so eager to finish my game and I am almost there, i Just can't get passed this one snag.

i currently have a surfaceview instance, and a seperate game thread with a while loop that continuously does this:

canvas = surfaceHolder.lockCanvas();
doDraw(canvas);

in my doDrawmethod I continously update pixels and what not.

Now i want to add some 3d rendering in there, so I changed the view from SurfaceView to GLSurfaceView, and I copied the Cube and CubeRender class over. In my glsurfaceview instance i make a call in the constructor setRender(new CubeRender() );

However, no cube is displayed. In fact, the method onDrawFrame in the cuberender class never EVER gets called.

I can't figure it out ....PLEASE HELP ME!!!
thank you.
netvampire
Freshman
Freshman
 
Posts: 6
Joined: Fri May 01, 2009 1:52 am

Top

Postby netvampire » Sat Jun 06, 2009 11:24 pm

i solved my problem by calling super.surfacecreated, super.surfacedestroyed, super.surfaceChanged in the methods that I override.

However now i have a new problem where I do not know how to draw ontop of my opengl canvas. i would simply like to do canvas.drawLine() but i can't figure out how. Any suggestions?
netvampire
Freshman
Freshman
 
Posts: 6
Joined: Fri May 01, 2009 1:52 am

Postby andre » Sun Jun 07, 2009 9:55 am

You should not mix Canvas and OpenGL. There are some articles in the forum here describing how to mix 2d and 3d operations easily.
Puzzle Blox - Android Game
Check out my tilt and touch based android game Puzzle Blox here: http://android.rabold.org
Image
User avatar
andre
Freshman
Freshman
 
Posts: 9
Joined: Mon Jun 01, 2009 9:45 am

Postby netvampire » Sun Jun 07, 2009 3:54 pm

thanks for the response
i read thru some prevoius form posts and came across the overlay method. is this an effective way to go or is there a better approach.

Thanks
netvampire
Freshman
Freshman
 
Posts: 6
Joined: Fri May 01, 2009 1:52 am

Top

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

Who is online

Users browsing this forum: Google Feedfetcher and 3 guests