Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: 16x16 Texture too big

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10

    Question 16x16 Texture too big

    Hello,

    I'm making a tile based game, and the Textures for the Tiles are 16x16. Whenever I try to load the Texture so it can be rendered,
    I get this error:
    Code :
    java.io.IOException: Attempt to allocate a texture to big for the current hardware
    	at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:292)
    	at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:231)
    	at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:184)
    	at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
    	at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:24)
    	at main.Tile.loadTexture(Tile.java:124)
    	at main.Draw.drawMap(Draw.java:282)
    	at main.Draw.render(Draw.java:324)
    	at main.LaunchWindow.main(LaunchWindow.java:65)
    Exception in thread "main" java.lang.NullPointerException
    	at main.Draw.drawMap(Draw.java:284)
    	at main.Draw.render(Draw.java:324)
    	at main.LaunchWindow.main(LaunchWindow.java:65)

    Now, I know that my gpu can handle it because its a 1GB card.

    I ran
    Code :
    GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE)
    and got 16384.

    Here is the code for loading the Texture:

    Code :
    	public void loadTexture(String a){
    		try {
    			texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(a));
    			System.out.println(texture.getTextureRef());
     
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}


    And the code called when it needs to be rendered:

    Code :
    	public void drawMap(Map b){
    		Color.white.bind();
    		glBegin(GL_QUADS);
     
    		b.divideMap(10);
    		Tile[][] t = b.makeMap(b.getK());
     
    		for(int y = 0; y < b.tiles.length; y++){
    			for(int x = 0; x < b.tiles[y].length; x++){
    				Texture a;
    				t[y][x].loadTexture(t[y][x].getLocation());
    				a = t[y][x].getTexture();
    				System.out.println(a.getTextureRef());
    				a.bind();
    				glTexCoord2f(0,0);
    				glVertex2f(x,y);
    				glTexCoord2f(1,0);
    				glVertex2f(x + a.getWidth(), y);
    				glTexCoord2f(1,1);
    				glVertex2f(x + a.getWidth(), y +  a.getHeight());
    				glTexCoord2f(0,1);
    				glVertex2f(x, y +  a.getHeight());
    			}
    		}
     
    		glEnd();
    	}


    Any help is appreciated.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,105
    I am not a Java person but I would sugest looking at the loader code - things like missing file

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    8
    I am also not a Java (not with opengl at least) person but my guess would be would be that the space for the texture was never allocated correctly. Did you call glGenTexture and all that stuff (not sure what it would be in java)

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    10
    Ahh All I had to do is load the textures outside of the gameloop.

    @cookedbird, Yes I did

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •