java中onpreviewfram_java – onDrawFrame没有在Android上调用

在Android应用中,一个实现了GLSurfaceView.Renderer的渲染器对象的onDrawFrame方法未被调用,导致画面无法正常渲染。代码检查了onSurfaceChanged和onSurfaceCreated方法,但在onDrawFrame内设置的断点从未触发,因此画布上只显示黑色背景。问题可能在于渲染模式设置或OpenGL上下文的初始化。
摘要由CSDN通过智能技术生成

我有一个问题,渲染器对象似乎根本没有调用它的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没有正确渲染?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值