0
반투명 한 빨간색 사각형을 화면 표면에 그리는 방법을 알 수 없습니다.SDL : 반투명 사각형을 그립니다.
#!/usr/bin/perl
use SDL;
use SDL::Video;
use SDL::Surface;
use SDL::Rect;
# the size of the window box or the screen resolution if fullscreen
my $screen_width = 800;
my $screen_height = 600;
SDL::init(SDL_INIT_VIDEO);
# setting video mode
my $screen_surface = SDL::Video::set_video_mode($screen_width, $screen_height, 32, SDL_ANYFORMAT|SDL_SRCALPHA);
# drawing something somewhere
my $mapped_color = SDL::Video::map_RGBA($screen_surface->format(), 255, 0, 0, 128); #should be half-transparent, I suppose?
SDL::Video::fill_rect($screen_surface,
SDL::Rect->new($screen_width/4, $screen_height/4,
$screen_width/2, $screen_height/2), $mapped_color);
# update an area on the screen so its visible
SDL::Video::update_rect($screen_surface, 0, 0, $screen_width, $screen_height);
sleep(5); # just to have time to see it
그것은 내가 달성하기 위해 노력하고 무엇을하지 않은 검은 색 바탕에 빨간색 불투명 한 사각형 결과 : 는 여기에 지금까지 가지고있는 코드입니다.
감사합니다, 그것은 도움이! – varnie
나는 왜 물어볼 필요가있다. 왜 "(void)"를 넣을 까? 컴파일러는 반환 값을 무시하고 저장하지 않습니까? –