Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tobias Leich
committed
Nov 30, 2009
1 parent
90d6eb1
commit be0c2a2
Showing
5 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package SDL::GFX::Primitives; | ||
use strict; | ||
use warnings; | ||
require Exporter; | ||
require DynaLoader; | ||
our @ISA = qw(Exporter DynaLoader); | ||
bootstrap SDL::GFX::Primitives; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
#include "EXTERN.h" | ||
#include "perl.h" | ||
#include "XSUB.h" | ||
|
||
#ifndef aTHX_ | ||
#define aTHX_ | ||
#endif | ||
|
||
#include <SDL.h> | ||
#include <SDL_gfxPrimitives.h> | ||
|
||
MODULE = SDL::GFX::Primitives PACKAGE = SDL::GFX::Primitives PREFIX = gfx_prim_ | ||
|
||
=for documentation | ||
|
||
The Following are XS bindings to the SDL_gfx Library | ||
|
||
Described here: | ||
|
||
See: L<http://www.ferzkopp.net/joomla/content/view/19/14/> | ||
|
||
=cut | ||
|
||
int | ||
gfx_prim_pixel_color(dst, x, y, color) | ||
SDL_Surface *dst | ||
Sint16 x | ||
Sint16 y | ||
Uint32 color | ||
CODE: | ||
RETVAL = pixelColor(dst, x, y, color); | ||
OUTPUT: | ||
RETVAL | ||
|
||
=for documentation | ||
|
||
pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Horizontal line */ | ||
|
||
hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color); | ||
hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Vertical line */ | ||
|
||
vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color); | ||
vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Rectangle */ | ||
|
||
rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); | ||
rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, | ||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Filled rectangle (Box) */ | ||
|
||
boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); | ||
boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, | ||
Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Line */ | ||
|
||
lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); | ||
lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, | ||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* AA Line */ | ||
aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color); | ||
aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, | ||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Circle */ | ||
|
||
circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); | ||
circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Circle */ | ||
|
||
arcColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Sint16 start, Sint16 end, Uint32 color); | ||
arcRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* AA Circle */ | ||
|
||
aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); | ||
aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, | ||
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Filled Circle */ | ||
|
||
filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color); | ||
filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, | ||
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Ellipse */ | ||
|
||
ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); | ||
ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, | ||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* AA Ellipse */ | ||
|
||
aaellipseColor(SDL_Surface * dst, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color); | ||
aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, | ||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Filled Ellipse */ | ||
|
||
filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color); | ||
filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, | ||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
#define CLOCKWISE | ||
|
||
/* Pie */ | ||
|
||
pieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, | ||
Sint16 start, Sint16 end, Uint32 color); | ||
pieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, | ||
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Filled Pie */ | ||
|
||
filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, | ||
Sint16 start, Sint16 end, Uint32 color); | ||
filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, | ||
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Trigon */ | ||
|
||
trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); | ||
trigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, | ||
Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* AA-Trigon */ | ||
|
||
aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); | ||
aatrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, | ||
Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Filled Trigon */ | ||
|
||
filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color); | ||
filledTrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, | ||
Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Polygon */ | ||
|
||
polygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color); | ||
polygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, | ||
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* AA-Polygon */ | ||
|
||
aapolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color); | ||
aapolygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, | ||
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
/* Filled Polygon */ | ||
|
||
filledPolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color); | ||
filledPolygonRGBA(SDL_Surface * dst, const Sint16 * vx, | ||
const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
texturedPolygon(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy); | ||
|
||
/* (Note: These MT versions are required for multi-threaded operation.) */ | ||
|
||
filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color, int **polyInts, int *polyAllocated); | ||
filledPolygonRGBAMT(SDL_Surface * dst, const Sint16 * vx, | ||
const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a, | ||
int **polyInts, int *polyAllocated); | ||
texturedPolygonMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy, int **polyInts, int *polyAllocated); | ||
|
||
/* Bezier */ | ||
/* (s = number of steps) */ | ||
|
||
bezierColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, int s, Uint32 color); | ||
bezierRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, | ||
int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
|
||
/* Characters/Strings */ | ||
|
||
characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color); | ||
characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *c, Uint32 color); | ||
stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *c, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
|
||
gfxPrimitivesSetFont(const void *fontdata, int cw, int ch); | ||
|
||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!perl | ||
use strict; | ||
use warnings; | ||
use SDL; | ||
use SDL::Config; | ||
use SDL::Video; | ||
use SDL::Surface; | ||
use SDL::GFX::Primitives; | ||
use Test::More; | ||
|
||
use lib 't/lib'; | ||
use SDL::TestTool; | ||
|
||
if( !SDL::TestTool->init(SDL_INIT_VIDEO) ) | ||
{ | ||
plan( skip_all => 'Failed to init video' ); | ||
} | ||
elsif( !SDL::Config->has('SDL_gfx') ) | ||
{ | ||
plan( skip_all => 'SDL_gfx support not compiled' ); | ||
} | ||
else | ||
{ | ||
plan( tests => 5 ); | ||
} | ||
|
||
use_ok('SDL'); | ||
use_ok('SDL::Surface'); | ||
use_ok('SDL::GFX::Primitives'); | ||
|
||
my $display = SDL::Video::set_video_mode(640,480,32, SDL_HWSURFACE ); | ||
|
||
if(!$display) | ||
{ | ||
plan skip_all => 'Couldn\'t set video mode: ' . SDL::get_error(); | ||
} | ||
|
||
SDL::Video::lock_surface($display) if(SDL::Video::MUSTLOCK($display)); | ||
|
||
is( SDL::GFX::Primitives::pixel_color($display, 5, 5, 0xFFFFFF00), 0, 'pixel_color' ); | ||
|
||
SDL::Video::unlock_surface($display) if(SDL::Video::MUSTLOCK($display)); | ||
|
||
SDL::Video::update_rect($display, 0, 0, 640, 480); | ||
|
||
SDL::delay(2000); | ||
|
||
pass 'Are we still alive? Checking for segfaults'; |