SDL-1.2.2: cleanup

git-svn-id: svn://kolibrios.org@6335 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2016-03-13 06:17:04 +00:00
parent caa8658f76
commit 77815d548c
9 changed files with 0 additions and 1845 deletions

View File

@ -1,362 +0,0 @@
/*
SDL_anim: an animation library for SDL
Copyright (C) 2001, 2002 Michael Leonhard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Michael Leonhard
mike@tamale.net
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <png.h>
#include "SDL_anim.h"
/* deal with MSVC++ crappiness */
#ifdef WIN32
#define strcasecmp _strcmpi
#endif
void Anim_Free( SDL_Animation *anim ) {
SDL_FreeSurface( anim->surface );
free( anim );
}
int Anim_GetFrameNum( SDL_Animation *anim, Uint32 start, Uint32 now ) {
int mspf, ms, frame;
if( now < start ) return 0;
mspf = anim->duration / anim->frames;
ms = now - start;
if( mspf == 0 ) frame = 0;
else frame = ms / mspf;
return frame;
}
void Anim_GetFrameRect( SDL_Animation *anim, int frame, SDL_Rect *rect ) {
rect->x = anim->w * (frame % anim->frames);
rect->y = 0;
rect->w = anim->w;
rect->h = anim->h;
}
int Anim_BlitFrame( SDL_Animation *anim, Uint32 start, Uint32 now, SDL_Surface *dest, SDL_Rect *dr ) {
int frame;
frame = Anim_GetFrameNum( anim, start, now );
return Anim_BlitFrameNum( anim, frame, dest, dr );
}
int Anim_BlitFrameNum( SDL_Animation *anim, int frame, SDL_Surface *dest, SDL_Rect *dr ) {
SDL_Rect rect;
Anim_GetFrameRect( anim, frame, &rect );
return SDL_BlitSurface( anim->surface, &rect, dest, dr );
}
int Anim_DisplayFormat( SDL_Animation *anim ) {
struct SDL_Surface *newsurface;
if( SDL_WasInit( SDL_INIT_VIDEO ) == 0 ) return 0;/*"Video is not initialized.\n"*/
newsurface = SDL_DisplayFormatAlpha( anim->surface );
if( !newsurface ) return 0;
anim->surface = newsurface;
return 1;
}
int DoAnimFormat( char *text, int *duration, int *framewidth, int *numframes ) {
char *tok;
SDL_printf( "file is \"%s\"\n", text );
/* SDL_anim */
tok = strtok( text, " " );
if( !tok ) return 0;
if( strcasecmp( tok, "SDL_anim" ) != 0 ) {
SDL_printf( "no SDL_anim\n" );
return 0;
}
/* duration */
tok = strtok( NULL, " " );
if( !tok ) return 0;
*duration = atoi( tok );
if( *duration < 1 ) {
SDL_printf( "no duration\n" );
return 0;
}
/* framewidth */
tok = strtok( NULL, " " );
if( !tok ) return 0;
*framewidth = atoi( tok );
if( *framewidth < 1 ) {
SDL_printf( "no framewidth\n" );
return 0;
}
/* numframes */
tok = strtok( NULL, " " );
if( !tok ) return 0;
*numframes = atoi( tok );
if( *numframes < 1 ) {
SDL_printf( "no numframes\n" );
return 0;
}
return 1;
}
struct SDL_Animation *Anim_Load( const char *file ) {
int ckey = -1, i;
char buf[8];
static FILE *fp; /* "static" prevents setjmp corruption */
png_structp read_ptr;
png_infop read_info_ptr, end_info_ptr;
png_bytep *row_pointers;
png_textp text_ptr;
int num_text, t;
int interlace_type, compression_type, filter_type, bit_depth, color_type;
png_uint_32 width, height, row;
int duration, framewidth, numframes;
png_color_16p background;
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
double gamma;
int intent;
png_uint_16p hist;
png_uint_32 offset_x, offset_y;
int unit_type;
png_charp purpose, units;
png_charpp params;
png_int_32 X0, X1;
int type, nparams;
png_uint_32 res_x, res_y;
/* png_colorp palette;
int num_palette;
*/ png_color_8p sig_bit;
png_bytep trans;
int num_trans;
png_color_16p trans_values;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
SDL_Animation *anim;
SDL_Surface *surface;
SDL_Palette *palette;
if( !file ) return NULL;
/* printf( "opening file \"%s\"\n", file );
*/
/* open the file handle */
fp = fopen( file, "rb" );
if( fp == NULL ) {
SDL_printf( "fopen() failed\n" );
return NULL;
}
/* check if it's PNG */
if( fread( buf, 1, 8, fp ) != 8 ) {
SDL_printf( "fread() failed\n" );
return NULL;
}
if( png_sig_cmp( buf, (png_size_t)0, 8 ) ) {
SDL_printf( "not a PNG file\n" );
return NULL;
}
fseek( fp, 0, SEEK_SET );
/* allocate read structure */
read_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, (png_voidp)NULL, (png_error_ptr)NULL, (png_error_ptr)NULL );
if( read_ptr == NULL ) {
SDL_printf( "png_create_read_struct() failed\n" );
return NULL;
}
/* allocate read info structure */
read_info_ptr = png_create_info_struct( read_ptr );
if( read_info_ptr == NULL ) {
SDL_printf( "png_create_info_struct() failed\n" );
return NULL;
}
end_info_ptr = png_create_info_struct( read_ptr );
if( end_info_ptr == NULL ) {
SDL_printf( "png_create_info_struct() failed\n" );
return NULL;
}
/* set error handler code */
if( setjmp( read_ptr->jmpbuf ) ) {
SDL_printf( "libpng read error\n" );
return NULL;
}
/* initialize stream */
png_init_io( read_ptr, fp );
png_set_read_status_fn( read_ptr, NULL );
/* read png info struct */
png_read_info( read_ptr, read_info_ptr );
/* get the info */
if( !png_get_IHDR( read_ptr, read_info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, &compression_type, &filter_type ) ) {
SDL_printf( "png_get_IHDR() failed\n" );
return NULL;
}
/* background color */
png_get_bKGD( read_ptr, read_info_ptr, &background );
png_get_cHRM( read_ptr, read_info_ptr, &white_x, &white_y, &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y );
/* gamma */
png_get_gAMA( read_ptr, read_info_ptr, &gamma );
/* rendering intent */
png_get_sRGB( read_ptr, read_info_ptr, &intent );
/* Histogram */
png_get_hIST( read_ptr, read_info_ptr, &hist );
/* offsets */
png_get_oFFs( read_ptr, read_info_ptr, &offset_x, &offset_y, &unit_type );
png_get_pCAL( read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, &nparams, &units, &params );
/* pixel density */
png_get_pHYs( read_ptr, read_info_ptr, &res_x, &res_y, &unit_type );
/* png_get_PLTE( read_ptr, read_info_ptr, &palette, &num_palette );
*/
/* significant bits */
png_get_sBIT( read_ptr, read_info_ptr, &sig_bit );
/* transparency */
if( png_get_tRNS( read_ptr, read_info_ptr, &trans, &num_trans, &trans_values ) ) {
if( color_type == PNG_COLOR_TYPE_PALETTE ) {
if( num_trans == 1 ) ckey = trans[0];
else png_set_expand( read_ptr );
}
else ckey = 0; /* actual value will be set later */
}
/* text chunks */
num_text = 0;
if( !png_get_text( read_ptr, read_info_ptr, &text_ptr, &num_text ) ) {
SDL_printf( "file has no text chunks\n" );
return NULL;
}
for( t = 0; t < num_text; t++ ) {
if( strcasecmp( text_ptr[t].key, "format" ) == 0 ) {
if( DoAnimFormat( text_ptr[t].text, &duration, &framewidth, &numframes ) ) break;
}
}
if( t == num_text ) {
SDL_printf( "file is not an SDL_anim PNG\n" );
return NULL;
}
png_set_strip_16( read_ptr );
png_set_packing( read_ptr );
if(color_type == PNG_COLOR_TYPE_GRAY)
png_set_expand( read_ptr );
/* Allocate the SDL surface to hold the image */
Rmask = Gmask = Bmask = Amask = 0;
if( color_type != PNG_COLOR_TYPE_PALETTE ) {
if( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
Rmask = 0x000000FF;
Gmask = 0x0000FF00;
Bmask = 0x00FF0000;
Amask = (read_info_ptr->channels == 4)? 0xFF000000 : 0;
}
else {
int s = (read_info_ptr->channels == 4) ? 0 : 8;
Rmask = 0xFF000000 >> s;
Gmask = 0x00FF0000 >> s;
Bmask = 0x0000FF00 >> s;
Amask = 0x000000FF >> s;
}
}
surface = SDL_AllocSurface( SDL_SWSURFACE, width, height, bit_depth * read_info_ptr->channels, Rmask, Gmask, Bmask, Amask );
if( surface == NULL ) {
Anim_SetError("Out of memory");
return NULL;
}
if(ckey != -1) {
if( color_type != PNG_COLOR_TYPE_PALETTE ) ckey = SDL_MapRGB( surface->format, (Uint8)trans_values->red, (Uint8)trans_values->green, (Uint8)trans_values->blue );
SDL_SetColorKey( surface, SDL_SRCCOLORKEY, ckey );
}
/* allocate row pointers */
row_pointers = (png_bytep *)malloc( sizeof( png_bytep ) * height );
if( row_pointers == NULL ) {
SDL_printf( "malloc() failed\n" );
return NULL;
}
for( row = 0; row < height; row++ ) {
row_pointers[row] = (Uint8 *)surface->pixels + row * surface->pitch;
}
png_read_image( read_ptr, row_pointers );
/* end io */
/* printf( "done\n" );
*/ png_read_end( read_ptr, end_info_ptr );
/* cleanup */
png_destroy_read_struct( &read_ptr, &read_info_ptr, &end_info_ptr);
fclose( fp );
/* Load the palette, if any */
palette = surface->format->palette;
if( palette ) {
if(color_type == PNG_COLOR_TYPE_GRAY) {
palette->ncolors = 256;
for( i = 0; i < 256; i++ ) {
palette->colors[i].r = i;
palette->colors[i].g = i;
palette->colors[i].b = i;
}
}
else if( read_info_ptr->num_palette > 0 ) {
palette->ncolors = read_info_ptr->num_palette;
for( i = 0; i < read_info_ptr->num_palette; ++i ) {
palette->colors[i].b = read_info_ptr->palette[i].blue;
palette->colors[i].g = read_info_ptr->palette[i].green;
palette->colors[i].r = read_info_ptr->palette[i].red;
}
}
}
anim = (struct SDL_Animation *)malloc( sizeof( struct SDL_Animation ) );
if( !anim ) {
SDL_printf( "malloc() failed\n" );
return NULL;
}
anim->surface = surface;
anim->w = framewidth;
anim->h = height;
anim->frames = numframes;
anim->duration = duration;
return anim;
}

