… | |
… | |
9 | int x, y, w, h; |
9 | int x, y, w, h; |
10 | } tc_area; |
10 | } tc_area; |
11 | |
11 | |
12 | extern int tc_generation; |
12 | extern int tc_generation; |
13 | |
13 | |
14 | void tc_get (tc_area *area, int width, int height); |
14 | static void tc_get (tc_area *area, int width, int height); |
15 | void tc_put (tc_area *area); |
15 | static void tc_put (tc_area *area); |
16 | void tc_clear (); |
16 | static void tc_clear (void); |
|
|
17 | static void tc_backup (void); |
|
|
18 | static void tc_restore (void); |
17 | |
19 | |
18 | ///////////////////////////////////////////////////////////////////////////// |
20 | ///////////////////////////////////////////////////////////////////////////// |
19 | |
21 | |
20 | #include <glib.h> |
22 | #include <glib.h> |
21 | |
23 | |
… | |
… | |
54 | |
56 | |
55 | ++tc_generation; |
57 | ++tc_generation; |
56 | } |
58 | } |
57 | |
59 | |
58 | 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 |
59 | tc_backup (void) |
82 | tc_backup (void) |
60 | { |
83 | { |
61 | tc_texture *tex = first_texture; |
84 | tc_texture *tex; |
62 | while (tex) |
85 | |
63 | { |
86 | for (tex = first_texture; tex; tex = tex->next) |
64 | tex->saved = g_slice_alloc (TC_WIDTH * TC_HEIGHT); |
87 | tex_backup (tex); |
65 | |
|
|
66 | glBindTexture (GL_TEXTURE_2D, tex->name); |
|
|
67 | glGetTexImage (GL_TEXTURE_2D, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tex->saved); |
|
|
68 | |
|
|
69 | tex = tex->next; |
|
|
70 | } |
|
|
71 | } |
88 | } |
72 | |
89 | |
73 | void |
90 | void |
74 | tc_restore (void) |
91 | tc_restore (void) |
75 | { |
92 | { |
76 | tc_texture *tex = first_texture; |
93 | tc_texture *tex; |
77 | |
94 | |
78 | while (tex) |
95 | for (tex = first_texture; tex; tex = tex->next) |
79 | { |
96 | tex_restore (tex); |
80 | glBindTexture (GL_TEXTURE_2D, tex->name); |
|
|
81 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
|
|
82 | glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
|
|
83 | glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, TC_WIDTH, TC_HEIGHT, 0, GL_ALPHA, GL_UNSIGNED_BYTE, tex->saved); |
|
|
84 | |
|
|
85 | g_slice_free1 (TC_WIDTH * TC_HEIGHT, tex->saved); |
|
|
86 | tex->saved = 0; |
|
|
87 | |
|
|
88 | tex = tex->next; |
|
|
89 | } |
|
|
90 | } |
97 | } |
91 | |
98 | |
92 | void |
99 | void |
93 | tc_get (tc_area *area, int width, int height) |
100 | tc_get (tc_area *area, int width, int height) |
94 | { |
101 | { |