Hi John -
 
I'm a Java3D newbie, but I've worked with a number of other 3D APIs (most recently Direct3D).  I've seen this problem several times in other systems.  Here's what might be going on: Java3D - or the underlying native API - is indeed buffering up primitives and state changes, and executing them in batches (either when the buffer fills or the user calls flush()).  However, texture changes don't go into the buffer, because they're sometimes heavyweight operations.  In other words, providing a new texture can require a lot of data (the texture pixmap itself) and so texture loads "go around" the pipeline in the buffer.
 
In your case, it appears that you already have two textures loaded and you're merely switching between them, so you'd think the changes would go into the buffer.  Perhaps this is a bug in the native API/hardware, or in J3D's management of that API.  Have you tried this on a different graphics card?
 
I sure would like to know if this is expected behavior, and if so, why J3D doesn't internally flush the pipeline on a texture change.
 
Happy holidays,
 
Brad
 
-----Original Message-----
From: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]]On Behalf Of John Owen
Sent: Saturday, December 23, 2000 4:58 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Immediate Mode Appearance Question/Problem

 
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