mirror of https://github.com/bjornbytes/lovr.git
Organize api folder;
This commit is contained in:
parent
79ba7a7ad5
commit
4a47afca38
|
@ -324,7 +324,7 @@ set(LOVR_SRC
|
||||||
src/util.c
|
src/util.c
|
||||||
src/luax.c
|
src/luax.c
|
||||||
src/types.c
|
src/types.c
|
||||||
src/api/lovr.c
|
src/api/l_lovr.c
|
||||||
src/lib/utf.c
|
src/lib/utf.c
|
||||||
src/lib/maf.c
|
src/lib/maf.c
|
||||||
src/lib/map/map.c
|
src/lib/map/map.c
|
||||||
|
@ -363,9 +363,9 @@ if(LOVR_ENABLE_AUDIO)
|
||||||
src/audio/audio.c
|
src/audio/audio.c
|
||||||
src/audio/source.c
|
src/audio/source.c
|
||||||
src/audio/microphone.c
|
src/audio/microphone.c
|
||||||
src/api/audio.c
|
src/api/l_audio.c
|
||||||
src/api/types/source.c
|
src/api/l_source.c
|
||||||
src/api/types/microphone.c
|
src/api/l_microphone.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -380,13 +380,13 @@ if(LOVR_ENABLE_DATA)
|
||||||
src/data/rasterizer.c
|
src/data/rasterizer.c
|
||||||
src/data/soundData.c
|
src/data/soundData.c
|
||||||
src/data/textureData.c
|
src/data/textureData.c
|
||||||
src/api/data.c
|
src/api/l_data.c
|
||||||
src/api/types/audioStream.c
|
src/api/l_audioStream.c
|
||||||
src/api/types/blob.c
|
src/api/l_blob.c
|
||||||
src/api/types/modelData.c
|
src/api/l_modelData.c
|
||||||
src/api/types/rasterizer.c
|
src/api/l_rasterizer.c
|
||||||
src/api/types/soundData.c
|
src/api/l_soundData.c
|
||||||
src/api/types/textureData.c
|
src/api/l_textureData.c
|
||||||
src/lib/stb/stb_image.c
|
src/lib/stb/stb_image.c
|
||||||
src/lib/stb/stb_image_write.c
|
src/lib/stb/stb_image_write.c
|
||||||
src/lib/stb/stb_truetype.c
|
src/lib/stb/stb_truetype.c
|
||||||
|
@ -399,7 +399,7 @@ if(LOVR_ENABLE_EVENT)
|
||||||
add_definitions(-DLOVR_ENABLE_EVENT)
|
add_definitions(-DLOVR_ENABLE_EVENT)
|
||||||
target_sources(lovr PRIVATE
|
target_sources(lovr PRIVATE
|
||||||
src/event/event.c
|
src/event/event.c
|
||||||
src/api/event.c
|
src/api/l_event.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ if(LOVR_ENABLE_FILESYSTEM)
|
||||||
target_sources(lovr PRIVATE
|
target_sources(lovr PRIVATE
|
||||||
src/filesystem/file.c
|
src/filesystem/file.c
|
||||||
src/filesystem/filesystem.c
|
src/filesystem/filesystem.c
|
||||||
src/api/filesystem.c
|
src/api/l_filesystem.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -426,16 +426,16 @@ if(LOVR_ENABLE_GRAPHICS)
|
||||||
src/graphics/opengl.c
|
src/graphics/opengl.c
|
||||||
src/graphics/shader.c
|
src/graphics/shader.c
|
||||||
src/graphics/texture.c
|
src/graphics/texture.c
|
||||||
src/api/graphics.c
|
src/api/l_graphics.c
|
||||||
src/api/types/animator.c
|
src/api/l_animator.c
|
||||||
src/api/types/canvas.c
|
src/api/l_canvas.c
|
||||||
src/api/types/font.c
|
src/api/l_font.c
|
||||||
src/api/types/material.c
|
src/api/l_material.c
|
||||||
src/api/types/mesh.c
|
src/api/l_mesh.c
|
||||||
src/api/types/model.c
|
src/api/l_model.c
|
||||||
src/api/types/shader.c
|
src/api/l_shader.c
|
||||||
src/api/types/shaderBlock.c
|
src/api/l_shaderBlock.c
|
||||||
src/api/types/texture.c
|
src/api/l_texture.c
|
||||||
src/resources/shaders.c
|
src/resources/shaders.c
|
||||||
src/lib/glad/glad.c
|
src/lib/glad/glad.c
|
||||||
)
|
)
|
||||||
|
@ -444,7 +444,7 @@ endif()
|
||||||
if(LOVR_ENABLE_HEADSET)
|
if(LOVR_ENABLE_HEADSET)
|
||||||
add_definitions(-DLOVR_ENABLE_HEADSET)
|
add_definitions(-DLOVR_ENABLE_HEADSET)
|
||||||
target_sources(lovr PRIVATE
|
target_sources(lovr PRIVATE
|
||||||
src/api/headset.c
|
src/api/l_headset.c
|
||||||
src/headset/headset.c
|
src/headset/headset.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -481,13 +481,13 @@ if(LOVR_ENABLE_MATH)
|
||||||
src/math/curve.c
|
src/math/curve.c
|
||||||
src/math/pool.c
|
src/math/pool.c
|
||||||
src/math/randomGenerator.c
|
src/math/randomGenerator.c
|
||||||
src/api/math.c
|
src/api/l_math.c
|
||||||
src/api/types/curve.c
|
src/api/l_curve.c
|
||||||
src/api/types/pool.c
|
src/api/l_pool.c
|
||||||
src/api/types/randomGenerator.c
|
src/api/l_randomGenerator.c
|
||||||
src/api/types/vec3.c
|
src/api/l_vec3.c
|
||||||
src/api/types/quat.c
|
src/api/l_quat.c
|
||||||
src/api/types/mat4.c
|
src/api/l_mat4.c
|
||||||
src/lib/noise1234/noise1234.c
|
src/lib/noise1234/noise1234.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -500,11 +500,11 @@ if(LOVR_ENABLE_PHYSICS)
|
||||||
add_definitions(-DLOVR_ENABLE_PHYSICS)
|
add_definitions(-DLOVR_ENABLE_PHYSICS)
|
||||||
target_sources(lovr PRIVATE
|
target_sources(lovr PRIVATE
|
||||||
src/physics/physics.c
|
src/physics/physics.c
|
||||||
src/api/physics.c
|
src/api/l_physics.c
|
||||||
src/api/types/collider.c
|
src/api/l_collider.c
|
||||||
src/api/types/joints.c
|
src/api/l_joints.c
|
||||||
src/api/types/shapes.c
|
src/api/l_shapes.c
|
||||||
src/api/types/world.c
|
src/api/l_world.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -513,16 +513,16 @@ if(LOVR_ENABLE_THREAD)
|
||||||
target_sources(lovr PRIVATE
|
target_sources(lovr PRIVATE
|
||||||
src/thread/channel.c
|
src/thread/channel.c
|
||||||
src/thread/thread.c
|
src/thread/thread.c
|
||||||
src/api/thread.c
|
src/api/l_thread_module.c
|
||||||
src/api/types/channel.c
|
src/api/l_channel.c
|
||||||
src/api/types/thread.c
|
src/api/l_thread.c
|
||||||
src/lib/tinycthread/tinycthread.c
|
src/lib/tinycthread/tinycthread.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LOVR_ENABLE_TIMER)
|
if(LOVR_ENABLE_TIMER)
|
||||||
add_definitions(-DLOVR_ENABLE_TIMER)
|
add_definitions(-DLOVR_ENABLE_TIMER)
|
||||||
target_sources(lovr PRIVATE src/timer/timer.c src/api/timer.c)
|
target_sources(lovr PRIVATE src/timer/timer.c src/api/l_timer.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LOVR_ENABLE_ENET)
|
if(LOVR_ENABLE_ENET)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "luax.h"
|
#include "luax.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
// Module loaders
|
// Modules
|
||||||
LOVR_EXPORT int luaopen_lovr(lua_State* L);
|
LOVR_EXPORT int luaopen_lovr(lua_State* L);
|
||||||
LOVR_EXPORT int luaopen_lovr_audio(lua_State* L);
|
LOVR_EXPORT int luaopen_lovr_audio(lua_State* L);
|
||||||
LOVR_EXPORT int luaopen_lovr_data(lua_State* L);
|
LOVR_EXPORT int luaopen_lovr_data(lua_State* L);
|
||||||
|
@ -87,3 +87,40 @@ extern const char* UniformAccesses[];
|
||||||
extern const char* VerticalAligns[];
|
extern const char* VerticalAligns[];
|
||||||
extern const char* Windings[];
|
extern const char* Windings[];
|
||||||
extern const char* WrapModes[];
|
extern const char* WrapModes[];
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
|
||||||
|
#ifdef LOVR_ENABLE_DATA
|
||||||
|
struct Blob;
|
||||||
|
struct Blob* luax_readblob(lua_State* L, int index, const char* debug);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOVR_ENABLE_EVENT
|
||||||
|
struct Variant;
|
||||||
|
void luax_checkvariant(lua_State* L, int index, struct Variant* variant);
|
||||||
|
int luax_pushvariant(lua_State* L, struct Variant* variant);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOVR_ENABLE_GRAPHICS
|
||||||
|
struct Attachment;
|
||||||
|
struct Texture;
|
||||||
|
struct Uniform;
|
||||||
|
int luax_checkuniform(lua_State* L, int index, const struct Uniform* uniform, void* dest, const char* debug);
|
||||||
|
int luax_optmipmap(lua_State* L, int index, struct Texture* texture);
|
||||||
|
void luax_readattachments(lua_State* L, int index, struct Attachment* attachments, int* count);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOVR_ENABLE_MATH
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "math/pool.h" // TODO
|
||||||
|
#include "math/randomGenerator.h" // TODO
|
||||||
|
void luax_pushlightmathtype(lua_State* L, float* p, MathType type);
|
||||||
|
float* luax_tomathtype(lua_State* L, int index, MathType* type);
|
||||||
|
float* luax_checkmathtype(lua_State* L, int index, MathType type, const char* expected);
|
||||||
|
float* luax_newmathtype(lua_State* L, MathType type);
|
||||||
|
int luax_readvec3(lua_State* L, int index, float* v, const char* expected);
|
||||||
|
int luax_readscale(lua_State* L, int index, float* v, int components, const char* expected);
|
||||||
|
int luax_readquat(lua_State* L, int index, float* q, const char* expected);
|
||||||
|
int luax_readmat4(lua_State* L, int index, float* m, int scaleComponents);
|
||||||
|
Seed luax_checkrandomseed(lua_State* L, int index);
|
||||||
|
#endif
|
|
@ -1,3 +0,0 @@
|
||||||
#include "data/blob.h"
|
|
||||||
|
|
||||||
Blob* luax_readblob(lua_State* L, int index, const char* debug);
|
|
|
@ -1,4 +0,0 @@
|
||||||
#include "event/event.h"
|
|
||||||
|
|
||||||
void luax_checkvariant(lua_State* L, int index, Variant* variant);
|
|
||||||
int luax_pushvariant(lua_State* L, Variant* variant);
|
|
|
@ -1,9 +0,0 @@
|
||||||
#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);
|
|
|
@ -1,13 +1,15 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/data.h"
|
|
||||||
#include "api/math.h"
|
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
#include "audio/microphone.h"
|
#include "audio/microphone.h"
|
||||||
#include "audio/source.h"
|
#include "audio/source.h"
|
||||||
|
#include "data/blob.h"
|
||||||
#include "data/audioStream.h"
|
#include "data/audioStream.h"
|
||||||
#include "data/soundData.h"
|
#include "data/soundData.h"
|
||||||
|
#include "lib/maf.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct Blob* luax_readblob(lua_State* L, int index, const char* debug);
|
||||||
|
|
||||||
const char* SourceTypes[] = {
|
const char* SourceTypes[] = {
|
||||||
[SOURCE_STATIC] = "static",
|
[SOURCE_STATIC] = "static",
|
||||||
[SOURCE_STREAM] = "stream",
|
[SOURCE_STREAM] = "stream",
|
|
@ -1,18 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/graphics.h"
|
|
||||||
#include "graphics/canvas.h"
|
#include "graphics/canvas.h"
|
||||||
#include "graphics/graphics.h"
|
#include "graphics/graphics.h"
|
||||||
|
|
||||||
Texture* luax_checktexture(lua_State* L, int index) {
|
|
||||||
Canvas* canvas = luax_totype(L, index, Canvas);
|
|
||||||
if (canvas) {
|
|
||||||
const Attachment* attachment = lovrCanvasGetAttachments(canvas, NULL);
|
|
||||||
return attachment->texture;
|
|
||||||
} else {
|
|
||||||
return luax_checktype(L, index, Texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int luax_checkattachment(lua_State* L, int index, Attachment* attachment) {
|
static int luax_checkattachment(lua_State* L, int index, Attachment* attachment) {
|
||||||
if (lua_istable(L, index)) {
|
if (lua_istable(L, index)) {
|
||||||
lua_rawgeti(L, index, 1);
|
lua_rawgeti(L, index, 1);
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/event.h"
|
|
||||||
#include "thread/channel.h"
|
#include "thread/channel.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "math/curve.h"
|
#include "math/curve.h"
|
||||||
|
|
||||||
static int l_lovrCurveEvaluate(lua_State* L) {
|
static int l_lovrCurveEvaluate(lua_State* L) {
|
|
@ -1,6 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/data.h"
|
|
||||||
#include "data/audioStream.h"
|
#include "data/audioStream.h"
|
||||||
|
#include "data/blob.h"
|
||||||
#include "data/modelData.h"
|
#include "data/modelData.h"
|
||||||
#include "data/rasterizer.h"
|
#include "data/rasterizer.h"
|
||||||
#include "data/soundData.h"
|
#include "data/soundData.h"
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/event.h"
|
|
||||||
#include "event/event.h"
|
#include "event/event.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/data.h"
|
|
||||||
#include "filesystem/filesystem.h"
|
#include "filesystem/filesystem.h"
|
||||||
#include "data/blob.h"
|
#include "data/blob.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
|
@ -1,7 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/data.h"
|
|
||||||
#include "api/graphics.h"
|
|
||||||
#include "api/math.h"
|
|
||||||
#include "graphics/graphics.h"
|
#include "graphics/graphics.h"
|
||||||
#include "graphics/animator.h"
|
#include "graphics/animator.h"
|
||||||
#include "graphics/buffer.h"
|
#include "graphics/buffer.h"
|
||||||
|
@ -9,6 +6,7 @@
|
||||||
#include "graphics/material.h"
|
#include "graphics/material.h"
|
||||||
#include "graphics/mesh.h"
|
#include "graphics/mesh.h"
|
||||||
#include "graphics/model.h"
|
#include "graphics/model.h"
|
||||||
|
#include "data/blob.h"
|
||||||
#include "data/modelData.h"
|
#include "data/modelData.h"
|
||||||
#include "data/rasterizer.h"
|
#include "data/rasterizer.h"
|
||||||
#include "data/textureData.h"
|
#include "data/textureData.h"
|
||||||
|
@ -861,7 +859,7 @@ static int l_lovrGraphicsSphere(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_lovrGraphicsSkybox(lua_State* L) {
|
static int l_lovrGraphicsSkybox(lua_State* L) {
|
||||||
Texture* texture = luax_checktexture(L, 1);
|
Texture* texture = luax_checktype(L, 1, Texture);
|
||||||
float angle = luax_optfloat(L, 2, 0.f);
|
float angle = luax_optfloat(L, 2, 0.f);
|
||||||
float ax = luax_optfloat(L, 3, 0.f);
|
float ax = luax_optfloat(L, 3, 0.f);
|
||||||
float ay = luax_optfloat(L, 4, 1.f);
|
float ay = luax_optfloat(L, 4, 1.f);
|
||||||
|
@ -897,7 +895,15 @@ static int l_lovrGraphicsStencil(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_lovrGraphicsFill(lua_State* L) {
|
static int l_lovrGraphicsFill(lua_State* L) {
|
||||||
Texture* texture = lua_isnoneornil(L, 1) ? NULL : luax_checktexture(L, 1);
|
Texture* texture = NULL;
|
||||||
|
if (!lua_isnoneornil(L, 1)) {
|
||||||
|
Canvas* canvas = luax_totype(L, 1, Canvas);
|
||||||
|
if (canvas) {
|
||||||
|
texture = lovrCanvasGetAttachments(canvas, NULL)->texture;
|
||||||
|
} else {
|
||||||
|
texture = luax_checktype(L, 1, Texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
float u = luax_optfloat(L, 2, 0.f);
|
float u = luax_optfloat(L, 2, 0.f);
|
||||||
float v = luax_optfloat(L, 3, 0.f);
|
float v = luax_optfloat(L, 3, 0.f);
|
||||||
float w = luax_optfloat(L, 4, 1.f - u);
|
float w = luax_optfloat(L, 4, 1.f - u);
|
||||||
|
@ -925,6 +931,35 @@ static int l_lovrGraphicsNewAnimator(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components) {
|
||||||
|
size_t length;
|
||||||
|
lovrAssert(lua_type(L, index) == LUA_TSTRING, "Uniform types must be strings, got %s", lua_typename(L, index));
|
||||||
|
const char* type = lua_tolstring(L, index, &length);
|
||||||
|
|
||||||
|
if (!strcmp(type, "float")) {
|
||||||
|
*baseType = UNIFORM_FLOAT;
|
||||||
|
*components = 1;
|
||||||
|
} else if (!strcmp(type, "int")) {
|
||||||
|
*baseType = UNIFORM_INT;
|
||||||
|
*components = 1;
|
||||||
|
} else {
|
||||||
|
int n = type[length - 1] - '0';
|
||||||
|
lovrAssert(n >= 2 && n <= 4, "Unknown uniform type '%s'", type);
|
||||||
|
if (type[0] == 'v' && type[1] == 'e' && type[2] == 'c' && length == 4) {
|
||||||
|
*baseType = UNIFORM_FLOAT;
|
||||||
|
*components = n;
|
||||||
|
} else if (type[0] == 'i' && type[1] == 'v' && type[2] == 'e' && type[3] == 'c' && length == 5) {
|
||||||
|
*baseType = UNIFORM_INT;
|
||||||
|
*components = n;
|
||||||
|
} else if (type[0] == 'm' && type[1] == 'a' && type[2] == 't' && length == 4) {
|
||||||
|
*baseType = UNIFORM_MATRIX;
|
||||||
|
*components = n;
|
||||||
|
} else {
|
||||||
|
lovrThrow("Unknown uniform type '%s'", type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int l_lovrGraphicsNewShaderBlock(lua_State* L) {
|
static int l_lovrGraphicsNewShaderBlock(lua_State* L) {
|
||||||
vec_uniform_t uniforms;
|
vec_uniform_t uniforms;
|
||||||
vec_init(&uniforms);
|
vec_init(&uniforms);
|
||||||
|
@ -1122,7 +1157,7 @@ static int l_lovrGraphicsNewMaterial(lua_State* L) {
|
||||||
lovrRelease(TextureData, textureData);
|
lovrRelease(TextureData, textureData);
|
||||||
lovrRelease(Texture, texture);
|
lovrRelease(Texture, texture);
|
||||||
} else if (lua_isuserdata(L, index)) {
|
} else if (lua_isuserdata(L, index)) {
|
||||||
Texture* texture = luax_checktexture(L, index);
|
Texture* texture = luax_checktype(L, index, Texture);
|
||||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "headset/headset.h"
|
#include "headset/headset.h"
|
||||||
#include "data/modelData.h"
|
#include "data/modelData.h"
|
||||||
#include "graphics/model.h"
|
#include "graphics/model.h"
|
|
@ -1,6 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "math/math.h"
|
#include "math/math.h"
|
||||||
|
#include "math/pool.h"
|
||||||
#include "lib/maf.h"
|
#include "lib/maf.h"
|
||||||
|
|
||||||
int luax_readmat4(lua_State* L, int index, mat4 m, int scaleComponents) {
|
int luax_readmat4(lua_State* L, int index, mat4 m, int scaleComponents) {
|
|
@ -1,6 +1,6 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/graphics.h"
|
|
||||||
#include "graphics/material.h"
|
#include "graphics/material.h"
|
||||||
|
#include "graphics/texture.h"
|
||||||
|
|
||||||
static int l_lovrMaterialGetColor(lua_State* L) {
|
static int l_lovrMaterialGetColor(lua_State* L) {
|
||||||
Material* material = luax_checktype(L, 1, Material);
|
Material* material = luax_checktype(L, 1, Material);
|
||||||
|
@ -59,7 +59,7 @@ static int l_lovrMaterialSetTexture(lua_State* L) {
|
||||||
textureType = luaL_checkoption(L, index, NULL, MaterialTextures);
|
textureType = luaL_checkoption(L, index, NULL, MaterialTextures);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
Texture* texture = lua_isnoneornil(L, index) ? NULL : luax_checktexture(L, index);
|
Texture* texture = lua_isnoneornil(L, index) ? NULL : luax_checktype(L, index, Texture);
|
||||||
lovrMaterialSetTexture(material, textureType, texture);
|
lovrMaterialSetTexture(material, textureType, texture);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -1,10 +1,17 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "api/math.lua.h"
|
|
||||||
#include "math/math.h"
|
#include "math/math.h"
|
||||||
#include "math/curve.h"
|
#include "math/curve.h"
|
||||||
#include "math/pool.h"
|
#include "math/pool.h"
|
||||||
#include "math/randomGenerator.h"
|
#include "math/randomGenerator.h"
|
||||||
|
#include "resources/math.lua.h"
|
||||||
|
|
||||||
|
int l_lovrRandomGeneratorRandom(lua_State* L);
|
||||||
|
int l_lovrRandomGeneratorRandomNormal(lua_State* L);
|
||||||
|
int l_lovrRandomGeneratorGetSeed(lua_State* L);
|
||||||
|
int l_lovrRandomGeneratorSetSeed(lua_State* L);
|
||||||
|
int l_lovrVec3Set(lua_State* L);
|
||||||
|
int l_lovrQuatSet(lua_State* L);
|
||||||
|
int l_lovrMat4Set(lua_State* L);
|
||||||
|
|
||||||
static const char* lovrMathTypeNames[] = {
|
static const char* lovrMathTypeNames[] = {
|
||||||
[MATH_VEC3] = "vec3",
|
[MATH_VEC3] = "vec3",
|
|
@ -1,10 +1,9 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/data.h"
|
|
||||||
#include "api/math.h"
|
|
||||||
#include "graphics/buffer.h"
|
#include "graphics/buffer.h"
|
||||||
#include "graphics/graphics.h"
|
#include "graphics/graphics.h"
|
||||||
#include "graphics/material.h"
|
#include "graphics/material.h"
|
||||||
#include "graphics/mesh.h"
|
#include "graphics/mesh.h"
|
||||||
|
#include "data/blob.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
static int l_lovrMeshAttachAttributes(lua_State* L) {
|
static int l_lovrMeshAttachAttributes(lua_State* L) {
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "graphics/animator.h"
|
#include "graphics/animator.h"
|
||||||
#include "graphics/material.h"
|
#include "graphics/material.h"
|
||||||
#include "graphics/model.h"
|
#include "graphics/model.h"
|
|
@ -1,8 +1,11 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "math/pool.h"
|
#include "math/pool.h"
|
||||||
#include "lib/maf.h"
|
#include "lib/maf.h"
|
||||||
|
|
||||||
|
int l_lovrVec3Set(lua_State* L);
|
||||||
|
int l_lovrQuatSet(lua_State* L);
|
||||||
|
int l_lovrMat4Set(lua_State* L);
|
||||||
|
|
||||||
static int l_lovrPoolVec3(lua_State* L) {
|
static int l_lovrPoolVec3(lua_State* L) {
|
||||||
Pool* pool = luax_checktype(L, 1, Pool);
|
Pool* pool = luax_checktype(L, 1, Pool);
|
||||||
vec3 v = lovrPoolAllocate(pool, MATH_VEC3);
|
vec3 v = lovrPoolAllocate(pool, MATH_VEC3);
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "math/math.h"
|
#include "math/math.h"
|
||||||
|
|
||||||
int luax_readquat(lua_State* L, int index, quat q, const char* expected) {
|
int luax_readquat(lua_State* L, int index, quat q, const char* expected) {
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "math/randomGenerator.h"
|
#include "math/randomGenerator.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/graphics.h"
|
|
||||||
#include "api/math.h"
|
|
||||||
#include "graphics/buffer.h"
|
#include "graphics/buffer.h"
|
||||||
#include "graphics/shader.h"
|
#include "graphics/shader.h"
|
||||||
|
#include "lib/maf.h"
|
||||||
|
|
||||||
struct TempData {
|
struct TempData {
|
||||||
void* data;
|
void* data;
|
||||||
|
@ -183,35 +182,6 @@ int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* des
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components) {
|
|
||||||
size_t length;
|
|
||||||
lovrAssert(lua_type(L, index) == LUA_TSTRING, "Uniform types must be strings, got %s", lua_typename(L, index));
|
|
||||||
const char* type = lua_tolstring(L, index, &length);
|
|
||||||
|
|
||||||
if (!strcmp(type, "float")) {
|
|
||||||
*baseType = UNIFORM_FLOAT;
|
|
||||||
*components = 1;
|
|
||||||
} else if (!strcmp(type, "int")) {
|
|
||||||
*baseType = UNIFORM_INT;
|
|
||||||
*components = 1;
|
|
||||||
} else {
|
|
||||||
int n = type[length - 1] - '0';
|
|
||||||
lovrAssert(n >= 2 && n <= 4, "Unknown uniform type '%s'", type);
|
|
||||||
if (type[0] == 'v' && type[1] == 'e' && type[2] == 'c' && length == 4) {
|
|
||||||
*baseType = UNIFORM_FLOAT;
|
|
||||||
*components = n;
|
|
||||||
} else if (type[0] == 'i' && type[1] == 'v' && type[2] == 'e' && type[3] == 'c' && length == 5) {
|
|
||||||
*baseType = UNIFORM_INT;
|
|
||||||
*components = n;
|
|
||||||
} else if (type[0] == 'm' && type[1] == 'a' && type[2] == 't' && length == 4) {
|
|
||||||
*baseType = UNIFORM_MATRIX;
|
|
||||||
*components = n;
|
|
||||||
} else {
|
|
||||||
lovrThrow("Unknown uniform type '%s'", type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int l_lovrShaderGetType(lua_State* L) {
|
static int l_lovrShaderGetType(lua_State* L) {
|
||||||
Shader* shader = luax_checktype(L, 1, Shader);
|
Shader* shader = luax_checktype(L, 1, Shader);
|
||||||
lua_pushstring(L, ShaderTypes[lovrShaderGetType(shader)]);
|
lua_pushstring(L, ShaderTypes[lovrShaderGetType(shader)]);
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/graphics.h"
|
|
||||||
#include "graphics/buffer.h"
|
#include "graphics/buffer.h"
|
||||||
#include "graphics/shader.h"
|
#include "graphics/shader.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "audio/audio.h"
|
#include "audio/audio.h"
|
||||||
#include "audio/source.h"
|
#include "audio/source.h"
|
||||||
|
#include "lib/maf.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
static int l_lovrSourceGetBitDepth(lua_State* L) {
|
static int l_lovrSourceGetBitDepth(lua_State* L) {
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/graphics.h"
|
|
||||||
#include "graphics/texture.h"
|
#include "graphics/texture.h"
|
||||||
|
|
||||||
int luax_optmipmap(lua_State* L, int index, Texture* texture) {
|
int luax_optmipmap(lua_State* L, int index, Texture* texture) {
|
|
@ -1,5 +1,4 @@
|
||||||
#include "api.h"
|
#include "api.h"
|
||||||
#include "api/math.h"
|
|
||||||
#include "math/math.h"
|
#include "math/math.h"
|
||||||
#include "lib/maf.h"
|
#include "lib/maf.h"
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
#include "lib/maf.h"
|
|
||||||
#include "math/pool.h"
|
|
||||||
#include "math/randomGenerator.h"
|
|
||||||
|
|
||||||
void luax_pushlightmathtype(lua_State* L, float* p, MathType type);
|
|
||||||
float* luax_tomathtype(lua_State* L, int index, MathType* type);
|
|
||||||
float* luax_checkmathtype(lua_State* L, int index, MathType type, const char* expected);
|
|
||||||
float* luax_newmathtype(lua_State* L, MathType type);
|
|
||||||
int luax_readvec3(lua_State* L, int index, vec3 v, const char* expected);
|
|
||||||
int luax_readscale(lua_State* L, int index, vec3 v, int components, const char* expected);
|
|
||||||
int luax_readquat(lua_State* L, int index, quat q, const char* expected);
|
|
||||||
int luax_readmat4(lua_State* L, int index, mat4 m, int scaleComponents);
|
|
||||||
Seed luax_checkrandomseed(lua_State* L, int index);
|
|
||||||
int l_lovrRandomGeneratorRandom(lua_State* L);
|
|
||||||
int l_lovrRandomGeneratorRandomNormal(lua_State* L);
|
|
||||||
int l_lovrRandomGeneratorGetSeed(lua_State* L);
|
|
||||||
int l_lovrRandomGeneratorSetSeed(lua_State* L);
|
|
||||||
int l_lovrVec3Set(lua_State* L);
|
|
||||||
int l_lovrQuatSet(lua_State* L);
|
|
||||||
int l_lovrMat4Set(lua_State* L);
|
|
|
@ -30,7 +30,7 @@ typedef union {
|
||||||
struct Ref* ref;
|
struct Ref* ref;
|
||||||
} VariantValue;
|
} VariantValue;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct Variant {
|
||||||
VariantType type;
|
VariantType type;
|
||||||
VariantValue value;
|
VariantValue value;
|
||||||
} Variant;
|
} Variant;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
struct Texture;
|
struct Texture;
|
||||||
struct TextureData;
|
struct TextureData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct Attachment {
|
||||||
struct Texture* texture;
|
struct Texture* texture;
|
||||||
int slice;
|
int slice;
|
||||||
int level;
|
int level;
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef struct {
|
||||||
UniformAccess access;
|
UniformAccess access;
|
||||||
} Image;
|
} Image;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct Uniform {
|
||||||
char name[LOVR_MAX_UNIFORM_LENGTH];
|
char name[LOVR_MAX_UNIFORM_LENGTH];
|
||||||
UniformType type;
|
UniformType type;
|
||||||
int components;
|
int components;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "resources/boot.lua.h"
|
#include "resources/boot.lua.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "api.h"
|
#include "api/api.h"
|
||||||
#include "luax.h"
|
#include "luax.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
Loading…
Reference in New Issue