device_t device_create(struct gs_init_data *info) { struct gs_device *device = bmalloc(sizeof(struct gs_device)); memset(device, 0, sizeof(struct gs_device)); device->plat = gl_platform_create(device, info); if (!device->plat) goto fail; if (!gl_init_extensions(device)) goto fail; gl_enable(GL_CULL_FACE); glGenProgramPipelines(1, &device->pipeline); if (!gl_success("glGenProgramPipelines")) goto fail; glBindProgramPipeline(device->pipeline); if (!gl_success("glBindProgramPipeline")) goto fail; device_leavecontext(device); device->cur_swap = gl_platform_getswap(device->plat); return device; fail: blog(LOG_ERROR, "device_create (GL) failed"); bfree(device); return NULL; }
device_t device_create(struct gs_init_data *info) { struct gs_device *device = bmalloc(sizeof(struct gs_device)); memset(device, 0, sizeof(struct gs_device)); device->plat = gl_platform_create(device, info); if (!device->plat) goto fail; glGenProgramPipelines(1, &device->pipeline); if (!gl_success("glGenProgramPipelines")) goto fail; glBindProgramPipeline(device->pipeline); if (!gl_success("glBindProgramPipeline")) goto fail; #ifdef _DEBUG glEnable(GL_DEBUG_OUTPUT); if (glGetError() == GL_INVALID_ENUM) blog(LOG_DEBUG, "OpenGL debug information not available"); #endif gl_enable(GL_CULL_FACE); device_leavecontext(device); device->cur_swap = gl_platform_getswap(device->plat); return device; fail: blog(LOG_ERROR, "device_create (GL) failed"); bfree(device); return NULL; }