我正在尝试创建一个本身完全透明的 SDL 窗口,但是当将图像渲染到其上时,图像完全不透明并且图像的 Alpha 通道被保留(因此图像的透明像素保持透明)。因此,结果只是屏幕上的一个图像,周围没有任何容器(想象一下在屏幕上贴一张现实生活中的贴纸)
所以这是简化的代码:
#include <stdio.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_syswm.h>
#include <iostream>
#include <Windows.h>
#include <string>
SDL_Window* window;
SDL_Renderer* renderer;
SDL_Texture* image;
int imageWidth = 0;
int imageHeight = 0;
bool init()
{
//Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
return false;
}
//Set texture filtering to linear
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
{
printf("Warning: Linear texture filtering not enabled!");
}
//Create window
window = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 500, …Run Code Online (Sandbox Code Playgroud)