We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2546 - software renderer can't handle textures with (8-bit) alpha channels?
Summary: software renderer can't handle textures with (8-bit) alpha channels?
Status: RESOLVED DUPLICATE of bug 1550
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.3
Hardware: x86_64 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-14 21:26 UTC by Adam M.
Modified: 2014-05-15 18:47 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam M. 2014-05-14 21:26:16 UTC
It seems that the software renderer can't properly render textures with 8-bit alpha channels. Here is a simple example.

This may or may not be a duplicate of bug #1550 (which is about surfaces, not textures) or similar, depending on the internal implementation of texture rendering in the software renderer.

#define SDL_MAIN_HANDLED
#include <SDL.h>

int main()
{
  const int Width = 400, Height = 300;
  SDL_Init(SDL_INIT_EVENTS|SDL_INIT_VIDEO);
  SDL_Window *pWindow = SDL_CreateWindow("Window", 300, 300, Width, Height, 0);
  SDL_Renderer *pRenderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_SOFTWARE);
  SDL_Surface *troll = SDL_LoadBMP("pathTo/SDL/test/shapes/trollface_32alpha.bmp");
  SDL_Texture *texture = SDL_CreateTextureFromSurface(pRenderer, troll);
  while(true)
  {
    SDL_Event e;
    SDL_WaitEvent(&e);
    if(e.type == SDL_WINDOWEVENT && e.window.event == SDL_WINDOWEVENT_EXPOSED)
    {
      SDL_SetRenderDrawColor(pRenderer, 255, 255, 255, 255);
      SDL_RenderFillRect(pRenderer, NULL);
      SDL_Rect rect = { 10, 10, troll->w, troll->h };
      SDL_RenderCopy(pRenderer, texture, NULL, &rect);
      SDL_RenderPresent(pRenderer);
    }
    else if(e.type == SDL_QUIT) break;
  }

  SDL_DestroyRenderer(pRenderer);
  SDL_DestroyWindow(pWindow);
  SDL_Quit();
  return 0;
}
Comment 1 Adam M. 2014-05-14 21:27:56 UTC
I misremembered. Bug #1550 is not about surfaces. However, this example does no rotation and does not call RenderCopyEx at all, so it doesn't seem like a duplicate.
Comment 2 Adam M. 2014-05-14 21:29:00 UTC
The symptom is similar, however. It seems that pixels with either alpha != 255 or alpha < 128 simply aren't rendered.
Comment 3 Gabriel Jacobo 2014-05-15 12:59:38 UTC
The essential issue is the same as reported in #1550, marking as duplicate.

*** This bug has been marked as a duplicate of bug 1550 ***
Comment 4 Adam M. 2014-05-15 18:47:03 UTC
In that case I will update bug #1550 to say that it also happens with RenderCopy.