Update API + example

This commit is contained in:
2018-09-22 18:16:48 +02:00
parent b1febba24e
commit bdb827e07e
15 changed files with 680 additions and 722 deletions

View File

@@ -6,7 +6,7 @@
#include <stdio.h>
#include <assert.h>
#define USE_ES_SHADERS 0
#define USE_ES_SHADERS 1
static const GLfloat textureVertices[] =
{
@@ -79,16 +79,9 @@ static GLuint compile_shader(const char* vertex, const char* fragment)
// -------------------------------------------------------------------
bool lvrcInitFrameResources(struct lvrcInstance * instance)
bool InitFrameResources(Instance * instance)
{
Instance * internalState = (Instance*)instance;
if (!internalState->swapChain)
{
return false;
}
ohmd_device * hmd = internalState->device;
ohmd_device * hmd = instance->hmd;
float viewport_scale[2];
float distortion_coeffs[4];
@@ -151,13 +144,6 @@ bool lvrcInitFrameResources(struct lvrcInstance * instance)
return true;
}
bool lvrcReleaseFrameResources(struct lvrcInstance * state)
{
// TODO
return true;
}
bool lvrcBeginFrame(struct lvrcInstance * state)
{
return true; // nothing yet
@@ -188,13 +174,13 @@ bool lvrcSubmitFrameLeft(struct lvrcInstance * instance, GLuint texture)
{
Instance * internalInstance = (Instance*)instance;
if (!internalInstance->swapChain)
if (!internalInstance->mode)
{
return false;
}
unsigned int hmd_w = internalInstance->swapChain->mode->hdisplay;
unsigned int hmd_h = internalInstance->swapChain->mode->vdisplay;
unsigned int hmd_w = internalInstance->mode->hdisplay;
unsigned int hmd_h = internalInstance->mode->vdisplay;
prepare(texture);
@@ -212,13 +198,13 @@ bool lvrcSubmitFrameRight(struct lvrcInstance * instance, GLuint texture)
{
Instance * internalInstance = (Instance*)instance;
if (!internalInstance->swapChain)
if (!internalInstance->mode)
{
return false;
}
unsigned int hmd_w = internalInstance->swapChain->mode->hdisplay;
unsigned int hmd_h = internalInstance->swapChain->mode->vdisplay;
unsigned int hmd_w = internalInstance->mode->hdisplay;
unsigned int hmd_h = internalInstance->mode->vdisplay;
prepare(texture);
@@ -236,12 +222,14 @@ bool lvrcEndFrame(struct lvrcInstance * instance)
{
Instance * internalInstance = (Instance*)instance;
if (!internalInstance->swapChain)
{
return false;
}
eglMakeCurrent(internalInstance->vr_display, internalInstance->vr_surface, internalInstance->vr_surface, internalInstance->vr_context);
SwapBuffers(internalInstance->swapChain);
lvrcSubmitFrameLeft(instance, internalInstance->textures[0]);
lvrcSubmitFrameRight(instance, internalInstance->textures[1]);
eglSwapBuffers(internalInstance->vr_display, internalInstance->vr_surface);
SwapBuffers(internalInstance);
return true;
}