SDL2 textures don't work with pixel format ARGB2101010

Viewed 250

I am trying to use a texture with the SDL_PIXELFORMAT_ARGB2101010 color format but I only get a black texture. The same program works when using the SDL_PIXELFORMAT_ARG88888 format.

None of SDL's variables are null. This is my code:

#include <SDL2/SDL.h>

int main(int argc, const char * argv[]) {
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window *win = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
    SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_SOFTWARE);
    SDL_Texture *tex = SDL_CreateTexture(ren, SDL_PIXELFORMAT_ARGB2101010, SDL_TEXTUREACCESS_STREAMING, bufferWidth, bufferHeight);
    
    
    uint32_t* buffer = new uint32_t[bufferWidth * bufferHeight];
                      
    for(int bufferIdx = 0; bufferIdx < bufferWidth * bufferHeight; bufferIdx++) {
        buffer[bufferIdx] = 0xc0ffffff;
    }

    SDL_Event event;
        
    while(running) {
        while(SDL_PollEvent(&event)) {
            if(event.type == SDL_QUIT)
                running = false;
        }
    
        SDL_UpdateTexture(tex, nullptr, buffer, bufferWidth * 4);
        SDL_RenderCopy(ren, tex, nullptr, nullptr);
        SDL_RenderPresent(ren);
    }
}

This is some of my hardware and software:

  • AMD Radeon Pro 5500M GPU
  • SDL Version 2.0.14
  • MacOS 11.1
  • C++14
  • Compiled with default Xcode 12.3 settings
0 Answers
Related