Using draw texture extension for 2d games

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

Using draw texture extension for 2d games

Postby Kyros » Wed Oct 21, 2009 11:57 am

Hi all,

I have started learning OpenGL ES and would like to use it as an alternative to a canvas in my game to improve the frame rates.
I am unsure about how to make a framework for OpenGL ES though and how to load a texture and draw it.
Does anyone have a very basic example that shows this?
I have 3 classes for the framework so far, one is the Activity to setup the GLSurfaceView, another is the class that extends the GLSurfaceView, and the third is the renderer.
So with this I have drawn a basic triangle to show it works.
What I need now is a bit of code to load a texture and set it up and then a bit more code to show how to draw the texture?
I found Chris Pruetts Sprite Method test code but that is too advanced for me yet because I dont know what half of the Open GL calls are doing so I really need something basic.

Junior Developer
Junior Developer
Posts: 13
Joined: Wed Oct 21, 2009 11:49 am


Postby Kyros » Sun Oct 25, 2009 6:13 pm

Wow 113 views but no replies :(
Lots of interest in this topic.
No one on here using draw texture in their 2d games?
Junior Developer
Junior Developer
Posts: 13
Joined: Wed Oct 21, 2009 11:49 am

Postby alvion » Thu Feb 11, 2010 12:20 am

I can't think of an example other than SpriteMethodTest for using the DrawTexture extension. If you only care about the draw texture stuff, you can ignore a lot of the other opengl stuff, all you care about is the window setup (which you can find simpler versions of) and the gl code in the Sprite draw method. All the code in the Grid class is only for the other drawing methods.

One thing to keep in mind though is that you can't draw rotated sprites with the glDrawTex functions (although I believe you can scale them).

Outside of window setup, this is really all you need:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  2. gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureName);
  6. // Draw using the DrawTexture extension.
  8. ((GL11Ext) gl).glDrawTexfOES(x, y, z, width, height);
Parsed in 0.013 seconds, using GeSHi
Posts: 4
Joined: Sat Nov 07, 2009 12:51 am
Location: San Francisco, CA


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

Who is online

Users browsing this forum: No registered users and 5 guests