Release v0.5.
This commit is contained in:
13
API.md
13
API.md
@@ -7806,6 +7806,19 @@ Delete framebuffer from GPU
|
||||
|
||||
---
|
||||
|
||||
## RLGL - Shaders management
|
||||
|
||||
---
|
||||
|
||||
> success = RL.rlLoadShaderCode( string vsCode, string fsCode )
|
||||
|
||||
Load shader from code strings
|
||||
|
||||
- Failure return nil
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
## RLGL - Matrix state management
|
||||
|
||||
---
|
||||
|
||||
@@ -29,6 +29,14 @@ List of some MISSING features that are planned to be included. For specific func
|
||||
* Audio
|
||||
* AudioStream management functions
|
||||
|
||||
## Roadmap
|
||||
|
||||
v0.6
|
||||
* Switch from id based objects to Lua userdata(like most bindings). Resources won't be stored in State anymore.
|
||||
* Change argument checking to use more luaL_checkx functions and remove the TraceLog messages.
|
||||
v0.7
|
||||
* Switch to Raylib v5.0?
|
||||
|
||||
## Usage
|
||||
|
||||
Application needs 'main.lua' or 'main' file as entry point. ReiLua executable will first look it from same directory. Alternatively, path to the folder where "main.lua" is located can be given as argument. There are five Lua functions that the framework will call, 'RL.init', 'RL.process', 'RL.draw', 'RL.log' and 'RL.exit'.
|
||||
|
||||
@@ -6251,6 +6251,16 @@ function RL.rlFramebufferComplete( id ) end
|
||||
---@return any success
|
||||
function RL.rlUnloadFramebuffer( id ) end
|
||||
|
||||
-- RLGL - Shaders management
|
||||
|
||||
---Load shader from code strings
|
||||
---- Failure return nil
|
||||
---- Success return int
|
||||
---@param vsCode string
|
||||
---@param fsCode string
|
||||
---@return any success
|
||||
function RL.rlLoadShaderCode( vsCode, fsCode ) end
|
||||
|
||||
-- RLGL - Matrix state management
|
||||
|
||||
---Get internal modelview matrix
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
local textColor = RL.BLACK
|
||||
local textPos = { 192, 200 }
|
||||
local imageFont = -1
|
||||
local text = "Congrats! You created your first window!"
|
||||
|
||||
function RL.init()
|
||||
|
||||
@@ -28,6 +28,10 @@ typedef struct {
|
||||
int y;
|
||||
} Buffer;
|
||||
|
||||
typedef struct {
|
||||
int age;
|
||||
} Kissa;
|
||||
|
||||
bool luaInit( int argn, const char **argc );
|
||||
int luaTraceback( lua_State *L );
|
||||
bool luaCallMain();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 5
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_DEV 1
|
||||
#define VERSION_DEV 0
|
||||
|
||||
#include "glad.h"
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -981,7 +981,6 @@ int lcoreLoadShader( lua_State *L ) {
|
||||
lua_pushinteger( L, -1 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *vsFileName = NULL;
|
||||
char *fsFileName = NULL;
|
||||
|
||||
|
||||
@@ -641,21 +641,39 @@ static void defineGlobals() {
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
|
||||
static int freeBuffer( lua_State *L ) {
|
||||
static int gcBuffer( lua_State *L ) {
|
||||
Buffer *buffer = luaL_checkudata ( L, 1, "Buffer" );
|
||||
free( buffer->data );
|
||||
}
|
||||
|
||||
static void defineCBuffer() {
|
||||
static void defineBuffer() {
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "Buffer" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
lua_pushcfunction( L, freeBuffer );
|
||||
lua_pushcfunction( L, gcBuffer );
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
// static int gcTexture( lua_State *L ) {
|
||||
// Texture *texture = luaL_checkudata ( L, 1, "Texture" );
|
||||
// printf( "gcTexture\n" );
|
||||
// printf( "\ttexture->id = %d\n", texture->id );
|
||||
|
||||
// UnloadTexture( *texture );
|
||||
// }
|
||||
|
||||
// static void defineTexture() {
|
||||
// lua_State *L = state->luaState;
|
||||
|
||||
// luaL_newmetatable( L, "Texture" );
|
||||
// lua_pushvalue( L, -1 );
|
||||
// lua_setfield( L, -2, "__index" );
|
||||
// lua_pushcfunction( L, gcTexture );
|
||||
// lua_setfield( L, -2, "__gc" );
|
||||
// }
|
||||
|
||||
// Custom logging funtion.
|
||||
static void logCustom( int logLevel, const char *text, va_list args ) {
|
||||
char string[ STRING_LEN ] = {'\0'};
|
||||
@@ -678,6 +696,8 @@ static void logCustom( int logLevel, const char *text, va_list args ) {
|
||||
/* Call Lua log function if exists. */
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
/* Prevent calling lua log function when lua is already shutdown. */
|
||||
if ( L != NULL ) {
|
||||
lua_pushcfunction( L, luaTraceback );
|
||||
int tracebackidx = lua_gettop( L );
|
||||
|
||||
@@ -696,6 +716,7 @@ static void logCustom( int logLevel, const char *text, va_list args ) {
|
||||
}
|
||||
}
|
||||
lua_pop( L, -1 );
|
||||
}
|
||||
}
|
||||
|
||||
/* Window events. */
|
||||
@@ -1039,7 +1060,8 @@ bool luaInit( int argn, const char **argc ) {
|
||||
return false;
|
||||
}
|
||||
defineGlobals();
|
||||
defineCBuffer();
|
||||
defineBuffer();
|
||||
// defineTexture();
|
||||
|
||||
/* Set arguments. */
|
||||
lua_getglobal( L, "RL" );
|
||||
@@ -2166,6 +2188,7 @@ Vector2 uluaGetVector2( lua_State *L ) {
|
||||
}
|
||||
|
||||
Vector2 uluaGetVector2Index( lua_State *L, int index ) {
|
||||
// luaL_checktype( L, index, LUA_TTABLE );
|
||||
Vector2 vector = { 0.0f, 0.0f };
|
||||
|
||||
if ( !lua_istable( L, index ) ) {
|
||||
|
||||
23
src/rlgl.c
23
src/rlgl.c
@@ -1732,6 +1732,29 @@ int lrlglUnloadFramebuffer( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## RLGL - Shaders management
|
||||
*/
|
||||
|
||||
/*
|
||||
> success = RL.rlLoadShaderCode( string vsCode, string fsCode )
|
||||
|
||||
Load shader from code strings
|
||||
|
||||
- Failure return nil
|
||||
- Success return int
|
||||
*/
|
||||
// int lrlglUnloadFramebuffer( lua_State *L ) {
|
||||
// if ( !lua_isstring( L, 1 ) || !lua_isstring( L, 2 ) ) {
|
||||
// TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadShaderCode( string vsCode, string fsCode )" );
|
||||
// lua_pushnil( L );
|
||||
// return 1;
|
||||
// }
|
||||
// lua_pushinteger( L, rlLoadShaderCode( luaL_checkstring( L, 1 ), luaL_checkstring( L, 2 ) ) );
|
||||
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
/*
|
||||
## RLGL - Matrix state management
|
||||
*/
|
||||
|
||||
@@ -211,11 +211,12 @@ void stateFree() {
|
||||
if ( IsAudioDeviceReady() ) {
|
||||
CloseAudioDevice();
|
||||
}
|
||||
if ( state->hasWindow ) {
|
||||
CloseWindow();
|
||||
}
|
||||
if ( state->luaState != NULL ) {
|
||||
lua_close( state->luaState );
|
||||
state->luaState = NULL;
|
||||
}
|
||||
if ( state->hasWindow ) {
|
||||
CloseWindow();
|
||||
}
|
||||
free( state->images );
|
||||
free( state->textures );
|
||||
|
||||
@@ -1673,6 +1673,12 @@ int ltexturesLoadTexture( lua_State *L ) {
|
||||
int i = newTexture( TEXTURE_TYPE_TEXTURE );
|
||||
state->textures[i]->texture = LoadTexture( lua_tostring( L, 1 ) );
|
||||
lua_pushinteger( L, i );
|
||||
|
||||
// Texture loadedTex = LoadTexture( lua_tostring( L, 1 ) );
|
||||
// Texture *texture = lua_newuserdata( L, sizeof( Texture ) );
|
||||
// *texture = loadedTex;
|
||||
// luaL_setmetatable( L, "Texture" );
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
@@ -1921,10 +1927,12 @@ int ltexturesDrawTexture( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
// Texture *texture = luaL_checkudata( L, 1, "Texture" );
|
||||
Vector2 pos = uluaGetVector2Index( L, 2 );
|
||||
Color color = uluaGetColorIndex( L, 3 );
|
||||
|
||||
DrawTexture( texture, pos.x, pos.y, color );
|
||||
// DrawTexture( *texture, pos.x, pos.y, color );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
@@ -2174,6 +2182,9 @@ int ltexturesGetTextureSize( lua_State *L ) {
|
||||
Texture texture = uluaGetTexture( L, 1 );
|
||||
uluaPushVector2( L, (Vector2){ texture.width, texture.height } );
|
||||
|
||||
// Texture *texture = luaL_checkudata( L, 1, "Texture" );
|
||||
// uluaPushVector2( L, (Vector2){ texture->width, texture->height } );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user