Added InputStream

This commit is contained in:
Laurent Gomila committed 2011-07-21 20:38:54 +02:00
1 parent 56df80a7d3
commit 6e251c5415
15 files changed
+323 -33

No files matched your search

+11
View File
@@ -31,6 +31,7 @@
#include <SFML/Config.h>
#include <SFML/Audio/SoundStatus.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/InputStream.h>
////////////////////////////////////////////////////////////
@@ -54,6 +55,16 @@ CSFML_API sfMusic* sfMusic_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
CSFML_API sfMusic* sfMusic_CreateFromMemory(const void* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Create a new music and load it from a custom stream
///
/// \param stream : Source stream to read from
///
/// \return A new sfMusic object (NULL if failed)
///
////////////////////////////////////////////////////////////
CSFML_API sfMusic* sfMusic_CreateFromStream(sfInputStream* stream);
////////////////////////////////////////////////////////////
/// Destroy an existing music
///
+18 -31
View File
@@ -105,45 +105,32 @@ typedef int sfBool;
////////////////////////////////////////////////////////////
// Define portable types
// Define portable fixed-size types
////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <limits.h>
// All "common" platforms use the same size for char, short and int
// (basically there are 3 types for 3 sizes, so no other match is possible),
// we can use them without doing any kind of check
// 8 bits integer types
#if UCHAR_MAX == 0xFF
typedef signed char sfInt8;
typedef unsigned char sfUint8;
#else
#error No 8 bits integer type for this platform
#endif
typedef signed char sfInt8;
typedef unsigned char sfUint8;
// 16 bits integer types
#if USHRT_MAX == 0xFFFF
typedef signed short sfInt16;
typedef unsigned short sfUint16;
#elif UINT_MAX == 0xFFFF
typedef signed int sfInt16;
typedef unsigned int sfUint16;
#elif ULONG_MAX == 0xFFFF
typedef signed long sfInt16;
typedef unsigned long sfUint16;
#else
#error No 16 bits integer type for this platform
#endif
typedef signed short sfInt16;
typedef unsigned short sfUint16;
// 32 bits integer types
#if USHRT_MAX == 0xFFFFFFFF
typedef signed short sfInt32;
typedef unsigned short sfUint32;
#elif UINT_MAX == 0xFFFFFFFF
typedef signed int sfInt32;
typedef unsigned int sfUint32;
#elif ULONG_MAX == 0xFFFFFFFF
typedef signed long sfInt32;
typedef unsigned long sfUint32;
typedef signed int sfInt32;
typedef unsigned int sfUint32;
// 64 bits integer types
#if defined(_MSC_VER)
typedef signed __int64 sfInt64;
typedef unsigned __int64 sfUint64;
#else
#error No 32 bits integer type for this platform
typedef signed long long sfInt64;
typedef unsigned long long sfUint64;
#endif
+11
View File
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Glyph.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
////////////////////////////////////////////////////////////
@@ -53,6 +54,16 @@ CSFML_API sfFont* sfFont_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
CSFML_API sfFont* sfFont_CreateFromMemory(const void* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Create a new image font a custom stream
///
/// \param stream : Source stream to read from
///
/// \return A new sfFont object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfFont* sfFont_CreateFromStream(sfInputStream* stream);
////////////////////////////////////////////////////////////
/// Copy an existing font
///
+11
View File
@@ -32,6 +32,7 @@
#include <SFML/Graphics/Color.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
////////////////////////////////////////////////////////////
@@ -79,6 +80,16 @@ CSFML_API sfImage* sfImage_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromMemory(const void* data, size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// Create a new image from a custom stream
///
/// \param stream : Source stream to read from
///
/// \return A new sfImage object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfImage* sfImage_CreateFromStream(sfInputStream* stream);
////////////////////////////////////////////////////////////
/// Copy an existing image
///
+11
View File
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
#include <SFML/Graphics/Types.h>
#include <SFML/System/InputStream.h>
////////////////////////////////////////////////////////////
@@ -52,6 +53,16 @@ CSFML_API sfShader* sfShader_CreateFromFile(const char* filename);
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromMemory(const char* effect);
////////////////////////////////////////////////////////////
/// Create a new shader from a custom stream
///
/// \param stream : Source stream to read from
///
/// \return A new sfShader object, or NULL if it failed
///
////////////////////////////////////////////////////////////
CSFML_API sfShader* sfShader_CreateFromStream(sfInputStream* stream);
////////////////////////////////////////////////////////////
/// Copy an existing shader
///
+1
View File
@@ -31,6 +31,7 @@
#include <SFML/Config.h>
#include <SFML/System/Clock.h>
#include <SFML/System/InputStream.h>
#include <SFML/System/Mutex.h>
#include <SFML/System/Sleep.h>
#include <SFML/System/Thread.h>
+54
View File
@@ -0,0 +1,54 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_INPUTSTREAM_H
#define SFML_INPUTSTREAM_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
typedef sfInt64 (*sfInputStreamReadFunc)(char* data, sfInt64 size, void* userData);
typedef sfInt64 (*sfInputStreamSeekFunc)(sfInt64 position, void* userData);
typedef sfInt64 (*sfInputStreamTellFunc)(void* userData);
typedef sfInt64 (*sfInputStreamGetSizeFunc)(void* userData);
////////////////////////////////////////////////////////////
/// \brief Set of callbacks that allow users to define custom file streams
///
////////////////////////////////////////////////////////////
typedef struct sfInputStream
{
sfInputStreamReadFunc Read; ///< Function to read data from the stream
sfInputStreamSeekFunc Seek; ///< Function to set the current read position
sfInputStreamTellFunc Tell; ///< Function to get the current read position
sfInputStreamGetSizeFunc GetSize; ///< Function to get the total number of bytes in the stream
void* UserData; ///< User data that will be passed to the callbacks
} sfInputStream;
#endif // SFML_INPUTSTREAM_H