I needed a number of separate worlds for some operations including clipping and thought maybe world consumes few memory
... And it's my mistake. :/ I have a lot of things to learn.
Thanks for your support.
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.
Show posts Menu
List<World> w = new ArrayList<World>();
for(int i=0; i<100; i++) {
System.out.println("world " + i);
w.add(new World());
}
QuoteTry to set Config.useFramebufferWithAlpha=true; before creating the FrameBuffer and see if that helps.
public Viewport(int x, int y, int width, int height) {
m_rect.setBounds(x, y, width, height);
m_world = new World();
Camera m_cam = m_world.getCamera();
...
Config.useFramebufferWithAlpha = true;
m_buffer = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
m_buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
}
private Texture toTexture()
{
BufferedImage img = new BufferedImage(m_rect.width, m_rect.height, BufferedImage.TYPE_INT_ARGB);
m_buffer.clear(new Color(0, 0, 0, 0xff));
m_world.renderScene(m_buffer);
m_world.draw(m_buffer);
m_buffer.display(img.getGraphics());
Texture t = new Texture(img, true);
t.setClamping(true);
return t;
}
@Override
public void onDrawFrame(GL10 gl) {
cube.rotateY(m_cam.convertDEGAngleIntoFOV(0.5f));
buffer.clear(colBackground);
m_world.renderScene(buffer);
m_world.draw(buffer);
buffer.display();
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
if(buffer == null) {
Util.LOGD("make framebuffer");
m_world = new World();
m_cam = m_world.getCamera();
m_light = new Light(m_world);
m_light.setIntensity(250, 250, 250);
m_light.setPosition(new SimpleVector(50, -50, 50));
m_world.setAmbientLight(0, 0, 0);
Texture t = new Texture(100, 100, new RGBColor(0, 0xff, 0, 0x7f));
TextureManager.getInstance().addTexture("test", t);
TextureManager.getInstance().addTexture("bottom", new Texture(100, 100, RGBColor.BLUE));
cube = Primitives.getBox(10, 1);
cube.setShadingMode(Object3D.SHADING_FAKED_FLAT);
cube.setEnvmapped(true);
cube.calcTextureWrap();
cube.translate(0, -10, 0);
cube.setTexture("test");
cube.strip();
cube.build();
m_world.addObject(cube);
m_bottomPlane = Primitives.getPlane(20, 300);
m_bottomPlane.translate(SimpleVector.ORIGIN);
m_bottomPlane.setSpecularLighting(true);
m_bottomPlane.calcTextureWrap();
m_bottomPlane.rotateX((float)Math.PI/2f);
m_bottomPlane.setTexture("bottom");
m_bottomPlane.build();
m_world.addObject(m_bottomPlane);
m_cam.setPosition(20, -20, 20);
m_cam.lookAt(cube.getTransformedCenter());
}
if(buffer != null)
buffer.dispose();
buffer = new FrameBuffer(gl, width, height);
MemoryHelper.compact();
}
Page created in 0.032 seconds with 12 queries.