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

Started by
2 comments, last by Lactose 10 years, 4 months ago

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...

Advertisement
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.

Sean Middleditch – Game Systems Engineer – Join my team!

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?

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.

Hello to all my stalkers.

This topic is closed to new replies.

Advertisement