Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Clipping and rendering parts of a *.png image

This topic is 5306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Clipping and rendering parts of a *.png image Hei, I am a beginner level game programmer and am trying to develop an RTS title using the Torque engine from GarageGames.com. I have gone through your excellent openGL tutorials. Thanks for the effort. I have a specific openGL question which I was hoping to get some tips/suggestions from you. Here is the problem. I have a 512 by 512 pixel size *.png image file. I can successfully load the image file into openGL and texture an openGL quad with this 2D image. But I have not figured out how I can clip parts of the image file that has already been loaded and render it to the quad. Say I want to clip the top left hand corner of the image file (64 by 64 pixels) and render it to the quad. How do I do that? Any tips would be greatly appreciated. Best Regards Frederic

Share this post

Link to post
Share on other sites
If you need to display a rectangular area, can''t you just assign texcoords accordingly?
For complex shapes, you could use geometry to clip the image itself (it would take some care for complex shapes however).
Also mind the idea of using multitex to alpha-away parts of the image.

In the case of a 512x512 image in which you want to display only the 64x64 bottom-left part, the first method should be more than enough.
The others are just suggestions.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!