mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
set viewport in PGL.drawTexture(), fixes #1869
This commit is contained in:
@@ -407,6 +407,7 @@ public class PGL {
|
||||
|
||||
protected ByteBuffer byteBuffer;
|
||||
protected IntBuffer intBuffer;
|
||||
protected IntBuffer viewBuffer;
|
||||
|
||||
protected IntBuffer colorBuffer;
|
||||
protected FloatBuffer depthBuffer;
|
||||
@@ -465,6 +466,7 @@ public class PGL {
|
||||
|
||||
byteBuffer = allocateByteBuffer(1);
|
||||
intBuffer = allocateIntBuffer(1);
|
||||
viewBuffer = allocateIntBuffer(4);
|
||||
}
|
||||
|
||||
|
||||
@@ -1448,7 +1450,7 @@ public class PGL {
|
||||
|
||||
|
||||
protected void initTexture(int target, int format, int width, int height,
|
||||
int initColor) {
|
||||
int initColor) {
|
||||
int[] glcolor = new int[16 * 16];
|
||||
Arrays.fill(glcolor, javaToNativeARGB(initColor));
|
||||
IntBuffer texels = PGL.allocateDirectIntBuffer(16 * 16);
|
||||
@@ -1544,6 +1546,11 @@ public class PGL {
|
||||
boolean depthMask = getDepthWriteMask();
|
||||
depthMask(false);
|
||||
|
||||
// Making sure that the viewport matches the provided screen dimensions
|
||||
viewBuffer.rewind();
|
||||
getIntegerv(VIEWPORT, viewBuffer);
|
||||
viewport(0, 0, scrW, scrH);
|
||||
|
||||
useProgram(tex2DShaderProgram);
|
||||
|
||||
enableVertexAttribArray(tex2DVertLoc);
|
||||
@@ -1610,6 +1617,9 @@ public class PGL {
|
||||
disable(DEPTH_TEST);
|
||||
}
|
||||
depthMask(depthMask);
|
||||
|
||||
viewport(viewBuffer.get(0), viewBuffer.get(1),
|
||||
viewBuffer.get(2),viewBuffer.get(3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1649,6 +1659,11 @@ public class PGL {
|
||||
boolean depthMask = getDepthWriteMask();
|
||||
depthMask(false);
|
||||
|
||||
// Making sure that the viewport matches the provided screen dimensions
|
||||
viewBuffer.rewind();
|
||||
getIntegerv(VIEWPORT, viewBuffer);
|
||||
viewport(0, 0, scrW, scrH);
|
||||
|
||||
useProgram(texRectShaderProgram);
|
||||
|
||||
enableVertexAttribArray(texRectVertLoc);
|
||||
@@ -1715,6 +1730,9 @@ public class PGL {
|
||||
disable(DEPTH_TEST);
|
||||
}
|
||||
depthMask(depthMask);
|
||||
|
||||
viewport(viewBuffer.get(0), viewBuffer.get(1),
|
||||
viewBuffer.get(2),viewBuffer.get(3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2124,12 +2142,14 @@ public class PGL {
|
||||
|
||||
|
||||
protected int maxSamples() {
|
||||
intBuffer.rewind();
|
||||
getIntegerv(MAX_SAMPLES, intBuffer);
|
||||
return intBuffer.get(0);
|
||||
}
|
||||
|
||||
|
||||
protected int getMaxTexUnits() {
|
||||
intBuffer.rewind();
|
||||
getIntegerv(MAX_TEXTURE_IMAGE_UNITS, intBuffer);
|
||||
return intBuffer.get(0);
|
||||
}
|
||||
|
||||
@@ -3372,10 +3372,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (textTex.currentTex != info.texIndex) {
|
||||
textTex.setTexture(info.texIndex);
|
||||
}
|
||||
PImage tex = textTex.getCurrentTexture();
|
||||
|
||||
beginShape(QUADS);
|
||||
texture(tex);
|
||||
texture(textTex.getCurrentTexture());
|
||||
vertex(x0, y0, info.u0, info.v0);
|
||||
vertex(x1, y0, info.u1, info.v0);
|
||||
vertex(x1, y1, info.u1, info.v1);
|
||||
|
||||
@@ -1235,7 +1235,8 @@ public class Texture implements PConstants {
|
||||
// FBO copy:
|
||||
PGraphicsOpenGL.pushFramebuffer();
|
||||
PGraphicsOpenGL.setFramebuffer(tempFbo);
|
||||
// Clear the color buffer to make sure that the alpha of the
|
||||
// Clear the color buffer to make sure that the alpha channel is set to
|
||||
// full transparency
|
||||
pgl.clearColor(0, 0, 0, 0);
|
||||
pgl.clear(PGL.COLOR_BUFFER_BIT);
|
||||
if (scale) {
|
||||
@@ -1254,6 +1255,7 @@ public class Texture implements PConstants {
|
||||
x, y, w, h, x, y, w, h);
|
||||
}
|
||||
PGraphicsOpenGL.popFramebuffer();
|
||||
|
||||
updateTexels(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user