Sorry guys for the massive mail bombardement of the last days. Last not
least I solved my problem of "How to draw crisp text onto the Canvas3D
backbuffer in immediate mode" myself (inspired by Olivier's Text2D mail).

Java3D *does support* non-filtered Textures - just I was using the utility
class TextureLoader, which creates filtered mip-map levels for the new
texture. Pitfall: at an exact 1:1 scale, Java3D displays a mip-map level
image that has nearly, but not exactly the original resolution and therefore
appears a bit "blurred" (because when calculating mip-map levels, a
smoothing algorithm like area-averaging or bicubic or so is used). It seems
like every mip-map level has power-of-two dimensions and therefore my "odd"
bitmap (150x100 Pixels for example) was always filtered.

Now, the simple solution to the "draw crisp text" problem is: manually
create a Texture object from the source BufferedImage, specifying
Texture2D.BASE_LEVEL as mipmap mode when constructing the Texture2D. That
way, mip mapping is in effect turned off so that only the base level (that
is, the original bitmap) is used. Naturally, scene antialiasing should be
turned off as well.

The following code snippet demonstrates creating a texture that can be
rendered without filtering. (This is nothing special, code like this
contained in a thousand samples.)

<pre>
        Dimension texSize=new Dimension(512,64); // needs to be powers of two on my
system
        BufferedImage buffer=new
BufferedImage(texSize.width,texSize.height,BufferedImage.TYPE_INT_ARGB);
        Graphics g=buffer.getGraphics();
        g.setFont(new Font("Dialog",Font.PLAIN,8));
        g.setColor(Color.white);
        g.drawString(2,36,"Crisp Text!");
        g.dispose();

        Texture texture=new
Texture2D(Texture2D.BASE_LEVEL,Texture2D.RGBA,texSize.width,texSize.height);
        texture.setImage(0,new
ImageComponent2D(ImageComponent2D.FORMAT_RGBA,buffer));

        Appearance app=new Appearance();
        app.setTexture(texture);
</pre>

By creating a rectangular geometry that maps to a rectangular screen area
which has exactly the size of the bitmap (in this case, 512x64) and applying
above Appearance, you can display crisp text and crisp bitmaps (like those
displayed by Text2D and Raster) in immediate mode too.

If a bitmap has "odd" dimensions like 150x100, you need to create a larger
BufferedImage that has power-of-two dimensions, copy the bitmap into the
BufferedImage and set the texture coordinates appropriately.

OK that's it, thanks to all of you who spent time thinking about this
problem.

-- Julian

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to