• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Rectangle to Texture in SDL2 C

Resolved: Rectangle to Texture in SDL2 C

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

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.

Answer:

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.

If you have better answer, please add a comment about this, thank you!

Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Unable to run Docker .NET 6 console image

02/04/2023

Resolved: Input Focus between two React Components

02/04/2023

Resolved: linq2db throws exception when filtering by nested collection

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.