本文整理汇总了C++中SDL_RWtell函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_RWtell函数的具体用法?C++ SDL_RWtell怎么用?C++ SDL_RWtell使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_RWtell函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flac_length_music_cb
static FLAC__StreamDecoderLengthStatus flac_length_music_cb (
const FLAC__StreamDecoder *decoder,
FLAC__uint64 *stream_length,
void *client_data)
{
FLAC_music *data = (FLAC_music*)client_data;
int pos = SDL_RWtell (data->rwops);
int length = SDL_RWseek (data->rwops, 0, RW_SEEK_END);
if (SDL_RWseek (data->rwops, pos, RW_SEEK_SET) != pos || length < 0) {
/* there was an error attempting to return the stream to the original
* position, or the length was invalid. */
return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR;
}
else {
*stream_length = (FLAC__uint64)length;
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
}
}
示例2: IMG_isGIF
/* See if an image is contained in a data source */
int IMG_isGIF(SDL_RWops *src)
{
Sint64 start;
int is_GIF;
char magic[6];
if ( !src )
return 0;
start = SDL_RWtell(src);
is_GIF = 0;
if ( SDL_RWread(src, magic, sizeof(magic), 1) ) {
if ( (SDL_strncmp(magic, "GIF", 3) == 0) &&
((SDL_memcmp(magic + 3, "87a", 3) == 0) ||
(SDL_memcmp(magic + 3, "89a", 3) == 0)) ) {
is_GIF = 1;
}
}
SDL_RWseek(src, start, RW_SEEK_SET);
return(is_GIF);
}
示例3: SDL_RWtell
MREADER *_mm_new_rwops_reader(SDL_RWops * rw)
{
int here;
MRWOPSREADER* reader=(MRWOPSREADER*)_mm_malloc(sizeof(MRWOPSREADER));
if (reader) {
reader->core.Eof =&_mm_RWopsReader_Eof;
reader->core.Read=&_mm_RWopsReader_Read;
reader->core.Get =&_mm_RWopsReader_Get;
reader->core.Seek=&_mm_RWopsReader_Seek;
reader->core.Tell=&_mm_RWopsReader_Tell;
reader->rw=rw;
/* RWops does not explicitly support an eof check, so we shall find
the end manually - this requires seek support for the RWop */
here = SDL_RWtell(rw);
reader->end = SDL_RWseek(rw, 0, SEEK_END);
SDL_RWseek(rw, here, SEEK_SET); /* Move back */
}
return (MREADER*)reader;
}
示例4: flac_eof_music_cb
static FLAC__bool flac_eof_music_cb(
const FLAC__StreamDecoder *decoder,
void *client_data )
{
FLAC_music *data = (FLAC_music*)client_data;
int pos = SDL_RWtell (data->rwops);
int end = SDL_RWseek (data->rwops, 0, RW_SEEK_END);
// was the original position equal to the end (a.k.a. the seek didn't move)?
if (pos == end) {
// must be EOF
return true;
}
else {
// not EOF, return to the original position
SDL_RWseek (data->rwops, pos, RW_SEEK_SET);
return false;
}
}
示例5: isLBM
static int isLBM()
{
SDL_RWops* src = 0;
int start;
int is_LBM;
Uint8 magic[4+4+4];
start = SDL_RWtell(src);
is_LBM = 0;
if ( SDL_RWread( src, magic, sizeof(magic), 1 ) )
{
if ( !memcmp( magic, "FORM", 4 ) &&
( !memcmp( magic + 8, "PBM ", 4 ) ||
!memcmp( magic + 8, "ILBM", 4 ) ) )
{
is_LBM = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
return( is_LBM );
}
示例6: IMG_isPNG
/* See if an image is contained in a data source */
int IMG_isPNG(SDL_RWops *src)
{
int start;
int is_PNG;
Uint8 magic[4];
if ( !src )
return 0;
start = SDL_RWtell(src);
is_PNG = 0;
if ( SDL_RWread(src, magic, 1, sizeof(magic)) == sizeof(magic) ) {
if ( magic[0] == 0x89 &&
magic[1] == 'P' &&
magic[2] == 'N' &&
magic[3] == 'G' ) {
is_PNG = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
return(is_PNG);
}
示例7: SDL_RWtell
bool Serializer::writeScriptData() {
int64_t fieldsPtr = SDL_RWtell(_rw);
if (fieldsPtr < 0)
return false;
if (!SDL_WriteBE32(_rw, 0)) // 4 placeholder bytes for the actual number of fields
return false;
lua_getglobal(_L, "dgPersistence");
int32_t numFields = writeTable("dgPersistence");
if (numFields < 0)
return false;
if (SDL_RWseek(_rw, fieldsPtr, RW_SEEK_SET) < 0) // Restore file pointer to 4 placeholder bytes
return false;
if (!SDL_WriteBE32(_rw, numFields))
return false;
if (SDL_RWseek(_rw, 0, RW_SEEK_END) < 0) // Restore file pointer to end
return false;
return true;
}
示例8: IMG_isLBM
int IMG_isLBM( SDL_RWops *src )
{
Sint64 start;
int is_LBM;
Uint8 magic[4+4+4];
if ( !src )
return 0;
start = SDL_RWtell(src);
is_LBM = 0;
if ( SDL_RWread( src, magic, sizeof(magic), 1 ) )
{
if ( !SDL_memcmp( magic, "FORM", 4 ) &&
( !SDL_memcmp( magic + 8, "PBM ", 4 ) ||
!SDL_memcmp( magic + 8, "ILBM", 4 ) ) )
{
is_LBM = 1;
}
}
SDL_RWseek(src, start, RW_SEEK_SET);
return( is_LBM );
}
示例9: vw_WriteIntoVFSfromFile
//------------------------------------------------------------------------------------
// запись данных в VFS
//------------------------------------------------------------------------------------
int vw_WriteIntoVFSfromFile(const char *SrcName, const char *DstName)
{
if (SrcName == 0) return -1;
if (DstName == 0) return -1;
// читаем данные файла в буфер
SDL_RWops *Ftmp = SDL_RWFromFile(SrcName, "rb");
// Если файл не найден - выходим
if (Ftmp == NULL)
{
fprintf(stderr, "Can't find file %s !!!\n", SrcName);
return -1;
}
// получаем размер файла
SDL_RWseek(Ftmp, 0, SEEK_END);
int tmpLength = SDL_RWtell(Ftmp);
SDL_RWseek(Ftmp, 0, SEEK_SET);
// копируем все данные файла в массив
BYTE *tmp = 0;
tmp = new BYTE[tmpLength];
SDL_RWread(Ftmp, tmp, tmpLength, 1);
SDL_RWclose(Ftmp);
// запись в VFS
if (0 != vw_WriteIntoVFSfromMemory(DstName, tmp, tmpLength))
{
// какая-то ошибка, не можем записать в VFS
delete [] tmp; tmp = 0;
fprintf(stderr, "Can't write into VFS from memory %s !!!\n", DstName);
return -1;
}
// Освобождаем память
delete [] tmp; tmp = 0;
return 0;
}
示例10: AG_isGIF
/*--------------------------------------------------------------------------*/
int AG_isGIF( SDL_RWops* src )
{
int isGIF = FALSE;
if ( src )
{
int start = SDL_RWtell( src );
char magic[6];
if ( SDL_RWread(src,magic,sizeof(magic),1) )
{
if ( (strncmp(magic,"GIF",3) == 0) && ((memcmp(magic+3,"87a",3) == 0) || (memcmp(magic+3,"89a",3) == 0)) )
{
isGIF = TRUE;
}
}
SDL_RWseek( src, start, SEEK_SET );
}
return isGIF;
}
示例11: ged_SDL_RWFromFile
void Compression::DoCompression(const char *from, SDL_RWops *dst)
{
int lenght, lenghtComp;
SDL_RWops *src = ged_SDL_RWFromFile(from, "rb");
if(!src) return;
SDL_RWseek( src, 0, SEEK_END );
lenght = SDL_RWtell( src );
SDL_RWseek( src, 0, SEEK_SET );
U8 *in = new U8[lenght];
U8 *out = new U8[2*lenght/*lenght + lenght / 8 + 256*/]; //Solved crash when export Alittlecash_player.ged
SDL_RWread(src, in, lenght, 1);
lenghtComp = DoCompression(in, lenght, out, 2*lenght/*lenght + lenght / 8 + 256*/);
if(lenghtComp < lenght)
{
SDL_WriteLE32( dst, lenght );
SDL_WriteLE32( dst, lenghtComp );
SDL_RWwrite(dst, out, lenghtComp, 1);
}
else
{
//No compression
SDL_WriteLE32( dst, lenght );
SDL_WriteLE32( dst, lenght );
SDL_RWwrite(dst, in, lenght, 1);
}
delete [] in;
delete [] out;
SDL_RWclose(src);
}
示例12: malloc
NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *rw)
{
NativeMidiSong *song = NULL;
char *extra;
song = malloc(sizeof(NativeMidiSong));
if (!song) {
return NULL;
};
SDL_RWseek(rw, 0, SEEK_END);
song->file_size = SDL_RWtell(rw);
SDL_RWseek(rw, 0, SEEK_SET);
song->filebuf = malloc(song->file_size);
if (!song->filebuf) {
free(song);
return NULL;
}
SDL_RWread(rw, song->filebuf, song->file_size, 1);
return song;
}
示例13: IMG_isPCX
/* See if an image is contained in a data source */
int IMG_isPCX(SDL_RWops *src)
{
int start;
int is_PCX;
const int ZSoft_Manufacturer = 10;
const int PC_Paintbrush_Version = 5;
const int PCX_RunLength_Encoding = 1;
struct PCXheader pcxh;
if ( !src )
return 0;
start = SDL_RWtell(src);
is_PCX = 0;
if ( SDL_RWread(src, &pcxh, sizeof(pcxh), 1) == 1 ) {
if ( (pcxh.Manufacturer == ZSoft_Manufacturer) &&
(pcxh.Version == PC_Paintbrush_Version) &&
(pcxh.Encoding == PCX_RunLength_Encoding) ) {
is_PCX = 1;
}
}
SDL_RWseek(src, start, SEEK_SET);
return(is_PCX);
}
示例14: init
static MAD_WRAPPER* init( SDL_RWops *src )
{
MAD_WRAPPER *mad = new MAD_WRAPPER;
SDL_RWseek( src, 0, SEEK_END );
mad->length = SDL_RWtell( src );
SDL_RWseek( src, 0, SEEK_SET );
mad->src = src;
mad_stream_init( &mad->Stream );
mad_frame_init( &mad->Frame );
mad_synth_init( &mad->Synth );
mad->volume = 64;
mad->input_buf = new unsigned char[ INPUT_BUFFER_SIZE ];
mad->output_buf = new unsigned char[ 1152*4*5 ]; /* 1152 because that's what mad has as a max; *4 because */
mad->output_buf_index = 0;
mad->is_playing = false;
return mad;
}
示例15: SDL_RWtell
/* Load a XXX type image from an SDL datasource */
SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src)
{
int start;
const char *error = NULL;
SDL_Surface *surface = NULL;
if ( !src ) {
/* The error message has been set in SDL_RWFromFile */
return NULL;
}
start = SDL_RWtell(src);
/* Load the image here */
if ( error ) {
SDL_RWseek(src, start, RW_SEEK_SET);
if ( surface ) {
SDL_FreeSurface(surface);
surface = NULL;
}
IMG_SetError("%s", error);
}
return surface;
}