static int lua_newT(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments."); #endif Timer* new_timer = (Timer*)malloc(sizeof(Timer)); // Calculating current frame new_timer->tick = osGetTime(); new_timer->magic = 0x4C544D52; new_timer->isPlaying = true; drawCommand("Timer.new: ","Timer created at offset 0x%lX.\n",(u32)new_timer); allocatedDatas = allocatedDatas + sizeof(Timer); size_t percent = (allocatedDatas * 100) / maxDatas; drawDebug("Debug: ","Allocated %lu bytes (Mem. usage: %u%%).\n",sizeof(Timer), percent); if (percent > 80) drawWarning("Warning: ", "High memory usage!"); if (percent > 100){ drawError("FATAL ERROR: ", "Out of memory!"); return luaL_error(L, "internal error."); } lua_pushinteger(L,(u32)new_timer); return 1; }
static int lua_openfile(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if ((argc != 2) && (argc != 3) && (argc != 4)) return luaL_error(L, "wrong number of arguments"); #endif char file_tbo[256]; const char *file_tmp = luaL_checkstring(L, 1); int type = luaL_checkinteger(L, 2); u32 archive_id; u32 filesize; if (argc >= 3){ char warn[256]; archive_id = luaL_checknumber(L,3); sprintf(warn,"Extdata is unavailable on PC, using %s.ext%lu as file.\n", file_tmp, archive_id); drawWarning("Warning: ", warn); if (argc == 4) filesize = luaL_checkinteger(L, 4); sprintf(file_tbo, "%s.ext%lu", file_tmp, archive_id); }else sprintf(file_tbo, "%s", file_tmp); FILE* handle; if (type == 0) handle = fopen(file_tbo, "r"); else if (type == 1) handle = fopen(file_tbo, "r+"); else handle = fopen(file_tbo, "w+"); #ifndef SKIP_ERROR_HANDLING if (handle == NULL) return luaL_error(L, "file doesn't exist."); #endif drawCommand("io.open: ","Opening file handle at offset 0x%lX.\n",(u32)handle); lua_pushinteger(L,(u32)handle); return 1; }
static int lua_detectsd(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.checkSDMC: ", "Returning true.\n"); lua_pushboolean(L, true); return 1; }
static int lua_getLang(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.getLanguage: ", "Returning EN language.\n"); lua_pushinteger(L,1); return 1; }
static int lua_ischarge(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.isBatteryCharging: ", "Returning false.\n"); lua_pushboolean(L, false); return 1; }
static int lua_getbattery(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.getBatteryLife: ", "Returning 100% state.\n"); lua_pushinteger(L,4); return 1; }
static int lua_checkbuild(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.checkBuild: ", "Returning CFW mode.\n"); lua_pushinteger(L,1); return 1; }
static int lua_getBirth(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.getBirthday: ", "Returning 9 February as birthday.\n"); lua_pushinteger(L,9); lua_pushinteger(L,2); return 2; }
static int lua_reboot(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.reboot: ", "Closing interpreter.\n"); char string[20]; strcpy(string,"lpp_exit_0456432"); luaL_dostring(L, "collectgarbage()"); return luaL_error(L, string); // NOTE: This is a fake error }
static int lua_getUsername(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif char username[0x0E]; memcpy(username,"lpp-3ds bot",11); drawCommand("System.getUsername: "******"Returning default username.\n"); lua_pushstring(L,username); return 1; }
static int lua_getK(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 0) return luaL_error(L, "wrong number of arguments"); #endif drawCommand("System.getKernel: ", "Returning 2.50-9 NATIVE_FIRM version.\n"); lua_pushinteger(L,2); lua_pushinteger(L,50); lua_pushinteger(L,9); return 3; }
static int lua_launchcia(lua_State *L) { int argc = lua_gettop(L); #ifndef SKIP_ERROR_HANDLING if (argc != 2) return luaL_error(L, "wrong number of arguments"); #endif u32 unique_id = luaL_checkinteger(L,1); u32 mediatype = luaL_checkinteger(L,2); drawCommand("System.launchCIA: ", "Closing interpreter.\n"); char string[20]; strcpy(string,"lpp_exit_0456432"); luaL_dostring(L, "collectgarbage()"); return luaL_error(L, string); // NOTE: This is a fake error }
/** * Draw another frame */ void FWRenderer::drawFrame() { drawBackground(); drawOverlays(); if (!_cmd.empty()) { drawCommand(); } if (_changePal) { refreshPalette(); } const int menus = _menuStack.size(); for (int i = 0; i < menus; ++i) _menuStack[i]->drawMenu(*this, (i == menus - 1)); blit(); }
void CRigidRenderer::Init() { m_Effect= new CRigidShader(); m_Effect->Load(); CMeshData meshData; CGeomCreator geomCreator; geomCreator.CreateBox(1,1,1,meshData); m_PosVB.InputSlot(0); m_PosVB.SetData(meshData.Positions); m_Tex0VB.InputSlot(1); m_Tex0VB.SetData(meshData.UV0); m_IB.SetData(meshData.Indices); // InstanceData { m_InstanceData.clear(); for (int z = 0; z < 4; ++z) { for (int x = 0; x < 4; ++x) { float size = (4 * 3) * 0.5; CRigidShader::INSTANCE_DATA inst_data; inst_data.Pos = glm::vec4(x * 4 - size, 0, z * 4 - size, 1); inst_data.Rotation = glm::vec4(0, 0, 0, 1); m_InstanceData.push_back(inst_data); } } m_InstanceVB.InputSlot(2); m_InstanceVB.BufferUsage(DYNAMIC_DRAW); m_InstanceVB.SetData(m_InstanceData); } // Indirect Draw vector<GLDrawElementsIndirectCommand> drawCommands; { GLDrawElementsIndirectCommand drawCommand(meshData.Indices.size(), m_InstanceData.size()); drawCommands.push_back(drawCommand); } m_DrawElementsCommand.SetData(drawCommands); }
/** Draws scene using specific case parameters. * * @return Returns true if no error occurred, false otherwise. */ bool ShaderDrawParametersTestBase::draw() { const Functions& gl = m_context.getRenderContext().getFunctions(); ProgramSources sources = makeVtxFragSources(sdp_vertShader, sdp_fragShader); ShaderProgram program(gl, sources); if (!program.isOk()) { m_testCtx.getLog() << tcu::TestLog::Message << "Shader build failed.\n" << "Vertex: " << program.getShaderInfo(SHADERTYPE_VERTEX).infoLog << "\n" << "Fragment: " << program.getShaderInfo(SHADERTYPE_FRAGMENT).infoLog << "\n" << "Program: " << program.getProgramInfo().infoLog << tcu::TestLog::EndMessage; return false; } gl.useProgram(program.getProgram()); GLU_EXPECT_NO_ERROR(gl.getError(), "glUseProgram"); gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f); gl.clear(GL_COLOR_BUFFER_BIT); gl.enable(GL_BLEND); gl.blendFunc(GL_ONE, GL_ONE); gl.enableVertexAttribArray(0); GLU_EXPECT_NO_ERROR(gl.getError(), "glEnableVertexAttribArray"); gl.vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); GLU_EXPECT_NO_ERROR(gl.getError(), "glVertexAttribPointer"); drawCommand(); gl.disableVertexAttribArray(0); GLU_EXPECT_NO_ERROR(gl.getError(), "glDisableVertexAttribArray"); gl.disable(GL_BLEND); return true; }