如何在 SDL 2.0 中绘制矩形轮廓 [英] How to draw a rectangle outline in SDL 2.0

查看:60
本文介绍了如何在 SDL 2.0 中绘制矩形轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 SDL 2.0 中绘制矩形轮廓以用作选择框.有谁知道如何在 SDL 2.0 中制作一个?

I'm trying to draw a rectangle outline in SDL 2.0 in order to use as a selection box. Does anyone know how to make one in SDL 2.0?

推荐答案

您正在寻找 SDL_RenderDrawRect:

int SDL_RenderDrawRect(SDL_Renderer*   renderer,
                   const SDL_Rect* rect);

典型用法是:

SDL_Rect rectToDraw = {100,100,100,100} // Just some random rect

//Set Color of Rect with SDL_SetRenderDrawColor if needed

SDL_RenderDrawRect(renderer, &rectToDraw);

要绘制一个填充矩形,然后使用 SDL_RenderFillRect

To draw a filled rect it would then be with SDL_RenderFillRect

这篇关于如何在 SDL 2.0 中绘制矩形轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