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

Method TexSubImage

src/lua/LuaTextures.cpp:1064–1106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062
1063
1064int LuaTextureMgr::TexSubImage(lua_State* L) {
1065 const LuaTexture* texture = CheckLuaTexture(L, 1);
1066 if (!texture->IsWritable()) {
1067 return luaL_pushnil(L);
1068 }
1069
1070 TextureData texData;
1071 if (!texData.Parse(L, 2)) {
1072 return luaL_pushnil(L);
1073 }
1074
1075 const GLenum target = (GLenum)luaL_optint(L, 3, texture->GetTarget());
1076 const GLint level = (GLint) luaL_optint(L, 4, 0);
1077 const GLint x = (GLint) luaL_optint(L, 5, 0);
1078 const GLint y = (GLint) luaL_optint(L, 6, 0);
1079
1080 if (!OpenGLPassState::PushAttrib(GL_TEXTURE_BIT)) {
1081 return luaL_pushnil(L); // exceeded the attrib stack depth
1082 }
1083
1084 if (!texture->Bind()) {
1085 OpenGLPassState::PopAttrib();
1086 lua_pushboolean(L, false);
1087 return 1;
1088 }
1089
1090 glGetError(); // clear the error
1091 glTexSubImage2D(target, level, x, y,
1092 texData.xsize, texData.ysize,
1093 texData.format, texData.type, texData.data);
1094
1095 const GLenum errgl = glGetError();
1096 OpenGLPassState::PopAttrib();
1097
1098 if (errgl != GL_NO_ERROR) {
1099 lua_pushboolean(L, false);
1100 lua_pushinteger(L, errgl);
1101 return 2;
1102 }
1103
1104 lua_pushboolean(L, true);
1105 return 1;
1106}
1107
1108
1109int LuaTextureMgr::CopyToTexture(lua_State* L) {

Callers

nothing calls this directly

Calls 7

luaL_pushnilFunction · 0.85
ParseMethod · 0.80
BindMethod · 0.80
lua_pushbooleanFunction · 0.50
lua_pushintegerFunction · 0.50
IsWritableMethod · 0.45
GetTargetMethod · 0.45

Tested by

no test coverage detected