Nic*_*tch 2 android android-ndk-r4
这是我一直遇到的一个问题,我希望这里的某个人能够对此有所了解.
我有一个Android游戏加载一个GLSurfaceView谁的渲染器设置如下:
public class GameRenderer implements GLSurfaceView.Renderer
{
public void onSurfaceCreated(GL10 gl, EGLConfig config)
{
BaseLib.init(); // Initializes the native code
}
public void onSurfaceChanged(GL10 gl, int width, int height)
{}
public void onDrawFrame(GL10 gl)
{
BaseLib.render(); // Call to native method to render/update the current frame
}
}
Run Code Online (Sandbox Code Playgroud)
视图是这样的:
public class GameView extends GLSurfaceView implements SurfaceHolder.Callback
{
private GameRenderer _renderer;
private GameListener _listener;
public GameView(Context context)
{
super(context);
this._renderer = new GameRenderer();
setRenderer(this._renderer);
this._listener = new GameListener();
BaseLib.setListener(this._listener);
}
public boolean onTouchEvent(final MotionEvent event)
{
int action = -1;
switch(event.getAction())
{
case MotionEvent.ACTION_DOWN: action = 0; break;
case MotionEvent.ACTION_UP: action = 1; break;
case MotionEvent.ACTION_MOVE: action = 2; break;
}
if(action >= 0)
BaseLib.touch(action, event.getX(), event.getY());
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我一直在寻找本机代码,我注意到一个问题,在touch事件的中途,它似乎render()正在进行另一个 调用.由于触摸事件尚未完成,因此它会尝试渲染尚未完成加载的对象,从而产生一些错误.
这可能是本机代码本身的一个问题,但是到目前为止我还没有找到问题,我想询问Java代码是否可能在完成之前中断调用touch并调用另一个onDrawFrame().
| 归档时间: |
|
| 查看次数: |
2421 次 |
| 最近记录: |