Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In my old game based on canvas and bitmaps I used surfaceHolder and Thread to call onDraw:

public class GameThread extends Thread {
private SurfaceHolder _surfaceHolder;
private ScreenObjectsView _panel;
private boolean _run = false;

public static int mOnDrawPeriodGap = 20;


public GameThread(SurfaceHolder surfaceHolder, ScreenObjectsView panel) {
    _surfaceHolder = surfaceHolder;
    _panel = panel;
}

public void setRunning(boolean run) {
    _run = run;
}

public SurfaceHolder getSurfaceHolder() {
    return _surfaceHolder;
}

@Override
public void run() {
    Canvas c;
    while (_run) {

        if(!_surfaceHolder.getSurface().isValid()){
            continue;
        }

        c = null;
        //Log.e("test","thread running");
        try {
            c = _surfaceHolder.lockCanvas(null);
            synchronized (_surfaceHolder) {
                _panel.updatePhysics();
                _panel.onDraw(c);

                /** onDraw() method  run too fast, lets slower it*/
                try {
                    Thread.sleep(mOnDrawPeriodGap);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        } finally {
            // do this in a finally so that if an exception is thrown
            // during the above, we don't leave the Surface in an
            // inconsistent state
            if (c != null) {
                _surfaceHolder.unlockCanvasAndPost(c);
            }
        }
    }
}

}

Today I try to adapt my game to openGL 2D. I'm new in openGL world.

Do I need to do the same for new framework?

As I know It (openGL) seems already starts a second thread for rendering, calling into the Renderer methods.

Thank you,

share|improve this question

closed as off-topic by Anko, Seth Battin, Trevor Powell, Byte56 Mar 12 at 14:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – Seth Battin, Byte56
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.