mirror of https://github.com/bjornbytes/lovr.git
Graphics now draw, although head tracking is not correct
This commit is contained in:
parent
b892d0143f
commit
d17dec1b0e
|
@ -24,7 +24,7 @@ typedef struct {
|
|||
typedef struct Canvas Canvas;
|
||||
|
||||
Canvas* lovrCanvasCreate(int width, int height, CanvasFlags flags);
|
||||
Canvas* lovrCanvasCreateFromHandle(uint32_t handle);
|
||||
Canvas* lovrCanvasCreateFromHandle(int width, int height, CanvasFlags flags, uint32_t handle, int attachmentCount);
|
||||
void lovrCanvasDestroy(void* ref);
|
||||
const Attachment* lovrCanvasGetAttachments(Canvas* canvas, int* count);
|
||||
void lovrCanvasSetAttachments(Canvas* canvas, Attachment* attachments, int count);
|
||||
|
|
|
@ -233,7 +233,6 @@ typedef gpuProc (*getGpuProcProc)(const char*);
|
|||
|
||||
void lovrGpuInit(bool srgb, getGpuProcProc getProcAddress);
|
||||
void lovrGpuDestroy();
|
||||
void lovrGpuBindFramebuffer(uint32_t framebuffer);
|
||||
void lovrGpuBindPipeline(Pipeline* pipeline);
|
||||
void lovrGpuSetViewports(float* viewports, int count);
|
||||
void lovrGpuClear(Canvas* canvas, Color* color, float* depth, int* stencil);
|
||||
|
|
|
@ -512,7 +512,7 @@ static void lovrGpuDestroySyncResource(void* resource, uint8_t incoherent) {
|
|||
}
|
||||
}
|
||||
|
||||
void lovrGpuBindFramebuffer(uint32_t framebuffer) {
|
||||
static void lovrGpuBindFramebuffer(uint32_t framebuffer) {
|
||||
if (state.framebuffer != framebuffer) {
|
||||
state.framebuffer = framebuffer;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
|
@ -1232,11 +1232,15 @@ Canvas* lovrCanvasCreate(int width, int height, CanvasFlags flags) {
|
|||
return canvas;
|
||||
}
|
||||
|
||||
Canvas* lovrCanvasCreateFromHandle(uint32_t handle) {
|
||||
Canvas* lovrCanvasCreateFromHandle(int width, int height, CanvasFlags flags, uint32_t handle, int attachmentCount) {
|
||||
Canvas* canvas = lovrAlloc(Canvas, lovrCanvasDestroy);
|
||||
if (!canvas) return NULL;
|
||||
|
||||
canvas->framebuffer = handle;
|
||||
canvas->attachmentCount = attachmentCount;
|
||||
canvas->width = width;
|
||||
canvas->height = height;
|
||||
canvas->flags = flags;
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
|
|
@ -4,32 +4,25 @@
|
|||
#include "math/quat.h"
|
||||
#include "graphics/graphics.h"
|
||||
#include "math/mat4.h"
|
||||
#include "lib/glad/glad.h"
|
||||
|
||||
static void (*renderCallback)(void*);
|
||||
static void* renderUserdata;
|
||||
|
||||
void lovrOculusMobileDraw(int eye, int framebuffer, int width, int height, float *eyeViewMatrix, float *projectionMatrix) {
|
||||
lovrGraphicsPush();
|
||||
lovrGpuBindFramebuffer(framebuffer);
|
||||
void lovrOculusMobileDraw(int framebuffer, int width, int height, float *eyeViewMatrix, float *projectionMatrix) {
|
||||
CanvasFlags flags = {0};
|
||||
Canvas *canvas = lovrCanvasCreateFromHandle(width, height, flags, framebuffer, 1);
|
||||
|
||||
float m[16];
|
||||
mat4_set(m, projectionMatrix);
|
||||
mat4_multiply(m, eyeViewMatrix);
|
||||
Camera camera = { .canvas = canvas, .stereo = false };
|
||||
memcpy(camera.viewMatrix[0], eyeViewMatrix, sizeof(camera.viewMatrix[0]));
|
||||
memcpy(camera.projection[0], projectionMatrix, sizeof(camera.projection[0]));
|
||||
|
||||
lovrGraphicsOrigin();
|
||||
lovrGraphicsMatrixTransform(m);
|
||||
|
||||
Color color = lovrGraphicsGetBackgroundColor();
|
||||
float depth = 1.f;
|
||||
int stencil = 0;
|
||||
lovrGraphicsClear(&color, &depth, &stencil); // Needed?
|
||||
|
||||
float viewports[4] = { 0, 0, width, height };
|
||||
lovrGpuSetViewports(viewports, 1);
|
||||
lovrGraphicsSetCamera(&camera, true);
|
||||
|
||||
renderCallback(renderUserdata);
|
||||
|
||||
lovrGraphicsPop();
|
||||
lovrGraphicsSetCamera(NULL, false);
|
||||
lovrRelease(canvas);
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
@ -57,7 +50,7 @@ static bool oculusMobileIsMounted() {
|
|||
return true; // ???
|
||||
}
|
||||
|
||||
static void oculusMobileIsMirrored(bool* mirrored, bool* eye) {
|
||||
static void oculusMobileIsMirrored(bool* mirrored, HeadsetEye * eye) {
|
||||
*mirrored = false; // Can't ever??
|
||||
*eye = false;
|
||||
}
|
||||
|
@ -133,7 +126,7 @@ static float oculusMobileControllerGetAxis(Controller* controller, ControllerAxi
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int oculusMobileControllerIsDown(Controller* controller, ControllerButton button) {
|
||||
static bool oculusMobileControllerIsDown(Controller* controller, ControllerButton button) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void lovrOculusMobileDraw(int framebuffer, int width, int height, float *eyeViewMatrix, float *projectionMatrix);
|
Loading…
Reference in New Issue