Some additional info…
Here is what I tried and I’m sure I messed this up but…
Changed the SDL_BLENDMODE enum to the following:
Code:
typedef enum
{
SDL_BLENDMODE_NONE = 0x00000000, /< no blending
dstRGBA = srcRGBA */
SDL_BLENDMODE_BLEND = 0x00000001, /< alpha blending
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
dstA = srcA + (dstA * (1-srcA)) */
SDL_BLENDMODE_ADD = 0x00000002, /< additive blending
dstRGB = (srcRGB * srcA) + dstRGB
dstA = dstA */
SDL_BLENDMODE_MOD = 0x00000004, /< color modulate
dstRGB = srcRGB * dstRGB
dstA = dstA */
SDL_BLENDMODE_PREMULTIPLIED = 0x00000008 /**< new test mode */
} SDL_BlendMode;
In SDL_render_gl.c changed the switch statement in GL_SetBlendMode() to the following:
Code:
switch (blendMode) {
case SDL_BLENDMODE_NONE:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
data->glDisable(GL_BLEND);
break;
case SDL_BLENDMODE_BLEND:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
data->glEnable(GL_BLEND);
data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
break;
case SDL_BLENDMODE_ADD:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
data->glEnable(GL_BLEND);
data->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
break;
case SDL_BLENDMODE_MOD:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
data->glEnable(GL_BLEND);
data->glBlendFuncSeparate(GL_ZERO, GL_SRC_COLOR, GL_ZERO, GL_ONE);
break;
case SDL_BLENDMODE_PREMULTIPLIED:
data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
data->glEnable(GL_BLEND);
data->glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
break;
}
Rebuilt the sdl2 library and using the newly rebuilt lib/dll I added the following code:
Code:
SDL_SetTextureBlendMode(texturefile, SDL_BLENDMODE_PREMULTIPLIED);
I also tried:
Code:
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_PREMULTIPLIED);
After trying these things: nothing changed
Here’s what I don’t understand. I created the following image:
[Image: http://i.imgur.com/2kwVot9.png ]
When I apply no SDL_BLENDMODE flag to the image or when I apply SDL_BLENDMODE_BLEND with the following:
Code:
SDL_SetTextureBlendMode(cloudbox, SDL_BLENDMODE_BLEND);
I get the bordered result: [Image: http://i.imgur.com/eferkhX.png ]
But when I apply the following flag:
Code:
SDL_SetTextureBlendMode(cloudbox, SDL_BLENDMODE_NONE);
I get the following result: [Image: http://i.imgur.com/uNeZcOf.png ]
It’s perfect… but how is it even working if the blendmode is set to SDL_BLENDMODE_BLEND how is it drawing the transparent areas correctly? And why is this one image not drawing the dark border?