dealing with ogl in a nice way

Put your problem here if it does not fit any of the other categories.

dealing with ogl in a nice way

Postby supagu » Wed Nov 04, 2009 12:48 pm

so currently i have opengl working on pc with java using lwjgl library.
this works in a similar way to c/c++ opengl in that it does what you want with opengl when you want.
ie. there is no pesky callback such as:

void onSurfaceCreated(GL10 gl, EGLConfigChooser config)

so I'm wondering if there is a way to avoid all the callbacks and get it to function in a similar way as this is making doing cross platform code painful.

i guess the final solution is to wait for android to call onSurfaceCreated, just pause my game code until this occurs, but im not sure how to do this.

here's my code currently:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4.  
  5.  
  6. class AppView extends GLSurfaceView implements SurfaceHolder.Callback, OnKeyListener
  7.  
  8. {
  9.  
  10.         public AppView(Application app)
  11.  
  12.         {
  13.  
  14.                 super(app);
  15.  
  16.                
  17.  
  18.                 setOnKeyListener(this);
  19.  
  20.                 setFocusable(true);
  21.  
  22.                 setFocusableInTouchMode(true);
  23.  
  24.                 requestFocus();
  25.  
  26.                
  27.  
  28.                 //mGame = game;
  29.  
  30.         }
  31.  
  32.  
  33.  
  34.         @Override
  35.  
  36.         public boolean onKey(View v, int keyCode, KeyEvent event) {
  37.  
  38.                 // TODO Auto-generated method stub
  39.  
  40.                 return false;
  41.  
  42.         }
  43.  
  44.        
  45.  
  46. }
  47.  
  48.  
  49.  
  50. class AppRenderer implements GLSurfaceView.Renderer
  51.  
  52. {
  53.  
  54.     public AppRenderer(AndroidDevice game)
  55.  
  56.     {
  57.  
  58.         //mGame = game;
  59.  
  60.     }
  61.  
  62.    
  63.  
  64.     public void onSurfaceCreated(GL10 gl, EGLConfigChooser config)
  65.  
  66.     {
  67.  
  68.         int nothing = 0;
  69.  
  70.         //mGame.onSurfaceCreated(gl, config);
  71.  
  72.     }
  73.  
  74.  
  75.  
  76.     public void onDrawFrame(GL10 gl)
  77.  
  78.     {
  79.  
  80.         //mGame.Render();
  81.  
  82.     }
  83.  
  84.  
  85.  
  86.     public void onSurfaceChanged(GL10 gl, int width, int height)
  87.  
  88.     {
  89.  
  90.         //mGame.Resize(width, height);
  91.  
  92.     }
  93.  
  94.  
  95.  
  96.         @Override
  97.  
  98.         public void onSurfaceCreated(GL10 gl, EGLConfig config)
  99.  
  100.         {
  101.  
  102.                 // TODO Auto-generated method stub
  103.  
  104.                
  105.  
  106.         }
  107.  
  108.    
  109.  
  110.     //private Game              mGame;
  111.  
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118. class AndroidDevice
  119.  
  120. {
  121.  
  122.  
  123.  
  124. public AndroidDevice(AndroidFactory.InitParam param)//String resourcePath, GL10 gl, Resources res)
  125.  
  126.         {/*
  127.  
  128.                 mGL = gl;
  129.  
  130.                 mResources = res;
  131.  
  132.                 mResourcePath = resourcePath;*/
  133.  
  134.                
  135.  
  136.  
  137.  
  138.                 param.activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
  139.  
  140.        
  141.  
  142.         mAppView = new AppView(param.activity.getApplication());
  143.  
  144.         mAppRenderer = new AppRenderer(this);
  145.  
  146.         mAppView.setRenderer(mAppRenderer);
  147.  
  148.         param.activity.setContentView(mAppView);
  149.  
  150.        
  151.  
  152.         // register our interest in hearing about changes to our surface
  153.  
  154.         SurfaceHolder holder = mAppView.getHolder();
  155.  
  156.         holder.addCallback(mAppView);
  157.  
  158.         /*
  159.  
  160.         mThread = new Thread(this);*/
  161.  
  162.  
  163.  
  164. // HERE I WANT TO SIT AND WAIT TILL I HAVE AN OGL SURFACE!
  165.  
  166.         }
  167.  
  168.  
  169.  
  170.  public AppView                         mAppView;
  171.  
  172.     public AppRenderer          mAppRenderer;
  173.  
  174.     public Thread                       mThread;
  175.  
  176. }
  177.  
  178.  
  179.  
  180.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
supagu
Developer
Developer
 
Posts: 32
Joined: Sun Jun 07, 2009 3:50 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 26 guests