(Texture tex, int x, int y, int w, int h,
boolean scale)
| 1210 | |
| 1211 | // Copies source texture tex into this. |
| 1212 | protected void copyTexture(Texture tex, int x, int y, int w, int h, |
| 1213 | boolean scale) { |
| 1214 | if (tex == null) { |
| 1215 | throw new RuntimeException("Source texture is null"); |
| 1216 | } |
| 1217 | |
| 1218 | if (tempFbo == null) { |
| 1219 | tempFbo = new FrameBuffer(pg, glWidth, glHeight); |
| 1220 | } |
| 1221 | |
| 1222 | // This texture is the color (destination) buffer of the FBO. |
| 1223 | tempFbo.setColorBuffer(this); |
| 1224 | tempFbo.disableDepthTest(); |
| 1225 | |
| 1226 | // FBO copy: |
| 1227 | pg.pushFramebuffer(); |
| 1228 | pg.setFramebuffer(tempFbo); |
| 1229 | // Replaces anything that this texture might contain in the area being |
| 1230 | // replaced by the new one. |
| 1231 | pg.pushStyle(); |
| 1232 | pg.blendMode(REPLACE); |
| 1233 | if (scale) { |
| 1234 | // Rendering tex into "this", and scaling the source rectangle |
| 1235 | // to cover the entire destination region. |
| 1236 | pgl.drawTexture(tex.glTarget, tex.glName, tex.glWidth, tex.glHeight, |
| 1237 | 0, 0, tempFbo.width, tempFbo.height, 1, |
| 1238 | x, y, x + w, y + h, 0, 0, width, height); |
| 1239 | |
| 1240 | } else { |
| 1241 | // Rendering tex into "this" but without scaling so the contents |
| 1242 | // of the source texture fall in the corresponding texels of the |
| 1243 | // destination. |
| 1244 | pgl.drawTexture(tex.glTarget, tex.glName, tex.glWidth, tex.glHeight, |
| 1245 | 0, 0, tempFbo.width, tempFbo.height, 1, |
| 1246 | x, y, x + w, y + h, x, y, x + w, y + h); |
| 1247 | } |
| 1248 | pgl.flush(); // Needed to make sure that the change in this texture is |
| 1249 | // available immediately. |
| 1250 | pg.popStyle(); |
| 1251 | pg.popFramebuffer(); |
| 1252 | updateTexels(x, y, w, h); |
| 1253 | } |
| 1254 | |
| 1255 | |
| 1256 | // Copies source texture tex into this. |
no test coverage detected