Texture loading at joGL
- by Nour
hi 
I've been trying to load a bmp picture to use it as a texture at my program I've used a IOstream Class to extend DataInputStream to read the pixels at the photo with this code "based on a  texture loader code for c++ " :
//class Data members
public static int BMPtextures[];
public static int BMPtexCount = 30;
public static int currentTextureID = 0;
//loading methode
static int loadBMPTexture(int index, String fileName, GL gl)
    {
        try
        {
            IOStream wdis = new IOStream(fileName);
            wdis.skipBytes(18);
            int width = wdis.readIntW(); 
            int height = wdis.readIntW();
            wdis.skipBytes(28);
            byte buf[] = new byte[wdis.available()];
            wdis.read(buf);
            wdis.close();
            gl.glBindTexture(GL.GL_TEXTURE_2D, BMPtextures[index]);
            gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 3, width, height, 0, GL.GL_BGR, GL.GL_UNSIGNED_BYTE, buf);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
            currentTextureID = index; 
            return currentTextureID;
    }
        catch (IOException ex)
        {
            // Utils.msgBox("File Error\n" + fileName, "Error", Utils.MSG_WARN);
            return -1;
        }
    }
and IOStream code :
public class IOStream extends DataInputStream {
    public IOStream(String file) throws FileNotFoundException {
        super(new FileInputStream(file));
    }
    public short readShortW() throws IOException {
        return (short)(readUnsignedByte() + readUnsignedByte() * 256);
    }
    public int readIntW() throws IOException {
        return readShortW() + readShortW() * 256 * 256;
    }
    void read(Buffer[] buf) {
    }
}
and the calling: 
GTexture.loadBMPTexture(1,"/BasicJOGL/src/basicjogl/data/Font.bmp",gl);
after debugging I figured out that when it come to this line :
IOStream wdis = new IOStream(fileName);
an IOExeption occurred and it's a dispatchException  .. what this impose to mean ?? and how can I solve it ?
by the way i tried to :
1- use \ and \ and / and // 
2- change the path of the photo and take all the path from c:\ to the photoname.bmp 
3- rename the photo using numbers like 1.bmp 
but nothing seems to work :(