Results 1 to 9 of 9

Thread: Displaying Image Files using Texture mapping

  1. #1
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    4

    Displaying Image Files using Texture mapping

    Hello,
    I am trying to display image files seamlessly and without any effects. I am using code from this OpenGL Tutorial.
    The image comes in two pieces (Two Triangles) one triangle fills and another starts to fill the rest of the slot. I have images which I need to display them one after another quickly without distraction.
    Anyone has any ideas what should I change in this code?
    Thanks in advance.

  2. #2
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Displaying Image Files using Texture mapping

    So, what is your problem?

  3. #3
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    4

    Re: Displaying Image Files using Texture mapping

    Sorry not to be more descriptive.
    I am displaying images every 100msec (10 frame/sec) and when each image is loading it comes in two triangles instead of coming in one quad shape and it is sort of slow and distracting. Which part of the code should I move to Init section? How can I get rid of this effect in
    This Sample Tutorial ?

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2004
    Posts
    990

    Re: Displaying Image Files using Texture mapping

    You can try double buffering.
    Replace GLUT_SINGLE with GLUT_DOUBLE as argument to glutInitDisplayMode and replace glFlush() with glutSwapBuffers() in the display function.

  5. #5
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    4

    Re: Displaying Image Files using Texture mapping

    Thanks Nico you are a star! It worked ..
    One more question: there are some black images which I don't want to display do you know how I can check if an image is black?

  6. #6
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Displaying Image Files using Texture mapping

    Maybe, you can generate mipmaps for all pictures and check if the last mipmap level is a black pixel. If your pictures dimension are not power of two, you can render the picture in a power of two texture using a fbo and then generate mipmap...
    I don't know if it is a good solution, it is just a suggestion.

    Notice that you will need bilinear filtering to make it work with this method.

  7. #7
    Junior Member Newbie
    Join Date
    May 2008
    Posts
    4

    Re: Displaying Image Files using Texture mapping

    The Image Dimensions are 320x240. How should I check the mipmap level is a black pixel? Any recommended tutorials?
    Thanks for the Reply.

  8. #8
    Member Contributor
    Join Date
    May 2008
    Posts
    67

    Re: Displaying Image Files using Texture mapping

    http://www.sdltutorials.com if you get it to work please let me know as i am having compile problems

  9. #9
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: Displaying Image Files using Texture mapping

    I have never tried myself that, but what I suggest you is to load your images in texture rectangle since your pictures are rectangles. You can do that with the extension GL_ARB_texture_rectangle.
    But you can't generate mipmap levels with a texture rectangle since mipmaping divide texture size by 2 until a one pixel sized texture.
    So what you can do is to use framebuffer object to render this texture to another which size is a power of 2 (you will need another extension: GL_EXT_framebuffer_object). And finally you can generate mipmaps, render it on the framebuffer which size is 1x1 and call the glReadPixels function to read pixel on the screen. I know it is a very long shot and I assume there some libraries more specialized on this kind of computations...

    You can find more information here:

    http://www.opengl.org/registry/specs..._rectangle.txt
    http://oss.sgi.com/projects/ogl-samp...fer_object.txt
    http://www.opengl.org/sdk/docs/man/
    tutorial on rendering to texture with fbo:
    http://www.gamedev.net/reference/art...rticle2331.asp

Similar Threads

  1. BMP Image Texture Mapping
    By Satheesh chandra reddy in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 05-21-2014, 06:52 AM
  2. no texture displaying with png image
    By wwuster in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-21-2009, 07:01 AM
  3. Texture mapping using a DDS image
    By Random89 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 03-29-2009, 05:01 PM
  4. how to texture mapping by an image of 450*500
    By yqs2002 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-14-2002, 02:09 AM
  5. Need help texture mapping an image
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-01-2001, 08:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean