Textures

Hi,

I’m trying to create a sphere with a texture mapped inside, so when I’m inside it i can see the texture.

I’ve searched online how to create textures in JOGL, but everything I’ve found uses something called TextureReader, which gives me an error saying it’s not a class. I’ve also tried TextureLoader, but I get an error:

Multiple markers at this line
- The method load(String) is undefined for the type TextureLoader
- Access restriction: The type TextureLoader is not accessible due to restriction on required library /System/Library/Java/Extensions/

What’s the easiest way to get texture working?

If you’re looking at the nehe’s demo, it looks like they have a custom TextureReader that you can get somehow (in package demos.common). Where are you getting TextureLoader? Are you sure you’re using the newest version of JOGL?

The easiest way is probably with TextureIO, which is included with JOGL, but will have different methods that you need to call compared to what might be in a demo that uses the TextureReader.

you should use TYPE_INT_ARGB_PRE, its the fastet so far i know.


  Texture makeTex(BufferedImage img){
      if(img.getType() == BufferedImage.TYPE_INT_ARGB_PRE){
        return TextureIO.newTexture(img,false);
      }else{
        BufferedImage bimg = new BufferedImage(img.getWidth(),img.getHeight(),BufferedImage.TYPE_INT_ARGB_PRE);
        Graphics2D g2d = bimg.createGraphics();
        g2d.drawImage(img, 0, 0, null);
        g2d.dispose();
        return TextureIO.newTexture(bimg,false);
      }
  }

:persecutioncomplex: