ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/texcache.c
(Generate patch)

Comparing deliantra/Deliantra-Client/texcache.c (file contents):
Revision 1.1 by root, Tue Jul 4 23:23:32 2006 UTC vs.
Revision 1.4 by root, Sun Aug 12 08:44:22 2007 UTC

1// all these must be powers of two 1// all these must be powers of two
2// width and height better be <=256 as we use bytes in the rendercache
2#define TC_WIDTH 256 3#define TC_WIDTH 256
3#define TC_HEIGHT 256 4#define TC_HEIGHT 256
4#define TC_ROUND 4 5#define TC_ROUND 4
5 6
6typedef struct { 7typedef struct {
7 GLuint name; 8 GLuint name;
8 int x, y, w, h; 9 int x, y, w, h;
9} tc_area; 10} tc_area;
10 11
12extern int tc_generation;
13
11void tc_get (tc_area *area, int width, int height); 14void tc_get (tc_area *area, int width, int height);
12void tc_put (tc_area *area); 15void tc_put (tc_area *area);
13void tc_clear (); 16void tc_clear ();
14 17
15///////////////////////////////////////////////////////////////////////////// 18/////////////////////////////////////////////////////////////////////////////
16 19
17#include <glib.h> 20#include <glib.h>
21
22int tc_generation;
18 23
19typedef struct tc_texture { 24typedef struct tc_texture {
20 struct tc_texture *next; 25 struct tc_texture *next;
21 GLuint name; 26 GLuint name;
22 int avail; 27 int avail;
39 slices [i].name = 0; 44 slices [i].name = 0;
40 45
41 while (first_texture) 46 while (first_texture)
42 { 47 {
43 tc_texture *next = first_texture->next; 48 tc_texture *next = first_texture->next;
44 glDeleteTextures (1, &first_texture->name); 49 del_texture (first_texture->name);
45 g_slice_free (tc_texture, first_texture); 50 g_slice_free (tc_texture, first_texture);
46 first_texture = next; 51 first_texture = next;
47 } 52 }
53
54 ++tc_generation;
48} 55}
49 56
50void 57void
51tc_get (tc_area *area, int width, int height) 58tc_get (tc_area *area, int width, int height)
52{ 59{
71 if (!match) 78 if (!match)
72 { 79 {
73 match = g_slice_new (tc_texture); 80 match = g_slice_new (tc_texture);
74 match->next = first_texture; 81 match->next = first_texture;
75 first_texture = match; 82 first_texture = match;
76 glGenTextures (1, &match->name); 83 match->name = gen_texture ();
77 match->avail = TC_HEIGHT; 84 match->avail = TC_HEIGHT;
78 85
79 glBindTexture (GL_TEXTURE_2D, match->name); 86 glBindTexture (GL_TEXTURE_2D, match->name);
80 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 87 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
81 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 88 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines