},
libraries => [qw( SDL )],
},
+ Surface => {
+ file => {
+ from => 'src/Surface.xs',
+ to => 'lib/SDL/Surface.xs',
+ },
+ libraries => [qw( SDL SDL_image )],
+ },
OpenGL => {
file => {
from => 'src/OpenGL.xs',
+package SDL::Surface;
+use strict;
+use warnings;
+require Exporter;
+require DynaLoader;
+our @ISA = qw(Exporter DynaLoader);
+bootstrap SDL::Surface;
+
+1;
+
+__END__
+
#!/usr/bin/env perl
#
# Surface.pm
OUTPUT:
RETVAL
-SDL_Surface *
-CreateRGBSurface (flags, width, height, depth, Rmask, Gmask, Bmask, Amask )
- Uint32 flags
- int width
- int height
- int depth
- Uint32 Rmask
- Uint32 Gmask
- Uint32 Bmask
- Uint32 Amask
- CODE:
- RETVAL = SDL_CreateRGBSurface ( flags, width, height,
- depth, Rmask, Gmask, Bmask, Amask );
- OUTPUT:
- RETVAL
+=for comment
+Comment out for now as it does not compile
SDL_Surface *
CreateRGBSurfaceFrom (pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask )
OUTPUT:
RETVAL
+=cut
+
=for comment
Comment out for now as it does not compile
OUTPUT:
RETVAL
-=cut
-
int
MUSTLOCK ( surface )
SDL_Surface *surface
OUTPUT:
RETVAL
+=cut
HV *
VideoInfo ()
OUTPUT:
RETVAL
+SDL_Surface *
+SetVideoMode ( width, height, bpp, flags )
+ int width
+ int height
+ int bpp
+ Uint32 flags
+
+ CODE:
+ char* CLASS;
+ RETVAL = SDL_SetVideoMode(width,height,bpp,flags);
+ OUTPUT:
+ RETVAL
+
+int
+Flip ( surface )
+ SDL_Surface *surface
+ CODE:
+ RETVAL = SDL_Flip(surface);
+ OUTPUT:
+ RETVAL
+
+
=for comment
Comment out for now as it does not compile
OUTPUT:
RETVAL
-=cut
+
int
VideoModeOK ( width, height, bpp, flags )
int num_rects,i;
if ( items < 2 ) return;
num_rects = items - 1;
-
+ SDL_UpdateRects(surface,num_rects,rects);
rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
for(i=0;i<num_rects;i++) {
temp = (SDL_Rect *)SvIV(ST(i+1));
}
SDL_UpdateRects(surface,num_rects,rects);
safefree(rects);
-
int
Flip ( surface )
OUTPUT:
RETVAL
+=cut
+
int
FillRect ( dest, dest_rect, color )
SDL_Surface *dest
OUTPUT:
RETVAL
+=for comment
+
SDL_Surface*
TTFRenderTextSolid ( font, text, fg )
TTF_Font *font
OUTPUT:
RETVAL
+=cut
+
#endif
SDL_Overlay*
#ifdef HAVE_SDL_GFX
+=cut
+
SDL_Surface *
GFXRotoZoom ( src, angle, zoom, smooth)
SDL_Surface * src
OUTPUT:
RETVAL
+=cut
+
int
GFXPixelColor ( dst, x, y, color )
SDL_Surface* dst
#ifdef HAVE_SDL_IMAGE
+=for comment
+
SDL_Surface *
NewFont ( filename )
char *filename
OUTPUT:
RETVAL
+=cut
+
void
UseFont ( surface )
SDL_Surface *surface
--- /dev/null
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#ifndef aTHX_
+#define aTHX_
+#endif
+
+#include <SDL.h>
+
+MODULE = SDL::Surface PACKAGE = SDL::Surface PREFIX = surface_
+
+=for documentation
+
+SDL_Surface -- Graphic surface structure
+
+ typedef struct SDL_Surface {
+ Uint32 flags; /* Read-only */
+ SDL_PixelFormat *format; /* Read-only */
+ int w, h; /* Read-only */
+ Uint16 pitch; /* Read-only */
+ void *pixels; /* Read-write */
+ SDL_Rect clip_rect; /* Read-only */
+ int refcount; /* Read-mostly */
+
+ /* This structure also contains private fields not shown here */
+ } SDL_Surface;
+
+=cut
+
+SDL_Surface *
+surface_new (CLASS, flags, width, height, depth, Rmask, Gmask, Bmask, Amask )
+ char* CLASS
+ Uint32 flags
+ int width
+ int height
+ int depth
+ Uint32 Rmask
+ Uint32 Gmask
+ Uint32 Bmask
+ Uint32 Amask
+ CODE:
+ RETVAL = SDL_CreateRGBSurface ( flags, width, height,
+ depth, Rmask, Gmask, Bmask, Amask );
+ OUTPUT:
+ RETVAL
+
+
+SDL_Surface *
+surface_load (CLASS, filename )
+ char* CLASS
+ char* filename
+ CODE:
+ RETVAL = IMG_Load(filename);
+ OUTPUT:
+ RETVAL
+
+int
+surface_blit ( src, src_rect, dest, dest_rect )
+ SDL_Surface *src
+ SDL_Surface *dest
+ SDL_Rect *src_rect
+ SDL_Rect *dest_rect
+ CODE:
+ RETVAL = SDL_BlitSurface(src,src_rect,dest,dest_rect);
+ OUTPUT:
+ RETVAL
+
+int
+surface_fill_rect ( dest, dest_rect, color )
+ SDL_Surface *dest
+ SDL_Color *color
+ SDL_Rect *dest_rect
+ CODE:
+ Uint32 pixel = SDL_MapRGB(dest->format,color->r,color->g,color->b);
+ RETVAL = SDL_FillRect(dest,dest_rect,pixel);
+ OUTPUT:
+ RETVAL
+
+void
+surface_update_rect ( surface, x, y, w ,h )
+ SDL_Surface *surface
+ int x
+ int y
+ int w
+ int h
+ CODE:
+ SDL_UpdateRect(surface,x,y,w,h);
+
+void
+surface_update_rects ( surface, ... )
+ SDL_Surface *surface
+ CODE:
+ SDL_Rect *rects, *temp;
+ int num_rects,i;
+ if ( items < 2 ) return;
+ num_rects = items - 1;
+
+ rects = (SDL_Rect *)safemalloc(sizeof(SDL_Rect)*items);
+ for(i=0;i<num_rects;i++) {
+ temp = (SDL_Rect *)SvIV(ST(i+1));
+ rects[i].x = temp->x;
+ rects[i].y = temp->y;
+ rects[i].w = temp->w;
+ rects[i].h = temp->h;
+ }
+ SDL_UpdateRects(surface,num_rects,rects);
+ safefree(rects);
+
+SDL_Surface *
+surface_display ( surface )
+ SDL_Surface *surface
+ CODE:
+ char* CLASS = 'SDL::Surface\0';
+ RETVAL = SDL_DisplayFormat(surface);
+ OUTPUT:
+ RETVAL
+
+Uint16
+surface_w ( surface )
+ SDL_Surface *surface
+ CODE:
+ RETVAL = surface->w;
+ OUTPUT:
+ RETVAL
+
+Uint16
+surface_h ( surface )
+ SDL_Surface *surface
+ CODE:
+ RETVAL = surface->h;
+ OUTPUT:
+ RETVAL
+
+void
+surface_DESTROY(surface)
+ SDL_Surface *surface
+ CODE:
+ Uint8* pixels = surface->pixels;
+ Uint32 flags = surface->flags;
+ SDL_FreeSurface(surface);
+ if (flags & SDL_PREALLOC)
+ Safefree(pixels);
my $app = SDL::App->new(-title => "Test", -width => 640, -height => 480, -init => SDL_INIT_VIDEO);
- my $rect = SDL::Rect->new( 0,0, $app->width, $app->height);
+ my $rect = SDL::Rect->new( 0,0, $app->w, $app->h);
my $blue = SDL::Color->new(
0x00,
$grect->x($_ );
$grect->centery($_ * 3);
$grect->size( ($_ / 40) * $_, ($_/38) * $_ );
- $app->fill($rect, $blue);
- $app->fill($grect, $col);
+ $app->fill_rect($rect, $blue);
+ $app->fill_rect($grect, $col);
- $app->update($rect);
- $app->update($grect);
+ $app->update_rects($rect);
+ $app->update_rects($grect);
$app->sync;
}
-#!/usr/bin/perl -w
-#
-# Copyright (C) 2003 Tels
-# Copyright (C) 2004 David J. Goehrig
-#
-# Copyright (C) 2005 David J. Goehrig <dgoehrig\@cpan.org>
-#
-# ------------------------------------------------------------------------------
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# ------------------------------------------------------------------------------
-#
-# Please feel free to send questions, suggestions or improvements to:
-#
-# David J. Goehrig
-# dgoehrig\@cpan.org
-#
-#
-# basic testing of SDL::Surface
-
-BEGIN {
- unshift @INC, 'blib/lib','blib/arch';
-}
-
+#!perl
use strict;
+use warnings;
+use Test::More tests => 11;
+use_ok('SDL');
+use_ok('SDL::Color');
+use_ok('SDL::Rect');
+use_ok('SDL::Surface');
+
+my $surface
+ = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 0, 0, 0, 0, 0 );
+isa_ok( $surface, 'SDL::Surface' );
+is( $surface->w, 640, 'surface has width' );
+is( $surface->h, 320, 'surface has height' );
+
+my $image = SDL::Surface->load('test/data/logo.png');
+is( $image->w, 608, 'image has width' );
+is( $image->h, 126, 'image has height' );
+
+$surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ),
+ SDL::Color->new( 200, 200, 200 ) );
+ok( 1, 'Managed to fill_rect' );
+
+my $rect = SDL::Rect->new( 0, 0, 64, 64 );
+$image->blit( $rect, $surface, $rect );
+ok( 1, 'Managed to blit' );
+
+#my $image_format = $surface->display;
+#$surface->update_rect( 0, 0, 32, 32 );
+#ok( 1, 'Managed to update_rect' );
+#$surface->update_rects( SDL::Rect->new( 0, 0, 32, 32 ) );
+#ok( 1, 'Managed to update_rects' );
-use Test::More;
-
-plan ( tests => 3 );
-
-use_ok( 'SDL::Surface' );
-
-can_ok ('SDL::Surface', qw/
- new
- flags
- palette
- bpp
- bytes_per_pixel
- Rshift
- Gshift
- Bshift
- Ashift
- Rmask
- Bmask
- Gmask
- Amask
- color_key
- alpha
- width
- height
- pitch
- pixels
- pixel
- fill
- lockp
- lock
- unlock
- update
- flip
- blit
- set_colors
- set_color_key
- set_alpha
- display_format
- rgb
- rgba
- print
- save_bmp
- video_info /);
-
-my $surface = SDL::Surface->new();
-
-isa_ok($surface,'SDL::Surface');
-
-#
-# Copyright (C) 2005 David J. Goehrig <dgoehrig\@cpan.org>
-#
-# ------------------------------------------------------------------------------
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# ------------------------------------------------------------------------------
-#
-# Please feel free to send questions, suggestions or improvements to:
-#
-# David J. Goehrig
-# dgoehrig\@cpan.org
-#
Sint32 T_IV
Sint32 * T_PTR
SDL_Event * T_PTR
-SDL_Surface * T_PTR
+SDL_Surface * O_OBJECT
SDL_SysWMmsg * T_PTR
SDL_CD * T_PTR
SDL_CDtrack * T_PTR