Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4272132
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:32:11+00:00 2026-05-21T07:32:11+00:00

Ok, time to use OpenGL (gulp!) to render sprites in my apps (games), and

  • 0

Ok, time to use OpenGL (gulp!) to render sprites in my apps (games), and forgetting Bitmap.draw etc.

After trawling through hundreds of sites/blogs (well maybe) ‘explaining’ how to code using OpenGL, I have hit a brick wall.

The problem is my apps are fully functional and on the Market at the moment, but my latest app was developed on an HTC Desire HD, and I am getting many reports of bad performance on less powerful devices.

The obvious route is a move to OpenGL. All the tutorial sites are geared towards developing from scratch. This is great for anyone starting a new project, but I need a ‘retro-fit’ to my apps. I don’t fancy rewriting from scratch!

Has anyone had experience of this? Any thoughts would be hugely appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T07:32:12+00:00Added an answer on May 21, 2026 at 7:32 am

    I recently did something similar with my app and did receive a large performance benefit. A lot of what you ‘should change’ depends on how your application is structured.

    For me the hardest thing was translating my UI elements because I had to re-generate the entire ‘which control got touched’ logic and setup text rendering. Neither of these problems are tough enough to be deal beakers but I’d avoid them if you can.

    Fortunately there are some good sides. Since your app is already only 2d you can avoid the most complex parts of learning OpenGL, dealing with the 3d dimension! I’d start by setting up a gl.SurfaceView. Use glOrtho to setup the extents of your GL world, if your game was already resolution independent that should should have idea of how wide the screen is in some ‘independent’ manner. Just setup glOrtho to use those same extents.

    I created a simple sprite class which I used for all my rendering. The Sprite had simple vertex buffer as a members, I just had it make a 1 by 1 rect, then used used scale to setup the size. (So if it was really 30×30, I would set the scale to ScaleX=30 ScaleY=30).

    It looked something like this

            ByteBuffer vbb = ByteBuffer.allocateDirect( mNumVerts * 2 * 4 );
            vbb.order( ByteOrder.nativeOrder() );
            mVtxBuf = vbb.asIntBuffer();
    
            vbb = ByteBuffer.allocateDirect( mNumVerts * 2 * 4 );
            vbb.order( ByteOrder.nativeOrder() );
            mTexBuf = vbb.asIntBuffer();
    
            mVtxBuf.put( -Fixed32.HALF ); mVtxBuf.put( -Fixed32.HALF ); mTexBuf.put( 0 ); mTexBuf.put( Fixed32.ONE );
            mVtxBuf.put(  Fixed32.HALF ); mVtxBuf.put( -Fixed32.HALF ); mTexBuf.put( Fixed32.ONE ); mTexBuf.put( Fixed32.ONE );
            mVtxBuf.put(  Fixed32.HALF ); mVtxBuf.put(  Fixed32.HALF ); mTexBuf.put( Fixed32.ONE ); mTexBuf.put( 0 );
    
            mVtxBuf.put( -Fixed32.HALF ); mVtxBuf.put( -Fixed32.HALF ); mTexBuf.put( 0 ); mTexBuf.put( Fixed32.ONE );
            mVtxBuf.put(  Fixed32.HALF ); mVtxBuf.put(  Fixed32.HALF ); mTexBuf.put( Fixed32.ONE ); mTexBuf.put( 0 );        
            mVtxBuf.put( -Fixed32.HALF ); mVtxBuf.put(  Fixed32.HALF ); mTexBuf.put( 0 ); mTexBuf.put( 0 );
    
            mVtxBuf.position( 0 );        
            mTexBuf.position( 0 );
    

    (Fixed32.HALF is just 0.5 in fixed point, you can just use 0.5 and change the Draw calls to FLOAT instead of FIXED)

    With the drawing code of…

            gl.glMatrixMode( GL10.GL_MODELVIEW );
            gl.glLoadIdentity();
            gl.glEnableClientState( GL10.GL_VERTEX_ARRAY );                 
            gl.glEnableClientState( GL10.GL_TEXTURE_COORD_ARRAY );
    
            gl.glColor4f( 1.0f * thing.getAlpha() , 1.0f * thing.getAlpha() , 1.0f * thing.getAlpha() , thing.getAlpha() );  
    
            gl.glTranslatef( thing.getX(), thing.getY(), thing.getZ() );
            gl.glScalef( thing.getXScale(), thing.getYScale(), thing.getZScale() );
    
            gl.glFrontFace( GL10.GL_CW );
            gl.glVertexPointer( 2, GL10.GL_FIXED, 0, mdl.getVtxBuf() );
    
            gl.glTexCoordPointer( 2, GL10.GL_FIXED, 0, mdl.getTexBuf() );
            // gl.glColorPointer( 4, GL10.GL_FLOAT, 0, mColorBuffer );
            gl.glDrawArrays( GL10.GL_TRIANGLES, 0, mdl.getVtxCount() ); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've moved on from trying to use OpenGL through Penumbra to trying to draw
I am having a hard time trying to draw simple lines through an OpenGL
I use opengl to draw values from an array. The values are from the
first time use JTree. Just wondering is it possible to have more than one
Each time I use Merge() I have the following: 'Cannot implicitly convert type 'void'
Any time I use the recipe at http://code.activestate.com/recipes/134892/ I can't seem to get it
Its my first time to use web service in iOS. REST was my first
For the first time i use eclipse with m2e and i want to configure
use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More no_plan; use Test::Exception;
I am trying to figure out something - Every time I use AVAudioPlayer I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.