Sign in to follow this  
Zanman777

Please tell me there's a way to set line width in SDL

Recommended Posts

Zanman777    219

I can't find a way to set a line width for the SDL_RenderDrawLine function, but I can't believe there's no way to set it. That's just... basic. Is there really no way to do so? Are the lines always 1 pixel wide, or what?

 

EDIT: Found an extension library (SDL_GFX) that provides that feature. It's wierd native SDL doesn't have that, though...

Edited by Zanman777

Share this post


Link to post
Share on other sites
SeanMiddleditch    17565
Hardware doesn't support it since nobody seriously uses lines outside of debug uses and hence don't need width so OpenGL and D3D contexts can't support it. It can only be done with slow software rendering or with non-trivial triangularization or very specialized shader effects. This is likely why SDL doesn't support it. SDL_gfx is a software rasterizer.

Share this post


Link to post
Share on other sites
Zanman777    219

My purpose was to draw buttons' borders. There is no way to specify the SDL_Rect border width, so I was trying the line approach. How can I draw a customisable button border, then?

Share this post


Link to post
Share on other sites
Lactose    11471

If you're using a image for the button, the border can be included in the image.

 

If not, I guess you can draw a bigger (filled) rectangle first, and then the button rectangle after? When the button rectangle overwrites the larger, you'll just be left with what looks like a border. This might be very wasteful, especially if you have many or large buttons.

Another option could be to draw 4 (filled) rectangles around the button's rectangle.

 

Just some suggestions off the top of my head, maybe they can help you achieve what you want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this