Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

c++ with OpenGL questions

Options
  • 21-02-2008 3:12pm
    #1
    Registered Users 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

  • Moderators, Music Moderators Posts: 1,481 Mod ✭✭✭✭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 Posts: 7 thunderBuns


    thanks very much
    May king Louis live forever


Advertisement