Fix DisplayFormat and DisplayFormatAlpha
[sdlgit/SDL_perl.git] / t / core_surface.t
CommitLineData
b7ed9095 1#!perl -w
2# Copyright (C) 2009 kthakore
3#
4# Spec tests for SDL::Surface
5#
6
7BEGIN {
9a70569a 8 unshift @INC, 'blib/lib', 'blib/arch';
9}
b7ed9095 10
11use strict;
12use SDL;
13use SDL::Config;
14use SDL::Surface;
15use SDL::App;
16use SDL::Rect;
17use SDL::Color;
41a5a9ee 18use Test::More tests => 17;
9a70569a 19
20my $surface
af85b4e9 21 = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 8, 0, 0, 0, 0 );
9a70569a 22isa_ok( $surface, 'SDL::Surface' );
af85b4e9 23is( $surface->w, 640, 'surface has width' );
24is( $surface->h, 320, 'surface has height' );
25is( $surface->pitch, 640, 'surface has pitch' );
26my $clip_rect = SDL::Rect->new( 0, 0, 0, 0 );
27SDL::GetClipRect( $surface, $clip_rect );
28isa_ok( $clip_rect, 'SDL::Rect' );
29is( $clip_rect->x, 0, 'clip_rect has x' );
30is( $clip_rect->y, 0, 'clip_rect has y' );
31is( $clip_rect->w, 640, 'clip_rect has width' );
32is( $clip_rect->h, 320, 'clip_rect has height' );
9a70569a 33
34my $image = SDL::Surface->load('test/data/logo.png');
35is( $image->w, 608, 'image has width' );
36is( $image->h, 126, 'image has height' );
37
38$surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ),
39 SDL::Color->new( 200, 200, 200 ) );
40ok( 1, 'Managed to fill_rect' );
41
42my $small_rect = SDL::Rect->new( 0, 0, 64, 64 );
43$image->blit( $small_rect, $surface, $small_rect );
44ok( 1, 'Managed to blit' );
45
46#my $image_format = $surface->display;
47#$surface->update_rect( 0, 0, 32, 32 );
48#ok( 1, 'Managed to update_rect' );
49#$surface->update_rects( SDL::Rect->new( 0, 0, 32, 32 ) );
50#ok( 1, 'Managed to update_rects' );
51
52my $app = SDL::App->new(
53 -title => "Test",
54 -width => 640,
55 -height => 480,
56 -init => SDL_INIT_VIDEO
57);
b7ed9095 58
59pass 'did this pass';
60
41a5a9ee 61my $image_format = $image->display;
62isa_ok( $image_format, 'SDL::Surface' );
63
64my $image_format_alpha = $image->display_alpha;
65isa_ok( $image_format_alpha, 'SDL::Surface' );
66
9a70569a 67my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h );
b7ed9095 68
9a70569a 69my $blue = SDL::Color->new( 0x00, 0x00, 0xff, );
b7ed9095 70
9a70569a 71$app->fill_rect( $rect, $blue );
b7ed9095 72
9a70569a 73diag( 'This is in surface : ' . SDL::Surface::get_pixels($app) );
b7ed9095 74
75pass 'did this pass';
76