View File

@ -1,328 +0,0 @@
/*
SDL_anim: an animation library for SDL
Copyright (C) 2001, 2002 Michael Leonhard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Michael Leonhard
mike@tamale.net
*/
#include <stdlib.h>
#include <stdio.h>
#include <png.h>
/* deal with MSVC++ crappiness */
#ifdef WIN32
#define snprintf _snprintf
#endif
typedef struct inputstruct {
FILE *file;
char *name;
png_structp read_ptr;
png_infop read_info_ptr;
};
int numfiles;
struct inputstruct *input;
int main( int argc, char *argv[] ) {
int f, rowbytes;
char buf[256];
static FILE *fpout; /* "static" prevents setjmp corruption */
png_structp write_ptr;
png_infop write_info_ptr, end_info_ptr;
png_bytep row_buf, here;
png_uint_32 y;
png_textp text_ptr, new_text_ptr;
int num_text;
int interlace_type, compression_type, filter_type, bit_depth, color_type;
int it, ct, ft, bd, clrt;
png_uint_32 width, height, w, h;
int duration;
if( argc < 4 ) {
printf( "makeanim v0.2\nusage: makeanim <duration in milliseconds> <input files ...> <output file>\n" );
printf( "example: makeanim 1500 a00.png a01.png a02.png a03.png a04.png a.anim\n" );
return 1;
}
duration = atoi( argv[1] );
if( duration < 1 ) {
printf( "duration is incorrect\n" );
return 1;
}
numfiles = argc - 3;
input = (struct inputstruct *)malloc( sizeof( struct inputstruct ) * numfiles );
if( !input ) return 1;
for( f = 0; f < numfiles; f++ ) {
input[f].name = argv[f + 2];
printf( "opening file %d, \"%s\"\n", f, input[f].name );
/* open the file handle */
input[f].file = fopen( input[f].name, "rb" );
if( input[f].file == NULL ) {
printf( "fopen() failed\n" );
return 1;
}
/* check if it's PNG */
if( fread( buf, 1, 8, input[f].file ) != 8 ) {
printf( "fread() failed for file \"%s\"\n", input[f].name );
return 1;
}
if( png_sig_cmp( buf, (png_size_t)0, 8 ) ) {
printf( "not a PNG file\n" );
return 1;
}
fseek( input[f].file, 0, SEEK_SET );
/* allocate read structure */
input[f].read_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, (png_voidp)NULL, (png_error_ptr)NULL, (png_error_ptr)NULL );
if( input[f].read_ptr == NULL ) {
printf( "png_create_read_struct() failed\n" );
return 1;
}
/* allocate read info structure */
input[f].read_info_ptr = png_create_info_struct( input[f].read_ptr );
if( input[f].read_info_ptr == NULL ) {
printf( "png_create_info_struct() failed\n" );
return 1;
}
/* set error handler code */
if( setjmp( input[f].read_ptr->jmpbuf ) ) {
printf( "libpng read error\n" );
return 1;
}
/* initialize stream */
png_init_io( input[f].read_ptr, input[f].file );
png_set_read_status_fn( input[f].read_ptr, NULL );
/* read png info struct */
png_read_info( input[f].read_ptr, input[f].read_info_ptr );
/* get the info */
if( !png_get_IHDR( input[f].read_ptr, input[f].read_info_ptr, &w, &h, &bd, &clrt, &it, &ct, &ft ) ) {
printf( "png_get_IHDR() failed\n" );
return 1;
}
/* save the info of the first frame */
if( f == 0 ) {
width = w;
height = h;
bit_depth = bd;
color_type = clrt;
interlace_type = it;
compression_type = ct;
filter_type = ft;
}
/* compare all other frames to first frame */
else if( (w != width) ||
(h != height) ||
(bd != bit_depth) ||
(clrt != color_type) ||
(it != interlace_type) ||
(ct != compression_type) ||
(ft != filter_type) ) {
if( w != width ) printf( "width is different\n" );
if( h != height ) printf( "height is different\n" );
if( bd != bit_depth ) printf( "bit depth is different\n" );
if( clrt != color_type ) printf( "color type is different\n" );
if( it != interlace_type ) printf( "interlace type is different\n" );
if( ct != compression_type ) printf( "compression type is different\n" );
if( ft != filter_type ) printf( "filter type is different\n" );
return 1;
}
}
row_buf = (png_bytep)NULL;
/* open output file */
printf( "opening file \"%s\"\n", argv[numfiles + 2] );
fpout = fopen( argv[numfiles + 2], "wb" );
if( fpout == NULL ) {
printf( "fopen() failed\n" );
return 1;
}
/* allocate write structure */
write_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING, (png_voidp)NULL, (png_error_ptr)NULL, (png_error_ptr)NULL );
/* allocate info structures */
write_info_ptr = png_create_info_struct( write_ptr );
end_info_ptr = png_create_info_struct( write_ptr );
/* error handling */
if( setjmp( write_ptr->jmpbuf ) ) {
printf( "libpng write error\n" );
return 1;
}
/* initialize output stream */
png_init_io( write_ptr, fpout );
png_set_write_status_fn( write_ptr, NULL );
/* set info */
png_set_IHDR( write_ptr, write_info_ptr, width * numfiles, height, bit_depth, color_type, PNG_INTERLACE_NONE, compression_type, filter_type);
/* image characteristics */
{
png_color_16p background;
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
double gamma;
int intent;
png_uint_16p hist;
png_uint_32 offset_x, offset_y;
int unit_type;
png_charp purpose, units;
png_charpp params;
png_int_32 X0, X1;
int type, nparams;
png_uint_32 res_x, res_y;
png_colorp palette;
int num_palette;
png_color_8p sig_bit;
png_bytep trans;
int num_trans;
png_color_16p trans_values;
/* background color */
if( png_get_bKGD( input[0].read_ptr, input[0].read_info_ptr, &background ) ) {
png_set_bKGD( write_ptr, write_info_ptr, background );
}
if( png_get_cHRM( input[0].read_ptr, input[0].read_info_ptr, &white_x, &white_y, &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y ) ) {
png_set_cHRM( write_ptr, write_info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y );
}
/* gamma */
if( png_get_gAMA( input[0].read_ptr, input[0].read_info_ptr, &gamma ) ) {
png_set_gAMA( write_ptr, write_info_ptr, gamma );
}
/* rendering intent */
if( png_get_sRGB( input[0].read_ptr, input[0].read_info_ptr, &intent ) ) {
png_set_sRGB( write_ptr, write_info_ptr, intent );
}
/* Histogram */
if( png_get_hIST( input[0].read_ptr, input[0].read_info_ptr, &hist ) ) {
png_set_hIST( write_ptr, write_info_ptr, hist );
}
/* offsets */
if( png_get_oFFs( input[0].read_ptr, input[0].read_info_ptr, &offset_x, &offset_y, &unit_type ) ) {
png_set_oFFs( write_ptr, write_info_ptr, offset_x, offset_y, unit_type );
}
if( png_get_pCAL( input[0].read_ptr, input[0].read_info_ptr, &purpose, &X0, &X1, &type, &nparams, &units, &params ) ) {
png_set_pCAL( write_ptr, write_info_ptr, purpose, X0, X1, type, nparams, units, params );
}
/* pixel density */
if( png_get_pHYs( input[0].read_ptr, input[0].read_info_ptr, &res_x, &res_y, &unit_type ) ) {
png_set_pHYs( write_ptr, write_info_ptr, res_x, res_y, unit_type );
}
/* text chunks */
/* if( png_get_text( input[0].read_ptr, input[0].read_info_ptr, &text_ptr, &num_text ) > 0 ) {
printf( "Handling %d tEXt/zTXt chunks\n", num_text );
png_set_text( write_ptr, write_info_ptr, text_ptr, num_text );
}
*/
/* palette */
if( png_get_PLTE( input[0].read_ptr, input[0].read_info_ptr, &palette, &num_palette ) ) {
png_set_PLTE( write_ptr, write_info_ptr, palette, num_palette );
}
/* significant bits */
if( png_get_sBIT( input[0].read_ptr, input[0].read_info_ptr, &sig_bit ) ) {
png_set_sBIT( write_ptr, write_info_ptr, sig_bit );
}
/* transparency */
if( png_get_tRNS( input[0].read_ptr, input[0].read_info_ptr, &trans, &num_trans, &trans_values ) ) {
png_set_tRNS( write_ptr, write_info_ptr, trans, num_trans, trans_values );
}
}
/* text chunks */
num_text = 0;
if( !png_get_text( input[0].read_ptr, input[0].read_info_ptr, &text_ptr, &num_text ) ) num_text = 0;
new_text_ptr = (struct png_text_struct *)malloc( sizeof( struct png_text_struct ) * num_text + 1 );
if( !new_text_ptr ) {
printf( "malloc() failed\n" );
return 1;
}
memcpy( new_text_ptr, text_ptr, sizeof( struct png_text_struct ) * num_text );
snprintf( buf, 255, "SDL_anim %d %d %d", duration, width, numfiles );
buf[255] = 0;
new_text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE;
new_text_ptr[num_text].key = "format";
new_text_ptr[num_text].text = buf;
new_text_ptr[num_text].text_length = strlen( buf );
num_text++;
png_set_text( write_ptr, write_info_ptr, new_text_ptr, num_text );
/* write info */
png_write_info( write_ptr, write_info_ptr );
/* allocate buffer */
rowbytes = png_get_rowbytes( input[0].read_ptr, input[0].read_info_ptr );
row_buf = (png_bytep)png_malloc( write_ptr, rowbytes * numfiles );
if( row_buf == NULL ) {
printf( "png_malloc() failed\n" );
return 1;
}
/* copy raw data */
for( y = 0; y < height; y++ ) {
/* grab a scanline from each file */
here = row_buf;
for( f = 0; f < numfiles; f++ ) {
png_read_rows( input[f].read_ptr, (png_bytepp)&here, (png_bytepp)NULL, 1 );
here += rowbytes;
}
/* write the long scanline */
png_write_rows( write_ptr, (png_bytepp)&row_buf, 1 );
}
/* end io */
for( f = 0; f < numfiles; f++ ) png_read_end( input[f].read_ptr, end_info_ptr );
png_write_end( write_ptr, end_info_ptr );
/* cleanup */
png_free( write_ptr, row_buf );
for( f = 0; f < numfiles; f++ ) {
png_destroy_read_struct( &input[f].read_ptr, &input[f].read_info_ptr, &end_info_ptr);
fclose( input[f].file );
}
png_destroy_write_struct( &write_ptr, &write_info_ptr );
fclose( fpout );
return 0;
}

