# How do I draw a full resolution texture to a window of the same resolution?

My image is 1280x800, and my screen size is 1280x800. It should draw perfectly. I'm creating a quad the size of the screen, and setting the texture to fit the quad. But right now it draws a square texture on my upper left corner of my screen that's out of scale and not large enough.

I don't know why it doesn't work, I've tried writing the size of the texture larger when drawing and it seems to work sort-of, but I don't know why it didn't work when drawing on a 1280x800 quad.

How do I create a fullscreen quad?

Here's how I'm currently doing it:

This is my OPENGL and display setup code:

    DisplayMode displayMode = null;
DisplayMode[] modes = Display.getAvailableDisplayModes();

for (int i = 0; i < modes.length; i++) {
if (modes[i].getWidth() == World.SCREEN_WIDTH && modes[i].getHeight() == World.SCREEN_HEIGHT && modes[i].isFullscreenCapable()) {
displayMode = modes[i];
}
}

Display.setDisplayMode(displayMode);
Display.setFullscreen(false);
Display.create();

glMatrixMode(GL_PROJECTION);
glOrtho(0, World.SCREEN_WIDTH, World.SCREEN_HEIGHT, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);


This is my code for drawing the textured quad:

    background = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/menu/background.png")));

glBindTexture(GL_TEXTURE_2D, background.getTextureID());
glPushMatrix();
glTexCoord2f(0, 0);
glVertex2f(0, 0); // Upper left

glTexCoord2f(1, 0);
glVertex2f(World.SCREEN_WIDTH, 0); // Upper right

glTexCoord2f(1, 1);
glVertex2f(World.SCREEN_WIDTH, World.SCREEN_HEIGHT); // Lower right

glTexCoord2f(0, 1);
glVertex2f(0, World.SCREEN_HEIGHT); // Lower left
glEnd();
glPopMatrix();

• Sounds like Slick2D creates a texture that is power-of-two size. See slick.ninjacave.com/forum/viewtopic.php?p=26076 Aug 21 '13 at 11:42
• @msell Then how to I cover my 1280x800 screen? Aug 21 '13 at 11:45
• While this might be true problem to you, this seems to be more like "debug my code" type of question, that does not fit to stack exchange Q/A style.
– Katu
Aug 21 '13 at 13:43
• Actually it's not, this is a true LWJGL problem. I've got the answer to the question. But I dislike how people with high rank goes around giving down votes with out really looking at the content @Katu Aug 21 '13 at 14:41
• Power-of-two sizing shouldn't matter as the texcoords used will either stretch or squeeze the texture to fill the screen. More probable is that the modelview matrix is not identity - see my answer below. Aug 21 '13 at 16:15

A probable cause is that you may not have identity in your modelview matrix when you come to draw the fullscreen quad. This could happen if you're drawing anything else before the quad.

I note from your setup code that you correctly switch the matrix mode to GL_MODELVIEW, but then you don't make a glLoadIdentity call after doing so (this is OK as it should be initially identity, but it's a good habit to get into).

When drawing your quad, you have it surrounded by a glPushMatrix/glPopMatrix call. This on it's own isn't sufficient to make a matrix identity; from the specification:

glPushMatrix pushes the current matrix stack down by one, duplicating the current matrix. That is, after a glPushMatrix call, the matrix on top of the stack is identical to the one below it.

(My emphasis.)

In other words, if your previous modelview matrix was not identity, then following the glPushMatrix call the new modelview matrix will also not be identity.