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; }
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; }