View File

@ -1,52 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_byteorder.h,v 1.3 2001/05/10 20:25:51 hercules Exp $";
#endif
/* Macros for determining the byte-order of this platform */
#ifndef _SDL_byteorder_h
#define _SDL_byteorder_h
/* The two types of endianness */
#define SDL_LIL_ENDIAN 1234
#define SDL_BIG_ENDIAN 4321
/* Pardon the mess, I'm trying to determine the endianness of this host.
I'm doing it by preprocessor defines rather than some sort of configure
script so that application code can use this too. The "right" way would
be to dynamically generate this file on install, but that's a lot of work.
*/
#if defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
(defined(__alpha__) || defined(__alpha)) || \
defined(__arm__) || \
(defined(__mips__) && defined(__MIPSEL__)) || \
defined(__LITTLE_ENDIAN__)
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#else
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#endif
#endif /* _SDL_byteorder_h */

View File

@ -1,97 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_main.h,v 1.3 2001/06/07 14:28:11 hercules Exp $";
#endif
#ifndef _SDL_main_h
#define _SDL_main_h
/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(macintosh) || defined(__APPLE__)
#ifdef __cplusplus
#define C_LINKAGE "C"
#else
#define C_LINKAGE
#endif /* __cplusplus */
/* The application's main() function must be called with C linkage,
and should be declared like this:
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
{
}
*/
#define main SDL_main
/* The prototype for the application's main() function */
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
/* From the SDL library code -- needed for registering the app on Win32 */
#if defined(WIN32)
#include "SDL_types.h"
#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/* This should be called from your WinMain() function, if any */
extern DECLSPEC int SDL_RegisterApp(char *name, Uint32 style, void *hInst);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif
/* From the SDL library code -- needed for registering QuickDraw on MacOS */
#if defined(macintosh)
#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declaration so we don't need to include QuickDraw.h */
struct QDGlobals;
/* This should be called from your main() function, if any */
extern DECLSPEC void SDL_InitQuickDraw(struct QDGlobals *the_qd);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif
#endif /* Need to redefine main()? */
#endif /* _SDL_main_h */

