multithreading - Android: OpenGL in several threads -


i having opengl surfaceview. needs updated external event coming on networksocket, networksocket running in external thread, since needs listen time on port incoming traffic, when traffic arrives new opengl object should created , shown on screen. far understand opengl stuff, can't change objects outer thread, queueevent() have chance. code looks following, unfortunatelly isn ot working:

public class gamemain extends activity {   protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     glview=new gameview(this);     setcontentview(glview);     }  }   public class myglsurfaceview extends glsurfaceview{     public myglsurfaceview(context context) {     super(context);             renderer = new openglrenderer();             this.setrenderer(renderer);      }      public void do(serversocket ss){         try{     while(true){             try {                 ss.setsotimeout(500);             socket s = ss.accept();                             renderer.set();                        }catch(sockettimeoutexception e){}                      }              }catch(exception e){                     handleexception();      }      public void handleevent(){     thread t = new thread(new runnable() {         @override         public void run() {             try{                 serversocket ss = new serversocket(7070);                 while(true){                     get(ss);                 }             }catch(exception e){                 e.printstacktrace();             }         }     });     queueevent(t);     t.start(); }  } public class openglrenderer implements  rend{  cube c = null;     public openglrenderer(){          //inits      } public void onsurfacecreated(gl10 gl, eglconfig config) {            //.....      }     public void ondrawframe(gl10 gl) {       if(c!=null)          dosth();              //....     }    public void set(){        c = new cube();    }   } 

so set() method called when networking traffic arriving, unfortunatelly local variable c not updated ondrawframe() method. why case, how can achieve this?

can please me!?

thanks lot regards

what's queueevent(t); ? read code, calling handleevent() starts socket listen... when arrives on socket want add cube display. right?

if so, it's in socket-listening thread want send message rendering thread via queueevent(), , don't send thread function run! code stands running socket listening function twice... once on dedicated thread, once on rendering thread (!).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -