summaryrefslogtreecommitdiff
path: root/include/lua_core.h
blob: 405f054e74314c77a569e176b51b1dfd5b19cb37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#pragma once

// Function specifiers in case library is build/used as a shared library
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
// NOTE: visibility("default") attribute makes symbols "visible" when compiled with -fvisibility=hidden
#if defined( _WIN32 )
    #if defined( __TINYC__ )
        #define __declspec(x) __attribute__( (x) )
    #endif
    #if defined( EXPOSE_API_SYMBOLS )
        #define REILUAPI __declspec( dllexport )     // We are building the library as a Win32 shared library (.dll)
    #elif defined( USE_LIBTYPE_SHARED )
        #define REILUAPI __declspec( dllimport )     // We are using the library as a Win32 shared library (.dll)
    #endif
#else
    #if defined( EXPOSE_API_SYMBOLS )
        #define REILUAPI __attribute__( ( visibility( "default" ) ) ) // We are building as a Unix shared library (.so/.dylib)
    #endif
#endif

#ifndef REILUAPI
    #define REILUAPI       // Functions defined as 'extern' by default (implicit specifiers)
#endif

enum BufferType {
	BUFFER_UNSIGNED_CHAR,
	BUFFER_UNSIGNED_SHORT,
	BUFFER_UNSIGNED_INT,
	BUFFER_UNSIGNED_LONG,
	BUFFER_CHAR,
	BUFFER_SHORT,
	BUFFER_INT,
	BUFFER_LONG,
	BUFFER_FLOAT,
	BUFFER_DOUBLE
};

typedef struct {
	int type;
	size_t size;
	void* data;
} Buffer;

/* Global assing functions. */
void assignGlobalInt( int value, const char* name );
void assignGlobalFloat( float value, const char* name );
void assignGlobalDouble( double value, const char* name );
void assignGlobalColor( Color color, const char* name );
void assingGlobalFunction( const char* name, int ( *functionPtr )( lua_State* ) );

bool luaInit( int argn, const char** argc );
int luaTraceback( lua_State* L );
void luaCallMain();
void luaCallInit();
void luaCallUpdate();
void luaCallDraw();
void luaCallExit();
void luaCallLoad( const char* type, void* object );
void luaCallUnload( const char* type, void* object );
void luaRegister();
void platformDefineGlobals();
void luaPlatformRegister();
/* Lua get types. */
REILUAPI bool uluaGetBoolean( lua_State* L, int index );
REILUAPI Color uluaGetColor( lua_State* L, int index );
REILUAPI Vector2 uluaGetVector2( lua_State* L, int index );
REILUAPI Vector3 uluaGetVector3( lua_State* L, int index );
REILUAPI Vector4 uluaGetVector4( lua_State* L, int index );
REILUAPI Rectangle uluaGetRectangle( lua_State* L, int index );
REILUAPI Quaternion uluaGetQuaternion( lua_State* L, int index );
REILUAPI Matrix uluaGetMatrix( lua_State* L, int index );
REILUAPI BoundingBox uluaGetBoundingBox( lua_State* L, int index );
REILUAPI Ray uluaGetRay( lua_State* L, int index );
REILUAPI NPatchInfo uluaGetNPatchInfo( lua_State* L, int index );
REILUAPI BoneInfo uluaGetBoneInfo( lua_State* L, int index );
REILUAPI Transform uluaGetTransform( lua_State* L, int index );
REILUAPI Buffer* uluaGetBuffer( lua_State* L, int index );
REILUAPI Image* uluaGetImage( lua_State* L, int index );
REILUAPI Texture* uluaGetTexture( lua_State* L, int index );
REILUAPI RenderTexture* uluaGetRenderTexture( lua_State* L, int index );
REILUAPI Shader* uluaGetShader( lua_State* L, int index );
REILUAPI Mesh* uluaGetMesh( lua_State* L, int index );
REILUAPI Camera2D* uluaGetCamera2D( lua_State* L, int index );
REILUAPI Camera3D* uluaGetCamera3D( lua_State* L, int index );
REILUAPI Font* uluaGetFont( lua_State* L, int index );
REILUAPI GlyphInfo* uluaGetGlyphInfo( lua_State* L, int index );
REILUAPI Wave* uluaGetWave( lua_State* L, int index );
REILUAPI Sound* uluaGetSound( lua_State* L, int index );
REILUAPI Music* uluaGetMusic( lua_State* L, int index );
REILUAPI Light* uluaGetLight( lua_State* L, int index );
REILUAPI Material* uluaGetMaterial( lua_State* L, int index );
REILUAPI Model* uluaGetModel( lua_State* L, int index );
REILUAPI ModelAnimation* uluaGetModelAnimation( lua_State* L, int index );
REILUAPI rlRenderBatch* uluaGetRLRenderBatch( lua_State* L, int index );
REILUAPI AutomationEvent* uluaGetAutomationEvent( lua_State* L, int index );
REILUAPI AutomationEventList* uluaGetAutomationEventList( lua_State* L, int index );