View File

@ -1,165 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_syswm.h,v 1.5 2001/07/08 09:00:06 hercules Exp $";
#endif
/* Include file for SDL custom system window manager hooks */
#ifndef _SDL_syswm_h
#define _SDL_syswm_h
#include "SDL_version.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/* Your application has access to a special type of event 'SDL_SYSWMEVENT',
which contains window-manager specific information and arrives whenever
an unhandled window event occurs. This event is ignored by default, but
you can enable it with SDL_EventState()
*/
#ifdef SDL_PROTOTYPES_ONLY
struct SDL_SysWMinfo;
typedef struct SDL_SysWMinfo SDL_SysWMinfo;
#else
/* This is the structure for custom window manager events */
#if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \
(!defined(DISABLE_X11) && !defined(__CYGWIN32__))
/* AIX is unix, of course, but the native compiler CSet doesn't define unix */
#include <X11/Xlib.h>
#include <X11/Xatom.h>
/* These are the various supported subsystems under UNIX */
typedef enum {
SDL_SYSWM_X11
} SDL_SYSWM_TYPE;
/* The UNIX custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
SDL_SYSWM_TYPE subsystem;
union {
XEvent xevent;
} event;
};
/* The UNIX custom window manager information structure.
When this structure is returned, it holds information about which
low level system it is using, and will be one of SDL_SYSWM_TYPE.
*/
typedef struct {
SDL_version version;
SDL_SYSWM_TYPE subsystem;
union {
struct {
Display *display; /* The X11 display */
Window window; /* The X11 display window */
/* These locking functions should be called around
any X11 functions using the display variable.
They lock the event thread, so should not be
called around event functions or from event filters.
*/
void (*lock_func)(void);
void (*unlock_func)(void);
/* Introduced in SDL 1.0.2 */
Window fswindow; /* The X11 fullscreen window */
Window wmwindow; /* The X11 managed input window */
} x11;
} info;
} SDL_SysWMinfo;
#elif defined(ENABLE_NANOX)
#include <microwin/nano-X.h>
/* The generic custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
int data;
};
/* The windows custom window manager information structure */
typedef struct {
SDL_version version ;
GR_WINDOW_ID window ; /* The display window */
} SDL_SysWMinfo;
#elif defined(WIN32)
#include <windows.h>
/* The windows custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
HWND hwnd; /* The window for the message */
UINT msg; /* The type of message */
WPARAM wParam; /* WORD message parameter */
LPARAM lParam; /* LONG message parameter */
};
/* The windows custom window manager information structure */
typedef struct {
SDL_version version;
HWND window; /* The Win32 display window */
} SDL_SysWMinfo;
#else
/* The generic custom event structure */
struct SDL_SysWMmsg {
SDL_version version;
int data;
};
/* The generic custom window manager information structure */
typedef struct {
SDL_version version;
int data;
} SDL_SysWMinfo;
#endif /* OS type */
#endif /* SDL_PROTOTYPES_ONLY */
/* Function prototypes */
/*
* This function gives you custom hooks into the window manager information.
* It fills the structure pointed to by 'info' with custom information and
* returns 1 if the function is implemented. If it's not implemented, or
* the version member of the 'info' structure is invalid, it returns 0.
*/
extern DECLSPEC int SDL_GetWMInfo(SDL_SysWMinfo *info);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_syswm_h */

View File

@ -1,91 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
/* This file sets things up for C dynamic library function definitions,
static inlined functions, and structures aligned at 4-byte alignment.
If you don't like ugly C preprocessor code, don't look at this file. :)
*/
/* This shouldn't be nested -- included it around code only. */
#ifdef _begin_code_h
#error Nested inclusion of begin_code.h
#endif
#define _begin_code_h
/* Some compilers use a special export keyword */
#ifndef DECLSPEC
# ifdef __BEOS__
# if defined(__GNUC__)
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC __declspec(export)
# endif
# else
# ifdef WIN32
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC
# endif
# endif
#endif
/* Force structure packing at 4 byte alignment.
This is necessary if the header is included in code which has structure
packing set to an alternate value, say for loading structures from disk.
The packing is reset to the previous value in close_code.h
*/
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
#ifdef _MSC_VER
#pragma warning(disable: 4103)
#endif
#ifdef __BORLANDC__
#pragma nopackwarning
#endif
#pragma pack(push,4)
#endif /* Compiler needs structure packing set */
/* Set up compiler-specific options for inlining functions */
#ifndef SDL_INLINE_OKAY
#ifdef __GNUC__
#define SDL_INLINE_OKAY
#else
/* Add any special compiler-specific cases here */
#if defined(_MSC_VER)
#define __inline__ __inline
#define SDL_INLINE_OKAY
#else
#if !defined(__MRC__) && !defined(_SGI_SOURCE)
#define __inline__ inline
#define SDL_INLINE_OKAY
#endif /* Not a funky compiler */
#endif /* Visual C++ */
#endif /* GNU C */
#endif /* SDL_INLINE_OKAY */
/* If inlining isn't supported, remove "__inline__", turning static
inlined functions into static functions (resulting in code bloat
in all files which include the offending header files)
*/
#ifndef SDL_INLINE_OKAY
#define __inline__
#endif

View File

@ -1,46 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_sysevents.h,v 1.2 2001/04/26 16:50:17 hercules Exp $";
#endif
#include "SDL_sysvideo.h"
/* Useful functions and variables from SDL_sysevents.c */
#ifdef __BEOS__ /* The Be event loop runs in a separate thread */
#define MUST_THREAD_EVENTS
#endif
#ifdef WIN32 /* Win32 doesn't allow a separate event thread */
#define CANT_THREAD_EVENTS
#endif
#ifdef macintosh /* MacOS 7/8 don't support preemptive multi-tasking */
#define CANT_THREAD_EVENTS
#endif
#ifdef __MENUETOS__
#define CANT_THREAD_EVENTS
#endif

View File

