@@ -105,6 +105,9 @@ public void dispose() {
105
105
/** Current flush mode. */
106
106
protected int flushMode = FLUSH_WHEN_FULL ;
107
107
108
+ /** Orientation of Y axis. */
109
+ static protected boolean Y_AXIS_DOWN = true ;
110
+
108
111
// ........................................................
109
112
110
113
// VBOs for immediate rendering:
@@ -3577,10 +3580,14 @@ protected void textCharImpl(char ch, float x, float y) {
3577
3580
float lextent = glyph .leftExtent / (float ) textFont .getSize ();
3578
3581
float textent = glyph .topExtent / (float ) textFont .getSize ();
3579
3582
3583
+ // The default text setting assumes an Y axis pointing down, so
3584
+ // inverting in the the case Y points up
3585
+ int sign = Y_AXIS_DOWN ? +1 : -1 ;
3586
+
3580
3587
float x1 = x + lextent * textSize ;
3581
- float y1 = y - textent * textSize ;
3588
+ float y1 = y - sign * textent * textSize ;
3582
3589
float x2 = x1 + bwidth * textSize ;
3583
- float y2 = y1 + high * textSize ;
3590
+ float y2 = y1 + sign * high * textSize ;
3584
3591
3585
3592
textCharModelImpl (tinfo , x1 , y1 , x2 , y2 );
3586
3593
} else if (textMode == SHAPE ) {
@@ -5875,7 +5882,7 @@ protected void loadTextureImpl(int sampling, boolean mipmap) {
5875
5882
Texture .Parameters params = new Texture .Parameters (ARGB ,
5876
5883
sampling , mipmap );
5877
5884
texture = new Texture (this , pixelWidth , pixelHeight , params );
5878
- texture .invertedY (true );
5885
+ texture .invertedY (Y_AXIS_DOWN );
5879
5886
texture .colorBuffer (true );
5880
5887
setCache (this , texture );
5881
5888
}
@@ -5886,7 +5893,7 @@ protected void createPTexture() {
5886
5893
updatePixelSize ();
5887
5894
if (texture != null ) {
5888
5895
ptexture = new Texture (this , pixelWidth , pixelHeight , texture .getParameters ());
5889
- ptexture .invertedY (true );
5896
+ ptexture .invertedY (Y_AXIS_DOWN );
5890
5897
ptexture .colorBuffer (true );
5891
5898
}
5892
5899
}
@@ -6026,7 +6033,7 @@ public void filter(PShader shader) {
6026
6033
if (filterTexture == null || filterTexture .contextIsOutdated ()) {
6027
6034
filterTexture = new Texture (this , texture .width , texture .height ,
6028
6035
texture .getParameters ());
6029
- filterTexture .invertedY (true );
6036
+ filterTexture .invertedY (Y_AXIS_DOWN );
6030
6037
filterImage = wrapTexture (filterTexture );
6031
6038
}
6032
6039
filterTexture .set (texture );
@@ -6096,7 +6103,7 @@ public void copy(int sx, int sy, int sw, int sh,
6096
6103
loadTexture ();
6097
6104
if (filterTexture == null || filterTexture .contextIsOutdated ()) {
6098
6105
filterTexture = new Texture (this , texture .width , texture .height , texture .getParameters ());
6099
- filterTexture .invertedY (true );
6106
+ filterTexture .invertedY (Y_AXIS_DOWN );
6100
6107
filterImage = wrapTexture (filterTexture );
6101
6108
}
6102
6109
filterTexture .put (texture , sx , height - (sy + sh ), sw , height - sy );
@@ -6416,6 +6423,7 @@ protected Texture addTexture(PImage img, Texture.Parameters params) {
6416
6423
img .parent = parent ;
6417
6424
}
6418
6425
Texture tex = new Texture (this , img .pixelWidth , img .pixelHeight , params );
6426
+ tex .invertedY (!Y_AXIS_DOWN ); // Pixels are read upside down
6419
6427
setCache (img , tex );
6420
6428
return tex ;
6421
6429
}
0 commit comments