mirror of https://github.com/bjornbytes/lovr.git
Windows: Fix all the int warnings;
This commit is contained in:
parent
c384d54aa5
commit
7690db28af
|
@ -7,7 +7,7 @@
|
|||
|
||||
static int l_lovrAudioStreamDecode(lua_State* L) {
|
||||
AudioStream* stream = luax_checktype(L, 1, AudioStream);
|
||||
int samples = lovrAudioStreamDecode(stream, NULL, 0);
|
||||
size_t samples = lovrAudioStreamDecode(stream, NULL, 0);
|
||||
if (samples > 0) {
|
||||
SoundData* soundData = lovrSoundDataCreate(samples / stream->channelCount, stream->sampleRate, stream->bitDepth, stream->channelCount);
|
||||
memcpy(soundData->blob.data, stream->buffer, samples * (stream->bitDepth / 8));
|
||||
|
|
|
@ -33,10 +33,10 @@ static int l_lovrColliderGetShapes(lua_State* L) {
|
|||
Collider* collider = luax_checktype(L, 1, Collider);
|
||||
size_t count;
|
||||
Shape** shapes = lovrColliderGetShapes(collider, &count);
|
||||
lua_createtable(L, count, 0);
|
||||
lua_createtable(L, (int) count, 0);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
luax_pushshape(L, shapes[i]);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
lua_rawseti(L, -2, (int) i + 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ static int l_lovrColliderGetJoints(lua_State* L) {
|
|||
Collider* collider = luax_checktype(L, 1, Collider);
|
||||
size_t count;
|
||||
Joint** joints = lovrColliderGetJoints(collider, &count);
|
||||
lua_createtable(L, count, 0);
|
||||
lua_createtable(L, (int) count, 0);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
luax_pushjoint(L, joints[i]);
|
||||
lua_rawseti(L, -2, i + 1);
|
||||
lua_rawseti(L, -2, (int) i + 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ static int l_lovrGraphicsGetStats(lua_State* L) {
|
|||
lua_setfield(L, 1, "drawcalls");
|
||||
lua_pushinteger(L, stats->shaderSwitches);
|
||||
lua_setfield(L, 1, "shaderswitches");
|
||||
lua_createtable(L, 0, stats->timers.length);
|
||||
lua_createtable(L, 0, (int) stats->timers.length);
|
||||
for (size_t i = 0; i < stats->timers.length; i++) {
|
||||
lua_pushstring(L, stats->timers.data[i].label);
|
||||
lua_pushnumber(L, stats->timers.data[i].time);
|
||||
|
|
|
@ -409,7 +409,7 @@ int l_lovrHeadsetIsTouched(lua_State* L) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static const size_t axisCounts[MAX_AXES] = {
|
||||
static const int axisCounts[MAX_AXES] = {
|
||||
[AXIS_TRIGGER] = 1,
|
||||
[AXIS_PINCH] = 1,
|
||||
[AXIS_GRIP] = 1,
|
||||
|
@ -420,7 +420,7 @@ static const size_t axisCounts[MAX_AXES] = {
|
|||
int l_lovrHeadsetGetAxis(lua_State* L) {
|
||||
Device device = luax_optdevice(L, 1);
|
||||
DeviceAxis axis = luaL_checkoption(L, 2, NULL, DeviceAxes);
|
||||
size_t count = axisCounts[axis];
|
||||
int count = axisCounts[axis];
|
||||
float value[4];
|
||||
FOREACH_TRACKING_DRIVER(driver) {
|
||||
if (driver->getAxis(device, axis, value)) {
|
||||
|
|
|
@ -29,7 +29,7 @@ static int l_lovrSourceGetCone(lua_State* L) {
|
|||
static int l_lovrSourceGetDuration(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
TimeUnit unit = luaL_checkoption(L, 2, "seconds", TimeUnits);
|
||||
int duration = lovrSourceGetDuration(source);
|
||||
size_t duration = lovrSourceGetDuration(source);
|
||||
|
||||
if (unit == UNIT_SECONDS) {
|
||||
lua_pushnumber(L, (float) duration / lovrSourceGetSampleRate(source));
|
||||
|
@ -279,7 +279,7 @@ static int l_lovrSourceStop(lua_State* L) {
|
|||
static int l_lovrSourceTell(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
TimeUnit unit = luaL_checkoption(L, 2, "seconds", TimeUnits);
|
||||
int offset = lovrSourceTell(source);
|
||||
size_t offset = lovrSourceTell(source);
|
||||
|
||||
if (unit == UNIT_SECONDS) {
|
||||
lua_pushnumber(L, (float) offset / lovrSourceGetSampleRate(source));
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
#ifndef EMSCRIPTEN
|
||||
#ifdef _WIN32
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#define GLFW_EXPOSE_NATIVE_WGL
|
||||
#endif
|
||||
#include <GLFW/glfw3native.h>
|
||||
#endif
|
||||
|
||||
|
@ -235,10 +239,10 @@ bool lovrPlatformIsKeyDown(KeyCode key) {
|
|||
|
||||
#ifdef _WIN32
|
||||
HANDLE lovrPlatformGetWindow() {
|
||||
return (HANDLE) glfwGetWin32Window();
|
||||
return (HANDLE) glfwGetWin32Window(state.window);
|
||||
}
|
||||
|
||||
HGLRC lovrPlatformGetContext() {
|
||||
return glfwGetWGLContext();
|
||||
return glfwGetWGLContext(state.window);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@ struct Microphone {
|
|||
|
||||
Microphone* lovrMicrophoneCreate(const char* name, size_t samples, uint32_t sampleRate, uint32_t bitDepth, uint32_t channelCount) {
|
||||
Microphone* microphone = lovrAlloc(Microphone);
|
||||
ALCdevice* device = alcCaptureOpenDevice(name, sampleRate, lovrAudioConvertFormat(bitDepth, channelCount), samples);
|
||||
ALCdevice* device = alcCaptureOpenDevice(name, sampleRate, lovrAudioConvertFormat(bitDepth, channelCount), (ALCsizei) samples);
|
||||
lovrAssert(device, "Error opening capture device for microphone '%s'", name);
|
||||
microphone->device = device;
|
||||
microphone->name = name ? name : alcGetString(device, ALC_CAPTURE_DEVICE_SPECIFIER);
|
||||
|
@ -52,7 +52,7 @@ SoundData* lovrMicrophoneGetData(Microphone* microphone) {
|
|||
}
|
||||
|
||||
SoundData* soundData = lovrSoundDataCreate(samples, microphone->sampleRate, microphone->bitDepth, microphone->channelCount);
|
||||
alcCaptureSamples(microphone->device, soundData->blob.data, samples);
|
||||
alcCaptureSamples(microphone->device, soundData->blob.data, (ALCsizei) samples);
|
||||
return soundData;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,10 +304,10 @@ void lovrSourceStream(Source* source, ALuint* buffers, size_t count) {
|
|||
|
||||
// Keep decoding until there is nothing left to decode or all the buffers are filled
|
||||
while (n < count && (samples = lovrAudioStreamDecode(stream, NULL, 0)) != 0) {
|
||||
alBufferData(buffers[n++], format, stream->buffer, samples * sizeof(ALshort), frequency);
|
||||
alBufferData(buffers[n++], format, stream->buffer, (ALsizei) (samples * sizeof(ALshort)), frequency);
|
||||
}
|
||||
|
||||
alSourceQueueBuffers(source->id, n, buffers);
|
||||
alSourceQueueBuffers(source->id, (ALsizei) n, buffers);
|
||||
|
||||
if (samples == 0 && source->isLooping && n < count) {
|
||||
lovrAudioStreamRewind(stream);
|
||||
|
|
|
@ -39,7 +39,7 @@ size_t lovrAudioStreamDecode(AudioStream* stream, int16_t* destination, size_t s
|
|||
size_t samples = 0;
|
||||
|
||||
while (samples < capacity) {
|
||||
int count = stb_vorbis_get_samples_short_interleaved(decoder, channelCount, buffer + samples, capacity - samples);
|
||||
int count = stb_vorbis_get_samples_short_interleaved(decoder, channelCount, buffer + samples, (int) (capacity - samples));
|
||||
if (count == 0) break;
|
||||
samples += count * channelCount;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void lovrAudioStreamRewind(AudioStream* stream) {
|
|||
|
||||
void lovrAudioStreamSeek(AudioStream* stream, size_t sample) {
|
||||
stb_vorbis* decoder = (stb_vorbis*) stream->decoder;
|
||||
stb_vorbis_seek(decoder, sample);
|
||||
stb_vorbis_seek(decoder, (int) sample);
|
||||
}
|
||||
|
||||
size_t lovrAudioStreamTell(AudioStream* stream) {
|
||||
|
|
|
@ -35,7 +35,7 @@ static void parseMtl(char* path, arr_texturedata_t* textures, arr_material_t* ma
|
|||
char name[128];
|
||||
bool hasName = sscanf(s + 7, "%s\n%n", name, &lineLength);
|
||||
lovrAssert(hasName, "Bad OBJ: Expected a material name");
|
||||
map_set(names, name, materials->length);
|
||||
map_set(names, name, (int) materials->length);
|
||||
arr_push(materials, ((ModelMaterial) {
|
||||
.scalars[SCALAR_METALNESS] = 1.f,
|
||||
.scalars[SCALAR_ROUGHNESS] = 1.f,
|
||||
|
@ -66,7 +66,7 @@ static void parseMtl(char* path, arr_texturedata_t* textures, arr_material_t* ma
|
|||
TextureData* texture = lovrTextureDataCreateFromBlob(blob, true);
|
||||
lovrAssert(materials->length > 0, "Tried to set a material property without declaring a material first");
|
||||
ModelMaterial* material = &materials->data[materials->length - 1];
|
||||
material->textures[TEXTURE_DIFFUSE] = textures->length;
|
||||
material->textures[TEXTURE_DIFFUSE] = (uint32_t) textures->length;
|
||||
material->filters[TEXTURE_DIFFUSE].mode = FILTER_TRILINEAR;
|
||||
material->wraps[TEXTURE_DIFFUSE] = (TextureWrap) { .s = WRAP_REPEAT, .t = WRAP_REPEAT };
|
||||
arr_push(textures, texture);
|
||||
|
@ -153,7 +153,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source) {
|
|||
arr_push(&indexBlob, *index);
|
||||
} else {
|
||||
int v, vt, vn;
|
||||
int newIndex = vertexBlob.length / 8;
|
||||
int newIndex = (int) vertexBlob.length / 8;
|
||||
arr_push(&indexBlob, newIndex);
|
||||
map_set(&vertexMap, s, newIndex);
|
||||
|
||||
|
@ -227,11 +227,11 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source) {
|
|||
|
||||
model->blobCount = 2;
|
||||
model->bufferCount = 2;
|
||||
model->attributeCount = 3 + groups.length;
|
||||
model->primitiveCount = groups.length;
|
||||
model->attributeCount = 3 + (uint32_t) groups.length;
|
||||
model->primitiveCount = (uint32_t) groups.length;
|
||||
model->nodeCount = 1;
|
||||
model->textureCount = textures.length;
|
||||
model->materialCount = materials.length;
|
||||
model->textureCount = (uint32_t) textures.length;
|
||||
model->materialCount = (uint32_t) materials.length;
|
||||
lovrModelDataAllocate(model);
|
||||
|
||||
model->blobs[0] = lovrBlobCreate(vertexBlob.data, vertexBlob.length * sizeof(float), "obj vertex data");
|
||||
|
@ -255,7 +255,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source) {
|
|||
model->attributes[0] = (ModelAttribute) {
|
||||
.buffer = 0,
|
||||
.offset = 0,
|
||||
.count = vertexBlob.length / 8,
|
||||
.count = (uint32_t)vertexBlob.length / 8,
|
||||
.type = F32,
|
||||
.components = 3
|
||||
};
|
||||
|
@ -263,7 +263,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source) {
|
|||
model->attributes[1] = (ModelAttribute) {
|
||||
.buffer = 0,
|
||||
.offset = 3 * sizeof(float),
|
||||
.count = vertexBlob.length / 8,
|
||||
.count = (uint32_t) vertexBlob.length / 8,
|
||||
.type = F32,
|
||||
.components = 3
|
||||
};
|
||||
|
@ -271,7 +271,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source) {
|
|||
model->attributes[2] = (ModelAttribute) {
|
||||
.buffer = 0,
|
||||
.offset = 6 * sizeof(float),
|
||||
.count = vertexBlob.length / 8,
|
||||
.count = (uint32_t) vertexBlob.length / 8,
|
||||
.type = F32,
|
||||
.components = 2
|
||||
};
|
||||
|
@ -304,7 +304,7 @@ ModelData* lovrModelDataInitObj(ModelData* model, Blob* source) {
|
|||
model->nodes[0] = (ModelNode) {
|
||||
.transform = MAT4_IDENTITY,
|
||||
.primitiveIndex = 0,
|
||||
.primitiveCount = groups.length,
|
||||
.primitiveCount = (uint32_t) groups.length,
|
||||
.skin = ~0u,
|
||||
.matrix = true
|
||||
};
|
||||
|
|
|
@ -28,9 +28,9 @@ SoundData* lovrSoundDataInitFromAudioStream(SoundData* soundData, AudioStream* a
|
|||
|
||||
size_t samples;
|
||||
int16_t* buffer = soundData->blob.data;
|
||||
int offset = 0;
|
||||
size_t offset = 0;
|
||||
lovrAudioStreamRewind(audioStream);
|
||||
while ((samples = lovrAudioStreamDecode(audioStream, buffer + offset, (int) soundData->blob.size - (offset * sizeof(int16_t)))) != 0) {
|
||||
while ((samples = lovrAudioStreamDecode(audioStream, buffer + offset, soundData->blob.size - (offset * sizeof(int16_t)))) != 0) {
|
||||
offset += samples;
|
||||
}
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ bool lovrTextureDataEncode(TextureData* textureData, const char* filename) {
|
|||
int width = textureData->width;
|
||||
int height = textureData->height;
|
||||
void* data = (uint8_t*) textureData->blob.data + (textureData->height - 1) * textureData->width * components;
|
||||
int stride = -textureData->width * components;
|
||||
int stride = -1 * (int) (textureData->width * components);
|
||||
bool success = stbi_write_png_to_func(writeCallback, &file, width, height, components, data, stride);
|
||||
lovrFileDestroy(&file);
|
||||
return success;
|
||||
|
|
|
@ -270,7 +270,7 @@ void lovrModelAnimate(Model* model, uint32_t animationIndex, float time, float a
|
|||
lerp(property, channel->data + keyframe * n, z);
|
||||
break;
|
||||
case SMOOTH_CUBIC: {
|
||||
int stride = 3 * n;
|
||||
size_t stride = 3 * n;
|
||||
float* p0 = channel->data + (keyframe - 1) * stride + 1 * n;
|
||||
float* m0 = channel->data + (keyframe - 1) * stride + 2 * n;
|
||||
float* p1 = channel->data + (keyframe - 0) * stride + 1 * n;
|
||||
|
|
|
@ -1463,11 +1463,11 @@ void lovrTextureReplacePixels(Texture* texture, TextureData* textureData, uint32
|
|||
switch (texture->type) {
|
||||
case TEXTURE_2D:
|
||||
case TEXTURE_CUBE:
|
||||
glCompressedTexImage2D(binding, i, glInternalFormat, m->width, m->height, 0, m->size, m->data);
|
||||
glCompressedTexImage2D(binding, i, glInternalFormat, m->width, m->height, 0, (GLsizei) m->size, m->data);
|
||||
break;
|
||||
case TEXTURE_ARRAY:
|
||||
case TEXTURE_VOLUME:
|
||||
glCompressedTexSubImage3D(binding, i, x, y, slice, m->width, m->height, 1, glInternalFormat, m->size, m->data);
|
||||
glCompressedTexSubImage3D(binding, i, x, y, slice, m->width, m->height, 1, glInternalFormat, (GLsizei) m->size, m->data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2020,7 +2020,7 @@ static void lovrShaderSetupUniforms(Shader* shader) {
|
|||
offset += uniform.components * (uniform.type == UNIFORM_MATRIX ? uniform.components : 1);
|
||||
}
|
||||
|
||||
map_set(&shader->uniformMap, uniform.name, shader->uniforms.length);
|
||||
map_set(&shader->uniformMap, uniform.name, (int) shader->uniforms.length);
|
||||
arr_push(&shader->uniforms, uniform);
|
||||
textureSlot += uniform.type == UNIFORM_SAMPLER ? uniform.count : 0;
|
||||
imageSlot += uniform.type == UNIFORM_IMAGE ? uniform.count : 0;
|
||||
|
|
|
@ -85,7 +85,7 @@ bool lovrShaderHasUniform(Shader* shader, const char* name) {
|
|||
}
|
||||
|
||||
const Uniform* lovrShaderGetUniform(Shader* shader, const char* name) {
|
||||
int* index = map_get(&shader->uniformMap, name);
|
||||
size_t* index = map_get(&shader->uniformMap, name);
|
||||
if (!index) {
|
||||
return false;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ const Uniform* lovrShaderGetUniform(Shader* shader, const char* name) {
|
|||
}
|
||||
|
||||
static void lovrShaderSetUniform(Shader* shader, const char* name, UniformType type, void* data, int start, int count, int size, const char* debug) {
|
||||
int* index = map_get(&shader->uniformMap, name);
|
||||
size_t* index = map_get(&shader->uniformMap, name);
|
||||
if (!index) {
|
||||
return;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ char* lovrShaderBlockGetShaderCode(ShaderBlock* block, const char* blockName, si
|
|||
}
|
||||
|
||||
const Uniform* lovrShaderBlockGetUniform(ShaderBlock* block, const char* name) {
|
||||
int* index = map_get(&block->uniformMap, name);
|
||||
size_t* index = map_get(&block->uniformMap, name);
|
||||
if (!index) return NULL;
|
||||
|
||||
return &block->uniforms.data[*index];
|
||||
|
|
|
@ -95,7 +95,7 @@ typedef arr_t(Uniform, 8) arr_uniform_t;
|
|||
typedef struct {
|
||||
BlockType type;
|
||||
arr_uniform_t uniforms;
|
||||
map_int_t uniformMap;
|
||||
map_t(size_t) uniformMap;
|
||||
struct Buffer* buffer;
|
||||
} ShaderBlock;
|
||||
|
||||
|
@ -115,7 +115,7 @@ typedef struct Shader {
|
|||
arr_uniform_t uniforms;
|
||||
arr_block_t blocks[2];
|
||||
map_int_t attributes;
|
||||
map_int_t uniformMap;
|
||||
map_t(size_t) uniformMap;
|
||||
map_int_t blockMap;
|
||||
bool multiview;
|
||||
GPU_SHADER_FIELDS
|
||||
|
|
|
@ -5,13 +5,13 @@ HeadsetInterface* lovrHeadsetDriver = NULL;
|
|||
HeadsetInterface* lovrHeadsetTrackingDrivers = NULL;
|
||||
static bool initialized = false;
|
||||
|
||||
bool lovrHeadsetInit(HeadsetDriver* drivers, uint32_t count, float offset, uint32_t msaa) {
|
||||
bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float offset, uint32_t msaa) {
|
||||
if (initialized) return false;
|
||||
initialized = true;
|
||||
|
||||
HeadsetInterface* lastTrackingDriver = NULL;
|
||||
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
HeadsetInterface* interface = NULL;
|
||||
|
||||
switch (drivers[i]) {
|
||||
|
|
|
@ -125,5 +125,5 @@ extern HeadsetInterface* lovrHeadsetTrackingDrivers;
|
|||
#define FOREACH_TRACKING_DRIVER(i)\
|
||||
for (HeadsetInterface* i = lovrHeadsetTrackingDrivers; i != NULL; i = i->next)
|
||||
|
||||
bool lovrHeadsetInit(HeadsetDriver* drivers, uint32_t count, float offset, uint32_t msaa);
|
||||
bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float offset, uint32_t msaa);
|
||||
void lovrHeadsetDestroy(void);
|
||||
|
|
|
@ -233,7 +233,7 @@ static void openvr_destroy(void) {
|
|||
|
||||
static bool openvr_getName(char* name, size_t length) {
|
||||
ETrackedPropertyError error;
|
||||
state.system->GetStringTrackedDeviceProperty(HEADSET, ETrackedDeviceProperty_Prop_ManufacturerName_String, name, length, &error);
|
||||
state.system->GetStringTrackedDeviceProperty(HEADSET, ETrackedDeviceProperty_Prop_ManufacturerName_String, name, (uint32_t) length, &error);
|
||||
return error == ETrackedPropertyError_TrackedProp_Success;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ Vector lovrPoolAllocate(Pool* pool, VectorType type, float** data) {
|
|||
if (pool->cursor + count > pool->count - 4) { // Leave 4 floats of padding for alignment adjustment
|
||||
lovrPoolGrow(pool, pool->count * 2);
|
||||
}
|
||||
Vector v = { type, pool->generation, pool->cursor };
|
||||
Vector v = { type, (uint8_t) pool->generation, (uint16_t) pool->cursor };
|
||||
if (data) {
|
||||
*data = pool->floats + pool->cursor;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue