Reputation: 25
I have configured most of it to the letter of the slick tutorials but what I get is the png in the lower left corner filling only 3/4 of the quad the dimensions are 100x100 for the quad and the texture is to fill it entirely but for some reason I cant get wrapping to work(HELP!! if that is my mistake)
Code for registry:
public Form(String fileName, Frame frame) {
try {
texture = TextureLoader.getTexture(
"PNG",
ResourceLoader.getResourceAsStream("img/" + fileName
+ ".png"));
} catch (IOException e) {
e.printStackTrace();
}
this.frame = frame;
VectorFrame = a.constructVectorFrame(frame);
}
And the code for the rendering:
GL11.glEnable(GL11.GL_TEXTURE_2D);
Color.white.bind();
texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2d(point.x, point.y);
GL11.glTexCoord2f(0, 1);
GL11.glVertex2d(point.x, point.y + frame.maxY);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2d(point.x + frame.maxX, point.y + frame.maxY);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2d(point.x + frame.maxX, point.y);
GL11.glEnd();
GL11.glDisable(GL11.GL_TEXTURE_2D);
a.renderVectorFrame(point, VectorFrame);
Upvotes: 1
Views: 246
Reputation:
Here is a easy way to do it. Use texture.getWidth()/getHeight() when setting the TextureCoordinates. Works perfectly for me
GL11.glEnable(GL11.GL_TEXTURE_2D);
Color.white.bind();
texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2d(point.x, point.y);
GL11.glTexCoord2f(0, texture.getHeight()); // <---
GL11.glVertex2d(point.x, point.y + frame.maxY);
GL11.glTexCoord2f(texture.getWidth(), texture.getHeight()); // <---
GL11.glVertex2d(point.x + frame.maxX, point.y + frame.maxY);
GL11.glTexCoord2f(texture.getWidth(), 0); // <---
GL11.glVertex2d(point.x + frame.maxX, point.y);
GL11.glEnd();
GL11.glDisable(GL11.GL_TEXTURE_2D);
a.renderVectorFrame(point, VectorFrame);
Upvotes: 0
Reputation: 1481
Slick forces you to use power-of-two textures. You have two ways to deal with this:
Also, look at this SO question: Texture doesn't stretch properly. Why is this happening?
Upvotes: 2