2004-06-26 00:18:03 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "res.h"
|
2004-10-06 16:00:43 +02:00
|
|
|
#include "ogl.h"
|
2004-09-19 13:36:26 +02:00
|
|
|
#include "tex.h"
|
|
|
|
#include "ogl_tex.h"
|
2004-06-26 00:18:03 +02:00
|
|
|
|
|
|
|
#include "lib.h"
|
|
|
|
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
int tex_filter = GL_LINEAR;
|
|
|
|
uint tex_bpp = 32; // 16 or 32
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// OpenGL helper routines
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static bool fmt_is_s3tc(GLenum fmt)
|
2004-06-26 00:18:03 +02:00
|
|
|
{
|
2005-03-10 18:04:42 +01:00
|
|
|
// specified to be contiguous, but this is safer.
|
|
|
|
switch(fmt)
|
|
|
|
{
|
|
|
|
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
|
|
|
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
|
|
|
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
|
|
|
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-26 00:18:03 +02:00
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
static bool filter_uses_mipmaps(GLint filter)
|
|
|
|
{
|
|
|
|
switch(filter)
|
2004-06-26 00:18:03 +02:00
|
|
|
{
|
2005-03-10 18:04:42 +01:00
|
|
|
case GL_NEAREST_MIPMAP_NEAREST:
|
|
|
|
case GL_LINEAR_MIPMAP_NEAREST:
|
|
|
|
case GL_NEAREST_MIPMAP_LINEAR:
|
|
|
|
case GL_LINEAR_MIPMAP_LINEAR:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// determine OpenGL texture format, given <bpp> and TexInfo <flags>.
|
|
|
|
// also choose an internal format based on the global <tex_bpp>
|
|
|
|
// performance vs. quality setting.
|
|
|
|
//
|
|
|
|
// rationale: we override the user's previous internal format preference.
|
|
|
|
// this is reasonable: 1) internal format is mostly performance optimization
|
|
|
|
// 2) if it does turn out to be significant, better to reevaluate the
|
|
|
|
// format decision after a reload than keep the user's setting.
|
|
|
|
static int get_gl_fmt(int bpp, int flags, GLenum* fmt, GLenum* int_fmt)
|
|
|
|
{
|
|
|
|
const bool alpha = (flags & TEX_ALPHA) != 0;
|
|
|
|
const bool bgr = (flags & TEX_BGR ) != 0;
|
|
|
|
const bool gray = (flags & TEX_GRAY ) != 0;
|
|
|
|
const int dxt = flags & TEX_DXT;
|
|
|
|
|
|
|
|
// in case we fail
|
|
|
|
*fmt = 0;
|
|
|
|
*int_fmt = 0;
|
|
|
|
|
|
|
|
// S3TC
|
|
|
|
if(dxt != 0)
|
|
|
|
{
|
|
|
|
switch(dxt)
|
|
|
|
{
|
|
|
|
case 1:
|
2005-03-10 21:29:27 +01:00
|
|
|
*fmt = alpha? GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
2005-03-10 18:04:42 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
*fmt = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
*fmt = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug_warn("get_gl_fmt: invalid DXT value");
|
|
|
|
return ERR_TEX_FMT_INVALID;
|
|
|
|
}
|
|
|
|
|
|
|
|
// note: S3TC textures don't need an internal format, since they're
|
|
|
|
// uploaded via glCompressedTexImage2DARB. we'll set it anyway for
|
|
|
|
// consistency.
|
|
|
|
*int_fmt = *fmt;
|
2004-06-26 00:18:03 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
|
|
|
|
// true => 8 bits per component; otherwise, 4
|
|
|
|
const bool high_quality = (tex_bpp == 32);
|
|
|
|
|
|
|
|
switch(bpp)
|
2004-06-26 00:18:03 +02:00
|
|
|
{
|
|
|
|
case 8:
|
|
|
|
*fmt = GL_LUMINANCE;
|
2005-03-10 18:04:42 +01:00
|
|
|
*int_fmt = high_quality? GL_LUMINANCE8 : GL_LUMINANCE4;
|
2004-06-26 00:18:03 +02:00
|
|
|
return 0;
|
|
|
|
case 16:
|
|
|
|
*fmt = GL_LUMINANCE_ALPHA;
|
2005-03-10 18:04:42 +01:00
|
|
|
*int_fmt = high_quality? GL_LUMINANCE8_ALPHA8 : GL_LUMINANCE4_ALPHA4;
|
2004-06-26 00:18:03 +02:00
|
|
|
return 0;
|
|
|
|
case 24:
|
2005-03-10 18:04:42 +01:00
|
|
|
assert(!alpha);
|
|
|
|
*fmt = bgr? GL_BGR : GL_RGB;
|
|
|
|
*int_fmt = high_quality? GL_RGB8 : GL_RGB4;
|
|
|
|
// note: BGR can't be used as internal format
|
|
|
|
return 0;
|
2004-12-01 22:37:01 +01:00
|
|
|
case 32:
|
2005-03-10 18:04:42 +01:00
|
|
|
assert(alpha);
|
|
|
|
*fmt = bgr? GL_BGRA : GL_RGBA;
|
|
|
|
*int_fmt = high_quality? GL_RGBA8 : GL_RGBA4;
|
|
|
|
// note: BGR can't be used as internal format
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
debug_warn("get_gl_fmt: invalid bpp");
|
|
|
|
return ERR_TEX_FMT_INVALID;
|
2004-06-26 00:18:03 +02:00
|
|
|
}
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
// unreachable
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// return a token for glTexParameteri that will enable automatic mipmap
|
|
|
|
// generation, or GL_FALSE if the GL implementation doesn't support it.
|
|
|
|
// does not cache the result.
|
|
|
|
//
|
|
|
|
// rationale: we don't assume GL_GENERATE_MIPMAP and GL_GENERATE_MIPMAP_SGIS
|
|
|
|
// have the same values, although this is implied by the spec governing
|
|
|
|
// 'promoted' ARB extensions. checking for both the old extension and
|
|
|
|
// core 1.4 is future-proof.
|
|
|
|
static GLint detect_auto_mipmap_gen()
|
|
|
|
{
|
|
|
|
// OpenGL 1.4 core. we don't assume this is supported by the driver,
|
|
|
|
// since software implementations usually only have 1.1.
|
|
|
|
if(oglHaveVersion("1.4"))
|
|
|
|
return GL_GENERATE_MIPMAP;
|
|
|
|
|
|
|
|
// widespread extension
|
|
|
|
if(oglHaveExtension("GL_SGIS_generate_mipmap"))
|
|
|
|
return GL_GENERATE_MIPMAP_SGIS;
|
|
|
|
|
|
|
|
// neither supported; need to build manually, e.g. with gluBuild2DMipmaps.
|
|
|
|
return GL_FALSE;
|
2004-06-26 00:18:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// texture resource implementation
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2004-06-26 00:18:03 +02:00
|
|
|
struct Tex
|
|
|
|
{
|
|
|
|
TexInfo ti;
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
// allocated by Tex_reload; indicates the texture is currently uploaded.
|
2004-06-26 00:18:03 +02:00
|
|
|
GLuint id;
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
// determined from TexInfo by gl_get_fmt (called from Tex_reload);
|
|
|
|
// user settings passed to tex_upload will override this until the
|
|
|
|
// next actual reload.
|
|
|
|
GLenum fmt;
|
2004-06-26 00:18:03 +02:00
|
|
|
GLenum int_fmt;
|
2004-08-28 19:44:28 +02:00
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
// set to default <tex_filter> by Tex_init; user settings passed to
|
|
|
|
// tex_upload will permanently override this.
|
|
|
|
GLint filter;
|
|
|
|
|
2004-08-28 19:44:28 +02:00
|
|
|
// flags influencing reload behavior
|
|
|
|
bool is_loaded;
|
2005-03-10 18:04:42 +01:00
|
|
|
// either we have the texture in memory (referenced by ti.hm),
|
|
|
|
// or it's already been uploaded to OpenGL => no reload necessary.
|
|
|
|
// needs to be a flag so it can be reset in Tex_dtor.
|
2004-08-28 19:44:28 +02:00
|
|
|
bool has_been_uploaded;
|
2004-06-26 00:18:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
H_TYPE_DEFINE(Tex);
|
|
|
|
|
|
|
|
static void Tex_init(Tex* t, va_list args)
|
|
|
|
{
|
|
|
|
UNUSED(args);
|
2005-03-10 18:04:42 +01:00
|
|
|
|
|
|
|
// set to default (once)
|
|
|
|
t->filter = tex_filter;
|
2004-06-26 00:18:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Tex_dtor(Tex* t)
|
|
|
|
{
|
|
|
|
tex_free(&t->ti);
|
|
|
|
|
|
|
|
glDeleteTextures(1, &t->id);
|
2005-03-10 18:04:42 +01:00
|
|
|
t->id = 0;
|
2004-08-28 19:44:28 +02:00
|
|
|
|
|
|
|
// need to clear this so actual reloads (triggered by h_reload)
|
|
|
|
// actually reload.
|
|
|
|
t->is_loaded = false;
|
2004-06-26 00:18:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int Tex_reload(Tex* t, const char* fn, Handle h)
|
|
|
|
{
|
2004-08-28 19:44:28 +02:00
|
|
|
if(t->is_loaded)
|
2004-06-26 00:18:03 +02:00
|
|
|
return 0;
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
TexInfo* const ti = &t->ti;
|
|
|
|
CHECK_ERR(tex_load(fn, ti));
|
|
|
|
CHECK_ERR(get_gl_fmt(ti->bpp, ti->flags, &t->fmt, &t->int_fmt));
|
|
|
|
// always override previous settings, since format in
|
|
|
|
// texture file may have changed (e.g. 24 -> 32 bpp).
|
|
|
|
|
2004-08-28 19:44:28 +02:00
|
|
|
t->is_loaded = true;
|
2004-06-26 00:18:03 +02:00
|
|
|
|
|
|
|
glGenTextures(1, &t->id);
|
|
|
|
|
2004-08-28 19:44:28 +02:00
|
|
|
// re-upload if necessary
|
|
|
|
if(t->has_been_uploaded)
|
2004-06-26 00:18:03 +02:00
|
|
|
CHECK_ERR(tex_upload(h, t->filter, t->int_fmt));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-10 00:12:02 +01:00
|
|
|
Handle tex_load(const char* fn, int scope)
|
2004-06-26 00:18:03 +02:00
|
|
|
{
|
|
|
|
return h_alloc(H_Tex, fn, scope);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int tex_free(Handle& ht)
|
|
|
|
{
|
|
|
|
return h_free(ht, H_Tex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int tex_bind(const Handle h)
|
|
|
|
{
|
|
|
|
Tex* t = H_USER_DATA(h, Tex);
|
|
|
|
if(!t)
|
|
|
|
{
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
return ERR_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
if(!t->id)
|
|
|
|
{
|
|
|
|
debug_warn("tex_bind: Tex.id is not a valid texture");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, t->id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tex_id(const Handle h)
|
|
|
|
{
|
|
|
|
Tex* t = H_USER_DATA(h, Tex);
|
|
|
|
return t ? t->id : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-12-10 00:12:02 +01:00
|
|
|
static int tex_validate(const uint line, const Tex* t)
|
2004-06-26 00:18:03 +02:00
|
|
|
{
|
|
|
|
const char* msg = 0;
|
|
|
|
int err = -1;
|
|
|
|
|
|
|
|
// pointer to texture data
|
|
|
|
size_t tex_file_size;
|
|
|
|
void* tex_file = mem_get_ptr(t->ti.hm, &tex_file_size);
|
|
|
|
if(!tex_file)
|
|
|
|
msg = "texture file not loaded";
|
|
|
|
// possible causes: texture file header is invalid,
|
|
|
|
// or file wasn't loaded completely.
|
|
|
|
if(t->ti.ofs > tex_file_size)
|
|
|
|
msg = "offset to texture data exceeds file size";
|
|
|
|
|
|
|
|
// width, height
|
|
|
|
GLsizei w = (GLsizei)t->ti.w;
|
|
|
|
GLsizei h = (GLsizei)t->ti.h;
|
|
|
|
// if w or h is 0, texture file probably not loaded successfully.
|
|
|
|
if(w == 0 || h == 0)
|
|
|
|
msg = "width or height is 0 - texture probably not loaded successfully";
|
|
|
|
// greater than max supported tex dimension?
|
|
|
|
// no-op if oglInit not yet called
|
|
|
|
if(w > (GLsizei)max_tex_size || h > (GLsizei)max_tex_size)
|
|
|
|
msg = "texture dimensions exceed OpenGL implementation limit";
|
|
|
|
// both NV_texture_rectangle and subtexture require work for the client
|
|
|
|
// (changing tex coords) => we'll just disallow non-power of 2 textures.
|
|
|
|
// TODO: ARB_texture_non_power_of_two
|
|
|
|
if(!is_pow2(w) || !is_pow2(h))
|
|
|
|
msg = "width or height is not a power-of-2";
|
|
|
|
|
|
|
|
// texel format
|
|
|
|
GLenum fmt = (GLenum)t->fmt;
|
|
|
|
if(!fmt)
|
|
|
|
msg = "texel format is 0";
|
|
|
|
// can't really check against a list of valid formats - loaders
|
|
|
|
// may define their own. not necessary anyway - if non-0, assume
|
|
|
|
// loader knows what it's doing, and that the format is valid.
|
|
|
|
|
|
|
|
// bits per pixel
|
|
|
|
u32 bpp = t->ti.bpp;
|
|
|
|
// half-hearted sanity check: must be divisible by 4.
|
|
|
|
// don't bother checking all values.
|
|
|
|
if(bpp % 4 || bpp > 32)
|
|
|
|
msg = "invalid bpp? should be one of {4,8,16,24,32}";
|
|
|
|
|
|
|
|
// upload parameters, set by tex_upload(Handle), or 0
|
|
|
|
GLint filter = t->filter;
|
|
|
|
GLenum int_fmt = t->int_fmt;
|
|
|
|
// TODO: check if valid
|
|
|
|
|
|
|
|
if(msg)
|
|
|
|
{
|
2004-10-21 17:08:10 +02:00
|
|
|
debug_out("tex_validate at line %d failed: %s (error code %d)\n", line, msg, err);
|
2004-06-26 00:18:03 +02:00
|
|
|
debug_warn("tex_validate failed");
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CHECK_TEX(t) CHECK_ERR(tex_validate(__LINE__, t))
|
|
|
|
|
|
|
|
|
|
|
|
int tex_upload(const Handle ht, int filter_ovr, int int_fmt_ovr, int fmt_ovr)
|
|
|
|
{
|
|
|
|
H_DEREF(ht, Tex, t);
|
2005-03-10 18:04:42 +01:00
|
|
|
|
2004-06-26 00:18:03 +02:00
|
|
|
// someone's requesting upload, but has already been uploaded.
|
|
|
|
// this happens if a cached texture is "loaded". no work to do.
|
|
|
|
if(t->id && t->ti.hm <= 0)
|
|
|
|
return 0;
|
2005-03-10 18:04:42 +01:00
|
|
|
|
|
|
|
CHECK_TEX(t); // must come after check above to avoid false alarms
|
2004-06-26 00:18:03 +02:00
|
|
|
|
|
|
|
const char* fn = h_filename(ht);
|
|
|
|
if(!fn)
|
|
|
|
{
|
|
|
|
fn = "(could not determine filename)";
|
|
|
|
debug_warn("tex_upload(Handle): h_filename failed");
|
|
|
|
}
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
// allow user override of format/settings
|
|
|
|
if(filter_ovr) t->filter = filter_ovr;
|
|
|
|
if(int_fmt_ovr) t->int_fmt = int_fmt_ovr;
|
|
|
|
if(fmt_ovr) t->fmt = fmt_ovr;
|
|
|
|
|
|
|
|
// convenient local copies. note: have been validated by CHECK_TEX.
|
|
|
|
GLsizei w = (GLsizei)t->ti.w;
|
|
|
|
GLsizei h = (GLsizei)t->ti.h;
|
|
|
|
u32 bpp = t->ti.bpp; // used for S3TC size calc
|
|
|
|
GLenum fmt = t->fmt;
|
|
|
|
GLint filter = t->filter;
|
|
|
|
GLenum int_fmt = t->int_fmt;
|
2004-06-26 00:18:03 +02:00
|
|
|
void* tex_data = (char*)mem_get_ptr(t->ti.hm) + t->ti.ofs;
|
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
// does filter call for uploading mipmaps?
|
|
|
|
const bool need_mipmaps = filter_uses_mipmaps(filter);
|
|
|
|
static GLint auto_mipmap_gen;
|
|
|
|
ONCE(auto_mipmap_gen = detect_auto_mipmap_gen());
|
|
|
|
|
2004-06-26 00:18:03 +02:00
|
|
|
|
|
|
|
CHECK_ERR(tex_bind(ht));
|
|
|
|
// we know ht is valid (H_DEREF above), but tex_bind can
|
|
|
|
// fail in debug builds if Tex.id isn't a valid texture name
|
|
|
|
|
|
|
|
// set upload params
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
2005-03-10 18:04:42 +01:00
|
|
|
const GLint mag_filter = (filter == GL_NEAREST)? GL_NEAREST : GL_LINEAR;
|
|
|
|
// magnify can only be linear or nearest
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
|
2004-06-26 00:18:03 +02:00
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
if(need_mipmaps)
|
2004-06-26 00:18:03 +02:00
|
|
|
{
|
2005-03-10 18:04:42 +01:00
|
|
|
if(auto_mipmap_gen != GL_FALSE)
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, auto_mipmap_gen, GL_TRUE);
|
|
|
|
// note: also works on S3TC-compressed textures
|
|
|
|
}
|
2004-06-26 00:18:03 +02:00
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
if(fmt_is_s3tc(fmt))
|
|
|
|
{
|
|
|
|
// auto generation not supported and gluBuild2DMipmaps doesn't
|
|
|
|
// work for precompressed textures => no easy way to generate
|
|
|
|
// mipmaps. revert to a filter that doesn't require them.
|
|
|
|
if(auto_mipmap_gen == GL_FALSE)
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
2004-10-23 16:39:28 +02:00
|
|
|
|
2005-03-10 18:04:42 +01:00
|
|
|
const GLsizei tex_size = w * h * bpp / 8;
|
2004-06-26 00:18:03 +02:00
|
|
|
glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, fmt, w, h, 0, tex_size, tex_data);
|
|
|
|
}
|
2005-03-10 18:04:42 +01:00
|
|
|
// uncompressed texture
|
2004-06-26 00:18:03 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// manual mipmap gen via GLU (box filter)
|
2005-03-10 18:04:42 +01:00
|
|
|
if(need_mipmaps && !auto_mipmap_gen)
|
2004-06-26 00:18:03 +02:00
|
|
|
gluBuild2DMipmaps(GL_TEXTURE_2D, int_fmt, w, h, fmt, GL_UNSIGNED_BYTE, tex_data);
|
|
|
|
// auto mipmap gen, or no mipmap
|
|
|
|
else
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, int_fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, tex_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
mem_free_h(t->ti.hm);
|
|
|
|
|
2004-08-28 19:44:28 +02:00
|
|
|
t->has_been_uploaded = true;
|
|
|
|
|
2004-06-26 00:18:03 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int tex_info(Handle ht, int* w, int* h, int* fmt, int* bpp, void** p)
|
|
|
|
{
|
|
|
|
H_DEREF(ht, Tex, t);
|
|
|
|
|
|
|
|
if(w)
|
|
|
|
*w = t->ti.w;
|
|
|
|
if(h)
|
|
|
|
*h = t->ti.h;
|
|
|
|
if(fmt)
|
|
|
|
*fmt = t->fmt;
|
|
|
|
if(bpp)
|
|
|
|
*bpp = t->ti.bpp;
|
|
|
|
if(p)
|
|
|
|
*p = mem_get_ptr(t->ti.hm);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|