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.3 by root, Fri Apr 27 21:27:51 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines