27 GLushort
s7[128][128];
28 GLushort
s8[256][256];
46 if (! t) {
return 0; }
55 #define FILL(next,from) do{ \
56 for (int i = 0; i < (1 << next); ++i) { \
57 for (int j = 0; j < (1 << next); ++j) { \
58 int k = t->s##from[i >> 1][j >> 1]; \
59 int n = t->s1[i & 1][j & 1]; \
60 t->s##next[i][j] = k + n * (1 << (from << 1)); \
73 #define INVERT(next) do{ \
74 for (int i = 0; i < (1 << next); ++i) { \
75 for (int j = 0; j < (1 << next); ++j) { \
76 int k = t->s##next[i][j]; \
78 int jj = k - (ii << next); \
79 t->c##next[ii][jj].i = i; \
80 t->c##next[ii][jj].j = j; \
95 glGenTextures(1, &t->
s_tex);
97 glBindTexture(GL_TEXTURE_2D, t->
s_tex);
98 #define UPLOAD(n) glTexImage2D(GL_TEXTURE_2D, SLICE_MAX - n, GL_R16UI, 1 << n, 1 << n, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, &t->s##n[0][0])
110 glGenTextures(1, &t->
c_tex);
112 glBindTexture(GL_TEXTURE_2D, t->
c_tex);
113 #define UPLOAD(n) glTexImage2D(GL_TEXTURE_2D, SLICE_MAX - n, GL_RG8UI, 1 << n, 1 << n, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, &t->c##n[0][0].i)
130 glBindTexture(GL_TEXTURE_2D, 0);
132 glBindTexture(GL_TEXTURE_2D, 0);
133 glDeleteTextures(1, &t->
s_tex);
134 glDeleteTextures(1, &t->
c_tex);
143 assert(n < (1 << (slice << 1)));
147 int jj = n - (ii << slice);
149 assert(ii < (1 << slice));
151 assert(jj < (1 << slice));
153 #define CASE(k) case k: *i = t->c##k[ii][jj].i; *j = t->c##k[ii][jj].j; break
164 default: assert(!
"invalid slice");
break;