Results 1 to 7 of 7

Thread: Texture coord problem...

  1. #1

    Texture coord problem...

    Hi all,

    I have yet another problem...
    I have a simple quad, and i want to bind a texture to it.. nice and simple..
    [pascal]
    Textures.Bind('Path1');
    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex3f(0, 0.1, 12;

    glTexCoord2f(1, 0);
    glVertex3f(64, 0.1, 12;

    glTexCoord2f(1, 1);
    glVertex3f(64, 0.1, 192);

    glTexCoord2f(0, 1);
    glVertex3f(0, 0.1, 192);
    glEnd;
    [/pascal]

    how ever instead of the texture turning out like:


    it turns out like:


    Iv messed around with the texture coords and the only result that i get is with:
    0, 0
    1, 0
    0, 1
    -1, 1

    But this messes the edges of my textures up..

    Im not sure if its the way OpenGL draws quads, but it seems to render as a 2 triangles..

    Is there any OpenGL function that will cause this kinda thing??
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  2. #2

    Texture coord problem...

    try to load identity matrix into gl_texture matrix..

    i've no ide if that may be the problem but the texture matrix can screw somethings up.

    the code shows just fine when i fire it up in my engine

    EDIT: if this doesn't solve it just switch the two texcoords in the middle so it becomes:

    0,0
    1,1
    1,0
    0,1
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    Texture coord problem...

    Ok, i think i have done it right:
    [pascal]
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity;
    glMatrixMode(GL_MODELVIEW);
    [/pascal]
    If so then it has no effect :s

    I tried your tex coords, but that doesnt solve it either, it turns out worse
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  4. #4

    Texture coord problem...

    that's pretty weird-- :?

    have you tried:

    0,0
    1,0
    0,1
    1,1

    if you're not able to get it right when altering the texcoords like this then i would bet that your bmp laoder code is the problem
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  5. #5

    Texture coord problem...

    I have no idea why its happening, im not accessing the texture matrix in any way, im creating new textures on the fly when i generate my terrain..

    I am positive its not my texture loading, i have saved that particular texture in BMP,JPG,PNG and TGA and the same problem occours.. and i dont have the same problem in any of my other applications that use the textures.. I also have a function built in to extract a TBitmap from the texture (using the loaded data) and that looks right too...

    I tried those coords too, and i had a similar effect as before...

    I have a little maths involved when calculating where the tiles are in the terrain...
    [pascal]
    For i := 0 to 256-1 Do
    For j := 0 To 256-1 Do
    Begin
    v1 := Vertex3f((64*i), 0, (64*j));
    v2 := Vertex3f((64*i)+64, 0, (64*j));
    v3 := Vertex3f((64*i)+64, 0, (64*j)+64);
    v4 := Vertex3f((64*i), 0, (64*j)+64);

    // Bind texture
    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex3fv(@v1);

    glTexCoord2f(1, 0);
    glVertex3fv(@v1);

    glTexCoord2f(1, 1);
    glVertex3fv(@v3);

    glTexCoord2f(0, 1);
    glVertex3fv(@v4);
    glEnd;
    [/pascal]
    I am fairly sure this gives the correct coords, and i am assuming that it shouldnt effect the texture coords?!?
    Maybe i have the maths the wrong way around??
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  6. #6

    Texture coord problem...

    Ok i have solved it, was a really stupid mistake on my part..
    It was the texture file itself it was supposed to be 128x128 but it was actually 119x119 :roll:

    Thanx for your help
    M109uk
    <br />--------------------------------------------------------
    <br />www.pulse-soft.oneuk.com

  7. #7

    Texture coord problem...

    hehe no problem. i've done precisely the same thing some time ago but i just couldn't remember what i did to solve it!
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •