开发者

OpenGL, remove sections from a shape

In OpenGL, how can开发者_如何学C one cut a triangle shaped hole from a square? making the hole transparent.

I'm also using SDL, maybe it can be achieved with an SDL surface?


While doing it on a texture is truly the easier way out, if you need it to be a real shape, you might try using the GLUtesselator from GLU toolkit. See a tutorial for it here.

General usage is that you create a tesselator object, create two contours (the outer and the inner in a reverse direction) and the tesselator translates that into pure OpenGL commands. Of course if it's efficiency you're seeking you should implement or find some higher order system that operates on vertex buffers.


You can use a texture and alpha blending: the texture would contain a transparent triangle. See this tutorial on blending.

EDIT: Of course alpha blending doesn't change the geometry. For that you need to perform treatments that are more complicated. See this tutorial on realtime CSG.

Reference: Constructive Solid Geometry

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