簡體   English   中英

在Android上沒有調用onDrawFrame

[英]onDrawFrame not being called on Android

我有一個問題,渲染器對象似乎根本沒有調用它的onDrawFrame 調試器永遠不會在函數內部遇到斷點。 因此,我的廣場不是畫畫。 這是代碼,如果您還需要其他信息,請告訴我:

public class renderer implements GLSurfaceView.Renderer {

Square square;

public void onDrawFrame(GL10 unused) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
    square.Draw();
}

public void onSurfaceChanged(GL10 gl, int width, int height) {
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
}

public void onSurfaceCreated(GL10 unused, int width, int height) {
    GLES20.glViewport(0, 0, width, height);

}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    square = new Square(5, 5);

}

主要活動是:

public class gameActivity extends Activity {
/** Called when the activity is first created. */

private GLSurfaceView mGLView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    staticHolder.context = getApplicationContext();
    mGLView = new GLSurface(this);
    setContentView(mGLView);
}
@Override
protected void onPause() {
    super.onPause();
    // The following call pauses the rendering thread.
    // If your OpenGL application is memory intensive,
    // you should consider de-allocating objects that
    // consume significant memory here.
    mGLView.onPause();
}

@Override
protected void onResume() {
    mGLView.onResume();
}


class GLSurface extends GLSurfaceView
{
    renderer r = new renderer();
    public GLSurface(Context context)

    {
        super(context);

        setEGLContextClientVersion(2);
        setRenderer(r);
        setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
    }
}

}

目前屏幕只是黑色。 有沒有想過為什么openGL沒有正確渲染?

好吧,這真的很愚蠢,但開始沒有問題。 問題是Eclipse / Java不關心像C#和其他語言那樣的歧義(如果我錯了,請糾正我)。 問題是我設法在不同的位置復制相同的類,一個更新,另一個不更新。 最終的結果是它抓住了它能找到的第一個。

經驗教訓,請注意自己的歧義,因為編譯器/解析器不會告訴你!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM