MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / RunQuery

Method RunQuery

src/lua/LuaGLQueries.cpp:217–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215
216
217int LuaGLQueryMgr::RunQuery(lua_State* L) {
218 static bool running = false;
219
220 if (running) {
221 luaL_error(L, "not re-entrant");
222 }
223
224 const LuaGLQuery* query = CheckLuaGLQuery(L, 1);
225 if (!query->IsValid()) {
226 luaL_error(L, "invalid query object");
227 }
228
229 int funcIndex = 2;
230
231 GLenum target = query->GetTarget();
232 if (lua_israwnumber(L, funcIndex)) {
233 target = (GLenum)lua_toint(L, funcIndex);
234 funcIndex++;
235 }
236
237 luaL_checktype(L, funcIndex, LUA_TFUNCTION);
238
239 running = true;
240 glBeginQuery(target, query->GetID());
241 const int top = lua_gettop(L);
242 const int error = lua_pcall(L, top - funcIndex, LUA_MULTRET, 0);
243 glEndQuery(target);
244 running = false;
245
246 if (error != 0) {
247 LuaLog(1, "gl.RunQuery: error(%i) = %s", error, lua_tostring(L, -1));
248 lua_error(L);
249 }
250
251 return lua_gettop(L) - (funcIndex - 1);
252}
253
254
255int LuaGLQueryMgr::GetQuery(lua_State* L) {

Callers

nothing calls this directly

Calls 11

lua_israwnumberFunction · 0.85
lua_tointFunction · 0.85
LuaLogFunction · 0.85
GetIDMethod · 0.80
luaL_errorFunction · 0.50
luaL_checktypeFunction · 0.50
lua_gettopFunction · 0.50
lua_pcallFunction · 0.50
lua_errorFunction · 0.50
IsValidMethod · 0.45
GetTargetMethod · 0.45

Tested by

no test coverage detected