www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: raft on August 20, 2010, 07:23:41 am

Title: compile
Post by: raft on August 20, 2010, 07:23:41 am
i know compile() method is removed because all objects are compiled in AE but it may still make sense to put it back. it's is useful as a preperation before game begins. if i dont miss something, at the moment we are forced to serialize even the simplest objects like particles. particles are typically cloned from a master and at each cloning a compile occurs
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 07:30:37 am
 ??? You don't have to serialize particles...at least i don't. I create a particle pool, pre-fill it with, let's say, 50 instances all cloned from the master. They all share the same mesh and the same compiled data (Object3d.shareCompiledData(<Object3D>); ).
If you want to make sure that everything is compiled before the game begins, just call World.compileAllObjects(). However, that doesn't include the actual filling of the native structures at runtime, which i can't push up to an earlier stage. It's pretty cheap anyway.
Title: Re: compile
Post by: raft on August 20, 2010, 03:08:42 pm
mm, i tried sharedCompileData thingy but couldn't manage to work, i must have messed something that time ::)

now it works in desktop version. i create my master particle in a static initializer block (like in Robombs). it works in desktop since i can compile it there. no such option for AE. so you do create master for each level ?

is compileAllObjects() thread safe ?
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 08:26:18 pm
The master object needs no explicit compile even if you use shareCompiledData() on it. The object compiler will compile it if needed once it encouters an object that shares data with it.

compileAllObjects() isn't thread safe, but i can easily make it if that does any good!?
Title: Re: compile
Post by: raft on August 20, 2010, 08:44:49 pm
i was getting this exception in AE when trying to share:
Code: [Select]
E/AndroidRuntime(10098): Caused by: java.lang.RuntimeException: [ 1282329180107 ] - ERROR: Can't enable data sharing after calling compile on object object28!
E/AndroidRuntime(10098): at com.threed.jpct.Logger.log(Logger.java:159)
E/AndroidRuntime(10098): at com.threed.jpct.Object3D.shareCompiledData(Object3D.java:837)

i was calling shareCompiledData() after build(). after your post i reversed the order and now it works. i suppose build is not even necessary there.
but the thing is, same code is now broken in desktop version. if it won't be trouble, adding compile to AE may really help.

for compileAllObjects(), it doesnt really matter. i can live both way.
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 09:03:14 pm
I don't like adding compile() to AE, because it's now done in build() anyway. Making it an extra method again forces one to call two methods where one would be sufficient. Instead, i've removed the check from shareCompiledData(). To be honest, i can't see any reason why i disallowed calling compile() before shareCompiledData()...might be that it was needed that way in former versions but i can't see why it's needed in the current implementation. Not in AE and not in the desktop version.

I've uploaded the fixed jar for AE.
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 09:05:22 pm
but the thing is, same code is now broken in desktop version.
Why is that? What happens on the desktop version when reversing the order?
Title: Re: compile
Post by: raft on August 20, 2010, 09:13:53 pm
thanks but this doesnt solve my situation. maybe i miss it something ???

i cannot call compile() on master object because there is no compile on AE. sharing data with it works on AE but desktop version complains saying "Can't set an uncompiled object was a source for compiled data!"

Quote
Making it an extra method again forces one to call two methods where one would be sufficient.
this may not be necessary, build() can still compile if object is not compiled yet. not sure this fits you..
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 09:25:08 pm
But doesn't the same problem apply to the cloned object? You can't call compile() on them either in AE, but you would have to in desktop version!?
Title: Re: compile
Post by: raft on August 20, 2010, 09:36:00 pm
yes it does. but i couldnt get your point. if you add compile to AE, i will call it on master of cloned objects too.
possibly you are talking about something else ???
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 09:43:05 pm
yes it does. but i couldnt get your point. if you add compile to AE, i will call it on master of cloned objects too.
possibly you are talking about something else ???
No, its the same thing. I just wanted to make sure that there isn't any other way to solve this than to put compile() back in...which i stil don't like, but i guess i have to...i've uploaded another jar that does this. Please give it a try and see if it helps.
Title: Re: compile
Post by: raft on August 20, 2010, 09:51:14 pm
thanks, it's ok now ;D sorry for the trouble ::)
Title: Re: compile
Post by: EgonOlsen on August 20, 2010, 10:10:42 pm
No problem. BTW: This doesn't replace compileAllObjects() in World, which really does the compilation. The call to compile() in Object3D only does some preparational work.
Title: Re: compile
Post by: raft on August 21, 2010, 12:35:58 am
Egon, i got the following exception, you may wanna know.

