@@ -407,6 +407,7 @@ public class PGL {
407407
408408 protected ByteBuffer byteBuffer ;
409409 protected IntBuffer intBuffer ;
410+ protected IntBuffer viewBuffer ;
410411
411412 protected IntBuffer colorBuffer ;
412413 protected FloatBuffer depthBuffer ;
@@ -465,6 +466,7 @@ public PGL(PGraphicsOpenGL pg) {
465466
466467 byteBuffer = allocateByteBuffer (1 );
467468 intBuffer = allocateIntBuffer (1 );
469+ viewBuffer = allocateIntBuffer (4 );
468470 }
469471
470472
@@ -1448,7 +1450,7 @@ protected void initTexture(int target, int format, int width, int height) {
14481450
14491451
14501452 protected void initTexture (int target , int format , int width , int height ,
1451- int initColor ) {
1453+ int initColor ) {
14521454 int [] glcolor = new int [16 * 16 ];
14531455 Arrays .fill (glcolor , javaToNativeARGB (initColor ));
14541456 IntBuffer texels = PGL .allocateDirectIntBuffer (16 * 16 );
@@ -1544,6 +1546,11 @@ protected void drawTexture2D(int id, int texW, int texH, int scrW, int scrH,
15441546 boolean depthMask = getDepthWriteMask ();
15451547 depthMask (false );
15461548
1549+ // Making sure that the viewport matches the provided screen dimensions
1550+ viewBuffer .rewind ();
1551+ getIntegerv (VIEWPORT , viewBuffer );
1552+ viewport (0 , 0 , scrW , scrH );
1553+
15471554 useProgram (tex2DShaderProgram );
15481555
15491556 enableVertexAttribArray (tex2DVertLoc );
@@ -1610,6 +1617,9 @@ protected void drawTexture2D(int id, int texW, int texH, int scrW, int scrH,
16101617 disable (DEPTH_TEST );
16111618 }
16121619 depthMask (depthMask );
1620+
1621+ viewport (viewBuffer .get (0 ), viewBuffer .get (1 ),
1622+ viewBuffer .get (2 ),viewBuffer .get (3 ));
16131623 }
16141624 }
16151625
@@ -1649,6 +1659,11 @@ protected void drawTextureRect(int id, int texW, int texH, int scrW, int scrH,
16491659 boolean depthMask = getDepthWriteMask ();
16501660 depthMask (false );
16511661
1662+ // Making sure that the viewport matches the provided screen dimensions
1663+ viewBuffer .rewind ();
1664+ getIntegerv (VIEWPORT , viewBuffer );
1665+ viewport (0 , 0 , scrW , scrH );
1666+
16521667 useProgram (texRectShaderProgram );
16531668
16541669 enableVertexAttribArray (texRectVertLoc );
@@ -1715,6 +1730,9 @@ protected void drawTextureRect(int id, int texW, int texH, int scrW, int scrH,
17151730 disable (DEPTH_TEST );
17161731 }
17171732 depthMask (depthMask );
1733+
1734+ viewport (viewBuffer .get (0 ), viewBuffer .get (1 ),
1735+ viewBuffer .get (2 ),viewBuffer .get (3 ));
17181736 }
17191737 }
17201738
@@ -2124,12 +2142,14 @@ protected boolean hasShaders() {
21242142
21252143
21262144 protected int maxSamples () {
2145+ intBuffer .rewind ();
21272146 getIntegerv (MAX_SAMPLES , intBuffer );
21282147 return intBuffer .get (0 );
21292148 }
21302149
21312150
21322151 protected int getMaxTexUnits () {
2152+ intBuffer .rewind ();
21332153 getIntegerv (MAX_TEXTURE_IMAGE_UNITS , intBuffer );
21342154 return intBuffer .get (0 );
21352155 }
0 commit comments