Hi:
 
I have a pure immediate mode application which draws a textured sphere. It works fine.
 
I modified the application so that it draws 2 spheres. It does this by using a single appearance object and setting the appearance's texture to  texture1 when I draw sphere1 and to texture2 when I draw sphere2. It doesn't work. It always draws both spheres with the same texture, texture2 (actually it is kind of funny, every few frames I can see the correct texture "flash" onto sphere1 and then it is drawn over with sphere2's texture).
 
If I use two different appearance objects, one for each sphere, the application works correctly. Why is this? Shouldn't I be able to change appearance attributes on the fly, call GraphicsContext3D.setAppearance() and expect the changes to take effect?
 
Thanks,
 
John
 
pseudo code looks like this:
 
Appearance appearance;
Geometry sphere1;
Geometry sphere2;
Texture2D texture1;
Texture2D texture2;
Canvas3D canvas;
GraphicsContext3D graphics;
 
.....
void draw() {
    graphics.clear();
    appearance.setTexture(texture1);
    graphics.setAppearance(appearance);
    graphics.draw(sphere1);
    appearance.setTexture(texture2);
    graphics.setAppearance(appearance);
    graphics.draw(sphere2);
    canvas.swap();
}
 

Reply via email to