[CHG] GRRLIB_CreateEmptyTexture is not inline anymore

This commit is contained in:
Crayon2000 2013-01-08 04:49:45 +00:00
parent 49ba2d5ebf
commit 9d5a12a1f2
4 changed files with 28 additions and 27 deletions

View file

@ -109,6 +109,30 @@ void RawTo4x4RGBA (const u8 *src, void *dst,
} }
} }
/**
* Create an empty texture.
* @param w Width of the new texture to create.
* @param h Height of the new texture to create.
* @return A GRRLIB_texImg structure newly created.
*/
GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const uint w, const uint h)
{
GRRLIB_texImg *my_texture = (struct GRRLIB_texImg *)calloc(1, sizeof(GRRLIB_texImg));
if(my_texture != NULL) {
my_texture->data = memalign(32, h * w * 4);
my_texture->w = w;
my_texture->h = h;
// Initialize the texture
memset(my_texture->data, '\0', (h * w) << 2);
GRRLIB_SetHandle(my_texture, 0, 0);
GRRLIB_FlushTex(my_texture);
}
return my_texture;
}
/** /**
* Load a texture from a buffer. * Load a texture from a buffer.
* @param my_img The JPEG, PNG or Bitmap buffer to load. * @param my_img The JPEG, PNG or Bitmap buffer to load.

View file

@ -112,7 +112,6 @@ INLINE bool GRRLIB_GetAntiAliasing (void);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// GRRLIB_texSetup.h - Create and setup textures // GRRLIB_texSetup.h - Create and setup textures
INLINE GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const uint w, const uint h);
INLINE void GRRLIB_ClearTex (GRRLIB_texImg* tex); INLINE void GRRLIB_ClearTex (GRRLIB_texImg* tex);
INLINE void GRRLIB_FlushTex (GRRLIB_texImg *tex); INLINE void GRRLIB_FlushTex (GRRLIB_texImg *tex);
INLINE void GRRLIB_FreeTexture (GRRLIB_texImg *tex); INLINE void GRRLIB_FreeTexture (GRRLIB_texImg *tex);

View file

@ -133,6 +133,7 @@ void GRRLIB_CompoEnd(int posx, int posy, GRRLIB_texImg *tex);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// GRRLIB_texEdit.c - Modifying the content of a texture // GRRLIB_texEdit.c - Modifying the content of a texture
GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const uint w, const uint h);
GRRLIB_texImg* GRRLIB_LoadTexture (const u8 *my_img); GRRLIB_texImg* GRRLIB_LoadTexture (const u8 *my_img);
GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png); GRRLIB_texImg* GRRLIB_LoadTexturePNG (const u8 *my_png);
GRRLIB_texImg* GRRLIB_LoadTextureJPG (const u8 *my_jpg); GRRLIB_texImg* GRRLIB_LoadTextureJPG (const u8 *my_jpg);

View file

@ -29,31 +29,6 @@ THE SOFTWARE.
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
/**
* Create an empty texture.
* @param w Width of the new texture to create.
* @param h Height of the new texture to create.
* @return A GRRLIB_texImg structure newly created.
*/
INLINE
GRRLIB_texImg* GRRLIB_CreateEmptyTexture (const uint w, const uint h)
{
GRRLIB_texImg *my_texture = (struct GRRLIB_texImg *)calloc(1, sizeof(GRRLIB_texImg));
if(my_texture != NULL) {
my_texture->data = memalign(32, h * w * 4);
my_texture->w = w;
my_texture->h = h;
// Initialize the texture
memset(my_texture->data, '\0', (h * w) << 2);
GRRLIB_SetHandle(my_texture, 0, 0);
GRRLIB_FlushTex(my_texture);
}
return my_texture;
}
/** /**
* Write the contents of a texture in the data cache down to main memory. * Write the contents of a texture in the data cache down to main memory.
* For performance the CPU holds a data cache where modifications are stored before they get written down to main memory. * For performance the CPU holds a data cache where modifications are stored before they get written down to main memory.
@ -71,7 +46,9 @@ void GRRLIB_FlushTex (GRRLIB_texImg *tex) {
INLINE INLINE
void GRRLIB_FreeTexture (GRRLIB_texImg *tex) { void GRRLIB_FreeTexture (GRRLIB_texImg *tex) {
if(tex != NULL) { if(tex != NULL) {
if (tex->data != NULL) free(tex->data); if (tex->data != NULL) {
free(tex->data);
}
free(tex); free(tex);
tex = NULL; tex = NULL;
} }