openTRI 0.1
triTexman.h
1/*
2 * triTexman.h: Header for Texture manager
3 * This file is part of the "tri Engine".
4 *
5 * Copyright (C) 2007 tri
6 * Copyright (C) 2007 Alexander Berl 'Raphael' <raphael@fx-world.org>
7 *
8 * $Id: $
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#ifndef __TRITEXMAN_H__
26#define __TRITEXMAN_H__
27
28#include "triTypes.h"
29#include "triImage.h"
30
31
36#define TRI_TEXMAN_PRIORITIES 8
38// Texture manager, keeping textures in VRAM on MFU (most frequently used) base
39
40typedef struct triTexture
41{
42 triS32 id;
43
44 triVoid *vram; // pointer to vram if uploaded
45 triVoid *data; // pointer to sysram copy
46
47 triVoid *paldata;
48 triS32 palformat;
49
50 triS32 size;
51 triS32 format;
52 triS32 width;
53 triS32 height;
54 triS32 bytesperline;
55 triS32 swizzle;
56 triS32 level;
57 triS32 allocated; // texture data was allocated by texture manager (mipmaps only)
58
59 triS32 refcount; // counter for number of allocations
60 triS32 priority; // priority to stay in VRAM
61
62 triS32 mipmaps; // number of mipmaps below this level
63 struct triTexture* next; // mipmap linkage
65
66
67triS32 triTextureGen( triS32 n, triS32 *id );
68triS32 triTexturePrioritize( triS32 n, triS32 *id, triS32 *priorities );
69triS32 triTextureSize( triS32 width, triS32 height, triS32 format );
70triS32 triTextureUpload( triS32 id, triS32 priority ); // force upload and set priority
71triS32 triTextureImage( triS32 id, triS32 level, triS32 width, triS32 height, triS32 format, triS32 swizzled, triVoid* data, triS32 palformat, triVoid* paldata );
72triS32 triTextureImage2( triS32 id, triS32 level, triImage* img );
73triS32 triTextureIslocal( triS32 id );
74triS32 triTextureBind( triS32 id );
75triS32 triTextureRel( triS32 n, triS32 *id );
76triS32 triTextureBuildMipmaps( triS32 id, triS32 levels );
77
78triS32 triTextureLoad( triChar* filename );
79triS32 triTextureLoadSream( stream* s );
80triS32 triTextureUnload( triS32 id );
81triImage* triTextureGet( triS32 id );
84#endif // __TRITEXMAN_H__
Definition streams.h:200
Image struct.
Definition triImage.h:158
Definition triTexman.h:41