DRAFT |
SDL_RWread
Use this function (macro) to *call the function pointed to by an SDL_RWops structure's read member.* green
Syntax
SDL_RWread(ctx, ptr, size, n)
green
(ctx)->read(ctx, ptr, size, n)
Function Parameters
ctx |
*a pointer to an SDL_RWops structure* |
ptr |
*a pointer to an area of memory to read data into* |
size |
*the size of each block of memory to read* |
n |
*the maximum number of memory blocks to read (it may read less)* |
Return Value
*Returns the number of memory blocks read, or -1 if the read failed*; call SDL_GetError() for more information.
Code Examples
*
#include <stdio.h>
#include "SDL_rwops.h"
int main()
{
int blocks;
char buf[256];
SDL_RWops *rw=SDL_RWFromFile("file.bin","rb");
if(rw==NULL)
{
fprintf(stderr,"Couldn't open file.bin\n");
return(1);
}
blocks=SDL_RWread(rw,buf,16,256/16);
SDL_RWclose(rw);
if(blocks<0)
{
fprintf(stderr,"Couldn't read from file.bin\n");
return(2);
}
fprintf(stderr,"Read %d 16-byte blocks\n",blocks);
return(0);
}
*
Remarks
*Note: This is not a built in function. This is a C macro that calls whatever function happens to be in the 'read' member of the SDL_RWops structure.
Bug: until SDL 1.2.9 this function returned inconsistent values, that depend on type of underlying stream. This bug is now solved.*
Related Functions
SDL_RWclose (Macro) *???
SDL_RWFromFile *???
SDL_RWseek(Macro) *???
SDL_RWwrite (Macro) *???
green
