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.6 by root, Tue Dec 25 19:08:31 2007 UTC vs.
Revision 1.7 by root, Thu Nov 26 07:19:11 2009 UTC

56 56
57 ++tc_generation; 57 ++tc_generation;
58} 58}
59 59
60void 60void
61tex_backup (tc_texture *tex)
62{
63 tex->saved = g_slice_alloc (TC_WIDTH * TC_HEIGHT);
64
65 glBindTexture (GL_TEXTURE_2D, tex->name);
66 glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tex->saved);
67}
68
69void
70tex_restore (tc_texture *tex)
71{
72 glBindTexture (GL_TEXTURE_2D, tex->name);
73 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
74 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
75 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tex->saved);
76
77 g_slice_free1 (TC_WIDTH * TC_HEIGHT, tex->saved);
78 tex->saved = 0;
79}
80
81void
61tc_backup (void) 82tc_backup (void)
62{ 83{
63 tc_texture *tex = first_texture; 84 tc_texture *tex;
64 while (tex) 85
65 { 86 for (tex = first_texture; tex; tex = tex->next)
66 tex->saved = g_slice_alloc (TC_WIDTH * TC_HEIGHT); 87 tex_backup (tex);
67
68 glBindTexture (GL_TEXTURE_2D, tex->name);
69 glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tex->saved);
70
71 tex = tex->next;
72 }
73} 88}
74 89
75void 90void
76tc_restore (void) 91tc_restore (void)
77{ 92{
78 tc_texture *tex = first_texture; 93 tc_texture *tex;
79 94
80 while (tex) 95 for (tex = first_texture; tex; tex = tex->next)
81 { 96 tex_restore (tex);
82 glBindTexture (GL_TEXTURE_2D, tex->name);
83 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
84 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
85 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tex->saved);
86
87 g_slice_free1 (TC_WIDTH * TC_HEIGHT, tex->saved);
88 tex->saved = 0;
89
90 tex = tex->next;
91 }
92} 97}
93 98
94void 99void
95tc_get (tc_area *area, int width, int height) 100tc_get (tc_area *area, int width, int height)
96{ 101{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines