Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: flipping textures

  1. #1
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    flipping textures

    gidday, how are yous dealing with loading textures in the most optimal fashion WRT image flipping.
    ie with some image formats the data is stored with the origin at the bottom, and with others the data starts at the top of the image.

    at the moment im loading the whole image in and then flipping the rows myself, is it perhaps better/faster loading in the image a row at a time?

    also is there some method to automatically flip the image in gl (ild expect it to be in the imagestore but i see nothing)

    cheers zed

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: flipping textures

    t = 1.0 - t

  3. #3
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: flipping textures

    if u mean changing the texture coordinates, then thats untidy for obvious reasons.

  4. #4
    Member Regular Contributor
    Join Date
    Aug 2003
    Location
    France
    Posts
    299

    Re: flipping textures

    Actually, to speed up the loading ... we reverse the picture by itself. As you can imagine, it works well ...

    SeskaPeel.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: flipping textures


    Great idea.

  6. #6
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: flipping textures

    I don't know but glPixelStore is probably the place to look. I think it would be GL_UNPACK_SKIP_PIXELS or GL_UNPACK_SKIP_ROWS.
    Maybe you pass glTexImage a pointer to the last row, and call glPixelStore(GL_UNPACK_SKIP_ROWS, -2)

    I've never tried this. Even if it works, I doubt it would be fast.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  7. #7
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    3,032

    Re: flipping textures

    Originally posted by SeskaPeel:
    Actually, to speed up the loading ... we reverse the picture by itself. As you can imagine, it works well ...

    SeskaPeel.
    Do you mean, "we reverse the picture ourselves"? So presumably you mean you flip certain picture formats in photoshop and save them out flipped?
    I'm pretty sure zed would simply not use a flipped format if he had the opportunity to flip it in photoshop! He probably doesn't have control over what images are fed into his engine, and in what format....in which case, seskapeel, your suggestion is pointless.
    Personally, I sometimes reverse the texture coordinates in the texture matrix...every texture in my system has an associated texture matrix, even if it's identity most of the time. I sometimes use this texture matrix to deal with non-pow2 textures as well.
    But, it may be simpler if you just write a little function to flip the image data itself after loading...saves confusion later on.
    Knackered

  8. #8
    Member Regular Contributor
    Join Date
    Aug 2003
    Location
    France
    Posts
    299

    Re: flipping textures

    Dear knackered, what you describe is what we do. We had control over the textures, zed never said he did or he did not.
    Your suggestion is as pointless as mine, as you considered he didn't.

    SeskaPeel.

  9. #9
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    3,032

    Re: flipping textures

    Ok peel, don't take offense - I didn't mean 'pointless' in the sense that you suggesting it was pointless...you shouldn't be so quick to take things the wrong way, you'll give yourself a stroke, no matter how much garlic you consume.
    With resources that I have control over (ie. in non-tool like apps) I tend to load them in whatever format they arrive from the artist in, process them (flip,swizzle or whatever on the CPU) then save them out as compressed (lossy or lossless) binary in my own format for subsequent quick loading. I cache them in a cache directory, and check incoming modified dates against cache modified dates to determine if the binary cache version needs updating.
    I would imagine everyone else does this also.
    Knackered

  10. #10
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: flipping textures

    I would imagine everyone else does this also.
    Nope, sounds pretty competent but it's not appropriate for a lot of applications.

Posting Permissions

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