Hello,
I have a series of 8-bit greyscale images that I render to a texture - like a video. What I have is
a block of unsigned char memory for the pixels.
The only way I can see how to do this is to create a RGB24 texture (SDL_TEXTUREACCESS_STREAMING) and
then using LockTexture() and UnLockTexture() and convert the greyscale pixels to RGB24. Now I would
like to draw on the textures using SDL_RenderDrawLine() (and others) and using SDL2_gfx. However, to
do so, I need to set the texture as the renderer’s target. For this to happen, I need to set the
texture to SDL_TEXTUREACCESS_TARGET. When I do this, LockTexture() complains that the texture is not
streaming.
So, my questions are:
-
What is the correct way to render 8-bit greyscale images? In SDL 1.2 I use
SDL_CreateRGBSurfaceFrom() to create a surface with a depth of 8. Then I would blit that surface
onto the main display surface (usually having a depth of 24 or 32 - RGB/A). I tried doing the same
in SDL2, but when I created a texture from the 8-bit surface, rendering that texture to my main
texture (not default texture) would fail or the main texture would end up being all white. The main
texture was configured as RGB24. -
Does it makes sense to want a streaming texture that can also be a render target? If not, please
clarify. -
Does it make sense that a target texture can be locked or is there something fundamental that I
am not understanding (very likely!).
Many thanks.
Regards,
Alvin