• GL线程





    1
    public class MiniLauncher extends AndroidApplication implements MenuActionListener { 2 3 public View glView =null; 4 public DesktopListener mListener; 5 @Override 6 public void onCreate(Bundle savedInstanceState) { 7 8 //得到的是一个surfaceView 9 glView = initializeDesktop(mListener, true); 10 setContentView(glView); 11 12 } 13 14 public View initializeDesktop(DesktopListener listener, 15 boolean useGL2IfAvailable) { 16 17 return initializeForView(listener, config); 18 19 20 21 } 22 }

       以下是gdx自己创建新线程的流程:

     1 AndroidApplication:
     2 
     3 protected AndroidGraphics graphics;
     4 protected ApplicationListener listener;
     5 public View initializeForView (ApplicationListener listener, AndroidApplicationConfiguration config) {
     6     //graphics will create another thread for ui drawing
     7     graphics = new AndroidGraphics(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy()
     8             : config.resolutionStrategy);
     9     this.listener = listener;
    10 }
    11 
    12 AndroidGraphics:
    13 final View view;
    14     public AndroidGraphics (AndroidApplication activity, AndroidApplicationConfiguration config,
    15         ResolutionStrategy resolutionStrategy) {
    16         //thread created here
    17         view = createGLSurfaceView(activity, config.useGL20, resolutionStrategy);    
    18         this.app = activity;
    19     }
    20     
    21     private View createGLSurfaceView (Activity activity, boolean useGL2, final ResolutionStrategy resolutionStrategy) {
    22         GLSurfaceView20 view = new GLSurfaceView20(activity, true,16,0,resolutionStrategy);
    23         view.setRenderer(this);
    24         return view;
    25     }
    26     
    27     @Override
    28     public void onDrawFrame (javax.microedition.khronos.opengles.GL10 gl) {
    29     
    30         //这里的 listener 就是 d3dListener
    31        if (lresume) {
    32            app.listener.resume();
    33        }
    34        if (lrunning) {
    35               app.listener.render();
    36        }
    37        if (lpause) {
    38             app.listener.pause();
    39         }
    40         if (ldestroy) {
    41             app.listener.dispose();
    42         }
    43     
    44     }
    45 GLSurfaceView:
    46 
    47  public void setRenderer(Renderer renderer) {
    48       mGLThread = new GLThread(renderer);
    49       mGLThread.start();
    50  }
    51  
    52   class GLThread extends Thread {
    53     mRenderer = renderer;
    54       public void run() {
    55        guardedRun();
    56     }
    57       
    58     private void guardedRun() throws InterruptedException {
    59          while (true) {
    60          
    61             //mRenderer 就是 graphics
    62             mRenderer.onDrawFrame(gl);
    63          
    64          }
    65        
    66        }
    67   }
  • 相关阅读:
    Asp.NetCore3.1 WebApi 获取配置json文件中的数据
    Dapper同时操作任意多张表的实现
    将视图批量新增到PowerDesigner中并以model图表的形式展示
    .NetCore3.1获取文件并重新命名以及大批量更新及写入数据
    .NetCore 简单的使用中间件
    比较复杂的SQL转Linq
    Asp.NetCore3.1版本的CodeFirst与经典的三层架构与AutoFac批量注入
    Git与GitLab的分支合并等简单的测试操作
    Winform的控件以及DataGridView的一般使用
    在Linux系统中运行并简单的测试RabbitMq容器
  • 原文地址:https://www.cnblogs.com/mogul/p/2975870.html
Copyright © 2020-2023  润新知