@ -1,305 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
/* This a stretch blit implementation based on ideas given to me by
Tomasz Cejner - thanks! :)
April 27, 2000 - Sam Lantinga
*/
#include "SDL_error.h"
#include "SDL_video.h"
#include "SDL_blit.h"
/* This isn't ready for general consumption yet - it should be folded
into the general blitting mechanism.
*/
#if (defined(WIN32) && !defined(_M_ALPHA) && !defined(_WIN32_WCE)) || \
defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
#define USE_ASM_STRETCH
#endif
#ifdef USE_ASM_STRETCH
#if defined(WIN32) || defined(i386)
#define PREFIX16 0x66
#define STORE_BYTE 0xAA
#define STORE_WORD 0xAB
#define LOAD_BYTE 0xAC
#define LOAD_WORD 0xAD
#define RETURN 0xC3
#else
#error Need assembly opcodes for this architecture
#endif
#if defined(__ELF__) && defined(__GNUC__)
extern unsigned char _copy_row[4096] __attribute__ ((alias ("copy_row")));
#endif
static unsigned char copy_row[4096];
static int generate_rowbytes(int src_w, int dst_w, int bpp)
{
static struct {
int bpp;
int src_w;
int dst_w;
} last;
int i;
int pos, inc;
unsigned char *eip;
unsigned char load, store;
/* See if we need to regenerate the copy buffer */
if ( (src_w == last.src_w) &&
(dst_w == last.src_w) && (bpp == last.bpp) ) {
return(0);
}
last.bpp = bpp;
last.src_w = src_w;
last.dst_w = dst_w;
switch (bpp) {
case 1:
load = LOAD_BYTE;
store = STORE_BYTE;
break;
case 2:
case 4:
load = LOAD_WORD;
store = STORE_WORD;
break;
default:
SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp);
return(-1);
}
pos = 0x10000;
inc = (src_w << 16) / dst_w;
eip = copy_row;
for ( i=0; i<dst_w; ++i ) {
while ( pos >= 0x10000L ) {
if ( bpp == 2 ) {
*eip++ = PREFIX16;
}
*eip++ = load;
pos -= 0x10000L;
}
if ( bpp == 2 ) {
*eip++ = PREFIX16;
}
*eip++ = store;
pos += inc;
}
*eip++ = RETURN;
/* Verify that we didn't overflow (too late) */
if ( eip > (copy_row+sizeof(copy_row)) ) {
SDL_SetError("Copy buffer overflow");
return(-1);
}
return(0);
}
#else
#define DEFINE_COPY_ROW(name, type) \
void name(type *src, int src_w, type *dst, int dst_w) \
{ \
int i; \
int pos, inc; \
type pixel = 0; \
\
pos = 0x10000; \
inc = (src_w << 16) / dst_w; \
for ( i=dst_w; i>0; --i ) { \
while ( pos >= 0x10000L ) { \
pixel = *src++; \
pos -= 0x10000L; \
} \
*dst++ = pixel; \
pos += inc; \
} \
}
DEFINE_COPY_ROW(copy_row1, Uint8)
DEFINE_COPY_ROW(copy_row2, Uint16)
DEFINE_COPY_ROW(copy_row4, Uint32)
#endif /* USE_ASM_STRETCH */
/* The ASM code doesn't handle 24-bpp stretch blits */
void copy_row3(Uint8 *src, int src_w, Uint8 *dst, int dst_w)
{
int i;
int pos, inc;
Uint8 pixel[3];
pos = 0x10000;
inc = (src_w << 16) / dst_w;
for ( i=dst_w; i>0; --i ) {
while ( pos >= 0x10000L ) {
pixel[0] = *src++;
pixel[1] = *src++;
pixel[2] = *src++;
pos -= 0x10000L;
}
*dst++ = pixel[0];
*dst++ = pixel[1];
*dst++ = pixel[2];
pos += inc;
}
}
/* Perform a stretch blit between two surfaces of the same format.
NOTE: This function is not safe to call from multiple threads!
*/
int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
int pos, inc;
int dst_width;
int dst_maxrow;
int src_row, dst_row;
Uint8 *srcp = NULL;
Uint8 *dstp;
SDL_Rect full_src;
SDL_Rect full_dst;
#if defined(USE_ASM_STRETCH) && defined(__GNUC__)
int u1, u2;
#endif
const int bpp = dst->format->BytesPerPixel;
if ( src->format->BitsPerPixel != dst->format->BitsPerPixel ) {
SDL_SetError("Only works with same format surfaces");
return(-1);
}
/* Verify the blit rectangles */
if ( srcrect ) {
if ( (srcrect->x < 0) || (srcrect->y < 0) ||
((srcrect->x+srcrect->w) > src->w) ||
((srcrect->y+srcrect->h) > src->h) ) {
SDL_SetError("Invalid source blit rectangle");
return(-1);
}
} else {
full_src.x = 0;
full_src.y = 0;
full_src.w = src->w;
full_src.h = src->h;
srcrect = &full_src;
}
if ( dstrect ) {
if ( (dstrect->x < 0) || (dstrect->y < 0) ||
((dstrect->x+dstrect->w) > dst->w) ||
((dstrect->y+dstrect->h) > dst->h) ) {
SDL_SetError("Invalid destination blit rectangle");
return(-1);
}
} else {
full_dst.x = 0;
full_dst.y = 0;
full_dst.w = dst->w;
full_dst.h = dst->h;
dstrect = &full_dst;
}
/* Set up the data... */
pos = 0x10000;
inc = (srcrect->h << 16) / dstrect->h;
src_row = srcrect->y;
dst_row = dstrect->y;
dst_width = dstrect->w*bpp;
#ifdef USE_ASM_STRETCH
/* Write the opcodes for this stretch */
if ( (bpp != 3) &&
(generate_rowbytes(srcrect->w, dstrect->w, bpp) < 0) ) {
return(-1);
}
#endif
/* Perform the stretch blit */
for ( dst_maxrow = dst_row+dstrect->h; dst_row<dst_maxrow; ++dst_row ) {
dstp = (Uint8 *)dst->pixels + (dst_row*dst->pitch)
+ (dstrect->x*bpp);
while ( pos >= 0x10000L ) {
srcp = (Uint8 *)src->pixels + (src_row*src->pitch)
+ (srcrect->x*bpp);
++src_row;
pos -= 0x10000L;
}
#ifdef USE_ASM_STRETCH
switch (bpp) {
case 3:
copy_row3(srcp, srcrect->w, dstp, dstrect->w);
break;
default:
#ifdef __GNUC__
__asm__ __volatile__ ("call _copy_row"
: "=&D" (u1), "=&S" (u2)
: "0" (dstp), "1" (srcp)
: "memory" );
#else
#ifdef WIN32
{ void *code = &copy_row;
__asm {
push edi
push esi
mov edi, dstp
mov esi, srcp
call dword ptr code
pop esi
pop edi
}
}
#else
#error Need inline assembly for this compiler
#endif
#endif /* __GNUC__ */
break;
}
#else
switch (bpp) {
case 1:
copy_row1(srcp, srcrect->w, dstp, dstrect->w);
break;
case 2:
copy_row2((Uint16 *)srcp, srcrect->w,
(Uint16 *)dstp, dstrect->w);
break;
case 3:
copy_row3(srcp, srcrect->w, dstp, dstrect->w);
break;
case 4:
copy_row4((Uint32 *)srcp, srcrect->w,
(Uint32 *)dstp, dstrect->w);
break;
}
#endif
pos += inc;
}
return(0);
}

