How can I make OpenGL textures scale without becoming blurry?

Posted by adorablepuppy on Game Development See other posts from Game Development or by adorablepuppy
Published on 2011-10-27T00:27:26Z Indexed on 2011/11/23 10:12 UTC
Read the original article Hit count: 467

Filed under:
|
|
|

I'm using OpenGL through LWJGL.

I have a 16x16 textured quad rendering at 16x16. When I change it's scale amount, the quad grows, then becomes blurrier as it gets larger.

How can I make it scale without becoming blurry, like in Minecraft.

Here is the code inside my RenderableEntity object:

public void render(){       
    Color.white.bind();
    this.spriteSheet.bind();        
    GL11.glBegin(GL11.GL_QUADS);
        GL11.glTexCoord2f(0,0);
        GL11.glVertex2f(this.x, this.y);
        GL11.glTexCoord2f(1,0);
        GL11.glVertex2f(getDrawingWidth(), this.y);
        GL11.glTexCoord2f(1,1);
        GL11.glVertex2f(getDrawingWidth(), getDrawingHeight());
        GL11.glTexCoord2f(0,1);
        GL11.glVertex2f(this.x, getDrawingHeight());
     GL11.glEnd();

}

And here is code from my initGL method in my game class

GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glClearColor(0.46f,0.46f,0.90f,1.0f);
GL11.glViewport(0,0,width,height);
GL11.glOrtho(0,width,height,0,1,-1);

And here is the code that does the actual drawing

public void start(){
    initGL(800,600);
    init();

    while(true){
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

        for(int i=0;i<entities.size();i++){
            ((RenderableEntity)entities.get(i)).render();
        }

        Display.update();
        Display.sync(100);

        if(Display.isCloseRequested()){
            Display.destroy();
            System.exit(0);
        }
    }
}

© Game Development or respective owner

Related posts about opengl

Related posts about java