Hmm,
ok, I am still doing something wrong... I know, that now I moved to the wider topic (blitting to a texture) but I hope you don't mind to finish it.
I rewrote the problem into the following simple example. It is all inside the onSurfaceChanged() method. I have 2 squares, the left one with the original texture and the right one, where I would expect a BLUE texture, or copy of the right-square texture. But no, I have still the dull black empty texture, so what am I missing? And what is more, during the fb.display() it anounces a warning: "<core_glCopyTexSubImage2D:318>: GL_INVALID_OPERATION"
Thanks again for your help.
public void onSurfaceChanged(GL10 gl, int w, int h) {
if(master != null){return;}
master = HelloWorld.this;
if (fb != null) {
fb.dispose();
}
fb = new FrameBuffer(gl, w, h);
world = new World();
world.setAmbientLight(150, 150, 150);
sun = new Light(world);
sun.setIntensity(100, 100, 100);
SimpleVector sv = new SimpleVector(0, -50, -80);
sun.setPosition(sv);
try {
tx1 = new Texture(HelloWorld.getApp().getAssets().open("Texture.png"), true);
TextureManager.getInstance().addTexture("tx1", tx1);
} catch (IOException e) {
e.printStackTrace();
}
tx2 = new Texture(256,256);
TextureManager.getInstance().addTexture("tx2", tx2);
int tx1ID = TextureManager.getInstance().getTextureID("tx1");
int tx2ID = TextureManager.getInstance().getTextureID("tx2");
int destX = convertX(fb, 0);
int destY = convertY(fb, tx2.getHeight() - 0);
int destWidth = convertX(fb, 256);
int destHeight = -convertY(fb, 256);
fb.setRenderTarget(tx2);
fb.sync();
fb.clear(RGBColor.BLUE);
fb.blit(tx1, 0, 0, destX, destY, 512, 512, destWidth, destHeight, 255, false);
fb.display();
fb.removeRenderTarget();
camera = world.getCamera();
camera.setPosition(0, 0, -50);
camera.lookAt(SimpleVector.ORIGIN);
try {
obj1 = new Object3D(2);
obj1.addTriangle(new SimpleVector(-1f,-1f,0), 0, 0, new SimpleVector(-1f,1f,0), 0, 1f, new SimpleVector(1f,1f,0), 1f, 1f, tx1ID);
obj1.addTriangle(new SimpleVector(-1f,-1f,0), 0, 0, new SimpleVector(1f,1f,0), 1f, 1f, new SimpleVector(1f,-1f,0), 1f, 0, tx1ID);
obj1.scale(10f);
world.addObject(obj1);
obj1.translate(-15f, 0f, 0f);
obj2 = new Object3D(2);
obj2.addTriangle(new SimpleVector(-1f,-1f,0), 0, 0, new SimpleVector(-1f,1f,0), 0, 1f, new SimpleVector(1f,1f,0), 1f, 1f, tx2ID);
obj2.addTriangle(new SimpleVector(-1f,-1f,0), 0, 0, new SimpleVector(1f,1f,0), 1f, 1f, new SimpleVector(1f,-1f,0), 1f, 0, tx2ID);
obj2.scale(10f);
world.addObject(obj2);
obj2.translate(15f, 0f, 0f);
} catch (Exception e) {
e.printStackTrace();
}
MemoryHelper.compact();
}