03-17-2008, 07:41 AM
I've just started playing around with openGL lately and I'm still learning the basics. What I would like to know is, how to draw a hole in something.
For example say I draw a simple colored box, how can I draw a hole in the middle of it that can be seen through. I've been looking around but haven't found any functions or anything for doing this.
Any advice would be appreciated.
03-17-2008, 08:07 AM
Yeah I don't know of any functions or tools for doing that either but I'm still a noob too so there prob is some simple method for it.
I don't know what/how exactly you plan to use it but one basic way I can think of that might help you do whatever you need to do is to draw the whole first just using GL_LINES.
With your example of a square:
Draw the hole first - lets say a small square. (using GL_LINES)
Then make up the outside square using a number of small rectangles or whatever shapes you need.
Heres some example code:
//the hole in the middle starts here
//The outside shapes start here
Once you know the coordinates of the hole you wouldn't even need to draw its outline just know where to place the outside shapes around it.
I hope this can help you out but it's pretty basic. If not there's some other threads about similar sort of things i've noticed around here somewhere. They seem a little more complicated though but maybe you can look into them for ideas.
03-17-2008, 12:24 PM
Use an existing CSG library like http://www.opencsg.org/
03-18-2008, 06:45 AM
Thanks for the replies I don't know why I didn't think of trying something like that. It should work for the basic stuff I'm doing.
I think I'll check out the CSG library though since that sounds like it would be the proper way to do things and would be good to know.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.