summaryrefslogtreecommitdiff
path: root/src/main.c
blob: ad64d2479b6d315e4d3829a77235159a8d339b16 (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
#include "main.h"
#include "state.h"
#include "lua_core.h"

int main( int argn, const char **argc ) {
	char exePath[ STRING_LEN ] = { '\0' };

	if ( 1 < argn ) {
		if ( strcmp( argc[1], "--version" ) == 0 || strcmp( argc[1], "-v" ) == 0 ) {
			printf( "ReiLua %d.%d.%d\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );

			return 1;
		}
		else{
			sprintf( exePath, "%s/%s", GetWorkingDirectory(), argc[1] );
		}
	}
	else {
		sprintf( exePath, "%s/", GetWorkingDirectory() );
	}

	stateInit( exePath );

	while ( state->run ) {
		if ( WindowShouldClose() ) {
			state->run = false;
		}
		if ( IsAudioDeviceReady() ) {
			UpdateMusicStream( state->music );
		}
		luaCallProcess();
		luaCallDraw();
	}
	stateFree();

	return 1;
}