texture problem when having 2 worlds running

Started by manumoi, July 24, 2007, 01:18:17 AM

Previous topic - Next topic

manumoi

hello

Got a strange thing. and i don t know if it is a bug of the TextureManager or not

I have an app with 2 different world objects (rendered using the same loop in two different canvas using AWTGLRenderer). One is supposed to show the selected object while the other one is displaying the whole map.

I don t know why but i am unable to have the same texture (registered in the TextureManager displayed in both world).

When texture are different there is no problem at all... I have spent hours checking my code and it seems to be correct, the good texture indice is called in order to paint a polygon...
In fact the first world where a texture will be called to be displayed will not be a problem. The problem will occur in the second one (i tested the order and the problem can be inversed)

So 3 questions.

Did anyone already do something similar that worked?

Do you have any idea what may cause this problem?

Here is a screenshot




here is the code i use to register texture in the texture manager

protected void addTexture(String textureName, String textureFile){
if (!TextureManager.getInstance().containsTexture(textureName)){
    Texture tmpTexture = new Texture(Constants.TEXTURE_PATH+textureFile);
    TextureManager.getInstance().addTexture(textureName, tmpTexture);
}
    }

    protected void addTexture(String textureFile){
addTexture(textureFile,textureFile);
    }



Here is my general loop:

public void startLoop(){
while (true){
    [...]
            myPanel3D.updateLoop();   // panel with the first JPCT world
    menuTabbedPanel.getMyPreviewPanel().updateLoop(); // panel with the second JPCT world
            // both these panels have a JPCTPanel super class that implements the updateLoop method
    [...]
            try{
Thread.sleep(10);
    }
    catch (InterruptedException ie){
System.err.println("startLoop");
ie.printStackTrace();
    }
    Thread.yield();
}
    }


and here is the update loop method


    public void updateLoop(){
buffer.clear();
updateCamera();
theWorld.renderScene(buffer);
theWorld.draw(buffer);
buffer.update();
synchronized(evt3DList){
    this.processEvt3DList();
}
synchronized(draggedCoordinateList){
    this.processDraggedCoordinate();
}
buffer.display(null);
myCanvas.repaint();
    }



So any idea????

thanks

EgonOlsen

This used to happen because multiple framebuffers mean multiple contexts which require multiple uploads (i.e. one context doesn't know the textures from the other). But it should have been fixed already. Which version of jPCT are you using?


Melssj5

I dont understand the problem of manumoi, by the screnshot I cant find anything wrong. But I remember that once jpct had problem when working with multiple frambuffers, Egon som changes for me and the version of that is on the model3d app on the download section, later I am not sure if the next release worked but Egon say yes so I never tested it.

Is your problem that a texture with the same name is not different on one world than in other? TextureManager works with static methods and I guess that only One image can be mapped to 1 name.
Nada por ahora

EgonOlsen

Quote from: Melssj5 on July 24, 2007, 05:24:54 PM
I dont understand the problem of manumoi, by the screnshot I cant find anything wrong. But I remember that once jpct had problem when working with multiple frambuffers, Egon som changes for me and the version of that is on the model3d app on the download section, later I am not sure if the next release worked but Egon say yes so I never tested it.
It still works. I'm always using your app as a test case before releasing a new version.

manumoi

#5
hello, changed to the Beta 1.15 and now everything is ok... I feel ashamed... the previous thread talking about this problem was launched more than 1 year ago... So i m surprised but it seems that i was using a "very" old version of JPCT. Anyway it works fine now.

Thanks egon

PS: Melssj, in the previous picture the problem was that the textures didn t appear on the object on the bottom right side of the picture

Melssj5

#6
QuoteIt still works. I'm always using your app as a test case before releasing a new version.


If something works with a so messy and bad structured code like the model3d, then everything will!! jajajajaja  :P
Nada por ahora

EgonOlsen

Quote from: Melssj5 on July 24, 2007, 09:53:31 PM
If something works with a so messy and bad structured code like the model3d, then everything will!! jajajajaja  :P
No. It's the only application that i know of that uses this feature and it does it to an extend, because it shows four canvas', not just two. ;D