sdlsdl-2blendingcolor-blendingblend-mode

How to implement custom blend mode in SDL2?


SDL2 provides by default 3 blend modes: alpha blend, additive, and multiply.

However I need to render filled rectangles using the Linear Light blend mode.

Is this possible to implement using OpenGL, or as a combination of the 3 built-in blend modes, or should I convert all my SDL_Textures to SDL_Surfaces and modify the pixel values manually?


Solution

  • SDL 2.0.6 introduced the function SDL_ComposeCustomBlendMode allowing you to create a new blend mode for 2D rendering.

    Here is the doc entry: https://wiki.libsdl.org/SDL_ComposeCustomBlendMode