SDL2 C中质地的矩形
是否可以创建一个矩形并以某种方式将其变成SDL2 C中的纹理?
您可以使用图像库轻松地将图像加载到纹理上,但是制作一个简单的矩形似乎更为复杂。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
是否可以创建一个矩形并以某种方式将其变成SDL2 C中的纹理?
您可以使用图像库轻松地将图像加载到纹理上,但是制作一个简单的矩形似乎更为复杂。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
通常,创建所有像素都是相同颜色的纹理通常没有意义的,因为这会浪费视频记忆。
如果您想在没有轮廓的情况下以单个颜色渲染一个矩形,则使用函数直接执行此操作
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
withSDL_CreateRGBSurface
, then useSDL_FillRect
on thatSDL_Surface
to set the color, and then useSDL_CreateTextureFromSurface
to create aSDL_Texture
from thatSDL_Surface
.