enum piglit_result piglit_display(void) { GLuint tex; GLboolean pass = GL_TRUE; glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); tex = create_texture(GL_COMPRESSED_RGB_S3TC_DXT1_EXT); display_mipmaps(10, 10 + (10 + SIZE) * 0); glDeleteTextures(1, &tex); tex = create_texture(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); display_mipmaps(10, 10 + (10 + SIZE) * 1); glDeleteTextures(1, &tex); tex = create_texture(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); display_mipmaps(10, 10 + (10 + SIZE) * 2); glDeleteTextures(1, &tex); tex = create_texture(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); display_mipmaps(10, 10 + (10 + SIZE) * 3); glDeleteTextures(1, &tex); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 0); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 1); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 2); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 3); glutSwapBuffers(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLuint tex; GLboolean pass = GL_TRUE; glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); tex = piglit_rgbw_texture(GL_COMPRESSED_RGB_FXT1_3DFX, SIZE, SIZE, GL_TRUE, GL_FALSE, GL_UNSIGNED_NORMALIZED); display_mipmaps(10, 10 + (10 + SIZE) * 0); glDeleteTextures(1, &tex); tex = piglit_rgbw_texture(GL_COMPRESSED_RGBA_FXT1_3DFX, SIZE, SIZE, GL_TRUE, GL_FALSE, GL_UNSIGNED_NORMALIZED); display_mipmaps(10, 10 + (10 + SIZE) * 1); glDeleteTextures(1, &tex); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 0); pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 1); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { const GLfloat red[4] = {1.0, 0.0, 0.0, 0.0}; const GLfloat blue[4] = {0.0, 0.0, 1.0, 0.0}; GLuint texture; int i; GLboolean pass = GL_TRUE; glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); /* Set up a texture object with mipmap generation */ glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); /* Set the first level of the new texture to red and display. */ fill_level(0, red); display_mipmaps(0, 0); glDeleteTextures(1, &texture); /* Set up texture object without mipmap generation */ glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); /* Paint normal blue mipmap set */ for (i = 0; SIZE / (1 << i) > 0; i++) fill_level(i, blue); display_mipmaps(0, SIZE); /* Enable GENERATE_MIPMAP and set the first (and thus all) levels to * red. */ glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); fill_level(0, red); display_mipmaps(0, SIZE * 2); glDeleteTextures(1, &texture); pass = pass && check_resulting_mipmaps(0, 0, red); pass = pass && check_resulting_mipmaps(0, SIZE, blue); pass = pass && check_resulting_mipmaps(0, SIZE * 2, red); piglit_present_results(); glFlush(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
enum piglit_result piglit_display(void) { GLuint tex, tex_src; bool pass; int level; unsigned bw, bh, bs; piglit_get_compressed_block_size(format->token, &bw, &bh, &bs); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); tex_src = piglit_rgbw_texture(format->token, SIZE, SIZE, true, false, GL_UNSIGNED_NORMALIZED); glCreateTextures(GL_TEXTURE_2D, 1, &tex); for (level = 0; (SIZE >> level) > 0; level++) { int w, h; int expected_size, size; void *compressed; w = SIZE >> level; h = SIZE >> level; expected_size = piglit_compressed_image_size(format->token, w, h); glBindTexture(GL_TEXTURE_2D, tex_src); glGetTexLevelParameteriv(GL_TEXTURE_2D, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size); if (size != expected_size) { fprintf(stderr, "Format %s level %d (%dx%d) size %d " "doesn't match expected size %d\n", piglit_get_gl_enum_name(format->token), level, w, h, size, expected_size); piglit_report_result(PIGLIT_FAIL); } compressed = malloc(size); glGetCompressedTextureImage(tex_src, level, size, compressed); glBindTexture(GL_TEXTURE_2D, tex); glCompressedTexImage2D(GL_TEXTURE_2D, level, format->token, w, h, 0, size, compressed); if (!piglit_check_gl_error(GL_NO_ERROR)) piglit_report_result(PIGLIT_FAIL); free(compressed); } glDeleteTextures(1, &tex_src); glBindTextureUnit(tex, 0); display_mipmaps(10, 10); pass = check_resulting_mipmaps(10, 10); piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }