How to make textures fill all area as it is specified? I'm getting small gaps if the texture is smaller than area example: gl_quads setup like these:

-1f, 1f, 0, 
-0.98f, 1f, 0, 
-0.98f, -1f, 0, 
-1f, -1f, 0 

I get this: http://i.stack.imgur.com/kWJnh.png

Red one's a texture, black is background, ignore it. Texture is imported by slick loader.

Texture itself: http://i.stack.imgur.com/8x7ZH.png (in case someone will think it has gaps)

Do I need to use a glTexParameter somehow on it? Added a rendering code down below:

//VertexArray initialization, vertexSize is 3, amountOfVertices is 8
private void initVertexArrays() {
    borderVertex = BufferUtils.createFloatBuffer(vertexSize
            * amountOfVertices);
    borderVertex.put(new float[] { -1f, 1f, 0, -0.98f, 1f, 0, -0.98f, -1f,
            0, -1f, -1f, 0 });

    borderTextureVertex = BufferUtils.createFloatBuffer(vertexSize
            * amountOfVertices);
    borderTextureVertex.put(new float[] { -1f, 1f, 0, -0.98f, 1f, 0,
            -0.98f, -1f, 0, -1f, -1f, 0 });

    amountOfArrays = 2;
//VertexBufferObject initialization
private void initVBO() {
    borderVertexHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, borderVertexHandle);
    glBufferData(GL_ARRAY_BUFFER, borderVertex, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    borderTextureHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, borderTextureHandle);
    glBufferData(GL_ARRAY_BUFFER, borderTextureVertex, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
//Texture loading with slick
private void setupTextures(){
    borderTexture = TextureDecoder.getTextureAt(borderTextureLocation,
//Rendering part
public void draw() {
    glBindBuffer(GL_ARRAY_BUFFER, borderVertexHandle);
    glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);

    glBindBuffer(GL_ARRAY_BUFFER, borderTextureHandle);
    glTexCoordPointer(vertexSize, GL_FLOAT, 0, 0);

    glDrawArrays(GL_QUADS, 0, amountOfVertices * amountOfArrays);
  • \$\begingroup\$ How do you render your background? A somewhat full example may help to explain your problem. \$\endgroup\$ – rioki Apr 2 '14 at 13:26
  • \$\begingroup\$ I'm not rendering it just for now, it's a simple display window. \$\endgroup\$ – Vanguard Apr 2 '14 at 13:26
  • \$\begingroup\$ Added rendering code for this part, just in case \$\endgroup\$ – Vanguard Apr 2 '14 at 13:32

Firs things first, The texture coordinates are probably not that what you want. You probably want 0, 0, 0, 1, 1, 0, 1, 1 with a size of 2.

Further you are using glVertexPointer and glTexCoordPointer with the value vertexSize, it is unclear what that is. It is probably 3 or the code would not render. Ensure that this is the number of values per vertex.

The remainder of the code looks sort of ok.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.