Code: [Select]
I/jPCT-AE (10652): Object 'object111' shares compiled data with object 'object110'
W/System.err(10652): java.lang.RuntimeException
W/System.err(10652): at com.threed.jpct.CompiledInstance.render(CompiledInstance.java:171)
W/System.err(10652): at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2027)
W/System.err(10652): at com.threed.jpct.World.draw(World.java:1310)
W/System.err(10652): at com.threed.jpct.World.draw(World.java:1092)
W/System.err(10652): at raft.jumpy.android.JumpyActivity$MyRenderer.onDrawFrame(JumpyActivity.java:539)
W/System.err(10652): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1116)
W/System.err(10652): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
I/jPCT-AE (10652): [ 1282343088183 ] - ERROR: Internal error, please report: render() called on an uncompiled object (object111)!

after some digging i've found the reason: i call build(false) on an object and then call shareCompiledData(..) on it. i know it makes no sense, i've corrected my code..
Title: Re: compile
Post by: EgonOlsen on August 21, 2010, 10:22:09 am
This can only happen if rendering interleaves with the build()...shareCompiledData()-sequence somehow. This might be the reason why i formerly insisted on calling share... before calling compile(). Anyway, with the latest changes, this can happen now and even if it's not nice, it's maybe nothing that should cause a crash anymore. I've changed the state of the message to a warning and return from rendering afterwards.
Title: Re: compile
Post by: raft on August 22, 2010, 05:19:59 pm
Quote from: EgonOlsen
This can only happen if rendering interleaves with the build()...shareCompiledData()-sequence somehow.
not sure about this. new particles are added in update method and rendering comes afterwards. and all is done in same thread
Title: Re: compile
Post by: EgonOlsen on August 22, 2010, 08:05:28 pm
Ok...but...this is the code in question:

Code: [Select]
if (obj.shareWith != null && !obj.sharing) {
       // Copy compiled data from another object
obj.sharing = true;
if (obj.compiled.size() != obj.shareWith.compiled.size()) {
Logger.log("Number of compiled instances don't match...can't share data!", Logger.ERROR);
return;
}

for (int i = 0; i < obj.compiled.size(); i++) {
CompiledInstance dcis = obj.compiled.get(i);
CompiledInstance scis = obj.shareWith.compiled.get(i);

if (Config.useVBO && gl11 != null && vboPossible && !dynamic) {
scis.createBuffers(gl11, rendy);
}

dcis.copy(scis);
}
filled = true;
Logger.log("Object '" + obj.getName() + "' shares compiled data with object '" + obj.shareWith.getName() + "'");
}

if (!filled) {
Logger.log("render() called on an uncompiled object (" + obj.getName() + ")!", Logger.WARNING);
return;
}

As you can see, filled is set to true right before the message about sharing is being printed out (it appears in your log too). Then, filled is checked...it can't be set to false in between, because there is no code that sets it to false anywhere in the engine. There's only one other part that sets it to true and that is after compiling an object that doesn't share data. So i don't see a way that can cause this except for some thread interaction between building/compiling/sharing/rendering...
Title: Re: compile
Post by: raft on August 22, 2010, 08:43:37 pm
you may be right, can't access code at the moment. isn't there a chance build(false) can interfere with it ?
Title: Re: compile
Post by: EgonOlsen on August 22, 2010, 08:52:43 pm
If done in another thread, then yes...i suppose... ;)
Title: Re: compile
Post by: raft on August 23, 2010, 12:46:26 am
well, this is really strange, i've tried but i couldnt create a test case ???

gui thread is involved, it loads the level, creates the world and objects but since then render thread is unaware of the world. then world is passed to renderer and game goes on..

i've made some tests. this happens only if sharedCompileData is called on the object in question (calling build(false) doesnt matter). the master object is constructed via add addTriangle(..) methods. if i pass -1 as texture id, this exception doesnt happen. really weird.

one more thing, this happens consistently at very first render, which suggest this is not a multi thread issue.
Title: Re: compile
Post by: raft on August 23, 2010, 12:51:26 am
this has definetely have something with texture id's. below is a test case.
uncomment the lines 44-45 to get rid of exception. really weird ???

Code: [Select]
package tmp;

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

import raft.jumpy.JConfig;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Object3D;
import com.threed.jpct.RGBColor;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.util.MemoryHelper;

/**
 *
 * @author  hakan eryargi (r a f t)
 */
