Author Topic: texture problem when having 2 worlds running  (Read 5554 times)

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
texture problem when having 2 worlds running
« on: July 24, 2007, 01:18:17 am »
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

Code: [Select]
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:
Code: [Select]
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

Code: [Select]
    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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: texture problem when having 2 worlds running
« Reply #1 on: July 24, 2007, 08:51:10 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: texture problem when having 2 worlds running
« Reply #2 on: July 24, 2007, 09:09:42 am »
Same problem (i think...) described here: http://www.jpct.net/forum2/index.php/topic,534.msg2720

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: texture problem when having 2 worlds running
« Reply #3 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.

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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: texture problem when having 2 worlds running
« Reply #4 on: July 24, 2007, 06:06:41 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.

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
Re: texture problem when having 2 worlds running
« Reply #5 on: July 24, 2007, 07:11:23 pm »
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
« Last Edit: July 24, 2007, 07:13:35 pm by manumoi »

Offline Melssj5

  • double
  • *****
  • Posts: 724
    • View Profile
Re: texture problem when having 2 worlds running
« Reply #6 on: July 24, 2007, 09:53:31 pm »
Quote
It 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
« Last Edit: July 24, 2007, 09:56:09 pm by Melssj5 »
Nada por ahora

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: texture problem when having 2 worlds running
« Reply #7 on: July 24, 2007, 10:17:36 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