bool init_fb(const struct grid_info grid) { bool ret = true; if (grid.stages & GL_COMPUTE_SHADER_BIT) { const struct image_info img = image_info_for_grid(grid); const unsigned n = product(grid.size) * image_num_components(grid.format); uint32_t *pixels = malloc(n * sizeof(*pixels)); ret = init_pixels(img, pixels, 0.5, 0.5, 0.5, 0.5) && upload_image(img, max_image_units(), pixels); free(pixels); } else { ret = generate_fb(grid, 0); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); glClearDepth(0.5); glClear(GL_DEPTH_BUFFER_BIT); } return ret; }
static bool init_image(const struct image_info img) { static uint32_t pixels[N][4]; return init_pixels(img, pixels[0], 99, 99, 99, 99) && upload_image(img, 0, pixels[0]); }
static bool init_image(const struct image_info img) { uint32_t pixels[4 * N]; return init_pixels(img, pixels, 1, 0, 0, 0) && upload_image(img, 0, pixels); }
PIGLIT_GL_TEST_CONFIG_END static bool init_image(const struct image_info img, uint32_t v) { uint32_t pixels[N]; return init_pixels(img, pixels, v, 0, 0, 0) && upload_image(img, 0, pixels); }
bool RenderHead( float angle, bool shadow, bool lighting, void *result, int width, int height, void *head, int headWidth, int headHeight, void *helm, int helmWidth, int helmHeight) { OSMesaContext ctx = init_osmesa(width, height, result); if (ctx) { // Initialize OpenGL init_gl(width, height); // Upload helm upload_image(1, head, headWidth, headHeight); if (helm) upload_image(2, helm, helmWidth, helmHeight); if (shadow) setup_shadow(angle); glEnable(GL_TEXTURE_2D); if (lighting) setup_lighting(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1.0f, 1.0f, 1.0f); glBindTexture(GL_TEXTURE_2D, 1); draw(1.0f, 1.0f, 1.0f, angle); if (helm) { glBindTexture(GL_TEXTURE_2D, 2); draw(1.05f, 1.05f, 1.05f, angle); } glFinish(); OSMesaDestroyContext(ctx); return true; } return false; }
static bool init_image(const struct image_info img) { uint32_t pixels[N]; int i; for (i = 0; i < N; ++i) pixels[i] = i / W; return upload_image(img, 0, pixels); }
static bool init_image(const struct image_info img, unsigned unit, bool strict_binding) { uint32_t pixels[4 * N]; bool ret = init_image_pixels(img, unit, pixels) && upload_image(img, unit, pixels); if (strict_binding) glBindImageTexture(unit, get_texture(unit), 0, GL_TRUE, 0, (unit == 1 ? GL_WRITE_ONLY : GL_READ_ONLY), img.format->format); return ret && piglit_check_gl_error(GL_NO_ERROR); }
static bool init_images(const struct image_info img) { uint32_t pixels[N]; int unit, i; for (unit = 0; unit < max_image_units(); ++unit) { for (i = 0; i < N; ++i) pixels[i] = (i == unit ? 1 : 0); if (!upload_image(img, unit, pixels)) return false; } return true; }
PIGLIT_GL_TEST_CONFIG_END static bool init_image(const struct image_info img, unsigned unit) { const unsigned n = image_num_components(img.format) * product(img.size); uint32_t *pixels = malloc(sizeof(uint32_t) * n); bool ret; int i; for (i = 0; i < n; ++i) pixels[i] = (unit == 0 ? encode(img.format, i) : 0); ret = upload_image(img, unit, pixels); free(pixels); return ret; }
PIGLIT_GL_TEST_CONFIG_END static bool init_image(const struct image_info img, bool layered, unsigned l) { uint32_t pixels[4 * N]; unsigned i; bool ret; for (i = 0; i < 4 * N; ++i) pixels[i] = encode(img.format, i); ret = upload_image(img, 0, pixels); glBindImageTexture(0, get_texture(0), 0, layered, l, GL_READ_WRITE, img.format->format); return ret && piglit_check_gl_error(GL_NO_ERROR); }