Author Topic: Hlep about two Renderer or two GLSurfaceView  (Read 2750 times)

Offline closuo001

  • byte
  • *
  • Posts: 3
    • View Profile
Hlep about two Renderer or two GLSurfaceView
« on: November 25, 2011, 10:15:50 am »
Code: [Select]
package sim.feel;

import java.io.IOException;
import java.io.InputStream;

import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;

import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Interact2D;
import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

public class mainact extends Activity {
// GLSurfaceView
GLSurfaceView glView;
// GLSurfaceView glView0;
int V_state;
//

yjmr mr = new yjmr(this);
welview wv=new welview(this);
//-
fthread ft = new fthread();
//P_Thread pt =new P_Thread(this,mr);
DisplayMetrics dm;

float camera_hts=130f;
int z=0;
int xpos;
int ypos;
SimpleVector dir1;
int td1=0;

int w_ws;
int w_hs;
//-
//flower 1
 
boolean start=false;
//flower 2

//-menu
   public static final int ITEM0=Menu.FIRST;//
   public static final int ITEM1=Menu.FIRST+1;
   
   //-menu 2

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//
requestWindowFeature(Window.FEATURE_NO_TITLE);
//
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//

//1

   dm = new DisplayMetrics();   
          getWindowManager().getDefaultDisplay().getMetrics(dm); 

w_ws=dm.widthPixels;
w_hs=dm.heightPixels;

//2
new LoadFile(getResources());



glView = new GLSurfaceView(this);


glView.setRenderer(wv);
// glView0 = new GLSurfaceView(this);
// glView0.setRenderer(mr);

setContentView(glView);
V_state=0;

}

public boolean onTouchEvent(MotionEvent me) {

if (me.getAction() == MotionEvent.ACTION_DOWN) {

// start=true;

xpos=(int)me.getX();
ypos=(int)me.getY();

//ft.start();
switch(V_state){
case 0:
Object3D p_obj0=leiheji.selpj(xpos, ypos, wv.world, wv.fb);
if(p_obj0==wv.anniu[0]){

glView = new GLSurfaceView(this);


glView.setRenderer(mr);
glView.requestRender();
// glView0 = new GLSurfaceView(this);
// glView0.setRenderer(mr);

setContentView(glView);
        wv.fb.dispose();
}

Hallo everyone

 :)

  I have problem about this , from one GLSurfaceView(or Renderer) switch to another GLSurfaceView(or Renderer) . 
maybe like above code ,but that is can't work.
 Are there some example or some can help ? Think you every much !!!

 :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Hlep about two Renderer or two GLSurfaceView
« Reply #1 on: November 25, 2011, 10:52:43 am »
Weird idea IMHO... ;) However...what exactly does not work?

Offline closuo001

  • byte
  • *
  • Posts: 3
    • View Profile
Re: Hlep about two Renderer or two GLSurfaceView
« Reply #2 on: November 25, 2011, 03:25:18 pm »
Weird idea IMHO... ;) However...what exactly does not work?


I had see a 2D game code about like this

Code: [Select]
public boolean onTouchEvent(MotionEvent event) {
if(event.getAction()== MotionEvent.ACTION_UP){
int x = (int)event.getX();
int y = (int)event.getY();
if(current == welcome){
if(rectGallery.contains(x, y)){
welcome.cg.galleryTouchEvnet(x, y);
}
else if(rectSound.contains(x, y)){
this.wantSound = !this.wantSound;
return true;
}
else if(rectStart.contains(x, y)){
if(checkLayout(welcome.layout)){
layoutArray = welcome.layout;
lv = new LoadingView(this);
this.setContentView(lv);
this.current = lv;
lv.lt.start();
new Thread(){
public void run(){
Looper.prepare();
if(wantSound){
initSound();
}

gv = new GameView(FootballActivity.this,imageIDs[welcome.cg.currIndex]);
lv.progress = 100;
welcome = null;
}
}.start();
}
}

That is a welcome view ,and use a onTouchEvent set to another view(like game view).
I think maybe GLSurfaceView can be use some way , cross "welcomeGLview" to "gameGLview".

So , I try. But it Error.

Activity--------------------> welcome GLSurfaceView (use onTouchEvent picking a Object3D )------->game GLSurfaceView..

Code: [Select]
else if(rectStart.contains(x, y)){
if(checkLayout(welcome.layout)){
layoutArray = welcome.layout;
lv = new GLSurfaceView(this);
                                                              lv.setRenderer(glRenderer);
this.setContentView(lv);