@@ -105,8 +105,10 @@ 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 ;
108
+ /**
109
+ * Keeps track of ENABLE_OPENGL_COORDINATES hint
110
+ */
111
+ protected boolean glCoordsEnabled = false ;
110
112
111
113
// ........................................................
112
114
@@ -1851,7 +1853,15 @@ public void hint(int which) {
1851
1853
return ;
1852
1854
}
1853
1855
1854
- if (which == DISABLE_DEPTH_TEST ) {
1856
+ if (which == DISABLE_OPENGL_COORDINATES ) {
1857
+ flush ();
1858
+ glCoordsEnabled = false ;
1859
+
1860
+ } else if (which == ENABLE_OPENGL_COORDINATES ) {
1861
+ flush ();
1862
+ glCoordsEnabled = true ;
1863
+
1864
+ } else if (which == DISABLE_DEPTH_TEST ) {
1855
1865
flush ();
1856
1866
pgl .disable (PGL .DEPTH_TEST );
1857
1867
} else if (which == ENABLE_DEPTH_TEST ) {
@@ -3465,7 +3475,7 @@ public void text(char c, float x, float y) {
3465
3475
defaultFontOrDeath ("text" );
3466
3476
}
3467
3477
3468
- int sign = Y_AXIS_DOWN ? +1 : -1 ;
3478
+ int sign = glCoordsEnabled ? +1 : -1 ;
3469
3479
3470
3480
if (textAlignY == CENTER ) {
3471
3481
y += sign * textAscent () / 2 ;
@@ -3488,7 +3498,7 @@ public void text(String str, float x, float y) {
3488
3498
defaultFontOrDeath ("text" );
3489
3499
}
3490
3500
3491
- int sign = Y_AXIS_DOWN ? +1 : -1 ;
3501
+ int sign = glCoordsEnabled ? +1 : -1 ;
3492
3502
3493
3503
int length = str .length ();
3494
3504
if (length > textBuffer .length ) {
@@ -3540,7 +3550,7 @@ public void text(String str, float x1, float y1, float x2, float y2) {
3540
3550
defaultFontOrDeath ("text" );
3541
3551
}
3542
3552
3543
- int sign = Y_AXIS_DOWN ? +1 : -1 ;
3553
+ int sign = glCoordsEnabled ? +1 : -1 ;
3544
3554
3545
3555
float hradius , vradius ;
3546
3556
switch (rectMode ) {
@@ -3618,21 +3628,21 @@ public void text(String str, float x1, float y1, float x2, float y2) {
3618
3628
if (textAlignY == CENTER ) {
3619
3629
lineX = 0 ;
3620
3630
float lineHigh = textAscent () + textLeading * (lineCount - 1 );
3621
- float y = Y_AXIS_DOWN ? y1 + textAscent () + (boxHeight - lineHigh ) / 2 : y2 - textAscent () - (boxHeight - lineHigh ) / 2 ;
3631
+ float y = glCoordsEnabled ? y1 + textAscent () + (boxHeight - lineHigh ) / 2 : y2 - textAscent () - (boxHeight - lineHigh ) / 2 ;
3622
3632
for (int i = 0 ; i < lineCount ; i ++) {
3623
3633
textLineAlignImpl (textBuffer , textBreakStart [i ], textBreakStop [i ], lineX , y );
3624
3634
y += sign * textLeading ;
3625
3635
}
3626
3636
3627
3637
} else if (textAlignY == BOTTOM ) {
3628
- float y = Y_AXIS_DOWN ? y2 - textDescent () - textLeading * (lineCount - 1 ) : y1 + textDescent () + textLeading * (lineCount - 1 );
3638
+ float y = glCoordsEnabled ? y2 - textDescent () - textLeading * (lineCount - 1 ) : y1 + textDescent () + textLeading * (lineCount - 1 );
3629
3639
for (int i = 0 ; i < lineCount ; i ++) {
3630
3640
textLineAlignImpl (textBuffer , textBreakStart [i ], textBreakStop [i ], lineX , y );
3631
3641
y += sign * textLeading ;
3632
3642
}
3633
3643
3634
3644
} else { // TOP or BASELINE just go to the default
3635
- float y = Y_AXIS_DOWN ? y1 + textAscent () : y2 - textAscent ();
3645
+ float y = glCoordsEnabled ? y1 + textAscent () : y2 - textAscent ();
3636
3646
for (int i = 0 ; i < lineCount ; i ++) {
3637
3647
textLineAlignImpl (textBuffer , textBreakStart [i ], textBreakStop [i ], lineX , y );
3638
3648
y += sign * textLeading ;
@@ -3764,7 +3774,7 @@ protected void textCharImpl(char ch, float x, float y) {
3764
3774
3765
3775
// The default text setting assumes an Y axis pointing down, so
3766
3776
// inverting in the the case Y points up
3767
- int sign = Y_AXIS_DOWN ? +1 : -1 ;
3777
+ int sign = glCoordsEnabled ? +1 : -1 ;
3768
3778
3769
3779
float x1 = x + lextent * textSize ;
3770
3780
float y1 = y - sign * textent * textSize ;
@@ -6064,7 +6074,7 @@ protected void loadTextureImpl(int sampling, boolean mipmap) {
6064
6074
Texture .Parameters params = new Texture .Parameters (ARGB ,
6065
6075
sampling , mipmap );
6066
6076
texture = new Texture (this , pixelWidth , pixelHeight , params );
6067
- texture .invertedY (Y_AXIS_DOWN );
6077
+ texture .invertedY (glCoordsEnabled );
6068
6078
texture .colorBuffer (true );
6069
6079
setCache (this , texture );
6070
6080
}
@@ -6075,7 +6085,7 @@ protected void createPTexture() {
6075
6085
updatePixelSize ();
6076
6086
if (texture != null ) {
6077
6087
ptexture = new Texture (this , pixelWidth , pixelHeight , texture .getParameters ());
6078
- ptexture .invertedY (Y_AXIS_DOWN );
6088
+ ptexture .invertedY (glCoordsEnabled );
6079
6089
ptexture .colorBuffer (true );
6080
6090
}
6081
6091
}
@@ -6215,7 +6225,7 @@ public void filter(PShader shader) {
6215
6225
if (filterTexture == null || filterTexture .contextIsOutdated ()) {
6216
6226
filterTexture = new Texture (this , texture .width , texture .height ,
6217
6227
texture .getParameters ());
6218
- filterTexture .invertedY (Y_AXIS_DOWN );
6228
+ filterTexture .invertedY (glCoordsEnabled );
6219
6229
filterImage = wrapTexture (filterTexture );
6220
6230
}
6221
6231
filterTexture .set (texture );
@@ -6285,7 +6295,7 @@ public void copy(int sx, int sy, int sw, int sh,
6285
6295
loadTexture ();
6286
6296
if (filterTexture == null || filterTexture .contextIsOutdated ()) {
6287
6297
filterTexture = new Texture (this , texture .width , texture .height , texture .getParameters ());
6288
- filterTexture .invertedY (Y_AXIS_DOWN );
6298
+ filterTexture .invertedY (glCoordsEnabled );
6289
6299
filterImage = wrapTexture (filterTexture );
6290
6300
}
6291
6301
filterTexture .put (texture , sx , height - (sy + sh ), sw , height - sy );
@@ -6605,7 +6615,7 @@ protected Texture addTexture(PImage img, Texture.Parameters params) {
6605
6615
img .parent = parent ;
6606
6616
}
6607
6617
Texture tex = new Texture (this , img .pixelWidth , img .pixelHeight , params );
6608
- tex .invertedY (!Y_AXIS_DOWN ); // Pixels are read upside down
6618
+ tex .invertedY (!glCoordsEnabled ); // Pixels are read upside down
6609
6619
setCache (img , tex );
6610
6620
return tex ;
6611
6621
}
0 commit comments