admin管理员组文章数量:1332339
Having the following simple PNG image rendering example:
#include <Windows.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_image.h>
#include <iostream>
char g_buffer[100];
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR str, int nWinMode) {
SDL_Event event;
SDL_Renderer* renderer = NULL;
SDL_Texture* texture = NULL;
SDL_Texture* texture2 = NULL;
SDL_Window* window = NULL;
SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
SDL_CreateWindowAndRenderer(
400, 400,
0, &window, &renderer
);
IMG_Init(IMG_INIT_PNG);
texture = IMG_LoadTexture(renderer, "D:/Pobrane_2/flower.png");
if (!texture)
{
sprintf(g_buffer, "IMG_LoadTexture error: %s\n", SDL_GetError());
MessageBox(NULL, g_buffer, "Error!", MB_OK | MB_ICONINFORMATION);
g_buffer[0] = 0;
return 1;
}
while (1) {
// Select the color for drawing. It is set to red here.
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
// Clear the entire screen to our selected color.
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
if (SDL_PollEvent(&event) && event.type == SDL_QUIT)
break;
}
SDL_DestroyTexture(texture);
IMG_Quit();
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return EXIT_SUCCESS;
}
How can one make the window background color transparent instead of solid red just to see what's behind the app window (for e.g. windows desktop)? I'd prefer platform independent code if possible.
Note: this is not a duplicate of my previous question: Making window background transparent
本文标签: cSet transparent SDL window backgroundStack Overflow
版权声明:本文标题:c++ - Set transparent SDL window background - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742328203a2454152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论