@@ -1027,8 +1027,10 @@ protected void copyToTexture(int target, int format, int id, int x, int y,
10271027 */
10281028 public void drawTexture (int target , int id , int width , int height ,
10291029 int X0 , int Y0 , int X1 , int Y1 ) {
1030+ // If a texture is drawing on a viewport of the same size as its resolution,
1031+ // the pixel factor is 1:1, so we override the surface's pixel factor.
10301032 drawTexture (target , id , width , height ,
1031- 0 , 0 , width , height ,
1033+ 0 , 0 , width , height , 1 ,
10321034 X0 , Y0 , X1 , Y1 ,
10331035 X0 , Y0 , X1 , Y1 );
10341036 }
@@ -1038,17 +1040,29 @@ public void drawTexture(int target, int id, int width, int height,
10381040 * Not an approved function, this will change or be removed in the future.
10391041 */
10401042 public void drawTexture (int target , int id ,int texW , int texH ,
1041- int viewX , int viewY , int scrW , int scrH ,
1043+ int viewX , int viewY , int viewW , int viewH ,
1044+ int texX0 , int texY0 , int texX1 , int texY1 ,
1045+ int scrX0 , int scrY0 , int scrX1 , int scrY1 ) {
1046+ int viewF = (int )pg .getPixelScale ();
1047+ drawTexture (target , id , texW , texH ,
1048+ viewX , viewY , viewW , viewH , viewF ,
1049+ texX0 , texY0 , texX1 , texY1 ,
1050+ scrX0 , scrY0 , scrX1 , scrY1 );
1051+ }
1052+
1053+
1054+ public void drawTexture (int target , int id ,int texW , int texH ,
1055+ int viewX , int viewY , int viewW , int viewH , int viewF ,
10421056 int texX0 , int texY0 , int texX1 , int texY1 ,
10431057 int scrX0 , int scrY0 , int scrX1 , int scrY1 ) {
10441058 if (target == TEXTURE_2D ) {
10451059 drawTexture2D (id , texW , texH ,
1046- viewX , viewY , scrW , scrH ,
1060+ viewX , viewY , viewW , viewH , viewF ,
10471061 texX0 , texY0 , texX1 , texY1 ,
10481062 scrX0 , scrY0 , scrX1 , scrY1 );
10491063 } else if (target == TEXTURE_RECTANGLE ) {
10501064 drawTextureRect (id , texW , texH ,
1051- viewX , viewY , scrW , scrH ,
1065+ viewX , viewY , viewW , viewH , viewF ,
10521066 texX0 , texY0 , texX1 , texY1 ,
10531067 scrX0 , scrY0 , scrX1 , scrY1 );
10541068 }
@@ -1089,7 +1103,7 @@ protected PGL initTex2DShader() {
10891103
10901104
10911105 protected void drawTexture2D (int id , int texW , int texH ,
1092- int viewX , int viewY , int scrW , int scrH ,
1106+ int viewX , int viewY , int viewW , int viewH , int viewF ,
10931107 int texX0 , int texY0 , int texX1 , int texY1 ,
10941108 int scrX0 , int scrY0 , int scrX1 , int scrY1 ) {
10951109 PGL ppgl = initTex2DShader ();
@@ -1109,7 +1123,7 @@ protected void drawTexture2D(int id, int texW, int texH,
11091123 // Making sure that the viewport matches the provided screen dimensions
11101124 viewBuffer .rewind ();
11111125 getIntegerv (VIEWPORT , viewBuffer );
1112- viewport ( viewX , viewY , scrW , scrH );
1126+ viewportImpl ( viewF * viewX , viewF * viewY , viewF * viewW , viewF * viewH );
11131127
11141128 useProgram (ppgl .tex2DShaderProgram );
11151129
@@ -1119,23 +1133,23 @@ protected void drawTexture2D(int id, int texW, int texH,
11191133 // Vertex coordinates of the textured quad are specified
11201134 // in normalized screen space (-1, 1):
11211135 // Corner 1
1122- texCoords [ 0 ] = 2 * (float )scrX0 / scrW - 1 ;
1123- texCoords [ 1 ] = 2 * (float )scrY0 / scrH - 1 ;
1136+ texCoords [ 0 ] = 2 * (float )scrX0 / viewW - 1 ;
1137+ texCoords [ 1 ] = 2 * (float )scrY0 / viewH - 1 ;
11241138 texCoords [ 2 ] = (float )texX0 / texW ;
11251139 texCoords [ 3 ] = (float )texY0 / texH ;
11261140 // Corner 2
1127- texCoords [ 4 ] = 2 * (float )scrX1 / scrW - 1 ;
1128- texCoords [ 5 ] = 2 * (float )scrY0 / scrH - 1 ;
1141+ texCoords [ 4 ] = 2 * (float )scrX1 / viewW - 1 ;
1142+ texCoords [ 5 ] = 2 * (float )scrY0 / viewH - 1 ;
11291143 texCoords [ 6 ] = (float )texX1 / texW ;
11301144 texCoords [ 7 ] = (float )texY0 / texH ;
11311145 // Corner 3
1132- texCoords [ 8 ] = 2 * (float )scrX0 / scrW - 1 ;
1133- texCoords [ 9 ] = 2 * (float )scrY1 / scrH - 1 ;
1146+ texCoords [ 8 ] = 2 * (float )scrX0 / viewW - 1 ;
1147+ texCoords [ 9 ] = 2 * (float )scrY1 / viewH - 1 ;
11341148 texCoords [10 ] = (float )texX0 / texW ;
11351149 texCoords [11 ] = (float )texY1 / texH ;
11361150 // Corner 4
1137- texCoords [12 ] = 2 * (float )scrX1 / scrW - 1 ;
1138- texCoords [13 ] = 2 * (float )scrY1 / scrH - 1 ;
1151+ texCoords [12 ] = 2 * (float )scrX1 / viewW - 1 ;
1152+ texCoords [13 ] = 2 * (float )scrY1 / viewH - 1 ;
11391153 texCoords [14 ] = (float )texX1 / texW ;
11401154 texCoords [15 ] = (float )texY1 / texH ;
11411155
@@ -1179,8 +1193,8 @@ protected void drawTexture2D(int id, int texW, int texH,
11791193 }
11801194 depthMask (depthMask );
11811195
1182- viewport (viewBuffer .get (0 ), viewBuffer .get (1 ),
1183- viewBuffer .get (2 ), viewBuffer .get (3 ));
1196+ viewportImpl (viewBuffer .get (0 ), viewBuffer .get (1 ),
1197+ viewBuffer .get (2 ), viewBuffer .get (3 ));
11841198 }
11851199 }
11861200
@@ -1216,7 +1230,7 @@ protected PGL initTexRectShader() {
12161230
12171231
12181232 protected void drawTextureRect (int id , int texW , int texH ,
1219- int viewX , int viewY , int scrW , int scrH ,
1233+ int viewX , int viewY , int viewW , int viewH , int viewF ,
12201234 int texX0 , int texY0 , int texX1 , int texY1 ,
12211235 int scrX0 , int scrY0 , int scrX1 , int scrY1 ) {
12221236 PGL ppgl = initTexRectShader ();
@@ -1240,7 +1254,7 @@ protected void drawTextureRect(int id, int texW, int texH,
12401254 // Making sure that the viewport matches the provided screen dimensions
12411255 viewBuffer .rewind ();
12421256 getIntegerv (VIEWPORT , viewBuffer );
1243- viewport ( viewX , viewY , scrW , scrH );
1257+ viewportImpl ( viewF * viewX , viewF * viewY , viewF * viewW , viewF * viewH );
12441258
12451259 useProgram (ppgl .texRectShaderProgram );
12461260
@@ -1250,23 +1264,23 @@ protected void drawTextureRect(int id, int texW, int texH,
12501264 // Vertex coordinates of the textured quad are specified
12511265 // in normalized screen space (-1, 1):
12521266 // Corner 1
1253- texCoords [ 0 ] = 2 * (float )scrX0 / scrW - 1 ;
1254- texCoords [ 1 ] = 2 * (float )scrY0 / scrH - 1 ;
1267+ texCoords [ 0 ] = 2 * (float )scrX0 / viewW - 1 ;
1268+ texCoords [ 1 ] = 2 * (float )scrY0 / viewH - 1 ;
12551269 texCoords [ 2 ] = texX0 ;
12561270 texCoords [ 3 ] = texY0 ;
12571271 // Corner 2
1258- texCoords [ 4 ] = 2 * (float )scrX1 / scrW - 1 ;
1259- texCoords [ 5 ] = 2 * (float )scrY0 / scrH - 1 ;
1272+ texCoords [ 4 ] = 2 * (float )scrX1 / viewW - 1 ;
1273+ texCoords [ 5 ] = 2 * (float )scrY0 / viewH - 1 ;
12601274 texCoords [ 6 ] = texX1 ;
12611275 texCoords [ 7 ] = texY0 ;
12621276 // Corner 3
1263- texCoords [ 8 ] = 2 * (float )scrX0 / scrW - 1 ;
1264- texCoords [ 9 ] = 2 * (float )scrY1 / scrH - 1 ;
1277+ texCoords [ 8 ] = 2 * (float )scrX0 / viewW - 1 ;
1278+ texCoords [ 9 ] = 2 * (float )scrY1 / viewH - 1 ;
12651279 texCoords [10 ] = texX0 ;
12661280 texCoords [11 ] = texY1 ;
12671281 // Corner 4
1268- texCoords [12 ] = 2 * (float )scrX1 / scrW - 1 ;
1269- texCoords [13 ] = 2 * (float )scrY1 / scrH - 1 ;
1282+ texCoords [12 ] = 2 * (float )scrX1 / viewW - 1 ;
1283+ texCoords [13 ] = 2 * (float )scrY1 / viewH - 1 ;
12701284 texCoords [14 ] = texX1 ;
12711285 texCoords [15 ] = texY1 ;
12721286
@@ -1310,8 +1324,8 @@ protected void drawTextureRect(int id, int texW, int texH,
13101324 }
13111325 depthMask (depthMask );
13121326
1313- viewport (viewBuffer .get (0 ), viewBuffer .get (1 ),
1314- viewBuffer .get (2 ), viewBuffer .get (3 ));
1327+ viewportImpl (viewBuffer .get (0 ), viewBuffer .get (1 ),
1328+ viewBuffer .get (2 ), viewBuffer .get (3 ));
13151329 }
13161330 }
13171331
@@ -2706,6 +2720,7 @@ protected interface FontOutline {
27062720
27072721 public abstract void depthRangef (float n , float f );
27082722 public abstract void viewport (int x , int y , int w , int h );
2723+ protected abstract void viewportImpl (int x , int y , int w , int h );
27092724
27102725 //////////////////////////////////////////////////////////////////////////////
27112726
0 commit comments