Java 在Android上未调用onDrawFrame
我遇到一个问题,渲染器对象似乎根本没有调用它的Java 在Android上未调用onDrawFrame,java,android,Java,Android,我遇到一个问题,渲染器对象似乎根本没有调用它的onDrawFrame。调试器从不命中函数内的断点。因此,我的正方形没有画图。这是代码,如果您还需要什么,请告诉我: public class renderer implements GLSurfaceView.Renderer { Square square; public void onDrawFrame(GL10 unused) { GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); sq
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#和其他语言那样的模糊性(如果我错了,请纠正我)。问题是我设法在不同的位置复制了同一个类,一个更新了,另一个没有。最终的结果是,它抓住了它能找到的第一个
从中吸取的教训是,你自己要注意歧义,因为编译器/解析器不会告诉你 程序中的其他断点是否正常工作?如果将
glClearColor(1,0,1,1)
添加到onDrawFrame的第一行,它仍然是黑色的吗?其他渲染器回调是否触发?GLES20.glClearColor(1,0,1,1);,什么都不做其他渲染器回调调用了吗?onSurfaceCreated或onSurfaceChanged?其他函数中没有断点。当我在GLSurface中放置断点时,会触发断点。由于活动中的断点正好命中,因此调试器已连接并工作。