Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - hika00

Pages: [1]
1
Support / texture loaded but failed to upload..?
« on: August 13, 2012, 03:58:27 pm »
LogCat
08-13 22:53:07.103: I/jPCT-AE(23333): Loading Texture...
08-13 22:53:07.193: I/jPCT-AE(23333): Texture loaded...4194304 bytes/1024*1024 pixels!
08-13 22:53:07.233: I/jPCT-AE(23333): [ 1344865987242 ] - ERROR: Failed to upload texture!

Debug
   GLRenderer.upload(Texture) line: 1592   
   TextureManager.preWarm(FrameBuffer) line: 297   

2
Support / ERROR: Failed to upload texture!
« on: August 06, 2012, 11:50:32 am »
Activity
---------------------------------------------------------------
package com.bsidesoft.test;

import com.bsidesoft.adr.bs;

import android.app.Activity;
import android.os.Bundle;

public class bsTest0 extends Activity{

   private bs _bs;
   
   @Override
    public void onCreate( Bundle $savedInstanceState ){
        super.onCreate( $savedInstanceState );
        _bs = new bs( this, $savedInstanceState, "bs", "file:///android_asset/url.html" );
        setContentView( _bs );
    }
   @Override
   protected void onStart(){
      super.onStart();
      _bs.onStart();
   }
   @Override
   protected void onResume(){
      super.onResume();
      _bs.onResume();
   }
   @Override
   protected void onPause(){
      super.onPause();
      _bs.onPause();
   }
   @Override
   protected void onStop(){
      super.onStop();
      _bs.onStop();
   }
   @Override
   protected void onDestroy(){
      super.onDestroy();
      _bs.onDestroy();
   }
}
--------------------------------------------------------------------
SurfaceView

final public class bs extends SurfaceView implements Callback, Runnable{

   final static int MAX_LAYER = 5;
   
   private Thread _thread;
   private boolean _isRunning = false;
   private boolean _isSurfaceChanged = false;
   
   private Activity _act;
   private SurfaceHolder _holder;
   private GL10 _gl;
   private EGL10 _egl;
   private EGLDisplay _eglDisplay;
   private EGLConfig _eglConfig;
   private EGLContext _eglContext;
   private EGLSurface _eglSurface;
   
   private int _width;
   private int _height;
   private boolean _isLandscape;
   
   private bsLayer[] _layers = {null, null, null, null, null};
   private bsLayer _curr;
   private TextureManager _textureManager;
   
   public bs( Activity $act, Bundle $bundle, String $storagePath, String $url ){
      super( $act.getApplication() );
      _act = $act;
      _holder = getHolder();
      _holder.addCallback( this );
      setFocusable( true );
      requestFocus();
      setFocusableInTouchMode( true );
      _textureManager = TextureManager.getInstance();
   }
   public void onStart(){
      Slog("onStart");
   }
   public void onResume(){
      Slog("onResume");
      _isRunning = true;
      _thread = new Thread( this );
      _thread.start();
   }
   @Override
   public void run(){
      while( _isRunning ){
         if( _isSurfaceChanged ){
            for( int i = 0 ; i < MAX_LAYER ; i++ ) if( _layers != null ) _layers.run();
         }
      }   
   }
   public void onPause(){
      Slog("onPause");
      _isSurfaceChanged = _isRunning = false;
      while( true ){
         try{
            _thread.join(); break;
         }catch( Exception $e ){}
      }
   }
   public void onStop(){
      Slog("onStop");
   }
   public void onDestroy(){
      Slog("onDestroy");
   }
   void Slog( String $log ){
      Log.i( "bs", $log );
   }

