开发者

Drawing Rounded Rectangle in DirectX/3D for 2D

开发者 https://www.devze.com 2023-02-02 05:38 出处:网络
I\'m using Direct3D to draw 2D elements in a C++ application of mine, and it\'d be neat if I could create rounded-rectangle GUI elements that were varying in size, but I\'m not sure how to do that in

I'm using Direct3D to draw 2D elements in a C++ application of mine, and it'd be neat if I could create rounded-rectangle GUI elements that were varying in size, but I'm not sure how to do that in the most efficient manner possible.

I thought of the "easy" way which would be to have images of the four corners and then just place them in the proper positions, and fill in the rest, but varying radii for the rectangle corners would be a definite plus, and this method doesn't accommodate that feature well.

Through my searches I've come across the terms Pixel Shader, Stencil Buffering, and HLSL, but I'm not sure whether these terms are relevant and which one t开发者_运维问答o jump into if so.

Thanks in advance,

Jengerer


Ideally you create a 9 polygons, by dividing a square up. The 9 images then draw the corners/sides/center and you can scale it however you want.

You are going to need to know how to draw and texture map polygons in order to do this, it lets you scale the corners and the box if required.

0

精彩评论

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