gs_texture_t device_cubetexture_create(gs_device_t device, uint32_t size,
		enum gs_color_format color_format, uint32_t levels,
		const uint8_t **data, uint32_t flags)
{
	struct gs_texture_cube *tex = bzalloc(sizeof(struct gs_texture_cube));
	tex->base.device             = device;
	tex->base.type               = GS_TEXTURE_CUBE;
	tex->base.format             = color_format;
	tex->base.levels             = levels;
	tex->base.gl_format          = convert_gs_format(color_format);
	tex->base.gl_internal_format = convert_gs_internal_format(color_format);
	tex->base.gl_target          = GL_TEXTURE_CUBE_MAP;
	tex->base.is_render_target   = (flags & GS_RENDER_TARGET) != 0;
	tex->base.gen_mipmaps        = (flags & GS_BUILD_MIPMAPS) != 0;
	tex->size                    = size;

	if (!gl_gen_textures(1, &tex->base.texture))
		goto fail;
	if (!upload_texture_cube(tex, data))
		goto fail;

	return (gs_texture_t)tex;

fail:
	gs_cubetexture_destroy((gs_texture_t)tex);
	blog(LOG_ERROR, "device_cubetexture_create (GL) failed");
	return NULL;
}
Example #2
0
static bool gl_init_stage_surface(struct gs_stage_surface *surf)
{
	bool success = true;

	if (!gl_gen_textures(1, &surf->texture))
		return false;
	if (!gl_bind_texture(GL_TEXTURE_2D, surf->texture))
		return false;

	if (!gl_init_face(GL_TEXTURE_2D, surf->gl_type, 1, surf->gl_format,
			surf->gl_internal_format, false,
			surf->width, surf->height, 0, NULL))
		success = false;

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

	if (success)
		success = create_pixel_pack_buffer(surf);

	return success;
}