Exemplo n.º 1
0
static inline bool upload_texture_cube(struct gs_texture_cube *tex,
		const uint8_t **data)
{
	uint32_t row_size   = tex->size * gs_get_format_bpp(tex->base.format);
	uint32_t tex_size   = tex->size * row_size / 8;
	uint32_t num_levels = tex->base.levels;
	bool     compressed = gs_is_compressed_format(tex->base.format);
	GLenum   gl_type    = get_gl_format_type(tex->base.format);
	bool     success    = true;
	uint32_t i;

	if (!num_levels)
		num_levels = gs_get_total_levels(tex->size, tex->size);

	for (i = 0; i < 6; i++) {
		GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;

		if (!gl_bind_texture(target, tex->base.texture))
			success = false;

		if (!gl_init_face(target, gl_type, num_levels,
					tex->base.gl_format,
					tex->base.gl_internal_format,
					compressed, tex->size, tex->size,
					tex_size, &data))
			success = false;

		if (!gl_bind_texture(target, 0))
			success = false;

		if (data)
			data++;
	}

	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, num_levels);
	if (!gl_success("glTexParameteri"))
		success = false;

	return success;
}
Exemplo n.º 2
0
stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
		uint32_t height, enum gs_color_format color_format)
{
	struct gs_stage_surface *surf;
	surf = bzalloc(sizeof(struct gs_stage_surface));
	surf->device             = device;
	surf->format             = color_format;
	surf->width              = width;
	surf->height             = height;
	surf->gl_format          = convert_gs_format(color_format);
	surf->gl_internal_format = convert_gs_internal_format(color_format);
	surf->gl_type            = get_gl_format_type(color_format);
	surf->bytes_per_pixel    = gs_get_format_bpp(color_format)/8;

	if (!create_pixel_pack_buffer(surf)) {
		blog(LOG_ERROR, "device_create_stagesurface (GL) failed");
		stagesurface_destroy(surf);
		return NULL;
	}

	return surf;
}