newbi needs help :(

Hello All,

I’m new to OpenGL and JOGL but after a little struggle I’m getting somewhere
I’ve got a little Swing app with a GLCanvas in it where I draw a cube and map some textures on the sides. Also have some sliders in the app that let you translate/rotate the cube. So I’m feelin proud of myself, I make it into a webstart app and tell a buddy of mine to check it out. When he views it the cube is solid white, no textures. I developed it on a linux box but tested it on a Win2K machine before trying to show it off. After a little more testing I find I can run it on serveral Win2K boxes but I have on where it does same thing, cube is solid white. The machine I have where it doesn’t work correctly is a fairly new Dell with a GForce 4 video card so I don’t think it’s hardware. I turned on the webstart debugger console and I don’t see any errors. Anybody seen similar behaviour before or have any idea what I’m doing worng or how to track it down??

Thanx
Dave

It’s all about how you load your texture buddy, sometimes it works just fine on your machine, but when converted into a webstart application, things don’t go as well as you planned.

Here’s some code to download images (PNG, GIF, JPG, TGA) from anywhere using either a desktop demo or a webstart application
Link

Java Cool Dude,
Thanks for the tip.
I did have trouble loading the textures when I went from a straight java app to a webstart app, but I’ve gotten over that hump. Now, even after sucssefully converting my app into a webstart app, it behaves differently on different machines. The image is bundled up in the jar file with the webstart app itself and I load it like this

private BufferedImage readPNGImage(String resourceName)
{
try
{
URL url=Main.class.getResource(resourceName);
if (url == null)
{
throw new RuntimeException("Error reading resource " + resourceName);
}
BufferedImage img = ImageIO.read(url);
java.awt.geom.AffineTransform tx = java.awt.geom.AffineTransform.getScaleInstance(1, -1);
tx.translate(0, -img.getHeight(null));
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
img = op.filter(img, null);
return img;
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
where Main is my top level class containing program entry point

Thanks for the code snippet, I’ll mess with it and see if I get any different results

Dave

Probably a ImageIO bug:
http://developer.java.sun.com/developer/bugParade/bugs/4764639.html

Try loading the image data into a byte[] and creating the image fram that.

Like I said try the stuff that I linked in my previous post, it’s known to work for sure.
I tired different approaches as well using MyClass.class.getResource etc and they all failed miserably to cope with JWS, however using this method


    BufferedImage bufferedImage = null;
    ClassLoader  fileLoader  = ImageLoader.class.getClassLoader();
    InputStream  input       = fileLoader.getResourceAsStream(textureLocation);

    try {
      if(input == null)
        input = new FileInputStream(textureLocation);

      bufferedImage = javax.imageio.ImageIO.read(input);
    }
    catch( Exception e){
    }

will help you out a lot

Hi,
Thanks for the help
Where does this ImageLoader class come from

ClassLoader fileLoader = ImageLoader.class.getClassLoader();

I don’t see it in the java API docs
I googled it and found several third party classes

Dave

Check out my link :wink:

Ok, I created a class like this

package joglTest;

import java.awt.image.DataBufferByte;
import java.awt.image.BufferedImage;
import java.io.FileInputStream;
import java.io.InputStream;

/**
*

  • @author drobbins
    */
    public class ImageLoader {

    /** Creates a new instance of ImageLoader */
    public ImageLoader() {
    }
    public BufferedImage loadImage(String resourceName)
    {
    BufferedImage bufferedImage = null;
    java.lang.ClassLoader fileLoader = ImageLoader.class.getClassLoader();
    java.io.InputStream input = fileLoader.getResourceAsStream(resourceName);

     try {
          if(input == null)
            input = new FileInputStream(resourceName);
    
          bufferedImage = javax.imageio.ImageIO.read(input);
     }
     catch( Exception e){
     }
     return bufferedImage;
    

    }

}

And in my app I create an instance of ImageLoader and call it’s load Image method with resourceName = “images/picture.png”, and

java.io.InputStream input = fileLoader.getResourceAsStream(resourceName);

returns null.
my ImageLoader class is in the top level directory of my app and the png is in a sub-directory named images. At this point this is just a java application, no webstart or jar files involved. See what I’m doing wrong???

Dave

Use this hierarchy (sp?)
http://www.users.xith.org/JavaCoolDude/JWS/Xith3D/WaterCubeMap/source/

JCD,

I ask this at the risk of sounding dense, but could you tell me where in this hierachy

http://www.users.xith.org/JavaCoolDude/JWS/Xith3D/WaterCubeMap/source/

the ImageLoader class gets used

Thanx for all the help
Dave