Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Reversing Up-Vector of the camera

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

    Reversing Up-Vector of the camera

    Hi,
    I have a texture(jpg) and when I map it to a cylinder OpenGL maps it upside down(I do not know why?)!
    Now I decided to reverse my Up-Vector instead of rotating my texture which is(I think) computationally expensive.
    Here is my code:
    gluLookAt(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0);

    Is it a good idea?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    943

    Re: Reversing Up-Vector of the camera

    Why don't you just mirror the UVs?

  3. #3
    Junior Member Regular Contributor tksuoran's Avatar
    Join Date
    Mar 2008
    Location
    United Kingdom
    Posts
    201

    Re: Reversing Up-Vector of the camera

    In general, GL functions assume (1, 1) is to the right and up from (0, 0). TexImage2D assumes data for (0, 0) come in first and (1, 1) come in last. Your image loading routine might assume top row first.

    Mirroring UV*like thokra advised is efficient and easy fix.

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2012
    Posts
    4

    Re: Reversing Up-Vector of the camera

    Thanks,
    When I use JIG's jpeg-8 library the image is mapped upside down, but when I use FreeImage library everything is OK.

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    513

    Re: Reversing Up-Vector of the camera

    Some libraries already flip the image in anticipation that it will be used as an OpenGL texture, others simply give you the data in the file, and some allow you to configure this. Check the documentation of the libs to see if you can make them behave consistently (if you need to keep the option to use both) or just pick one and stick with it

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jun 2009
    Location
    FL , USA
    Posts
    194

    Re: Reversing Up-Vector of the camera

    When I use JIG's jpeg-8 library the image is mapped upside down, but when I use FreeImage library everything is OK.
    I second to carsten's reply. Images like BMP (MS version) arrange data such that the first row is last and last row is first. So you need to first check the file format and then check with the library.

Posting Permissions

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