Search code examples
javaopenglrenderlwjgl

Opengl Quads not rendering


This is the problematic code:

glColor3f(1,1,1);
for(int x=0;x<125;x++){
    for(int y=0;y<10;y++){

        int p = levelArray[x][y];
        if(p == 0){
            break;
        }
        Texture t = pieces[1];
        t.bind();
        System.out.println(x*64+"|"+y*64 + " :: "+((x*64)+t.getTextureWidth())+"|"+((y*64)+t.getTextureHeight()));
        glBegin(GL_QUADS);
            glTexCoord2f(0,0);
            glVertex2f(x*64,y*64);
            glTexCoord2f(1,0);
            glVertex2f((x*64)+t.getTextureWidth(),y*64);
            glTexCoord2f(1,1);
            glVertex2f((x*64)+t.getTextureWidth(),(y*64)+t.getTextureHeight());
            glTexCoord2f(0,1);
        glEnd();    
    }
}

I am getting a print out, so I am reaching the glBegin, I have taken sample coordinates outputted by the print and drawn that quad the line above my first one shown here, using the exact same texture and it renders.


Solution

  • You only have three glVertex2f calls where you should have four (inside the GL_QUADS). You have four glTexCoord2f, so this must be a type-o in your code.