Refactoring

This commit is contained in:
2018-09-23 19:47:40 +02:00
parent 72b7d4e872
commit ec354d9d8c
19 changed files with 473 additions and 201 deletions

View File

@@ -1,7 +1,5 @@
#include "instance.h"
#include "lvrc_internal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -284,12 +282,8 @@ static int drm_find_psvr_xcb(Instance * instance)
#endif // ENABLE_XCB
struct lvrcInstance * lvrcCreateInstance(ohmd_device * hmd)
bool InitInstance(Instance * instance)
{
Instance * instance = calloc(1, sizeof(Instance));
instance->hmd = hmd;
#ifdef ENABLE_XCB
instance->connection = xcb_connect(NULL, &instance->screen);
@@ -306,34 +300,37 @@ struct lvrcInstance * lvrcCreateInstance(ohmd_device * hmd)
else
{
fprintf(stderr, "couldn't find devicee\n");
free(instance);
return NULL;
return false;
}
instance->device = gbm_create_device(instance->fd);
struct gbm_device * device = gbm_create_device(instance->fd);
if (instance->device == NULL)
if (device == NULL)
{
fprintf(stderr, "couldn't create gbm device\n");
free(instance);
return NULL;
return false;
}
instance->surface = gbm_surface_create(instance->device, instance->mode->hdisplay, instance->mode->vdisplay, GBM_BO_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
struct gbm_surface * surface = gbm_surface_create(device, instance->mode->hdisplay, instance->mode->vdisplay, GBM_BO_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
if (instance->surface == NULL)
if (surface == NULL)
{
fprintf(stderr, "couldn't create gbm surface\n");
free(instance);
return NULL;
gbm_device_destroy(device);
return false;
}
return (struct lvrcInstance *)instance;
instance->device = device;
instance->surface = surface;
return true;
}
void lvrcDestroyInstance(struct lvrcInstance * instance)
bool ReleaseInstance(Instance * instance)
{
free(instance);
(void)instance;
return false; // TODO
}
void SwapBuffers(Instance * instance)