View File

@ -1,399 +0,0 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_sysvideo.h,v 1.6 2001/06/19 13:33:53 hercules Exp $";
#endif
#ifndef _SDL_sysvideo_h
#define _SDL_sysvideo_h
#include "SDL_mouse.h"
#define SDL_PROTOTYPES_ONLY
#include "SDL_syswm.h"
#undef SDL_PROTOTYPES_ONLY
/* This file prototypes the video driver implementation.
This is designed to be easily converted to C++ in the future.
*/
/* OpenGL is pretty much available on all Windows systems */
#ifdef WIN32
#ifndef _WIN32_WCE
#define HAVE_OPENGL
#endif
#include <windows.h>
#endif
#ifdef HAVE_OPENGL
#ifdef MACOSX
#include <OpenGL/gl.h> /* OpenGL.framework */
#else
#include <GL/gl.h>
#endif /* MACOSX */
#endif /* HAVE_OPENGL */
/* The SDL video driver */
typedef struct SDL_VideoDevice SDL_VideoDevice;
/* Define the SDL video driver structure */
#define _THIS SDL_VideoDevice *_this
#ifndef _STATUS
#define _STATUS SDL_status *status
#endif
struct SDL_VideoDevice {
/* * * */
/* The name of this video driver */
const char *name;
/* * * */
/* Initialization/Query functions */
/* Initialize the native video subsystem, filling 'vformat' with the
"best" display pixel format, returning 0 or -1 if there's an error.
*/
int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
/* List the available video modes for the given pixel format, sorted
from largest to smallest.
*/
SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags);
/* Set the requested video mode, returning a surface which will be
set to the SDL_VideoSurface. The width and height will already
be verified by ListModes(), and the video subsystem is free to
set the mode to a supported bit depth different from the one
specified -- the desired bpp will be emulated with a shadow
surface if necessary. If a new mode is returned, this function
should take care of cleaning up the current mode.
*/
SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current,
int width, int height, int bpp, Uint32 flags);
/* Toggle the fullscreen mode */
int (*ToggleFullScreen)(_THIS, int on);
/* This is called after the video mode has been set, to get the
initial mouse state. It should queue events as necessary to
properly represent the current mouse focus and position.
*/
void (*UpdateMouse)(_THIS);
/* Create a YUV video surface (possibly overlay) of the given
format. The hardware should be able to perform at least 2x
scaling on display.
*/
SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height,
Uint32 format, SDL_Surface *display);
/* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
of the physical palette to those in 'colors'. If the device is
using a software palette (SDL_HWPALETTE not set), then the
changes are reflected in the logical palette of the screen
as well.
The return value is 1 if all entries could be set properly
or 0 otherwise.
*/
int (*SetColors)(_THIS, int firstcolor, int ncolors,
SDL_Color *colors);
/* This pointer should exist in the native video subsystem and should
point to an appropriate update function for the current video mode
*/
void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects);
/* Reverse the effects VideoInit() -- called if VideoInit() fails
or if the application is shutting down the video subsystem.
*/
void (*VideoQuit)(_THIS);
/* * * */
/* Hardware acceleration functions */
/* Information about the video hardware */
SDL_VideoInfo info;
/* Allocates a surface in video memory */
int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
/* Sets the hardware accelerated blit function, if any, based
on the current flags of the surface (colorkey, alpha, etc.)
*/
int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst);
/* Fills a surface rectangle with the given color */
int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
/* Sets video mem colorkey and accelerated blit function */
int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key);
/* Sets per surface hardware alpha value */
int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value);
/* Returns a readable/writable surface */
int (*LockHWSurface)(_THIS, SDL_Surface *surface);
void (*UnlockHWSurface)(_THIS, SDL_Surface *surface);
/* Performs hardware flipping */
int (*FlipHWSurface)(_THIS, SDL_Surface *surface);
/* Frees a previously allocated video surface */
void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
/* * * */
/* Gamma support */
Uint16 *gamma;
/* Set the gamma correction directly (emulated with gamma ramps) */
int (*SetGamma)(_THIS, float red, float green, float blue);
/* Get the gamma correction directly (emulated with gamma ramps) */
int (*GetGamma)(_THIS, float *red, float *green, float *blue);
/* Set the gamma ramp */
int (*SetGammaRamp)(_THIS, Uint16 *ramp);
/* Get the gamma ramp */
int (*GetGammaRamp)(_THIS, Uint16 *ramp);
/* * * */
/* OpenGL support */
/* Sets the dll to use for OpenGL and loads it */
int (*GL_LoadLibrary)(_THIS, const char *path);
/* Retrieves the address of a function in the gl library */
void* (*GL_GetProcAddress)(_THIS, const char *proc);
/* Get attribute information from the windowing system. */
int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value);
/* Make the context associated with this driver current */
int (*GL_MakeCurrent)(_THIS);
/* Swap the current buffers in double buffer mode. */
void (*GL_SwapBuffers)(_THIS);
/* OpenGL functions for SDL_OPENGLBLIT */
#ifdef HAVE_OPENGL
#ifndef WIN32
#define WINAPI
#endif
#define SDL_PROC(ret,func,params) ret (WINAPI *func) params;
#include "SDL_glfuncs.h"
#undef SDL_PROC
/* Texture id */
GLuint texture;
#endif
int is_32bit;
/* * * */
/* Window manager functions */
/* Set the title and icon text */
void (*SetCaption)(_THIS, const char *title, const char *icon);
/* Set the window icon image */
void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask);
/* Iconify the window.
This function returns 1 if there is a window manager and the
window was actually iconified, it returns 0 otherwise.
*/
int (*IconifyWindow)(_THIS);
/* Grab or ungrab keyboard and mouse input */
SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode);
/* Get some platform dependent window information */
int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info);
/* * * */
/* Cursor manager functions */
/* Free a window manager cursor
This function can be NULL if CreateWMCursor is also NULL.
*/
void (*FreeWMCursor)(_THIS, WMcursor *cursor);
/* If not NULL, create a black/white window manager cursor */
WMcursor *(*CreateWMCursor)(_THIS,
Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
/* Show the specified cursor, or hide if cursor is NULL */
int (*ShowWMCursor)(_THIS, WMcursor *cursor);
/* Warp the window manager cursor to (x,y)
If NULL, a mouse motion event is posted internally.
*/
void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y);
/* If not NULL, this is called when a mouse motion event occurs */
void (*MoveWMCursor)(_THIS, int x, int y);
/* Determine whether the mouse should be in relative mode or not.
This function is called when the input grab state or cursor
visibility state changes.
If the cursor is not visible, and the input is grabbed, the
driver can place the mouse in relative mode, which may result
in higher accuracy sampling of the pointer motion.
*/
void (*CheckMouseMode)(_THIS);
/* * * */
/* Event manager functions */
/* Initialize keyboard mapping for this driver */
void (*InitOSKeymap)(_THIS);
/* Handle any queued OS events */
void (*PumpEvents)(_THIS);
/* * * */
/* Data common to all drivers */
SDL_Surface *screen;
SDL_Surface *shadow;
SDL_Surface *visible;
SDL_Palette *physpal; /* physical palette, if != logical palette */
SDL_Color *gammacols; /* gamma-corrected colours, or NULL */
char *wm_title;
char *wm_icon;
int offset_x;
int offset_y;
SDL_GrabMode input_grab;
/* Driver information flags */
int handles_any_size; /* Driver handles any size video mode */
/* * * */
/* Data used by the GL drivers */
struct {
int red_size;
int green_size;
int blue_size;
int alpha_size;
int depth_size;
int buffer_size;
int stencil_size;
int double_buffer;
int accum_red_size;
int accum_green_size;
int accum_blue_size;
int accum_alpha_size;
int driver_loaded;
char driver_path[256];
void* dll_handle;
} gl_config;
/* * * */
/* Data private to this driver */
struct SDL_PrivateVideoData *hidden;
struct SDL_PrivateGLData *gl_data;
/* * * */
/* The function used to dispose of this structure */
void (*free)(_THIS);
};
#undef _THIS
typedef struct VideoBootStrap {
const char *name;
const char *desc;
int (*available)(void);
SDL_VideoDevice *(*create)(int devindex);
} VideoBootStrap;
#ifdef ENABLE_X11
extern VideoBootStrap X11_bootstrap;
#endif
#ifdef ENABLE_DGA
extern VideoBootStrap DGA_bootstrap;
#endif
#ifdef ENABLE_NANOX
extern VideoBootStrap NX_bootstrap;
#endif
#ifdef ENABLE_FBCON
extern VideoBootStrap FBCON_bootstrap;
#endif
#ifdef ENABLE_PS2GS
extern VideoBootStrap PS2GS_bootstrap;
#endif
#ifdef ENABLE_GGI
extern VideoBootStrap GGI_bootstrap;
#endif
#ifdef ENABLE_VGL
extern VideoBootStrap VGL_bootstrap;
#endif
#ifdef ENABLE_SVGALIB
extern VideoBootStrap SVGALIB_bootstrap;
#endif
#ifdef ENABLE_AALIB
extern VideoBootStrap AALIB_bootstrap;
#endif
#ifdef ENABLE_WINDIB
extern VideoBootStrap WINDIB_bootstrap;
#endif
#ifdef ENABLE_DIRECTX
extern VideoBootStrap DIRECTX_bootstrap;
#endif
#ifdef ENABLE_BWINDOW
extern VideoBootStrap BWINDOW_bootstrap;
#endif
#ifdef ENABLE_DUMMYVIDEO
extern VideoBootStrap DUMMY_bootstrap;
#endif
#ifdef ENABLE_PHOTON
extern VideoBootStrap ph_bootstrap;
#endif
/* MacOS X gets the proper defines from configure */
#if defined(macintosh) && !defined(MACOSX)
#define ENABLE_TOOLBOX
#if !TARGET_API_MAC_CARBON
#define ENABLE_DRAWSPROCKET
#endif
#endif
#ifdef ENABLE_TOOLBOX
extern VideoBootStrap TOOLBOX_bootstrap;
#endif
#ifdef ENABLE_DRAWSPROCKET
extern VideoBootStrap DSp_bootstrap;
#endif
#ifdef ENABLE_QUARTZ
extern VideoBootStrap QZ_bootstrap;
#endif
#ifdef ENABLE_CYBERGRAPHICS
extern VideoBootStrap CGX_bootstrap;
#endif
#ifdef ENABLE_MENUETOS
extern VideoBootStrap mosvideo_bootstrab;
#endif
/* This is the current video device */
extern SDL_VideoDevice *current_video;
#define SDL_VideoSurface (current_video->screen)
#define SDL_ShadowSurface (current_video->shadow)
#define SDL_PublicSurface (current_video->visible)
#endif /* _SDL_sysvideo_h */