bool LuaEngine::ExecuteExpression(UString expression) { LuaEngine& _engine = LuaEngine::instance(); if (expression.empty()) { DebugPrintF(VTEXT("SCRIPT EMPTY")); return false; } std::string _exp = UStringToStd(expression); int state = luaL_dostring(_engine.m_L, _exp.c_str()); if (!ReportScriptErrors(state)) { DebugPrintF(VTEXT("Failed to execute script expression")); return false; } return true; }
ErrCode LuaEngine::VExecuteExpression(const UString& expression) { ErrCode error = ErrCode::ERR_SUCCESS; if (expression.empty()) { DebugPrintF(VTEXT("SCRIPT EMPTY")); return ErrCode::ERR_NULL_PATH; } std::string _exp = UStringToStd(expression); int state = luaL_dostring(m_L, _exp.c_str()); error = ReportScriptErrors(state); if (CheckError(error)) { DebugPrintF(VTEXT("Failed to execute script expression")); } return error; }
ErrCode LuaEngine::VExecuteFile(const UString& path) { ErrCode error = ErrCode::ERR_SUCCESS; if (path.empty()) { DebugPrintF(VTEXT("Failed to execute script file: NULL PATH")); return ErrCode::ERR_NULL_PATH; } /*try and execute script file*/ std::string _path = UStringToStd(path); int state = luaL_dofile(m_L, _path.c_str()); error = ReportScriptErrors(state); if (CheckError(error)) { DebugPrintF(VTEXT("Failed to execute script file")); } return error; }
bool LuaEngine::ExecuteFile(UString filePath) { LuaEngine& _engine = LuaEngine::instance(); if (filePath.empty()) { DebugPrintF(VTEXT("Failed to execute script file: NULL PATH")); return false; } /*try and execute script file*/ std::string _path = UStringToStd(filePath); int state = luaL_dofile(_engine.m_L, _path.c_str()); if (!LuaEngine::ReportScriptErrors(state)) { DebugPrintF(VTEXT("Failed to execute script file")); return false; } return true; }
/// <summary> /// Loads the texture from file using stb_image.c library. /// </summary> /// <returns>TRUE on success.</returns> bool Texture::Load(const ustring& file) { int x, y, n; int force_channels = 4; unsigned char* image_data = nullptr; try { image_data = stbi_load(UStringToStd(file).c_str(), &x, &y, &n, force_channels); } catch (std::exception) { ucout << U("ERROR: could not load") << file << U("\n"); } glGenTextures(1, &m_TextureID); glBindTexture(GL_TEXTURE_2D, m_TextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); //OpenGL 4.2+ //glTexStorage2D(GL_TEXTURE_2D, 4, GL_RGBA8, x, y); //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, x, y, GL_BGRA, GL_UNSIGNED_BYTE, image_data); //generate mipmap glGenerateMipmap(GL_TEXTURE_2D); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //unbind texture glBindTexture(GL_TEXTURE_2D, 0); //free resources free(image_data); return true; }
std::string GameObject::GetName() { return UStringToStd(m_name); }