I "fixed" this problem by inserting a GraphicsContext3D.flush(true) statement between the rendering of each sphere (graphics.flush(false) does not work). This eats into the frame rate but produces the correct results.
 
So it seems like GraphicsContext3D.setAppearance() is not making a copy of my appearance object but is instead holding onto a reference. Does anybody know if this is by (ouch) design?
 
If so it leaves you leaves you with 2 pretty grim alternatives, call GraphicsContext3D.flush(true) before each call to GraphicsContext3D.setAppearance() and pay a performance cost since your app is going to block, or be forced into allocating a new appearance object before each call to GraphicsContext3D.setAppearance().
 
Please tell me this is a bug, thanks,
 
- John
----- Original Message -----
From: John Owen
Sent: Saturday, December 23, 2000 6:13 PM
Subject: [JAVA3D] Immediate Mode Appearance Question/Problem

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