Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
int device_create(gs_device_t *p_device, struct gs_init_data *info)
{
	struct gs_device *device = bzalloc(sizeof(struct gs_device));
	int errorcode = GS_ERROR_FAIL;

	device->plat = gl_platform_create(device, info);
	if (!device->plat)
		goto fail;

	if (!gl_init_extensions(device)) {
		errorcode = GS_ERROR_NOT_SUPPORTED;
		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_leave_context(device);
	device->cur_swap = gl_platform_getswap(device->plat);

	*p_device = device;
	return GS_SUCCESS;

fail:
	blog(LOG_ERROR, "device_create (GL) failed");
	bfree(device);

	*p_device = NULL;
	return errorcode;
}