Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

c++ with OpenGL questions

  • 21-02-2008 03:12PM
    #1
    Registered Users, Registered Users 2 Posts: 7


    hi I was wondering if any body could help me with a couple of problems I am having in c++ and openGL?
    1. how do I set up a polygon so that it has an inner edge basically giving it a hole in the middle. So far all I have found out is that I can't do this using the glPolygon function and that it can be done another way but no real explanation of how.
    2. how can I load a jpg file and use it as a texture for the polygon I mentioned above? again all I have found is stuff telling me it can be done but nothing on how to do it.
    Muchos gracias to any one that can help me out on this
    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    1. There are two easy ways to do this. The first and easier way is to break up the polygon into smaller polygons and basically model the hole you want. The other way is to texture map it with a texture whose alpha is 1.0 where you want the hole to be and zero everywhere else, and then render the polygon with alpha testing enabled (with the test function GL_LESS and a reference value of 1.0, so it only passes the pixels with an alpha value of less than 1.0).

    2. JPG isn't the best format to use due to the compression it uses - its non-trivial to read from file into a usable texture format, and the lossy compression can cause your textures to look bad. For simplicity's sake you're better off using something like non-compressed TGA, which you can just be read directly from disk into memory. That's easy to code up... you can have a look at this code I did ages ago to demonstrate loading & using simple TGA textures in OpenGL.


  • Registered Users, Registered Users 2 Posts: 7 thunderBuns


    thanks very much
    May king Louis live forever


Advertisement