public class Test2Activity extends Activity {

private static final float HALF_SIDE = 0.35f;
private static final float HEIGHT = 4f;

private static final Object3D MAGNET_PLANE_MASTER;
static {
TextureManager.getInstance().addTexture("white", new Texture(64, 64, RGBColor.WHITE));
TextureManager.getInstance().addTexture("blue", new Texture(64, 64, RGBColor.BLUE));


MAGNET_PLANE_MASTER = new Object3D(10);

int shiftTextureId = TextureManager.getInstance().getTextureID("blue");
int topTextureId = TextureManager.getInstance().getTextureID("white");

// uncomment these lines
// shiftTextureId = -1;
// topTextureId = -1;


// front side (looking from front)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, -HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);

// back side (looking from front)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, 0, HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, HALF_SIDE), 0, 0, // lower left
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
shiftTextureId);

// right side (looking from right)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, -HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, 0, HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);

// left side (looking from left)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, HALF_SIDE), 0, 0, // lower left
new SimpleVector(-HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);

// top side (looking from top)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
topTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0, // lower left
topTextureId);

//MAGNET_PLANE_MASTER.translate(0, -0.5f, 0);
MAGNET_PLANE_MASTER.translateMesh();
MAGNET_PLANE_MASTER.getTranslationMatrix().setIdentity();

//MAGNET_PLANE_MASTER.setTexture("tile_MAGNET_PLANE");
MAGNET_PLANE_MASTER.getMesh().compress();

//MAGNET_PLANE_MASTER.setBillboarding(Object3D.BILLBOARDING_ENABLED);
MAGNET_PLANE_MASTER.setTransparency((int)(JConfig.transparencyRange / 1.5f));
//MAGNET_PLANE_MASTER.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
MAGNET_PLANE_MASTER.setLighting(Object3D.LIGHTING_NO_LIGHTS);
MAGNET_PLANE_MASTER.setAdditionalColor(RGBColor.WHITE);

MAGNET_PLANE_MASTER.compile();
}

private GLSurfaceView mGLView;
private final MyRenderer renderer = new MyRenderer();

private World world;
private boolean compileAll;

@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());
setContentView(mGLView);

mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
// back to Pixelflinger on some device (read: Samsung I7500)
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});

mGLView.setRenderer(renderer);

world = new World();
world.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 2);


Object3D magnetBox = MAGNET_PLANE_MASTER.cloneObject();
magnetBox.shareCompiledData(MAGNET_PLANE_MASTER);

world.addObject(magnetBox);

compileAll = true;
}


@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

class MyRenderer implements GLSurfaceView.Renderer {

private FrameBuffer buffer = null;

public MyRenderer() {
}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, width, height);
MemoryHelper.compact();
}

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

@Override
public void onDrawFrame(GL10 gl) {
if (buffer == null)
return;

buffer.clear();

if (compileAll) {
world.compileAllObjects(buffer);
compileAll = false;
}

world.renderScene(buffer);
world.draw(buffer);

buffer.display();
Thread.yield();

}
}

}
Title: Re: compile
Post by: EgonOlsen on August 23, 2010, 06:35:32 am
I would rather think that this has something to do with the time it takes to upload an addional texture and not with the texture id itself. Because that wouldn't make any sense. Your code example fails all the time or just now and then?
Title: Re: compile
Post by: raft on August 23, 2010, 12:08:06 pm
all the time, at least till now all my trials failed. with those lines uncommented, always succeded ???

edit: fixed the typo: uncommented code always succeeds
Title: Re: compile
Post by: EgonOlsen on August 23, 2010, 05:16:08 pm
I'll see if i can reproduce this problem. Have you tried if it helps to synchronize object creation and rendering?
Title: Re: compile
Post by: raft on August 23, 2010, 05:38:53 pm
no, i didn't try it. i cant access the code at the moment
Title: Re: compile
Post by: raft on August 23, 2010, 09:10:26 pm
here is the synchronized version of test case. just to be sure, every jPCT related thing is aggresively synchronized. result is the same. setting texture id's to -1 fixes the exception

Code: [Select]
package tmp;

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

import raft.jumpy.JConfig;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;

import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Object3D;
import com.threed.jpct.RGBColor;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;
import com.threed.jpct.util.MemoryHelper;

/**
 *
 * @author  hakan eryargi (r a f t)
 */
