… | |
… | |
56 | |
56 | |
57 | ++tc_generation; |
57 | ++tc_generation; |
58 | } |
58 | } |
59 | |
59 | |
60 | void |
60 | void |
|
|
61 | tex_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 | |
|
|
69 | void |
|
|
70 | tex_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 | |
|
|
81 | void |
61 | tc_backup (void) |
82 | tc_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 | |
75 | void |
90 | void |
76 | tc_restore (void) |
91 | tc_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 | |
94 | void |
99 | void |
95 | tc_get (tc_area *area, int width, int height) |
100 | tc_get (tc_area *area, int width, int height) |
96 | { |
101 | { |