SDL2 C中质地的矩形

发布于 2025-02-07 19:03:55 字数 85 浏览 0 评论 0 原文

是否可以创建一个矩形并以某种方式将其变成SDL2 C中的纹理?

您可以使用图像库轻松地将图像加载到纹理上,但是制作一个简单的矩形似乎更为复杂。

Is it possible to create a Rectangle and somehow turn it into a Texture in SDL2 C?

You can easily load images to textures using the image library but making a simple rectangle seems a lot more complicated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过期情话 2025-02-14 19:03:55

通常,创建所有像素都是相同颜色的纹理通常没有意义的,因为这会浪费视频记忆。

如果您想在没有轮廓的情况下以单个颜色渲染一个矩形,则使用函数直接执行此操作 SDL_RENDERFILLRECT

如果您确实想为单个颜色的单个矩形创建一个没有轮廓的纹理,那么您可以创建 <<<<<<<代码> sdl_surface with sdl_fillect 在该 sdl_surface 上颜色,然后使用 ://wiki.libsdl.org/sdl_texture“ rel =“ nofollow noreferrer”> sdl_texture 来自该 sdl_surface

It is generally not meaningful to create a texture in which all pixels are the same color, as that would be a waste of video memory.

If you want to render a single rectangle in a single color without an outline, it would be more efficient to do this directly using the function SDL_RenderFillRect.

If you really want to create a texture for a single rectangle in a single color without an outline, then you can create an SDL_Surface with SDL_CreateRGBSurface, then use SDL_FillRect on that SDL_Surface to set the color, and then use SDL_CreateTextureFromSurface to create a SDL_Texture from that SDL_Surface.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文