   void start(){
      Ladd( 0 );
      _textureManager.addTexture( "a", new Texture( 10, 10, new RGBColor( 255, 0, 0 ) ) );
      Object3D plane = Primitives.getPlane( 1, 1 );
      plane.setTexture( "a" );
      _layers[0].world.addObject( plane );
   }
   @Override
   public void surfaceCreated( SurfaceHolder holder ){}
   @Override
   public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ){
      Slog("surfaceChanged");
      boolean isStart = false;
      if( _gl == null ){
         if( !init() ){
            Slog( "fail" );
            return;
         }
         isStart = true;
      }else{
         restart();
      }
      _isLandscape = _act.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
      for( int i = 0 ; i < MAX_LAYER ; i++ ) if( _layers != null ) Ladd( i, false );
      _isSurfaceChanged = true;
      if( isStart ) start();
   }
   public void Ladd( int $index){
      Ladd( $index, true );
   }
   void Ladd( int $index, boolean $isInit ){
      synchronized(this){
         bsLayer layer = new bsLayer();
         FrameBuffer fb = layer.fb;
         if( fb != null ) fb.dispose();
         layer.fb = new FrameBuffer( _gl, _width, _height );
         if( $isInit ){
            layer.world = new World();
            layer.world.setAmbientLight( 255, 255, 255 );
            layer.camera = layer.world.getCamera();
         }
         _layers[$index] = layer;
      }
   }
   
   private boolean init(){
      _egl = (EGL10) EGLContext.getEGL();
      _eglDisplay = _egl.eglGetDisplay( EGL10.EGL_DEFAULT_DISPLAY );
      
      {
         int[] version = {-1, -1};
         if( !_egl.eglInitialize( _eglDisplay, version ) ){
            Slog( "eglInit fail " );
            return false;
         }
      }
      
      {
         EGLConfig[] configs = new EGLConfig[1];
         int[] num = new int[1];
         int[] spec = {EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE};
         if( ! _egl.eglChooseConfig( _eglDisplay, spec, configs, 1, num) ){
            Slog( "eglChooseConfig fail " );
            return false;
         }
         _eglConfig = configs[0];
      }
      
      {
         _eglContext = _egl.eglCreateContext( _eglDisplay, _eglConfig, EGL10.EGL_NO_CONTEXT, null );
         if( _eglContext == EGL10.EGL_NO_CONTEXT ){
            Slog( "eglCreateContext fail " );
            return false;
         }
      }
      
      {
         _eglSurface = _egl.eglCreateWindowSurface( _eglDisplay, _eglConfig, _holder, null );
         if( _eglSurface == EGL10.EGL_NO_SURFACE ){
            Slog( "eglCreateWindowSurface fail " );
            return false;
         }
      }
      
      _gl = (GL10) _eglContext.getGL();
      
      {
         if( ! _egl.eglMakeCurrent( _eglDisplay, _eglSurface, _eglSurface, _eglContext ) ){
            Slog( "eglMakeCurrent fail " );
            return false;
         }
      }
      
      {
         Rect rect = _holder.getSurfaceFrame();
         _width = rect.width();
         _height = rect.height();
      }
      _egl.eglSwapBuffers(_eglDisplay, _eglSurface);
      return true;
   }
   private void restart(){
      
   }
   @Override
   public void surfaceDestroyed( SurfaceHolder holder ){
      
   }
}
---------------------------------------------------------------
Layer

final class bsLayer{
   
   static private RGBColor back = new RGBColor( 0, 0, 0, 0 );
   
   FrameBuffer fb;
   World world;
   Camera camera;
   
   void run(){
      fb.clear( back );
      world.renderScene( fb );
      world.draw( fb );
      fb.display();   
   }
}
----------------------------------------------------------------
flow

1. onStart - onResume - surfaceChanged
2. start ( after onDestroy )
3. thread - run()
4. world.draw()
5. GLRenderer.convertTexture()

----------------------------------------------------------------
please, what's the problem in custom SurfaceView?

----------------------------------------------------------------
error stack

