api: more modular helper functions;

This commit is contained in:
bjorn 2018-09-26 17:54:12 -07:00 committed by Bjorn Swenson
parent 1f12717357
commit 792834623c
15 changed files with 41 additions and 26 deletions

View File

@ -1,11 +1,4 @@
#include "luax.h"
#include "data/blob.h"
#include "event/event.h"
#include "graphics/canvas.h"
#include "graphics/mesh.h"
#include "math/math.h"
#include "math/randomGenerator.h"
#include "physics/physics.h"
// Module loaders
int l_lovrInit(lua_State* L);
@ -104,22 +97,3 @@ extern const char* UniformAccesses[];
extern const char* VerticalAligns[];
extern const char* Windings[];
extern const char* WrapModes[];
// Shared helpers
int luax_loadvertices(lua_State* L, int index, VertexFormat* format, VertexPointer vertices);
bool luax_checkvertexformat(lua_State* L, int index, VertexFormat* format);
int luax_pushvertexformat(lua_State* L, VertexFormat* format);
int luax_pushvertexattribute(lua_State* L, VertexPointer* vertex, Attribute attribute);
int luax_pushvertex(lua_State* L, VertexPointer* vertex, VertexFormat* format);
void luax_setvertexattribute(lua_State* L, int index, VertexPointer* vertex, Attribute attribute);
void luax_setvertex(lua_State* L, int index, VertexPointer* vertex, VertexFormat* format);
int luax_readtransform(lua_State* L, int index, mat4 transform, int scaleComponents);
Blob* luax_readblob(lua_State* L, int index, const char* debug);
Seed luax_checkrandomseed(lua_State* L, int index);
void luax_checkvariant(lua_State* L, int index, Variant* variant);
int luax_pushvariant(lua_State* L, Variant* variant);
int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* dest, const char* debug);
void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components);
int luax_optmipmap(lua_State* L, int index, Texture* texture);
Texture* luax_checktexture(lua_State* L, int index);
void luax_readattachments(lua_State* L, int index, Attachment* attachments, int* count);

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/data.h"
#include "data/audioStream.h"
#include "data/modelData.h"
#include "data/rasterizer.h"

11
src/api/data.h Normal file
View File

@ -0,0 +1,11 @@
#include "data/blob.h"
#include "data/vertexData.h"
int luax_loadvertices(lua_State* L, int index, VertexFormat* format, VertexPointer vertices);
bool luax_checkvertexformat(lua_State* L, int index, VertexFormat* format);
int luax_pushvertexformat(lua_State* L, VertexFormat* format);
int luax_pushvertexattribute(lua_State* L, VertexPointer* vertex, Attribute attribute);
int luax_pushvertex(lua_State* L, VertexPointer* vertex, VertexFormat* format);
void luax_setvertexattribute(lua_State* L, int index, VertexPointer* vertex, Attribute attribute);
void luax_setvertex(lua_State* L, int index, VertexPointer* vertex, VertexFormat* format);
Blob* luax_readblob(lua_State* L, int index, const char* debug);

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/event.h"
#include "event/event.h"
const char* EventTypes[] = {

4
src/api/event.h Normal file
View File

@ -0,0 +1,4 @@
#include "event/event.h"
void luax_checkvariant(lua_State* L, int index, Variant* variant);
int luax_pushvariant(lua_State* L, Variant* variant);

View File

@ -1,4 +1,6 @@
#include "api.h"
#include "api/data.h"
#include "api/graphics.h"
#include "graphics/graphics.h"
#include "graphics/animator.h"
#include "graphics/canvas.h"

9
src/api/graphics.h Normal file
View File

@ -0,0 +1,9 @@
#include "graphics/canvas.h"
#include "graphics/shader.h"
#include "graphics/texture.h"
int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* dest, const char* debug);
void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components);
int luax_optmipmap(lua_State* L, int index, Texture* texture);
Texture* luax_checktexture(lua_State* L, int index);
void luax_readattachments(lua_State* L, int index, Attachment* attachments, int* count);

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/math.h"
#include "math/math.h"
#include "math/mat4.h"
#include "math/quat.h"

5
src/api/math.h Normal file
View File

@ -0,0 +1,5 @@
#include "math/mat4.h"
#include "math/randomGenerator.h"
int luax_readtransform(lua_State* L, int index, mat4 transform, int scaleComponents);
Seed luax_checkrandomseed(lua_State* L, int index);

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/event.h"
#include "thread/channel.h"
static void luax_checktimeout(lua_State* L, int index, double* timeout) {

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/data.h"
#include "graphics/graphics.h"
#include <limits.h>

View File

@ -1,5 +1,7 @@
#include "api.h"
#include "api/math.h"
#include "math/randomGenerator.h"
#include <math.h>
static double luax_checkrandomseedpart(lua_State* L, int index) {
double x = luaL_checknumber(L, index);

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/graphics.h"
#include "graphics/shader.h"
#include "math/transform.h"

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/graphics.h"
#include "graphics/shader.h"
#include "math/transform.h"

View File

@ -1,4 +1,5 @@
#include "api.h"
#include "api/data.h"
int luax_loadvertices(lua_State* L, int index, VertexFormat* format, VertexPointer vertices) {
uint32_t count = lua_objlen(L, index);