SDL 버전 1.2 및 2.0과의 호환성 문제가 발생할 수 있습니다. SDL_MapRGB 및 SDL_FillRect를 사용하여 서페이스로 그릴 때 SDL 2.0은 RGB 빨강 및 파랑 채널을 SDL 1.2 하지 않습니다. 코드가 생성 (I 예상대로) (SDL 1.2 헤더 및 라이브러리를 사용)SDL 1.2 및 SDL 2.0 호환성
gcc $(sdl-config --cflags --libs) colourtest.c -o colourtest
컴파일 때
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
int main(void)
{
const unsigned height = 16;
const unsigned widthpercolour = 16;
SDL_Surface *surface;
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = widthpercolour;
rect.h = height;
if (SDL_Init(0) != 0) {
fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError());
return EXIT_FAILURE;
}
surface = SDL_CreateRGBSurface(0, 3 * widthpercolour, height, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
if (surface == NULL) {
fprintf(stderr, "Could not create SDL Surface: %s\n", SDL_GetError());
return EXIT_FAILURE;
}
SDL_FillRect(surface, NULL, 0);
SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 255, 0, 0));
rect.x += widthpercolour;
SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0, 255, 0));
rect.x += widthpercolour;
SDL_FillRect(surface, &rect, SDL_MapRGB(surface->format, 0, 0, 255));
if (SDL_SaveBMP(surface, "colourtest.bmp") != 0) {
SDL_FreeSurface(surface);
SDL_Quit();
fprintf(stderr, "Could not save SDL Surface: %s\n", SDL_GetError());
return EXIT_FAILURE;
}
SDL_FreeSurface(surface);
SDL_Quit();
return EXIT_SUCCESS;
}
다음 C 코드는 문제를 보여 최소한의 동작 예이며 다음 비트 맵 파일 :
그러나
,
0,123,516 컴파일 (SDL 2.0 사용)gcc $(sdl2-config --cflags --libs) colourtest.c -o colourtest
는 코드 (예기치) 다음의 비트 맵 파일이 생성
내가 (R, G, B)에 마스크를 변경 시도를하지만 아무것도 변화하지 않는다.
내가 알 수있는 한, 마이그레이션 가이드를 비롯한 문서에이 내용 중 아무 것도 언급되어 있지 않으며 문제에 관해서 다른 것을 찾을 수 없었습니다. 이것은 내가이 버그가 있거나 함수를 올바르게 사용하지 않는다고 생각하게한다.
여기에 질문이 있습니까? "내가 뭘해야하니?" 나는 버그 보고서를 제안 할 것이다. –