| 1107 | |
| 1108 | |
| 1109 | int LuaTextureMgr::CopyToTexture(lua_State* L) { |
| 1110 | //LuaOpenGL::CheckDrawingEnabled(L, __FUNCTION__); |
| 1111 | |
| 1112 | const LuaTexture* texture = CheckLuaTexture(L, 1); |
| 1113 | if (!texture->IsWritable()) { |
| 1114 | return luaL_pushnil(L); |
| 1115 | } |
| 1116 | const GLenum texTarget = texture->GetTarget(); |
| 1117 | |
| 1118 | if (!OpenGLPassState::PushAttrib(GL_TEXTURE_BIT)) { |
| 1119 | return luaL_pushnil(L); // exceeded the attrib stack depth |
| 1120 | } |
| 1121 | |
| 1122 | if (!texture->Bind()) { |
| 1123 | OpenGLPassState::PopAttrib(); |
| 1124 | lua_pushboolean(L, false); |
| 1125 | return 1; |
| 1126 | } |
| 1127 | |
| 1128 | const GLint xoff = (GLint)luaL_checkint(L, 2); |
| 1129 | const GLint yoff = (GLint)luaL_checkint(L, 3); |
| 1130 | const GLint x = (GLint)luaL_checkint(L, 4); |
| 1131 | const GLint y = (GLint)luaL_checkint(L, 5); |
| 1132 | const GLsizei w = (GLsizei)luaL_checkint(L, 6); |
| 1133 | const GLsizei h = (GLsizei)luaL_checkint(L, 7); |
| 1134 | const GLenum target = (GLenum)luaL_optint(L, 8, texTarget); |
| 1135 | const GLenum level = (GLenum)luaL_optint(L, 9, 0); |
| 1136 | |
| 1137 | glGetError(); // clear the error |
| 1138 | glCopyTexSubImage2D(target, level, xoff, yoff, x, y, w, h); |
| 1139 | |
| 1140 | const GLenum errgl = glGetError(); |
| 1141 | OpenGLPassState::PopAttrib(); |
| 1142 | |
| 1143 | if (errgl != GL_NO_ERROR) { |
| 1144 | lua_pushboolean(L, false); |
| 1145 | lua_pushinteger(L, errgl); |
| 1146 | return 2; |
| 1147 | } |
| 1148 | |
| 1149 | lua_pushboolean(L, true); |
| 1150 | return 1; |
| 1151 | } |
| 1152 | |
| 1153 | |
| 1154 | int LuaTextureMgr::GenerateMipMap(lua_State* L) { |
nothing calls this directly
no test coverage detected