mirror of https://github.com/bjornbytes/lovr.git
Style;
This commit is contained in:
parent
e1f5ed4641
commit
b7d1b1e5dc
|
@ -28,6 +28,10 @@ Buffer* lovrBufferCreate(int size, BufferFormat* format, BufferDrawMode drawMode
|
|||
stride += attribute.count * sizeof(attribute.type);
|
||||
}
|
||||
|
||||
if (stride == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer->size = size;
|
||||
buffer->stride = stride;
|
||||
buffer->data = malloc(buffer->size * buffer->stride);
|
||||
|
@ -155,8 +159,8 @@ void lovrBufferGetVertex(Buffer* buffer, int index, void* dest) {
|
|||
memcpy(dest, (char*) buffer->data + index * buffer->stride, buffer->stride);
|
||||
}
|
||||
|
||||
void lovrBufferSetVertex(Buffer* buffer, int index, void* data) {
|
||||
memcpy((char*) buffer->data + index * buffer->stride, data, buffer->stride);
|
||||
void lovrBufferSetVertex(Buffer* buffer, int index, void* vertex) {
|
||||
memcpy((char*) buffer->data + index * buffer->stride, vertex, buffer->stride);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, buffer->size * buffer->stride, buffer->data, buffer->usage);
|
||||
}
|
||||
|
@ -200,13 +204,13 @@ void lovrBufferGetDrawRange(Buffer* buffer, int* start, int* count) {
|
|||
*count = buffer->rangeCount;
|
||||
}
|
||||
|
||||
int lovrBufferSetDrawRange(Buffer* buffer, int rangeStart, int rangeCount) {
|
||||
if (rangeStart < 0 || rangeCount < 0 || rangeStart + rangeCount > buffer->size) {
|
||||
int lovrBufferSetDrawRange(Buffer* buffer, int start, int count) {
|
||||
if (start < 0 || count < 0 || start + count > buffer->size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
buffer->rangeStart = rangeStart;
|
||||
buffer->rangeCount = rangeCount;
|
||||
buffer->rangeStart = start;
|
||||
buffer->rangeCount = count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -148,9 +148,9 @@ void lovrModelDataDestroy(ModelData* modelData) {
|
|||
free(modelData);
|
||||
}
|
||||
|
||||
void lovrModelDraw(Model* model, float x, float y, float z, float size, float angle, float ax, float ay, float az) {
|
||||
void lovrModelDraw(Model* model, float x, float y, float z, float scale, float angle, float ax, float ay, float az) {
|
||||
lovrGraphicsPush();
|
||||
lovrGraphicsTransform(x, y, z, size, size, size, angle, ax, ay, az);
|
||||
lovrGraphicsTransform(x, y, z, scale, scale, scale, angle, ax, ay, az);
|
||||
lovrBufferDraw(model->buffer);
|
||||
lovrGraphicsPop();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ extern const char* lovrDefaultFragmentShader;
|
|||
extern const char* lovrSkyboxVertexShader;
|
||||
extern const char* lovrSkyboxFragmentShader;
|
||||
|
||||
GLuint compileShader(GLuint type, const char* filename);
|
||||
GLuint compileShader(GLuint type, const char* source);
|
||||
GLuint linkShaders(GLuint vertexShader, GLuint fragmentShader);
|
||||
|
||||
Shader* lovrShaderCreate(const char* vertexSource, const char* fragmentSource);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <vendor/vec/vec.h>
|
||||
|
||||
#ifndef LOVR_HEADSET_TYPES
|
||||
#define LOVR_HEADSET_TYPES
|
||||
|
||||
|
@ -30,6 +32,8 @@ typedef struct {
|
|||
ControllerHand hand;
|
||||
} Controller;
|
||||
|
||||
typedef vec_t(Controller) vec_controller_t;
|
||||
|
||||
typedef struct {
|
||||
char (*isPresent)(void* headset);
|
||||
const char* (*getType)(void* headset);
|
||||
|
@ -69,7 +73,7 @@ float lovrHeadsetGetBoundsWidth();
|
|||
float lovrHeadsetGetBoundsDepth();
|
||||
void lovrHeadsetGetBoundsGeometry(float* geometry);
|
||||
char lovrHeadsetIsBoundsVisible();
|
||||
void lovrHeadsetSetBoundsVisible(char isVisible);
|
||||
void lovrHeadsetSetBoundsVisible(char visible);
|
||||
void lovrHeadsetGetPosition(float* x, float* y, float* z);
|
||||
void lovrHeadsetGetOrientation(float* w, float* x, float* y, float* z);
|
||||
void lovrHeadsetGetVelocity(float* x, float* y, float* z);
|
||||
|
|
|
@ -51,7 +51,7 @@ void viveGetBoundsGeometry(void* headset, float* geometry);
|
|||
char viveIsBoundsVisible(void* headset);
|
||||
void viveSetBoundsVisible(void* headset, char visible);
|
||||
void viveGetPosition(void* headset, float* x, float* y, float* z);
|
||||
void viveGetOrientation(void* headset, float* x, float* y, float* z, float* w);
|
||||
void viveGetOrientation(void* headset, float* w, float* x, float* y, float* z);
|
||||
void viveGetVelocity(void* headset, float* x, float* y, float* z);
|
||||
void viveGetAngularVelocity(void* headset, float* x, float* y, float* z);
|
||||
Controller* viveGetController(void* headset, ControllerHand hand);
|
||||
|
|
|
@ -26,10 +26,10 @@ TextureData* lovrTextureDataFromFile(void* data, int size) {
|
|||
if (image) {
|
||||
textureData->data = image;
|
||||
return textureData;
|
||||
} else {
|
||||
free(textureData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
free(textureData);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TextureData* lovrTextureDataFromOpenVRModel(OpenVRModel* vrModel) {
|
||||
|
|
|
@ -264,16 +264,18 @@ int l_lovrBufferSetVertexMap(lua_State* L) {
|
|||
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
int count = lua_objlen(L, 2);
|
||||
unsigned int* indices = malloc(count * sizeof(int));
|
||||
unsigned int* indices = malloc(count * sizeof(unsigned int));
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
lua_rawgeti(L, 2, i + 1);
|
||||
if (!lua_isnumber(L, -1)) {
|
||||
free(indices);
|
||||
return luaL_error(L, "Buffer vertex map index #%d must be numeric", i);
|
||||
}
|
||||
|
||||
int index = lua_tointeger(L, -1);
|
||||
if (index > buffer->size || index < 0) {
|
||||
free(indices);
|
||||
return luaL_error(L, "Invalid vertex map value: %d", index);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,4 +22,4 @@ mat4 mat4_rotate(mat4 matrix, float w, float x, float y, float z);
|
|||
mat4 mat4_scale(mat4 matrix, float x, float y, float z);
|
||||
mat4 mat4_multiply(mat4 a, mat4 b);
|
||||
void mat4_multiplyVector(mat4 m, float* v);
|
||||
mat4 mat4_invert(mat4 matrix);
|
||||
mat4 mat4_invert(mat4 m);
|
||||
|
|
Loading…
Reference in New Issue