Re: How to Grayscale Texture
David Olofson <[email protected]>
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <CAAcqxQoh4fnqd4Lm-daRF8cHc_q47Lb1_1+NiYP_QYX_Bq7O7Q@mail.gmail.com> |
On Tue, Jul 26, 2016 at 1:10 PM, ancientcc <[email protected]> wrote: > Would like to use SDL_Texture widely in code, but SDL_RenderReadPixel is too > low, require grayscale texture directly. How to do? [...] Is this something that needs to be done in real time, or can you preprocess the graphics at load time? If it needs to be real time, you should use procedural textures, using an SDL_Surface or a raw buffer as source data. (See SDL_TEXTUREACCESS_STREAMING.) You should absolutely not use SDL_RenderReadPixels(), ever, for anything other than screenshots and the like. It's typically faster to do all rendering in software, just to avoid ever moving data from VRAM to system memory. :-) If you want it all really fast and accelerated, you probably need to use custom shaders, but AFAIK, that's not directly supported by the SDL 2D API, so you'd have to move to OpenGL or Direct3D. -- //David Olofson - Consultant, Developer, Artist, Open Source Advocate .--- Games, examples, libraries, scripting, sound, music, graphics ---. | http://consulting.olofson.net http://olofsonarcade.com | '---------------------------------------------------------------------'