Lines Matching refs:tex
12 GGLTexture * tex = (GGLTexture *)calloc(1, sizeof(GGLTexture));
13 tex->minFilter = GGLTexture::GGL_LINEAR; // should be NEAREST_ MIPMAP_LINEAR
14 tex->magFilter = GGLTexture::GGL_LINEAR;
15 return tex;
20 tex.textures = std::map<GLuint, GGLTexture *>(); // the entire struct has been zeroed in constructor
21 tex.tex2D = AllocTexture();
22 tex.textures[GL_TEXTURE_2D] = tex.tex2D;
23 tex.texCube = AllocTexture();
24 tex.textures[GL_TEXTURE_CUBE_MAP] = tex.texCube;
26 tex.tmus[i] = NULL;
27 tex.sampler2tmu[i] = NULL;
30 tex.active = 0;
32 tex.free = max(GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP) + 1;
34 tex.tex2D->format = GGL_PIXEL_FORMAT_RGBA_8888;
35 tex.tex2D->type = GL_TEXTURE_2D;
36 tex.tex2D->levelCount = 1;
37 tex.tex2D->wrapS = tex.tex2D->wrapT = GGLTexture::GGL_REPEAT;
38 tex.tex2D->minFilter = tex.tex2D->magFilter = GGLTexture::GGL_NEAREST;
39 tex.tex2D->width = tex.tex2D->height = 1;
40 tex.tex2D->levels = malloc(4);
41 *(unsigned *)tex.tex2D->levels = 0xff000000;
44 tex.texCube->format = GGL_PIXEL_FORMAT_RGBA_8888;
45 tex.texCube->type = GL_TEXTURE_CUBE_MAP;
46 tex.texCube->levelCount = 1;
47 tex.texCube->wrapS = tex.texCube->wrapT = GGLTexture::GGL_REPEAT;
48 tex.texCube->minFilter = tex.texCube->magFilter = GGLTexture::GGL_NEAREST;
49 tex.texCube->width = tex.texCube->height = 1;
50 tex.texCube->levels = malloc(4 * 6);
54 memcpy(tex.texCube->levels, texels, sizeof texels);
66 tex.unpack = 4;
78 for (std::map<GLuint, GGLTexture *>::iterator it = tex.textures.begin(); it != tex.textures.end(); it++) {
140 assert(NELEM(ctx->tex.tmus) > index);
142 ctx->tex.active = index;
148 // LOGD("agl2: glBindTexture target=0x%.4X texture=%u active=%u", target, texture, ctx->tex.active);
149 std::map<GLuint, GGLTexture *>::iterator it = ctx->tex.textures.find(texture);
150 GGLTexture * tex = NULL;
151 if (it != ctx->tex.textures.end()) {
152 tex = it->second;
153 if (!tex) {
154 tex = AllocTexture();
155 tex->type = target;
156 it->second = tex;
161 assert(target == tex->type);
165 tex = ctx->tex.tex2D;
170 tex = ctx->tex.texCube;
176 if (texture <= ctx->tex.free)
177 ctx->tex.free = texture + 1;
178 tex = AllocTexture();
179 tex->type = target;
180 ctx->tex.textures[texture] = tex;
183 ctx->tex.tmus[ctx->tex.active] = tex;
184 // LOGD("agl2: glBindTexture format=0x%.2X w=%u h=%u levels=%p", tex->format,
185 // tex->width, tex->height, tex->levels);
186 ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active);
215 assert(ctx->tex.tmus[ctx->tex.active]);
218 GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active];
219 tex.width = width;
220 tex.height = height;
221 tex.levelCount = 1;
222 tex.format = texFormat;
225 tex.levels = realloc(tex.levels, totalSize);
226 CopyTexture((char *)tex.levels, (const char *)ctx->rasterizer.frameSurface.data, bytesPerPixel,
233 ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active);
248 assert(ctx->tex.tmus[ctx->tex.active]);
249 GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active];
251 assert(tex.format == ctx->rasterizer.frameSurface.format);
252 assert(GGL_PIXEL_FORMAT_RGBA_8888 == tex.format);
261 assert(xoffset + width <= tex.width);
262 assert(yoffset + height <= tex.height);
266 CopyTexture((char *)tex.levels, (const char *)ctx->rasterizer.frameSurface.data, bytesPerPixel,
267 x, y, srcWidth, xoffset, yoffset, tex.width, width, height);
273 ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active);
280 std::map<GLuint, GGLTexture *>::iterator it = ctx->tex.textures.find(textures[i]);
281 if (it == ctx->tex.textures.end())
283 ctx->tex.free = min(ctx->tex.free, textures[i]);
285 if (ctx->tex.tmus[i] == it->second) {
287 ctx->tex.tmus[i] = ctx->tex.tex2D;
289 ctx->tex.tmus[i] = ctx->tex.texCube;
292 ctx->tex.UpdateSampler(ctx->iface, i);
298 ctx->tex.textures.erase(it);
307 for (ctx->tex.free; ctx->tex.free < 0xffffffffu; ctx->tex.free++)
308 if (ctx->tex.textures.find(ctx->tex.free) == ctx->tex.textures.end()) {
309 ctx->tex.textures[ctx->tex.free] = NULL;
310 textures[i] = ctx->tex.free;
311 ctx->tex.free++;
330 if (ctx->tex.textures.find(texture) == ctx->tex.textures.end())
342 ctx->tex.unpack = param;
356 assert(4 == ctx->tex.unpack);
372 // LOGD("texFormat=0x%.2X bytesPerPixel=%d active=%u", texFormat, bytesPerPixel, ctx->tex.active);
375 assert(ctx->tex.tmus[ctx->tex.active]);
377 GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active];
378 tex.width = width;
379 tex.height = height;
380 tex.levelCount = 1;
381 tex.format = texFormat;
385 assert(GL_TEXTURE_2D == ctx->tex.tmus[ctx->tex.active]->type);
395 assert(GL_TEXTURE_CUBE_MAP == ctx->tex.tmus[ctx->tex.active]->type);
405 tex.levels = realloc(tex.levels, totalSize);
407 CopyTexture((char *)tex.levels, (const char *)pixels, bytesPerPixel, 0, 0, width, 0, 0, width, width, height);
408 ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active);
425 assert(ctx->tex.tmus[ctx->tex.active]);
426 assert(target == ctx->tex.tmus[ctx->tex.active]->type);
427 GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active];
447 tex.wrapS = wrap;
449 tex.wrapT = wrap;
454 tex.minFilter = GGLTexture::GGL_NEAREST;
457 tex.minFilter = GGLTexture::GGL_LINEAR;
460 // tex.minFilter = GGLTexture::GGL_NEAREST_MIPMAP_NEAREST;
463 // tex.minFilter = GGLTexture::GGL_NEAREST_MIPMAP_LINEAR;
466 // tex.minFilter = GGLTexture::GGL_LINEAR_MIPMAP_NEAREST;
469 // tex.minFilter = GGLTexture::GGL_LINEAR_MIPMAP_LINEAR;
479 tex.minFilter = GGLTexture::GGL_NEAREST;
482 tex.minFilter = GGLTexture::GGL_LINEAR;
494 if (tex.magFilter != tex.minFilter)
495 tex.magFilter = tex.minFilter = GGLTexture::GGL_LINEAR;
496 ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active);
508 assert(target == ctx->tex.tmus[ctx->tex.active]->type);
514 assert(4 == ctx->tex.unpack);
519 GGLTexture & tex = *ctx->tex.tmus[ctx->tex.active];
523 assert(texFormat == tex.format);
527 CopyTexture((char *)tex.levels, (const char *)pixels, bytesPerPixel, 0, 0, width, xoffset,
528 yoffset, tex.width, width, height);
533 ctx->tex.UpdateSampler(ctx->iface, ctx->tex.active);