More number conversions;

This commit is contained in:
bjorn 2019-05-20 20:35:07 -07:00
parent e4c32d2f08
commit 4cc154fdfa
31 changed files with 203 additions and 211 deletions

View File

@ -1,22 +1,22 @@
#include "api.h"
#include "graphics/animator.h"
static int luax_checkanimation(lua_State* L, int index, Animator* animator) {
static uint32_t luax_checkanimation(lua_State* L, int index, Animator* animator) {
switch (lua_type(L, index)) {
case LUA_TNUMBER: {
int i = lua_tointeger(L, index) - 1;
lovrAssert(i < lovrAnimatorGetAnimationCount(animator), "Invalid animation '%d'", i + 1);
return i;
uint32_t i = lua_tointeger(L, index);
lovrAssert(i >= 1 && i <= lovrAnimatorGetAnimationCount(animator), "Invalid animation '%d'", i);
return i - 1;
}
case LUA_TSTRING: {
const char* name = lua_tostring(L, index);
int* i = lovrAnimatorGetAnimationIndex(animator, name);
uint32_t* i = lovrAnimatorGetAnimationIndex(animator, name);
lovrAssert(i, "Unknown animation '%s'", name);
return *i;
}
default:
luaL_typerror(L, index, "number or string");
return -1;
return ~0u;
}
}

View File

@ -219,7 +219,7 @@ static int l_lovrHeadsetGetBoundsDimensions(lua_State* L) {
}
static int l_lovrHeadsetGetBoundsGeometry(lua_State* L) {
int count;
uint32_t count;
const float* points = lovrHeadsetDriver->getBoundsGeometry(&count);
if (!points) {
@ -234,7 +234,7 @@ static int l_lovrHeadsetGetBoundsGeometry(lua_State* L) {
lua_createtable(L, count, 0);
}
for (int i = 0; i < count; i++) {
for (uint32_t i = 0; i < count; i++) {
lua_pushnumber(L, points[i]);
lua_rawseti(L, 1, i + 1);
}

View File

@ -11,7 +11,7 @@ static int l_lovrMeshAttachAttributes(lua_State* L) {
Mesh* other = luax_checktype(L, 2, Mesh);
int instanceDivisor = luaL_optinteger(L, 3, 0);
if (lua_isnoneornil(L, 4)) {
for (int i = 0; i < other->attributeCount; i++) {
for (uint32_t i = 0; i < other->attributeCount; i++) {
MeshAttribute attachment = other->attributes[i];
if (attachment.buffer != other->vertexBuffer) {
break;
@ -50,7 +50,7 @@ static int l_lovrMeshDetachAttributes(lua_State* L) {
Mesh* mesh = luax_checktype(L, 1, Mesh);
if (lua_isuserdata(L, 2)) {
Mesh* other = luax_checktype(L, 2, Mesh);
for (int i = 0; i < other->attributeCount; i++) {
for (uint32_t i = 0; i < other->attributeCount; i++) {
const MeshAttribute* attachment = &other->attributes[i];
if (attachment->buffer != other->vertexBuffer) {
break;
@ -115,7 +115,7 @@ static int l_lovrMeshSetDrawMode(lua_State* L) {
static int l_lovrMeshGetVertexFormat(lua_State* L) {
Mesh* mesh = luax_checktype(L, 1, Mesh);
lua_createtable(L, mesh->attributeCount, 0);
for (int i = 0; i < mesh->attributeCount; i++) {
for (uint32_t i = 0; i < mesh->attributeCount; i++) {
const MeshAttribute* attribute = &mesh->attributes[i];
if (attribute->buffer != mesh->vertexBuffer) {
break;
@ -150,7 +150,7 @@ static int l_lovrMeshGetVertex(lua_State* L) {
AttributeData data = { .raw = lovrBufferMap(mesh->vertexBuffer, index * mesh->attributes[0].stride) };
int components = 0;
for (int i = 0; i < mesh->attributeCount; i++) {
for (uint32_t i = 0; i < mesh->attributeCount; i++) {
const MeshAttribute* attribute = &mesh->attributes[i];
if (attribute->buffer != mesh->vertexBuffer) {
break;
@ -183,7 +183,7 @@ static int l_lovrMeshSetVertex(lua_State* L) {
size_t stride = mesh->attributes[0].stride;
AttributeData data = { .raw = lovrBufferMap(mesh->vertexBuffer, index * stride) };
int component = 0;
for (int i = 0; i < mesh->attributeCount; i++) {
for (uint32_t i = 0; i < mesh->attributeCount; i++) {
const MeshAttribute* attribute = &mesh->attributes[i];
if (attribute->buffer != mesh->vertexBuffer) {
break;
@ -218,11 +218,11 @@ static int l_lovrMeshSetVertex(lua_State* L) {
static int l_lovrMeshGetVertexAttribute(lua_State* L) {
Mesh* mesh = luax_checktype(L, 1, Mesh);
uint32_t vertexIndex = luaL_checkinteger(L, 2) - 1;
int attributeIndex = luaL_checkinteger(L, 3) - 1;
uint32_t attributeIndex = luaL_checkinteger(L, 3) - 1;
Buffer* buffer = lovrMeshGetVertexBuffer(mesh);
lovrAssert(lovrBufferIsReadable(buffer), "Mesh:getVertex can only be used if the Mesh was created with the readable flag");
lovrAssert(vertexIndex >= 0 && vertexIndex < lovrMeshGetVertexCount(mesh), "Invalid mesh vertex: %d", vertexIndex + 1);
lovrAssert(attributeIndex >= 0 && attributeIndex < mesh->attributeCount, "Invalid mesh attribute: %d", attributeIndex + 1);
lovrAssert(attributeIndex < mesh->attributeCount, "Invalid mesh attribute: %d", attributeIndex + 1);
lovrAssert(mesh->attributes[attributeIndex].buffer == mesh->vertexBuffer, "Invalid mesh attribute: %d", attributeIndex + 1);
MeshAttribute* attribute = &mesh->attributes[attributeIndex];
AttributeData data = { .raw = lovrBufferMap(buffer, vertexIndex * attribute->stride + attribute->offset) };
@ -243,10 +243,10 @@ static int l_lovrMeshGetVertexAttribute(lua_State* L) {
static int l_lovrMeshSetVertexAttribute(lua_State* L) {
Mesh* mesh = luax_checktype(L, 1, Mesh);
uint32_t vertexIndex = luaL_checkinteger(L, 2) - 1;
int attributeIndex = luaL_checkinteger(L, 3) - 1;
uint32_t attributeIndex = luaL_checkinteger(L, 3) - 1;
bool table = lua_istable(L, 4);
lovrAssert(vertexIndex >= 0 && vertexIndex < lovrMeshGetVertexCount(mesh), "Invalid mesh vertex: %d", vertexIndex + 1);
lovrAssert(attributeIndex >= 0 && attributeIndex < mesh->attributeCount, "Invalid mesh attribute: %d", attributeIndex + 1);
lovrAssert(attributeIndex < mesh->attributeCount, "Invalid mesh attribute: %d", attributeIndex + 1);
lovrAssert(mesh->attributes[attributeIndex].buffer == mesh->vertexBuffer, "Invalid mesh attribute: %d", attributeIndex + 1);
MeshAttribute* attribute = &mesh->attributes[attributeIndex];
AttributeData data = { .raw = lovrBufferMap(mesh->vertexBuffer, vertexIndex * attribute->stride + attribute->offset) };
@ -306,7 +306,7 @@ static int l_lovrMeshSetVertices(lua_State* L) {
lua_rawgeti(L, 2, i + 1);
luaL_checktype(L, -1, LUA_TTABLE);
int component = 0;
for (int j = 0; j < mesh->attributeCount; j++) {
for (uint32_t j = 0; j < mesh->attributeCount; j++) {
const MeshAttribute* attribute = &mesh->attributes[j];
if (attribute->buffer != mesh->vertexBuffer) {
break;

View File

@ -11,7 +11,6 @@ void lovrCanvasDestroy(void*);
void lovrChannelDestroy(void*);
#endif
void lovrColliderDestroy(void*);
void lovrControllerDestroy(void*);
void lovrCurveDestroy(void*);
void lovrFileDestroy(void*);
void lovrFontDestroy(void*);
@ -50,7 +49,6 @@ const TypeInfo lovrTypeInfo[T_MAX] = {
INFO(Channel),
#endif
INFO(Collider),
INFO(Controller),
INFO(Curve),
SUPERINFO(CylinderShape, Shape),
SUPERINFO(DistanceJoint, Joint),

View File

@ -17,7 +17,6 @@ typedef enum {
T_CapsuleShape,
T_Channel,
T_Collider,
T_Controller,
T_Curve,
T_CylinderShape,
T_DistanceJoint,

View File

@ -15,10 +15,10 @@ ModelData* lovrModelDataInit(ModelData* model, Blob* source) {
void lovrModelDataDestroy(void* ref) {
ModelData* model = ref;
for (int i = 0; i < model->blobCount; i++) {
for (uint32_t i = 0; i < model->blobCount; i++) {
lovrRelease(Blob, model->blobs[i]);
}
for (int i = 0; i < model->textureCount; i++) {
for (uint32_t i = 0; i < model->textureCount; i++) {
lovrRelease(TextureData, model->textures[i]);
}
free(model->data);

View File

@ -114,20 +114,20 @@ typedef struct {
uint32_t buffer;
uint32_t count;
AttributeType type;
unsigned int components : 3;
bool normalized : 1;
bool matrix : 1;
bool hasMin : 1;
bool hasMax : 1;
unsigned components : 3;
unsigned normalized : 1;
unsigned matrix : 1;
unsigned hasMin : 1;
unsigned hasMax : 1;
float min[4];
float max[4];
} ModelAttribute;
typedef struct {
int nodeIndex;
uint32_t nodeIndex;
AnimationProperty property;
SmoothMode smoothing;
int keyframeCount;
uint32_t keyframeCount;
float* times;
float* data;
} ModelAnimationChannel;
@ -135,20 +135,14 @@ typedef struct {
typedef struct {
const char* name;
ModelAnimationChannel* channels;
int channelCount;
uint32_t channelCount;
float duration;
} ModelAnimation;
typedef struct {
int imageIndex;
TextureFilter filter;
TextureWrap wrap;
} ModelTexture;
typedef struct {
float scalars[MAX_MATERIAL_SCALARS];
Color colors[MAX_MATERIAL_COLORS];
int textures[MAX_MATERIAL_TEXTURES];
uint32_t textures[MAX_MATERIAL_TEXTURES];
TextureFilter filters[MAX_MATERIAL_TEXTURES];
TextureWrap wraps[MAX_MATERIAL_TEXTURES];
} ModelMaterial;
@ -157,7 +151,7 @@ typedef struct {
ModelAttribute* attributes[MAX_DEFAULT_ATTRIBUTES];
ModelAttribute* indices;
DrawMode mode;
int material;
uint32_t material;
} ModelPrimitive;
typedef struct {
@ -169,7 +163,7 @@ typedef struct {
uint32_t childCount;
uint32_t primitiveIndex;
uint32_t primitiveCount;
int skin;
uint32_t skin;
} ModelNode;
typedef struct {
@ -189,26 +183,26 @@ typedef struct ModelData {
ModelAnimation* animations;
ModelSkin* skins;
ModelNode* nodes;
int rootNode;
uint32_t rootNode;
int blobCount;
int bufferCount;
int textureCount;
int materialCount;
int attributeCount;
int primitiveCount;
int animationCount;
int skinCount;
int nodeCount;
uint32_t blobCount;
uint32_t bufferCount;
uint32_t textureCount;
uint32_t materialCount;
uint32_t attributeCount;
uint32_t primitiveCount;
uint32_t animationCount;
uint32_t skinCount;
uint32_t nodeCount;
ModelAnimationChannel* channels;
uint32_t* children;
uint32_t* joints;
char* chars;
int channelCount;
int childCount;
int jointCount;
int charCount;
uint32_t channelCount;
uint32_t childCount;
uint32_t jointCount;
uint32_t charCount;
} ModelData;
ModelData* lovrModelDataInit(ModelData* model, struct Blob* blob);

View File

@ -40,8 +40,8 @@ typedef struct {
} gltfChunkHeader;
typedef struct {
int input;
int output;
uint32_t input;
uint32_t output;
SmoothMode smoothing;
} gltfAnimationSampler;
@ -65,12 +65,11 @@ typedef struct {
uint32_t nodeCount;
} gltfScene;
static int nomInt(const char* s) {
int n = 0;
bool negative = (*s == '-');
s += negative;
static uint32_t nomInt(const char* s) {
uint32_t n = 0;
lovrAssert(*s != '-', "Expected a positive number");
while (isdigit(*s)) { n = 10 * n + (*s++ - '0'); }
return negative ? -n : n;
return n;
}
static int nomValue(const char* data, jsmntok_t* token, int count, int sum) {
@ -82,14 +81,14 @@ static int nomValue(const char* data, jsmntok_t* token, int count, int sum) {
}
}
// Kinda like total += sum(map(arr, obj => #obj[key]))
static jsmntok_t* aggregate(const char* json, jsmntok_t* token, const char* target, int* total) {
// Kinda like count += sum(map(arr, obj => #obj[key]))
static jsmntok_t* aggregate(const char* json, jsmntok_t* token, const char* target, uint32_t* count) {
for (int i = (token++)->size; i > 0; i--) {
if (token->size > 0) {
for (int k = (token++)->size; k > 0; k--) {
gltfString key = NOM_STR(json, token);
if (STR_EQ(key, target)) {
*total += token->size;
*count += token->size;
}
token += NOM_VALUE(json, token);
}
@ -102,7 +101,7 @@ static jsmntok_t* resolveTexture(const char* json, jsmntok_t* token, ModelMateri
for (int k = (token++)->size; k > 0; k--) {
gltfString key = NOM_STR(json, token);
if (STR_EQ(key, "index")) {
int index = NOM_INT(json, token);
uint32_t index = NOM_INT(json, token);
material->textures[type] = textures[index].image;
material->filters[type] = samplers[textures[index].sampler].filter;
material->wraps[type] = samplers[textures[index].sampler].wrap;
@ -237,8 +236,8 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
gltfString key = NOM_STR(json, token);
if (STR_EQ(key, "samplers")) {
for (int j = (token++)->size; j > 0; j--, sampler++) {
sampler->input = -1;
sampler->output = -1;
sampler->input = ~0u;
sampler->output = ~0u;
sampler->smoothing = SMOOTH_LINEAR;
for (int kk = (token++)->size; kk > 0; kk--) {
gltfString key = NOM_STR(json, token);
@ -527,7 +526,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
animation->channelCount = (token++)->size;
animation->channels = model->channels + channelIndex;
channelIndex += animation->channelCount;
for (int j = 0; j < animation->channelCount; j++) {
for (uint32_t j = 0; j < animation->channelCount; j++) {
ModelAnimationChannel* channel = &animation->channels[j];
ModelAttribute* times = NULL;
ModelAttribute* data = NULL;
@ -632,7 +631,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
material->scalars[SCALAR_ROUGHNESS] = 1.f;
material->colors[COLOR_DIFFUSE] = (Color) { 1.f, 1.f, 1.f, 1.f };
material->colors[COLOR_EMISSIVE] = (Color) { 0.f, 0.f, 0.f, 0.f };
memset(material->textures, 0xff, MAX_MATERIAL_TEXTURES * sizeof(int));
memset(material->textures, 0xff, MAX_MATERIAL_TEXTURES * sizeof(uint32_t));
for (int k = (token++)->size; k > 0; k--) {
gltfString key = NOM_STR(json, token);
@ -688,7 +687,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
if (STR_EQ(key, "primitives")) {
for (uint32_t j = (token++)->size; j > 0; j--, primitive++) {
primitive->mode = DRAW_TRIANGLES;
primitive->material = -1;
primitive->material = ~0u;
for (int kk = (token++)->size; kk > 0; kk--) {
gltfString key = NOM_STR(json, token);
@ -713,7 +712,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
for (int a = 0; a < attributeCount; a++) {
DefaultAttribute attributeType = ~0;
gltfString name = NOM_STR(json, token);
int attributeIndex = NOM_INT(json, token);
uint32_t attributeIndex = NOM_INT(json, token);
if (STR_EQ(name, "POSITION")) { attributeType = ATTR_POSITION; }
else if (STR_EQ(name, "NORMAL")) { attributeType = ATTR_NORMAL; }
else if (STR_EQ(name, "TEXCOORD_0")) { attributeType = ATTR_TEXCOORD; }
@ -738,7 +737,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
}
// Nodes
int childIndex = 0;
uint32_t childIndex = 0;
if (model->nodeCount > 0) {
jsmntok_t* token = info.nodes;
ModelNode* node = model->nodes;
@ -748,7 +747,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
vec3 scale = vec3_set(node->scale, 1.f, 1.f, 1.f);
bool matrix = false;
node->primitiveCount = 0;
node->skin = -1;
node->skin = ~0u;
for (int k = (token++)->size; k > 0; k--) {
gltfString key = NOM_STR(json, token);
@ -836,7 +835,7 @@ ModelData* lovrModelDataInitGltf(ModelData* model, Blob* source) {
lastNode->children = &model->children[childIndex];
mat4_identity(lastNode->transform);
lastNode->primitiveCount = 0;
lastNode->skin = -1;
lastNode->skin = ~0u;
jsmntok_t* token = info.scenes;
int sceneCount = (token++)->size;

View File

@ -132,6 +132,6 @@ void lovrRasterizerLoadGlyph(Rasterizer* rasterizer, uint32_t character, Glyph*
msShapeDestroy(shape);
}
int lovrRasterizerGetKerning(Rasterizer* rasterizer, uint32_t left, uint32_t right) {
int32_t lovrRasterizerGetKerning(Rasterizer* rasterizer, uint32_t left, uint32_t right) {
return stbtt_GetCodepointKernAdvance(&rasterizer->font, left, right) * rasterizer->scale;
}

View File

@ -22,15 +22,15 @@ typedef struct Rasterizer {
} Rasterizer;
typedef struct {
int x;
int y;
int w;
int h;
int tw;
int th;
int dx;
int dy;
int advance;
int32_t x;
int32_t y;
uint32_t w;
uint32_t h;
uint32_t tw;
uint32_t th;
int32_t dx;
int32_t dy;
int32_t advance;
struct TextureData* data;
} Glyph;
@ -40,4 +40,4 @@ void lovrRasterizerDestroy(void* ref);
bool lovrRasterizerHasGlyph(Rasterizer* fontData, uint32_t character);
bool lovrRasterizerHasGlyphs(Rasterizer* fontData, const char* str);
void lovrRasterizerLoadGlyph(Rasterizer* fontData, uint32_t character, Glyph* glyph);
int lovrRasterizerGetKerning(Rasterizer* fontData, uint32_t left, uint32_t right);
int32_t lovrRasterizerGetKerning(Rasterizer* fontData, uint32_t left, uint32_t right);

View File

@ -6,7 +6,7 @@
#include <stdlib.h>
#include <stdint.h>
SoundData* lovrSoundDataInit(SoundData* soundData, int samples, int sampleRate, int bitDepth, int channelCount) {
SoundData* lovrSoundDataInit(SoundData* soundData, size_t samples, uint32_t sampleRate, uint32_t bitDepth, uint32_t channelCount) {
soundData->samples = samples;
soundData->sampleRate = sampleRate;
soundData->bitDepth = bitDepth;
@ -26,11 +26,11 @@ SoundData* lovrSoundDataInitFromAudioStream(SoundData* soundData, AudioStream* a
soundData->blob.data = calloc(1, soundData->blob.size);
lovrAssert(soundData->blob.data, "Out of memory");
int samples;
short* buffer = soundData->blob.data;
size_t samples;
int16_t* buffer = soundData->blob.data;
int offset = 0;
lovrAudioStreamRewind(audioStream);
while ((samples = lovrAudioStreamDecode(audioStream, buffer + offset, (int) soundData->blob.size - (offset * sizeof(short)))) != 0) {
while ((samples = lovrAudioStreamDecode(audioStream, buffer + offset, (int) soundData->blob.size - (offset * sizeof(int16_t)))) != 0) {
offset += samples;
}
@ -38,14 +38,17 @@ SoundData* lovrSoundDataInitFromAudioStream(SoundData* soundData, AudioStream* a
}
SoundData* lovrSoundDataInitFromBlob(SoundData* soundData, Blob* blob) {
int samples, channels;
soundData->bitDepth = 16;
soundData->samples = stb_vorbis_decode_memory(blob->data, (int) blob->size, &soundData->channelCount, &soundData->sampleRate, (short**) &soundData->blob.data);
soundData->samples = stb_vorbis_decode_memory(blob->data, (int) blob->size, &channels, &samples, (int16_t**) &soundData->blob.data);
soundData->samples = samples;
soundData->channelCount = channels;
soundData->blob.size = soundData->samples * soundData->channelCount * (soundData->bitDepth / 8);
return soundData;
}
float lovrSoundDataGetSample(SoundData* soundData, int index) {
lovrAssert(index >= 0 && index < (int) soundData->blob.size / (soundData->bitDepth / 8), "Sample index out of range");
float lovrSoundDataGetSample(SoundData* soundData, size_t index) {
lovrAssert(index < soundData->blob.size / (soundData->bitDepth / 8), "Sample index out of range");
switch (soundData->bitDepth) {
case 8: return ((int8_t*) soundData->blob.data)[index] / (float) CHAR_MAX;
case 16: return ((int16_t*) soundData->blob.data)[index] / (float) SHRT_MAX;
@ -53,8 +56,8 @@ float lovrSoundDataGetSample(SoundData* soundData, int index) {
}
}
void lovrSoundDataSetSample(SoundData* soundData, int index, float value) {
lovrAssert(index >= 0 && index < (int) soundData->blob.size / (soundData->bitDepth / 8), "Sample index out of range");
void lovrSoundDataSetSample(SoundData* soundData, size_t index, float value) {
lovrAssert(index < soundData->blob.size / (soundData->bitDepth / 8), "Sample index out of range");
switch (soundData->bitDepth) {
case 8: ((int8_t*) soundData->blob.data)[index] = value * CHAR_MAX; break;
case 16: ((int16_t*) soundData->blob.data)[index] = value * SHRT_MAX; break;

View File

@ -1,4 +1,5 @@
#include "data/blob.h"
#include <stdint.h>
#pragma once
@ -6,18 +7,18 @@ struct AudioStream;
typedef struct SoundData {
Blob blob;
int channelCount;
int sampleRate;
int samples;
int bitDepth;
uint32_t channelCount;
uint32_t sampleRate;
size_t samples;
uint32_t bitDepth;
} SoundData;
SoundData* lovrSoundDataInit(SoundData* soundData, int samples, int sampleRate, int bitDepth, int channels);
SoundData* lovrSoundDataInit(SoundData* soundData, size_t samples, uint32_t sampleRate, uint32_t bitDepth, uint32_t channels);
SoundData* lovrSoundDataInitFromAudioStream(SoundData* soundData, struct AudioStream* audioStream);
SoundData* lovrSoundDataInitFromBlob(SoundData* soundData, Blob* blob);
#define lovrSoundDataCreate(...) lovrSoundDataInit(lovrAlloc(SoundData), __VA_ARGS__)
#define lovrSoundDataCreateFromAudioStream(...) lovrSoundDataInitFromAudioStream(lovrAlloc(SoundData), __VA_ARGS__)
#define lovrSoundDataCreateFromBlob(...) lovrSoundDataInitFromBlob(lovrAlloc(SoundData), __VA_ARGS__)
float lovrSoundDataGetSample(SoundData* soundData, int index);
void lovrSoundDataSetSample(SoundData* soundData, int index, float value);
float lovrSoundDataGetSample(SoundData* soundData, size_t index);
void lovrSoundDataSetSample(SoundData* soundData, size_t index, float value);
void lovrSoundDataDestroy(void* ref);

View File

@ -17,7 +17,7 @@ Animator* lovrAnimatorInit(Animator* animator, ModelData* data) {
vec_reserve(&animator->tracks, data->animationCount);
animator->speed = 1.f;
for (int i = 0; i < data->animationCount; i++) {
for (uint32_t i = 0; i < data->animationCount; i++) {
vec_push(&animator->tracks, ((Track) {
.time = 0.f,
.speed = 1.f,
@ -69,7 +69,7 @@ void lovrAnimatorUpdate(Animator* animator, float dt) {
}
}
bool lovrAnimatorEvaluate(Animator* animator, int nodeIndex, mat4 transform) {
bool lovrAnimatorEvaluate(Animator* animator, uint32_t nodeIndex, mat4 transform) {
float properties[3][4];
ModelNode* node = &animator->data->nodes[nodeIndex];
vec3_init(properties[PROP_TRANSLATION], node->translation);
@ -77,10 +77,10 @@ bool lovrAnimatorEvaluate(Animator* animator, int nodeIndex, mat4 transform) {
vec3_init(properties[PROP_SCALE], node->scale);
bool touched = false;
for (int i = 0; i < animator->data->animationCount; i++) {
for (uint32_t i = 0; i < animator->data->animationCount; i++) {
ModelAnimation* animation = &animator->data->animations[i];
for (int j = 0; j < animation->channelCount; j++) {
for (uint32_t j = 0; j < animation->channelCount; j++) {
ModelAnimationChannel* channel = &animation->channels[j];
if (channel->nodeIndex != nodeIndex) {
continue;
@ -93,7 +93,7 @@ bool lovrAnimatorEvaluate(Animator* animator, int nodeIndex, mat4 transform) {
float duration = animator->data->animations[i].duration;
float time = fmodf(track->time, duration);
int k = 0;
uint32_t k = 0;
while (k < channel->keyframeCount && channel->times[k] < time) {
k++;
@ -101,10 +101,10 @@ bool lovrAnimatorEvaluate(Animator* animator, int nodeIndex, mat4 transform) {
float value[4];
bool rotate = channel->property == PROP_ROTATION;
int n = 3 + rotate;
size_t n = 3 + rotate;
float* (*lerp)(float* a, float* b, float t) = rotate ? quat_slerp : vec3_lerp;
if (k > 0 && k < channel->keyframeCount) {
if (k < channel->keyframeCount) {
float t1 = channel->times[k - 1];
float t2 = channel->times[k];
float z = (time - t1) / (t2 - t1);
@ -151,41 +151,41 @@ bool lovrAnimatorEvaluate(Animator* animator, int nodeIndex, mat4 transform) {
return touched;
}
int lovrAnimatorGetAnimationCount(Animator* animator) {
uint32_t lovrAnimatorGetAnimationCount(Animator* animator) {
return animator->data->animationCount;
}
int* lovrAnimatorGetAnimationIndex(Animator* animator, const char* name) {
uint32_t* lovrAnimatorGetAnimationIndex(Animator* animator, const char* name) {
return map_get(&animator->animations, name);
}
const char* lovrAnimatorGetAnimationName(Animator* animator, int index) {
const char* lovrAnimatorGetAnimationName(Animator* animator, uint32_t index) {
return animator->data->animations[index].name;
}
void lovrAnimatorPlay(Animator* animator, int animation) {
void lovrAnimatorPlay(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
track->playing = true;
track->time = 0;
track->time = 0.f;
}
void lovrAnimatorStop(Animator* animator, int animation) {
void lovrAnimatorStop(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
track->playing = false;
track->time = 0;
track->time = 0.f;
}
void lovrAnimatorPause(Animator* animator, int animation) {
void lovrAnimatorPause(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
track->playing = false;
}
void lovrAnimatorResume(Animator* animator, int animation) {
void lovrAnimatorResume(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
track->playing = true;
}
void lovrAnimatorSeek(Animator* animator, int animation, float time) {
void lovrAnimatorSeek(Animator* animator, uint32_t animation, float time) {
Track* track = &animator->tracks.data[animation];
float duration = animator->data->animations[animation].duration;
@ -193,7 +193,7 @@ void lovrAnimatorSeek(Animator* animator, int animation, float time) {
time -= duration;
}
while (time < 0) {
while (time < 0.f) {
time += duration;
}
@ -205,53 +205,53 @@ void lovrAnimatorSeek(Animator* animator, int animation, float time) {
}
}
float lovrAnimatorTell(Animator* animator, int animation) {
float lovrAnimatorTell(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
return track->time;
}
float lovrAnimatorGetAlpha(Animator* animator, int animation) {
float lovrAnimatorGetAlpha(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
return track->alpha;
}
void lovrAnimatorSetAlpha(Animator* animator, int animation, float alpha) {
void lovrAnimatorSetAlpha(Animator* animator, uint32_t animation, float alpha) {
Track* track = &animator->tracks.data[animation];
track->alpha = alpha;
}
float lovrAnimatorGetDuration(Animator* animator, int animation) {
float lovrAnimatorGetDuration(Animator* animator, uint32_t animation) {
return animator->data->animations[animation].duration;
}
bool lovrAnimatorIsPlaying(Animator* animator, int animation) {
bool lovrAnimatorIsPlaying(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
return track->playing;
}
bool lovrAnimatorIsLooping(Animator* animator, int animation) {
bool lovrAnimatorIsLooping(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
return track->looping;
}
void lovrAnimatorSetLooping(Animator* animator, int animation, bool loop) {
void lovrAnimatorSetLooping(Animator* animator, uint32_t animation, bool loop) {
Track* track = &animator->tracks.data[animation];
track->looping = loop;
}
int lovrAnimatorGetPriority(Animator* animator, int animation) {
int32_t lovrAnimatorGetPriority(Animator* animator, uint32_t animation) {
Track* track = &animator->tracks.data[animation];
return track->priority;
}
void lovrAnimatorSetPriority(Animator* animator, int animation, int priority) {
void lovrAnimatorSetPriority(Animator* animator, uint32_t animation, int32_t priority) {
Track* track = &animator->tracks.data[animation];
track->priority = priority;
vec_sort(&animator->tracks, trackSortCallback);
}
float lovrAnimatorGetSpeed(Animator* animator, int animation) {
if (animation < 0) {
float lovrAnimatorGetSpeed(Animator* animator, uint32_t animation) {
if (animation == ~0u) {
return animator->speed;
}
@ -259,8 +259,8 @@ float lovrAnimatorGetSpeed(Animator* animator, int animation) {
return track->speed;
}
void lovrAnimatorSetSpeed(Animator* animator, int animation, float speed) {
if (animation < 0) {
void lovrAnimatorSetSpeed(Animator* animator, uint32_t animation, float speed) {
if (animation == ~0u) {
animator->speed = speed;
}

View File

@ -10,7 +10,7 @@ typedef struct {
float time;
float speed;
float alpha;
int priority;
int32_t priority;
bool playing;
bool looping;
} Track;
@ -19,7 +19,7 @@ typedef vec_t(Track) vec_track_t;
typedef struct Animator {
struct ModelData* data;
map_int_t animations;
map_t(uint32_t) animations;
vec_track_t tracks;
float speed;
} Animator;
@ -29,23 +29,23 @@ Animator* lovrAnimatorInit(Animator* animator, struct ModelData* modelData);
void lovrAnimatorDestroy(void* ref);
void lovrAnimatorReset(Animator* animator);
void lovrAnimatorUpdate(Animator* animator, float dt);
bool lovrAnimatorEvaluate(Animator* animator, int nodeIndex, float* transform);
int lovrAnimatorGetAnimationCount(Animator* animator);
int* lovrAnimatorGetAnimationIndex(Animator* animator, const char* name);
const char* lovrAnimatorGetAnimationName(Animator* animator, int index);
void lovrAnimatorPlay(Animator* animator, int animation);
void lovrAnimatorStop(Animator* animator, int animation);
void lovrAnimatorPause(Animator* animator, int animation);
void lovrAnimatorResume(Animator* animator, int animation);
void lovrAnimatorSeek(Animator* animator, int animation, float time);
float lovrAnimatorTell(Animator* animator, int animation);
float lovrAnimatorGetAlpha(Animator* animator, int animation);
void lovrAnimatorSetAlpha(Animator* animator, int animation, float alpha);
float lovrAnimatorGetDuration(Animator* animator, int animation);
bool lovrAnimatorIsPlaying(Animator* animator, int animation);
bool lovrAnimatorIsLooping(Animator* animator, int animation);
void lovrAnimatorSetLooping(Animator* animator, int animation, bool loop);
int lovrAnimatorGetPriority(Animator* animator, int animation);
void lovrAnimatorSetPriority(Animator* animator, int animation, int priority);
float lovrAnimatorGetSpeed(Animator* animator, int animation);
void lovrAnimatorSetSpeed(Animator* animator, int animation, float speed);
bool lovrAnimatorEvaluate(Animator* animator, uint32_t nodeIndex, float* transform);
uint32_t lovrAnimatorGetAnimationCount(Animator* animator);
uint32_t* lovrAnimatorGetAnimationIndex(Animator* animator, const char* name);
const char* lovrAnimatorGetAnimationName(Animator* animator, uint32_t index);
void lovrAnimatorPlay(Animator* animator, uint32_t animation);
void lovrAnimatorStop(Animator* animator, uint32_t animation);
void lovrAnimatorPause(Animator* animator, uint32_t animation);
void lovrAnimatorResume(Animator* animator, uint32_t animation);
void lovrAnimatorSeek(Animator* animator, uint32_t animation, float time);
float lovrAnimatorTell(Animator* animator, uint32_t animation);
float lovrAnimatorGetAlpha(Animator* animator, uint32_t animation);
void lovrAnimatorSetAlpha(Animator* animator, uint32_t animation, float alpha);
float lovrAnimatorGetDuration(Animator* animator, uint32_t animation);
bool lovrAnimatorIsPlaying(Animator* animator, uint32_t animation);
bool lovrAnimatorIsLooping(Animator* animator, uint32_t animation);
void lovrAnimatorSetLooping(Animator* animator, uint32_t animation, bool loop);
int32_t lovrAnimatorGetPriority(Animator* animator, uint32_t animation);
void lovrAnimatorSetPriority(Animator* animator, uint32_t animation, int32_t priority);
float lovrAnimatorGetSpeed(Animator* animator, uint32_t animation);
void lovrAnimatorSetSpeed(Animator* animator, uint32_t animation, float speed);

View File

@ -28,7 +28,7 @@ Font* lovrFontInit(Font* font, Rasterizer* rasterizer) {
map_init(&font->kerning);
// Atlas
int padding = 1;
uint32_t padding = 1;
font->atlas.x = padding;
font->atlas.y = padding;
font->atlas.width = 128;
@ -228,7 +228,7 @@ void lovrFontSetFlipEnabled(Font* font, bool flip) {
font->flip = flip;
}
int lovrFontGetKerning(Font* font, unsigned int left, unsigned int right) {
int32_t lovrFontGetKerning(Font* font, unsigned int left, unsigned int right) {
char key[12];
snprintf(key, 12, "%d,%d", left, right);
@ -237,7 +237,7 @@ int lovrFontGetKerning(Font* font, unsigned int left, unsigned int right) {
return *entry;
}
int kerning = lovrRasterizerGetKerning(font->rasterizer, left, right);
int32_t kerning = lovrRasterizerGetKerning(font->rasterizer, left, right);
map_set(&font->kerning, key, kerning);
return kerning;
}

View File

@ -23,12 +23,12 @@ typedef enum {
} VerticalAlign;
typedef struct {
int x;
int y;
int width;
int height;
int rowHeight;
int padding;
uint32_t x;
uint32_t y;
uint32_t width;
uint32_t height;
uint32_t rowHeight;
uint32_t padding;
map_glyph_t glyphs;
} FontAtlas;
@ -56,7 +56,7 @@ float lovrFontGetLineHeight(Font* font);
void lovrFontSetLineHeight(Font* font, float lineHeight);
bool lovrFontIsFlipEnabled(Font* font);
void lovrFontSetFlipEnabled(Font* font, bool flip);
int lovrFontGetKerning(Font* font, unsigned int a, unsigned int b);
int32_t lovrFontGetKerning(Font* font, unsigned int a, unsigned int b);
float lovrFontGetPixelDensity(Font* font);
void lovrFontSetPixelDensity(Font* font, float pixelDensity);
Glyph* lovrFontGetGlyph(Font* font, uint32_t codepoint);

View File

@ -13,13 +13,13 @@ Material* lovrMaterialInit(Material* material) {
for (int i = 0; i < MAX_MATERIAL_COLORS; i++) {
if (i == COLOR_EMISSIVE) {
material->colors[i] = (Color) { 0, 0, 0, 0 };
material->colors[i] = (Color) { 0.f, 0.f, 0.f, 0.f };
} else {
material->colors[i] = (Color) { 1, 1, 1, 1 };
material->colors[i] = (Color) { 1.f, 1.f, 1.f, 1.f };
}
}
lovrMaterialSetTransform(material, 0, 0, 1, 1, 0);
lovrMaterialSetTransform(material, 0.f, 0.f, 1.f, 1.f, 0.f);
return material;
}

View File

@ -46,7 +46,7 @@ void lovrMeshDetachAttribute(Mesh* mesh, const char* name) {
memmove(mesh->attributeNames + *index, mesh->attributeNames + *index + 1, (mesh->attributeCount - *index - 1) * MAX_ATTRIBUTE_NAME_LENGTH * sizeof(char));
memmove(mesh->attributes + *index, mesh->attributes + *index + 1, (mesh->attributeCount - *index - 1) * sizeof(MeshAttribute));
mesh->attributeCount--;
for (int i = 0; i < MAX_ATTRIBUTES; i++) {
for (uint32_t i = 0; i < MAX_ATTRIBUTES; i++) {
if (mesh->locations[i] > *index) {
mesh->locations[i]--;
} else if (mesh->locations[i] == *index) {

View File

@ -31,7 +31,7 @@ typedef struct Mesh {
uint16_t enabledLocations;
uint16_t divisors[MAX_ATTRIBUTES];
map_int_t attributeMap;
int attributeCount;
uint32_t attributeCount;
struct Buffer* vertexBuffer;
struct Buffer* indexBuffer;
uint32_t vertexCount;

View File

@ -22,12 +22,12 @@ static void updateGlobalNodeTransform(Model* model, uint32_t nodeIndex, mat4 tra
}
}
static void renderNode(Model* model, uint32_t nodeIndex, int instances) {
static void renderNode(Model* model, uint32_t nodeIndex, uint32_t instances) {
ModelNode* node = &model->data->nodes[nodeIndex];
mat4 globalTransform = model->globalNodeTransforms + 16 * nodeIndex;
if (node->primitiveCount > 0) {
bool animated = node->skin >= 0 && model->animator;
bool animated = node->skin != ~0u && model->animator;
float pose[16 * MAX_BONES];
if (animated) {
@ -48,7 +48,7 @@ static void renderNode(Model* model, uint32_t nodeIndex, int instances) {
for (uint32_t i = 0; i < node->primitiveCount; i++) {
ModelPrimitive* primitive = &model->data->primitives[node->primitiveIndex + i];
Mesh* mesh = model->meshes[node->primitiveIndex + i];
Material* material = primitive->material >= 0 ? model->materials[primitive->material] : NULL;
Material* material = primitive->material == ~0u ? NULL : model->materials[primitive->material];
if (model->userMaterial) {
material = model->userMaterial;
@ -90,12 +90,12 @@ Model* lovrModelInit(Model* model, ModelData* data) {
}
model->meshes = calloc(data->primitiveCount, sizeof(Mesh*));
for (int i = 0; i < data->primitiveCount; i++) {
for (uint32_t i = 0; i < data->primitiveCount; i++) {
ModelPrimitive* primitive = &data->primitives[i];
model->meshes[i] = lovrMeshCreate(primitive->mode, NULL, 0);
bool setDrawRange = false;
for (int j = 0; j < MAX_DEFAULT_ATTRIBUTES; j++) {
for (uint32_t j = 0; j < MAX_DEFAULT_ATTRIBUTES; j++) {
if (primitive->attributes[j]) {
ModelAttribute* attribute = primitive->attributes[j];
@ -152,21 +152,21 @@ Model* lovrModelInit(Model* model, ModelData* data) {
model->textures = calloc(data->textureCount, sizeof(Texture*));
}
for (int i = 0; i < data->materialCount; i++) {
for (uint32_t i = 0; i < data->materialCount; i++) {
Material* material = lovrMaterialCreate();
for (int j = 0; j < MAX_MATERIAL_SCALARS; j++) {
for (uint32_t j = 0; j < MAX_MATERIAL_SCALARS; j++) {
lovrMaterialSetScalar(material, j, data->materials[i].scalars[j]);
}
for (int j = 0; j < MAX_MATERIAL_COLORS; j++) {
for (uint32_t j = 0; j < MAX_MATERIAL_COLORS; j++) {
lovrMaterialSetColor(material, j, data->materials[i].colors[j]);
}
for (int j = 0; j < MAX_MATERIAL_TEXTURES; j++) {
int index = data->materials[i].textures[j];
for (uint32_t j = 0; j < MAX_MATERIAL_TEXTURES; j++) {
uint32_t index = data->materials[i].textures[j];
if (index != -1) {
if (index != ~0u) {
if (!model->textures[index]) {
TextureData* textureData = data->textures[index];
bool srgb = j == TEXTURE_DIFFUSE || j == TEXTURE_EMISSIVE;
@ -184,7 +184,7 @@ Model* lovrModelInit(Model* model, ModelData* data) {
}
model->globalNodeTransforms = malloc(16 * sizeof(float) * model->data->nodeCount);
for (int i = 0; i < model->data->nodeCount; i++) {
for (uint32_t i = 0; i < model->data->nodeCount; i++) {
mat4_identity(model->globalNodeTransforms + 16 * i);
}
@ -193,16 +193,16 @@ Model* lovrModelInit(Model* model, ModelData* data) {
void lovrModelDestroy(void* ref) {
Model* model = ref;
for (int i = 0; i < model->data->bufferCount; i++) {
for (uint32_t i = 0; i < model->data->bufferCount; i++) {
lovrRelease(Buffer, model->buffers[i]);
}
for (int i = 0; i < model->data->primitiveCount; i++) {
for (uint32_t i = 0; i < model->data->primitiveCount; i++) {
lovrRelease(Mesh, model->meshes[i]);
}
lovrRelease(ModelData, model->data);
}
void lovrModelDraw(Model* model, mat4 transform, int instances) {
void lovrModelDraw(Model* model, mat4 transform, uint32_t instances) {
updateGlobalNodeTransform(model, model->data->rootNode, transform);
renderNode(model, model->data->rootNode, instances);
}
@ -229,7 +229,7 @@ void lovrModelSetMaterial(Model* model, Material* material) {
model->userMaterial = material;
}
static void applyAABB(Model* model, int nodeIndex, float aabb[6]) {
static void applyAABB(Model* model, uint32_t nodeIndex, float aabb[6]) {
ModelNode* node = &model->data->nodes[nodeIndex];
for (uint32_t i = 0; i < node->primitiveCount; i++) {

View File

@ -1,3 +1,5 @@
#include <stdint.h>
#pragma once
struct Animator;
@ -21,7 +23,7 @@ typedef struct {
Model* lovrModelInit(Model* model, struct ModelData* data);
#define lovrModelCreate(...) lovrModelInit(lovrAlloc(Model), __VA_ARGS__)
void lovrModelDestroy(void* ref);
void lovrModelDraw(Model* model, float* transform, int instances);
void lovrModelDraw(Model* model, float* transform, uint32_t instances);
struct Animator* lovrModelGetAnimator(Model* model);
void lovrModelSetAnimator(Model* model, struct Animator* animator);
struct Material* lovrModelGetMaterial(Model* model);

View File

@ -505,7 +505,7 @@ static void lovrGpuBindMesh(Mesh* mesh, Shader* shader, int baseDivisor) {
}
uint16_t enabledLocations = 0;
for (int i = 0; i < mesh->attributeCount; i++) {
for (uint32_t i = 0; i < mesh->attributeCount; i++) {
MeshAttribute* attribute;
int location;
@ -537,7 +537,7 @@ static void lovrGpuBindMesh(Mesh* mesh, Shader* shader, int baseDivisor) {
uint16_t diff = enabledLocations ^ mesh->enabledLocations;
if (diff != 0) {
for (int i = 0; i < MAX_ATTRIBUTES; i++) {
for (uint32_t i = 0; i < MAX_ATTRIBUTES; i++) {
if (diff & (1 << i)) {
if (enabledLocations & (1 << i)) {
glEnableVertexAttribArray(i);
@ -2038,7 +2038,7 @@ void lovrMeshDestroy(void* ref) {
Mesh* mesh = ref;
lovrGraphicsFlushMesh(mesh);
glDeleteVertexArrays(1, &mesh->vao);
for (int i = 0; i < mesh->attributeCount; i++) {
for (uint32_t i = 0; i < mesh->attributeCount; i++) {
lovrRelease(Buffer, mesh->attributes[i].buffer);
}
map_deinit(&mesh->attributeMap);

View File

@ -26,7 +26,7 @@ static struct {
double prevCursorY;
} state;
static bool desktop_init(float offset, int msaa) {
static bool desktop_init(float offset, uint32_t msaa) {
state.offset = offset;
state.clipNear = 0.1f;
state.clipFar = 100.f;
@ -69,7 +69,7 @@ static void desktop_getBoundsDimensions(float* width, float* depth) {
*width = *depth = 0.f;
}
static const float* desktop_getBoundsGeometry(int* count) {
static const float* desktop_getBoundsGeometry(uint32_t* count) {
*count = 0;
return NULL;
}

View File

@ -5,13 +5,13 @@ HeadsetInterface* lovrHeadsetDriver = NULL;
HeadsetInterface* lovrHeadsetTrackingDrivers = NULL;
static bool initialized = false;
bool lovrHeadsetInit(HeadsetDriver* drivers, int count, float offset, int msaa) {
bool lovrHeadsetInit(HeadsetDriver* drivers, uint32_t count, float offset, uint32_t msaa) {
if (initialized) return false;
initialized = true;
HeadsetInterface* lastTrackingDriver = NULL;
for (int i = 0; i < count; i++) {
for (uint32_t i = 0; i < count; i++) {
HeadsetInterface* interface = NULL;
switch (drivers[i]) {
@ -77,7 +77,3 @@ void lovrHeadsetDestroy() {
lovrHeadsetDriver = NULL;
}
}
void lovrControllerDestroy(void* ref) {
//
}

View File

@ -90,7 +90,7 @@ typedef enum {
typedef struct HeadsetInterface {
struct HeadsetInterface* next;
HeadsetDriver driverType;
bool (*init)(float offset, int msaa);
bool (*init)(float offset, uint32_t msaa);
void (*destroy)(void);
bool (*getName)(char* name, size_t length);
HeadsetOrigin (*getOriginType)(void);
@ -99,7 +99,7 @@ typedef struct HeadsetInterface {
void (*getClipDistance)(float* clipNear, float* clipFar);
void (*setClipDistance)(float clipNear, float clipFar);
void (*getBoundsDimensions)(float* width, float* depth);
const float* (*getBoundsGeometry)(int* count);
const float* (*getBoundsGeometry)(uint32_t* count);
bool (*getPose)(Device device, float* position, float* orientation);
bool (*getBonePose)(Device device, DeviceBone bone, float* position, float* orientation);
bool (*getVelocity)(Device device, float* velocity, float* angularVelocity);
@ -130,5 +130,5 @@ extern HeadsetInterface* lovrHeadsetTrackingDrivers;
#define FOREACH_TRACKING_DRIVER(i)\
for (HeadsetInterface* i = lovrHeadsetTrackingDrivers; i != NULL; i = i->next)
bool lovrHeadsetInit(HeadsetDriver* drivers, int count, float offset, int msaa);
bool lovrHeadsetInit(HeadsetDriver* drivers, uint32_t count, float offset, uint32_t msaa);
void lovrHeadsetDestroy(void);

View File

@ -40,7 +40,7 @@ static int loop(void* userdata) {
}
static void leap_destroy(void);
static bool leap_init(float offset, int msaa) {
static bool leap_init(float offset, uint32_t msaa) {
if (LeapCreateConnection(NULL, &state.connection) == eLeapRS_Success) {
if (LeapOpenConnection(state.connection) == eLeapRS_Success) {
LeapCreateClockRebaser(&state.clock);

View File

@ -69,7 +69,7 @@ static ovrInputState *refreshButtons() {
return &is;
}
static bool oculus_init(float offset, int msaa) {
static bool oculus_init(float offset, uint32_t msaa) {
ovrResult result = ovr_Initialize(NULL);
if (OVR_FAILURE(result)) {
return false;
@ -158,7 +158,7 @@ static void oculus_getBoundsDimensions(float* width, float* depth) {
*depth = dimensions.z;
}
static const float* oculus_getBoundsGeometry(int* count) {
static const float* oculus_getBoundsGeometry(uint32_t* count) {
*count = 0;
return NULL;
}

View File

@ -25,7 +25,7 @@ static struct {
// Headset driver object
static bool vrapi_init(float offset, int msaa) {
static bool vrapi_init(float offset, uint32_t msaa) {
state.offset = offset;
return true;
}
@ -69,7 +69,7 @@ static void vrapi_getBoundsDimensions(float* width, float* depth) {
*depth = 0.f;
}
static const float* vrapi_getBoundsGeometry(int* count) {
static const float* vrapi_getBoundsGeometry(uint32_t* count) {
*count = 0;
return NULL;
}

View File

@ -111,7 +111,7 @@ static TrackedDeviceIndex_t getDeviceIndex(Device device) {
}
static bool openvr_getName(char* name, size_t length);
static bool openvr_init(float offset, int msaa) {
static bool openvr_init(float offset, uint32_t msaa) {
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
return false;
}
@ -276,7 +276,7 @@ static void openvr_getBoundsDimensions(float* width, float* depth) {
state.chaperone->GetPlayAreaSize(width, depth);
}
static const float* openvr_getBoundsGeometry(int* count) {
static const float* openvr_getBoundsGeometry(uint32_t* count) {
struct HmdQuad_t quad;
if (state.chaperone->GetPlayAreaRect(&quad)) {
vec_clear(&state.boundsGeometry);

View File

@ -191,7 +191,7 @@ static struct {
static void openxr_destroy();
static bool openxr_init(float offset, int msaa) {
static bool openxr_init(float offset, uint32_t msaa) {
{ // Instance
XrInstanceCreateInfo info = {
@ -410,7 +410,7 @@ static void openxr_getBoundsDimensions(float* width, float* depth) {
*depth = bounds.height;
}
static const float* openxr_getBoundsGeometry(int* count) {
static const float* openxr_getBoundsGeometry(uint32_t* count) {
*count = 0;
return NULL;
}

View File

@ -3,7 +3,7 @@
#include <stdbool.h>
// Provided by resources/lovr.js
extern bool webvr_init(float offset, int msaa);
extern bool webvr_init(float offset, uint32_t msaa);
extern void webvr_destroy(void);
extern bool webvr_getName(char* name, size_t length);
extern HeadsetOrigin webvr_getOriginType(void);
@ -11,7 +11,7 @@ extern void webvr_getDisplayDimensions(uint32_t* width, uint32_t* height);
extern void webvr_getClipDistance(float* near, float* far);
extern void webvr_setClipDistance(float near, float far);
extern void webvr_getBoundsDimensions(float* width, float* depth);
extern const float* webvr_getBoundsGeometry(int* count);
extern const float* webvr_getBoundsGeometry(uint32_t* count);
extern bool webvr_getPose(Device device, float* position, float* orientation);
extern bool webvr_getBonePose(Device device, DeviceBone bone, float* position, float* orientation);
extern bool webvr_getVelocity(Device device, float* velocity, float* angularVelocity);