public class Test2Activity extends Activity {

private static final float HALF_SIDE = 0.35f;
private static final float HEIGHT = 4f;

private static final Object lock = new Object();

private static final Object3D MAGNET_PLANE_MASTER;
static {
synchronized (lock) {
TextureManager.getInstance().addTexture("white", new Texture(64, 64, RGBColor.WHITE));
TextureManager.getInstance().addTexture("blue", new Texture(64, 64, RGBColor.BLUE));


MAGNET_PLANE_MASTER = new Object3D(10);

int shiftTextureId = TextureManager.getInstance().getTextureID("blue");
int topTextureId = TextureManager.getInstance().getTextureID("white");

// uncomment these lines
// shiftTextureId = -1;
// topTextureId = -1;


// front side (looking from front)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, -HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);

// back side (looking from front)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, 0, HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, HALF_SIDE), 0, 0, // lower left
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
shiftTextureId);

// right side (looking from right)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, -HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, 0, HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, 0, HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);

// left side (looking from left)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, HALF_SIDE), 0, 0, // lower left
new SimpleVector(-HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, 0, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
shiftTextureId);

// top side (looking from top)
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0, // lower left
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, HALF_SIDE), 0, 0.5f, // upper left
topTextureId);
MAGNET_PLANE_MASTER.addTriangle(
new SimpleVector(HALF_SIDE, -HEIGHT, -HALF_SIDE), 1, 0, // lower right 
new SimpleVector(HALF_SIDE, -HEIGHT, HALF_SIDE), 1, 0.5f, // upper right
new SimpleVector(-HALF_SIDE, -HEIGHT, -HALF_SIDE), 0, 0, // lower left
topTextureId);

//MAGNET_PLANE_MASTER.translate(0, -0.5f, 0);
MAGNET_PLANE_MASTER.translateMesh();
MAGNET_PLANE_MASTER.getTranslationMatrix().setIdentity();

//MAGNET_PLANE_MASTER.setTexture("tile_MAGNET_PLANE");
MAGNET_PLANE_MASTER.getMesh().compress();

//MAGNET_PLANE_MASTER.setBillboarding(Object3D.BILLBOARDING_ENABLED);
MAGNET_PLANE_MASTER.setTransparency((int)(JConfig.transparencyRange / 1.5f));
//MAGNET_PLANE_MASTER.setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
MAGNET_PLANE_MASTER.setLighting(Object3D.LIGHTING_NO_LIGHTS);
MAGNET_PLANE_MASTER.setAdditionalColor(RGBColor.WHITE);

MAGNET_PLANE_MASTER.compile();
}
}

private GLSurfaceView mGLView;
private final MyRenderer renderer = new MyRenderer();

private World world;
private boolean compileAll;

@Override
protected void onCreate(Bundle savedInstanceState) {
synchronized (lock) {
        super.onCreate(savedInstanceState);
mGLView = new GLSurfaceView(getApplication());
setContentView(mGLView);

mGLView.setEGLConfigChooser(new GLSurfaceView.EGLConfigChooser() {
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
// Ensure that we get a 16bit framebuffer. Otherwise, we'll fall
// back to Pixelflinger on some device (read: Samsung I7500)
int[] attributes = new int[] { EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_NONE };
EGLConfig[] configs = new EGLConfig[1];
int[] result = new int[1];
egl.eglChooseConfig(display, attributes, configs, 1, result);
return configs[0];
}
});

mGLView.setRenderer(renderer);

world = new World();
world.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 2);


Object3D magnetBox = MAGNET_PLANE_MASTER.cloneObject();
magnetBox.shareCompiledData(MAGNET_PLANE_MASTER);

world.addObject(magnetBox);

compileAll = true;
}
}


@Override
protected void onPause() {
super.onPause();
mGLView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mGLView.onResume();
}

class MyRenderer implements GLSurfaceView.Renderer {

private FrameBuffer buffer = null;

public MyRenderer() {
}

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
synchronized (lock) {
if (buffer != null) {
buffer.dispose();
}
buffer = new FrameBuffer(gl, width, height);
MemoryHelper.compact();
}
}

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
}

@Override
public void onDrawFrame(GL10 gl) {
synchronized (lock) {
if (buffer == null)
return;

buffer.clear();

if (compileAll) {
world.compileAllObjects(buffer);
compileAll = false;
}

world.renderScene(buffer);
world.draw(buffer);

buffer.display();
Thread.yield();
}
}
}

}

Title: Re: compile
Post by: EgonOlsen on August 23, 2010, 09:43:15 pm
I can reproduce it in the emulator...i'm going to investigate this now...
Title: Re: compile
Post by: EgonOlsen on August 23, 2010, 10:05:53 pm
Fixed! I've uploaded a new AE jar as well as a new beta jar of desktop jPCT into the usual directories. The problem was, that sharing failed on objects that compiled down into more than one sub-object, which happened in your test case when using multiple textures (and not just -1 for both). In that case, only the first sub-object was marked as being filled, all others were still marked as not being filled (though they were actually filled correctly).
This should be fixed now, please try the new jar.
Title: Re: compile
Post by: raft on August 23, 2010, 10:54:52 pm
ok, it's ok now, thanks :D