REILUAPI void getVector2Array( lua_State* L, int index, Vector2 points[] );
/* Lua push types. */
REILUAPI void uluaPushColor( lua_State* L, Color color );
REILUAPI void uluaPushVector2( lua_State* L, Vector2 vector );
REILUAPI void uluaPushVector3( lua_State* L, Vector3 vector );
REILUAPI void uluaPushVector4( lua_State* L, Vector4 vector );
REILUAPI void uluaPushRectangle( lua_State* L, Rectangle rect );
REILUAPI void uluaPushQuaternion( lua_State* L, Quaternion quaternion );
REILUAPI void uluaPushMatrix( lua_State* L, Matrix matrix );
REILUAPI void uluaPushRay( lua_State* L, Ray ray );
REILUAPI void uluaPushRayCollision( lua_State* L, RayCollision rayCol );
REILUAPI void uluaPushBoundingBox( lua_State* L, BoundingBox box );
REILUAPI void uluaPushBoneInfo( lua_State* L, BoneInfo boneInfo );
REILUAPI void uluaPushTransform( lua_State* L, Transform transform );
// void uluaPushAutomationEvent( lua_State* L, AutomationEvent event );
REILUAPI void uluaPushBuffer( lua_State* L, Buffer buffer );
REILUAPI void uluaPushImage( lua_State* L, Image image );
REILUAPI void uluaPushTexture( lua_State* L, Texture texture );
REILUAPI void uluaPushRenderTexture( lua_State* L, RenderTexture renderTexture );
REILUAPI void uluaPushCamera2D( lua_State* L, Camera2D camera );
REILUAPI void uluaPushCamera3D( lua_State* L, Camera3D camera );
REILUAPI void uluaPushShader( lua_State* L, Shader shader );
REILUAPI void uluaPushFont( lua_State* L, Font font );
REILUAPI void uluaPushGlyphInfo( lua_State* L, GlyphInfo glyph );
REILUAPI void uluaPushWave( lua_State* L, Wave wave );
REILUAPI void uluaPushSound( lua_State* L, Sound sound );
REILUAPI void uluaPushSoundAlias( lua_State* L, Sound alias );
REILUAPI void uluaPushMusic( lua_State* L, Music music );
REILUAPI void uluaPushLight( lua_State* L, Light light );
REILUAPI void uluaPushMaterial( lua_State* L, Material material );
REILUAPI void uluaPushMesh( lua_State* L, Mesh mesh );
REILUAPI void uluaPushModel( lua_State* L, Model model );
REILUAPI void uluaPushModelAnimation( lua_State* L, ModelAnimation modelAnimation );
REILUAPI void uluaPushRLRenderBatch( lua_State* L, rlRenderBatch renderBatch );
REILUAPI void uluaPushAutomationEvent( lua_State* L, AutomationEvent event );
REILUAPI void uluaPushAutomationEventList( lua_State* L, AutomationEventList eventList );
/* Unload objects. */
void uluaUnloadBuffer( Buffer* buffer );
void uluaUnloadImage( Image* image );
void uluaUnloadTexture( Texture* texture );
void uluaUnloadRenderTexture( RenderTexture* renderTexture );
void uluaUnloadShader( Shader* shader );
void uluaUnloadFont( Font* font );
void uluaUnloadGlyphInfo( GlyphInfo* glyph );
void uluaUnloadWave( Wave* wave );
void uluaUnloadSound( Sound* sound );
void uluaUnloadSoundAlias( Sound* sound );
void uluaUnloadMusic( Music* music );
void uluaUnloadMaterial( Material* material, bool freeAll );
void uluaUnloadMesh( Mesh* mesh );
void uluaUnloadModel( Model* model );
void uluaUnloadModelAnimation( ModelAnimation* modelAnimation );
void uluaUnloadRLRenderBatch( rlRenderBatch* renderBatch );
void uluaUnloadAutomationEventList( AutomationEventList* eventList );
/* Utils. */
REILUAPI int uluaGetTableLen( lua_State* L, int index );
REILUAPI bool uluaIsNil( lua_State* L, int index );