bs [Android Application]   
   DalvikVM[localhost:8601]   
      Thread [<1> main] (Running)   
      Thread [<10> Binder Thread #2] (Running)   
      Thread [<9> Binder Thread #1] (Running)   
      Daemon Thread [<8> FinalizerWatchdogDaemon] (Running)   
      Daemon Thread [<7> FinalizerDaemon] (Running)   
      Daemon Thread [<6> ReferenceQueueDaemon] (Running)   
      Thread [<11> Thread-3942] (Suspended (exception RuntimeException))   
         Logger.log(String, int) line: 189   
         GLRenderer.convertTexture(Texture) line: 982   
         GLRenderer.setTextures(Object3D, int, int, FrameBuffer, World) line: 2339   
         GLRenderer.drawVertexArray(VisList, int, int, FrameBuffer, World) line: 2252   
         World.draw(FrameBuffer, boolean, int) line: 1354   
         World.draw(FrameBuffer) line: 1135   
         bsLayer.run() line: 19   
         bs.run() line: 81   
         Thread.run() line: 856   
      Thread [<12> Binder Thread #3] (Running)   

3
Support / get TextureName from loaded 3ds
« on: August 03, 2012, 10:11:01 am »
Object3D[] temp = Loader.load3DS( is , 1.0f );
for( int i = 0, j = temp.length ; i < j ; i++ ){
   log( temp.getName() + ":"+ _textureManager.getNameByID( temp.getPolygonManager().getPolygonTexture(0) ) );
}
--------------------------------------------------------
box1:--dummy--
box2:--dummy--
box3:--dummy--
....

How can I get the right Texture names?

4
I got Logger message

jPCT-AE  [1343799062848 ] - EEROR: Failed to upload textrue!

from

GLRenderer.convertTexture(Texture) line: 982

and here is all stacks.

Logger.log(String, int) line: 189   
GLRenderer.convertTexture(Texture) line: 982   
GLRenderer.setTextures(Object3D, int, int, FrameBuffer, World) line: 2339   
GLRenderer.drawVertexArray(VisList, int, int, FrameBuffer, World) line: 2252   
World.draw(FrameBuffer, boolean, int) line: 1354   
World.draw(FrameBuffer) line: 1135   
bs.renderDraw() line: 157   
bsGLView.run() line: 90   
Thread.run() line: 856   

I made SurfaceView and SurfaceHolder because GLSurfaceView lost all context when onPause.

public class bsGLView extends SurfaceView implements Callback, Runnable{

   private bs _bs;
   
   private SurfaceHolder _holder;
   private EGL10 _egl;
   private EGLConfig _eglConfig;
   private EGLDisplay _eglDisplay;
   private EGLSurface _eglSurface;
   private EGLContext _eglContext;
   private GL10 _gl;
   private Thread _thread;
   private boolean _isRunning = false;
   
   public bsGLView( Activity $act, String $path, String $url ){
      super( $act.getApplication() );
      getHolder().setFormat( PixelFormat.RGBA_8888 );
      getHolder().addCallback( this );
      _bs = new bs( $act, $path, $url );
   }
   @Override
   public void surfaceCreated( SurfaceHolder $holder ){}
   @Override
   public void surfaceChanged( SurfaceHolder $holder, int $format, int $width, int $height){
      Log.i("bs", "changed");
      if( _gl == null ){
         _holder = $holder;
         _egl = (EGL10)EGLContext.getEGL();
         _eglDisplay = _egl.eglGetDisplay( EGL10.EGL_DEFAULT_DISPLAY );
         if( !_egl.eglInitialize( _eglDisplay, new int[2] ) ){
            throw new Error("egl init");
         }
         {
            EGLConfig[] configs = new EGLConfig[1];
            if( !_egl.eglChooseConfig( _eglDisplay, new int[]{ EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE }, configs, 1, new int[]{0x3098, 2} ) ){
               throw new Error("egl config");
            }
            _eglConfig = configs[0];
         }
         _eglContext = _egl.eglCreateContext( _eglDisplay, _eglConfig, EGL10.EGL_NO_CONTEXT, null );
         if( _eglContext == EGL10.EGL_NO_CONTEXT ){
            throw new Error("egl context");
         }
         _eglSurface = _egl.eglCreateWindowSurface( _eglDisplay, _eglConfig, _holder, null );
         if( _eglSurface == EGL10.EGL_NO_SURFACE ){
            throw new Error("egl surface");
         }
         _gl = (GL10) _eglContext.getGL();
         if( !_egl.eglMakeCurrent( _eglDisplay, _eglSurface, _eglSurface, _eglContext ) ){
            throw new Error("egl current");
         }
         _bs.viewInit( this );
      }else{
         _eglSurface = _egl.eglCreateWindowSurface(_eglDisplay, _eglConfig, _holder, null );
         _egl.eglMakeCurrent( _eglDisplay, _eglSurface, _eglSurface, _eglContext );
      }
      _bs.renderSurfaceChanged( _gl, $width, $height );
      _egl.eglSwapBuffers(_eglDisplay, _eglSurface);
      _bs.renderDraw();
      _isRunning = true;
      _thread = new Thread( this );
      _thread.start();
   }
   @Override
   public void surfaceDestroyed( SurfaceHolder $holder ){
      Log.i("bs", "destroy");
      pause();
      _bs.viewFinish();
   }
   @Override
   public void run(){
      while( _isRunning ){
         _bs.renderDraw();
      }
   }
   public void pause(){
      Log.i("bs", "pause");
      if( _eglSurface != null ){
         _egl.eglMakeCurrent( _eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, _eglContext );
         _egl.eglDestroySurface( _eglDisplay, _eglSurface );
         _eglSurface = null;
      }
      _isRunning = false;
      while( true ){
         try{
            _thread.join(); break;
         }catch( Exception $e ){}
      }
      _bs.viewPause();
   }
   public void resume(){
      Log.i("bs", "resume");
      _bs.viewResume();
   }
   public void activityResult( int $request, int $result, Intent $data ){
      _bs.activityResult( $request, $result, $data );
   }
}

any good idea?

Pages: [1]