Quad Pang
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Functions
Texture.cpp File Reference
#include "Texture.h"
#include "string.h"
#include "util.h"
#include "Internal.h"

Go to the source code of this file.

Functions

static int LoadImage (const char *fileName, GLubyte *dest, size_t imageWidth, size_t imageHeight, int bits=3)

Function Documentation

static int LoadImage ( const char *  fileName,
GLubyte *  dest,
size_t  imageWidth,
size_t  imageHeight,
int  bits = 3 
) [static]

Definition at line 61 of file Texture.cpp.

References APP_NAME, mfopen(), and MIN.

{
    size_t elements_to_read = imageHeight * imageWidth;
    size_t readed_full = 0;
    size_t readed = 0;
    FILE* fp = 0;
    if (0 == (fp = mfopen(fileName, APP_NAME, "rb") ) )
    {
        fprintf(stderr, "Could not open file %s\n", fileName);
        return -1;
    }

   // GLubyte buf[4];
    while (readed = fread(dest + readed_full *bits, bits, MIN(elements_to_read, BUFSIZ /bits), fp) )
   // while (readed = fread(buf, bits, 1, fp ) )
    {
//  memcpy(dest + readed_full * 3, buf-bits+3, 3);
        readed_full += readed;
        elements_to_read -= readed;
    }

    fclose(fp);
    return 0;
}