Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: HELP!!! Textures are low quality!

  1. #1
    Newbie Newbie
    Join Date
    Aug 2013

    Exclamation HELP!!! Textures are low quality!

    The Texture that i'm mapping is a 1024 by 1024 png being loaded by the slick pngdecoder

    When viewed after being mapped onto a quad, it is very pixelated and the Large text gets transformed into a Brown rectangle

    Here is the texture
    and here is a screen-shot of the texture in the OpenGL display

    nvm thread wont post with the pictures

    if you need source code here is the texture loading method

    Code :
    public static int loadPNGTexture(String filename, int textureUnit) {
    		ByteBuffer buf = null;
    		int tWidth = 0;
    		int tHeight = 0;
    		try {
    			// Open the PNG file as an InputStream
    			InputStream in = new FileInputStream(filename);
    			// Link the PNG decoder to this stream
    			PNGDecoder decoder = new PNGDecoder(in);
    			// Get the width and height of the texture
    			tWidth = decoder.getWidth();
    			tHeight = decoder.getHeight();
    			System.out.println("Texture " + filename + "\n"
    					 + "Width: " + tWidth + " Height: "+ tHeight);
    			// Decode the PNG file in a ByteBuffer
    			buf = ByteBuffer.allocateDirect(
    					4 * decoder.getWidth() * decoder.getHeight());
    			decoder.decode(buf, decoder.getWidth() * 4, PNGDecoder.RGBA);
    		} catch (IOException e) {
    		// Create a new texture object in memory and bind it
    		int texId = GL11.glGenTextures();
    		GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
    		// All RGB bytes are aligned to each other and each component is 1 byte
    		GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    		// Upload the texture data and generate mip maps (for scaling)
    		GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0,*
    				GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
    		// Setup the ST coordinate system
    		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    		// Setup what to do when the texture has to be scaled
    		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,*
    		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,*
    		return texId;

    I played around with the glTexParameteri() values,

    PS. someone tell me how to post a picture

    Please help!!

  2. #2
    Member Regular Contributor
    Join Date
    Dec 2009
    GL_LINEAR_MIPMAP_NEAREST is not a valid magnification filter, it is only allowed for minification. You should use GL_LINEAR there.

Posting Permissions

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