zengine/include/ZE_Utility.h

121 lines
3.8 KiB
C
Raw Normal View History

/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
Copyright (C) 2002, 2003 James Turk
Licensed under a BSD-style license.
The maintainer of this library is James Turk (james@conceptofzero.net)
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
/*!
\file ZE_Utility.h
\brief Definition file for ZEngine Utilities.
Definition file for ZEngine Utilities which are used throughout the engine and can be used in
conjunction with ZEngine.
2003-10-13 21:40:05 +00:00
<br>$Id: ZE_Utility.h,v 1.8 2003/10/13 21:40:05 cozman Exp $<br>
2003-05-07 20:34:50 +00:00
\author James Turk
**/
2003-05-07 20:34:50 +00:00
#ifndef __ze_utility_h__
#define __ze_utility_h__
#include "ZE_Includes.h"
namespace ZE
{
/*!
2003-06-11 00:15:07 +00:00
\brief Parses a std::string and interprets variable arguments, similar to sprintf.
Takes % identifiers out of fmtstr and parses them, replacing them with cooresponding values
in the variable arguments list. For more detail view stdarg documentation.
2003-06-11 00:15:07 +00:00
\param fmtstr defines format of resulting std::string
\param ... variable number of arguments after fmtstr
2003-06-11 00:15:07 +00:00
\return std::string of parsed and combined std::string
**/
2003-06-11 00:15:07 +00:00
std::string FormatStr(const char *fmtstr, ...);
2003-10-05 19:42:34 +00:00
/*!
\brief Extracts a SDL_RWops memory structure from a zip archive.
Attempts to open a file from within a zipfile and return a SDL_RWops which can be used
2003-10-13 21:40:05 +00:00
to load a resource from memory.
Used internally, generally shouldn't be called by users.
2003-10-05 19:42:34 +00:00
\param zipname Name of zip-format archive to open.
\param filename Name of file within archive to access.
\return On success, pointer to SDL_RWops, on failure, NULL.
\since 0.8.5
**/
2003-09-24 01:49:52 +00:00
SDL_RWops* RWFromZip(std::string zipname, std::string filename);
2003-10-13 21:40:05 +00:00
/*!
\brief Rounds a number up to the nearest power of two.
Rounds a number up to the next highest power of two, used for OpenGL textures. (From testgl.c)
Used internally, generally shouldn't be called by users.
\param in Number to round up.
\return num rounded up to closest power of two.
\since 0.8.6
**/
int PowerOfTwo(int num);
/*!
\brief Converts an SDL_Surface to an OpenGL texture ID.
Given an SDL_Surface returns a texture ID representing the OpenGL
texture assigned to that surface. Also returns texture coordinates
via texcoord parameter. (From SDL_GL_LoadTexture in testgl.c)
Used internally, generally shouldn't be called by users.
\param surface SDL_Surface to assign an OpenGL ID, returns unmodified.
\param texcoord Should be an array of 4 GLfloat, assigned texture coordinates for OpenGL use.
\return OpenGL texture ID for SDL_Surface, 0 if an error occurs.
\since 0.8.6
**/
GLuint SurfaceToTexture(SDL_Surface *surface, GLfloat *texcoord);
/*!
2003-04-28 02:00:38 +00:00
\brief Properly free SDL_Surface.
Safely free an SDL_Surface* and set it to NULL.
2003-04-28 02:00:38 +00:00
\param image Image to free and set to NULL.
**/
2003-04-28 02:00:38 +00:00
void FreeImage(SDL_Surface *&image);
#ifdef USE_SDL_MIXER
2003-04-28 02:00:38 +00:00
/*!
2003-04-28 02:00:38 +00:00
\brief Properly free Mix_Chunk.
Safely free a Mix_Chunk* and set it to NULL.
2003-04-28 02:00:38 +00:00
\param chunk Chunk to free and set to NULL.
**/
2003-04-28 02:00:38 +00:00
void FreeSound(Mix_Chunk *&chunk);
/*!
2003-04-28 02:00:38 +00:00
\brief Properly free Mix_Music.
Safely free a Mix_Music* and set it to NULL.
2003-04-28 02:00:38 +00:00
\param music Music to free and set to NULL.
**/
2003-04-28 02:00:38 +00:00
void FreeMusic(Mix_Music *&music);
#endif
#ifdef USE_SDL_TTF
/*!
2003-04-28 02:00:38 +00:00
\brief Properly free TTF_Font.
Safely free a TTF_Font* and set it to NULL.
\param font Font to free and set to NULL.
**/
2003-04-28 02:00:38 +00:00
void FreeFont(TTF_Font *&font);
#endif
}
#endif //__ze_utility_h__