PyGL
This commit is contained in:
@@ -17,7 +17,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 python3-opengl
|
||||
- name: Configure CMake
|
||||
run: cmake -S . -B build -DDUSK_TARGET_SYSTEM=linux
|
||||
- name: Build
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5
|
||||
apt-get install -y build-essential cmake python3 python3-pip python3-polib python3-pil libsdl2-dev libgl1-mesa-dev libzip-dev python3-dotenv python3-pyqt5 python3-opengl
|
||||
- name: Configure CMake
|
||||
run: cmake -S . -B build -DDUSK_TARGET_SYSTEM=psp
|
||||
- name: Build
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "scriptmanager.h"
|
||||
#include "util/memory.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
#include "asset/asset.h"
|
||||
|
||||
@@ -28,31 +29,13 @@ errorret_t scriptManagerInit() {
|
||||
luaL_openlibs(SCRIPT_MANAGER.luaState);
|
||||
lua_register(SCRIPT_MANAGER.luaState, "luaCallable", luaCallable);
|
||||
|
||||
// Script test.
|
||||
assetscript_t script;
|
||||
assetLoad("script/test.dsf", &script);
|
||||
|
||||
if(lua_load(SCRIPT_MANAGER.luaState, assetScriptReader, &script, "script/test.dsf", NULL) != LUA_OK) {
|
||||
const char_t *strErr = lua_tostring(SCRIPT_MANAGER.luaState, -1);
|
||||
lua_pop(SCRIPT_MANAGER.luaState, 1);
|
||||
errorThrow("Failed to load Lua script: %s", strErr);
|
||||
}
|
||||
|
||||
if(lua_pcall(SCRIPT_MANAGER.luaState, 0, LUA_MULTRET, 0) != LUA_OK) {
|
||||
const char_t *strErr = lua_tostring(SCRIPT_MANAGER.luaState, -1);
|
||||
lua_pop(SCRIPT_MANAGER.luaState, 1);
|
||||
errorThrow("Failed to execute Lua script: %s", strErr);
|
||||
}
|
||||
|
||||
assetScriptDispose(&script);
|
||||
|
||||
errorChain(scriptManagerExecFile("script/test.dsf"));
|
||||
errorOk();
|
||||
}
|
||||
|
||||
errorret_t scriptManagerExecString(const char_t *script) {
|
||||
if(SCRIPT_MANAGER.luaState == NULL) {
|
||||
errorThrow("Lua state is not initialized");
|
||||
}
|
||||
assertNotNull(script, "Script cannot be NULL");
|
||||
assertNotNull(SCRIPT_MANAGER.luaState, "Lua state is not initialized");
|
||||
|
||||
if(luaL_dostring(SCRIPT_MANAGER.luaState, script) != LUA_OK) {
|
||||
const char_t *strErr = lua_tostring(SCRIPT_MANAGER.luaState, -1);
|
||||
@@ -64,16 +47,27 @@ errorret_t scriptManagerExecString(const char_t *script) {
|
||||
}
|
||||
|
||||
errorret_t scriptManagerExecFile(const char_t *filename) {
|
||||
if(SCRIPT_MANAGER.luaState == NULL) {
|
||||
errorThrow("Lua state is not initialized");
|
||||
}
|
||||
assertNotNull(filename, "Filename cannot be NULL");
|
||||
assertNotNull(SCRIPT_MANAGER.luaState, "Lua state is not initialized");
|
||||
|
||||
if(luaL_dofile(SCRIPT_MANAGER.luaState, filename) != LUA_OK) {
|
||||
assetscript_t script;
|
||||
errorChain(assetLoad(filename, &script));
|
||||
|
||||
if(lua_load(
|
||||
SCRIPT_MANAGER.luaState, assetScriptReader, &script, filename, NULL
|
||||
) != LUA_OK) {
|
||||
const char_t *strErr = lua_tostring(SCRIPT_MANAGER.luaState, -1);
|
||||
lua_pop(SCRIPT_MANAGER.luaState, 1);
|
||||
errorThrow("Failed to execute Lua file: %s", strErr);
|
||||
errorThrow("Failed to load Lua script: %s", strErr);
|
||||
}
|
||||
|
||||
if(lua_pcall(SCRIPT_MANAGER.luaState, 0, LUA_MULTRET, 0) != LUA_OK) {
|
||||
const char_t *strErr = lua_tostring(SCRIPT_MANAGER.luaState, -1);
|
||||
lua_pop(SCRIPT_MANAGER.luaState, 1);
|
||||
errorThrow("Failed to execute Lua script: %s", strErr);
|
||||
}
|
||||
|
||||
errorChain(assetScriptDispose(&script));
|
||||
errorOk();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,15 @@ errorret_t scriptManagerInit();
|
||||
* @param script The script to execute.
|
||||
* @return The error return value.
|
||||
*/
|
||||
errorret_t scriptManagerExec(const char_t *script);
|
||||
errorret_t scriptManagerExecString(const char_t *script);
|
||||
|
||||
/**
|
||||
* Execute a Lua script from a file.
|
||||
*
|
||||
* @param filename The filename of the script to execute.
|
||||
* @return The error return value.
|
||||
*/
|
||||
errorret_t scriptManagerExecFile(const char_t *filename);
|
||||
|
||||
/**
|
||||
* Dispose of the script manager.
|
||||
|
||||
Reference in New Issue
Block a user