@@ -105,10 +105,6 @@ public void dispose() {
105
105
/** Current flush mode. */
106
106
protected int flushMode = FLUSH_WHEN_FULL ;
107
107
108
- /**
109
- * Keeps track of ENABLE_OPENGL_COORDINATES hint
110
- */
111
- protected boolean glCoordsEnabled = false ;
112
108
113
109
// ........................................................
114
110
@@ -278,6 +274,12 @@ public void dispose() {
278
274
/** Flag to indicate that we are inside beginCamera/endCamera block. */
279
275
protected boolean manipulatingCamera ;
280
276
277
+ /**
278
+ * Sets the coordinates to "first person" setting: Y axis up, origin at
279
+ * screen center
280
+ */
281
+ protected boolean cameraUp = false ;
282
+
281
283
// ........................................................
282
284
283
285
// All the matrices required for camera and geometry transformations.
@@ -1583,7 +1585,7 @@ protected void restoreGL() {
1583
1585
pgl .disable (PGL .SCISSOR_TEST );
1584
1586
}
1585
1587
1586
- pgl .frontFace (glCoordsEnabled ? PGL .CCW : PGL .CW );
1588
+ pgl .frontFace (cameraUp ? PGL .CCW : PGL .CW );
1587
1589
pgl .disable (PGL .CULL_FACE );
1588
1590
1589
1591
pgl .activeTexture (PGL .TEXTURE0 );
@@ -3467,7 +3469,7 @@ public void text(char c, float x, float y) {
3467
3469
defaultFontOrDeath ("text" );
3468
3470
}
3469
3471
3470
- int sign = glCoordsEnabled ? -1 : +1 ;
3472
+ int sign = cameraUp ? -1 : +1 ;
3471
3473
3472
3474
if (textAlignY == CENTER ) {
3473
3475
y += sign * textAscent () / 2 ;
@@ -3490,7 +3492,7 @@ public void text(String str, float x, float y) {
3490
3492
defaultFontOrDeath ("text" );
3491
3493
}
3492
3494
3493
- int sign = glCoordsEnabled ? -1 : +1 ;
3495
+ int sign = cameraUp ? -1 : +1 ;
3494
3496
3495
3497
int length = str .length ();
3496
3498
if (length > textBuffer .length ) {
@@ -3542,7 +3544,7 @@ public void text(String str, float x1, float y1, float x2, float y2) {
3542
3544
defaultFontOrDeath ("text" );
3543
3545
}
3544
3546
3545
- int sign = glCoordsEnabled ? -1 : +1 ;
3547
+ int sign = cameraUp ? -1 : +1 ;
3546
3548
3547
3549
float hradius , vradius ;
3548
3550
switch (rectMode ) {
@@ -3619,23 +3621,23 @@ public void text(String str, float x1, float y1, float x2, float y2) {
3619
3621
3620
3622
if (textAlignY == CENTER ) {
3621
3623
float lineHigh = textAscent () + textLeading * (lineCount - 1 );
3622
- float y = glCoordsEnabled ? y2 - textAscent () - (boxHeight - lineHigh ) / 2 :
3624
+ float y = cameraUp ? y2 - textAscent () - (boxHeight - lineHigh ) / 2 :
3623
3625
y1 + textAscent () + (boxHeight - lineHigh ) / 2 ;
3624
3626
for (int i = 0 ; i < lineCount ; i ++) {
3625
3627
textLineAlignImpl (textBuffer , textBreakStart [i ], textBreakStop [i ], lineX , y );
3626
3628
y += sign * textLeading ;
3627
3629
}
3628
3630
3629
3631
} else if (textAlignY == BOTTOM ) {
3630
- float y = glCoordsEnabled ? y1 + textDescent () + textLeading * (lineCount - 1 ) :
3632
+ float y = cameraUp ? y1 + textDescent () + textLeading * (lineCount - 1 ) :
3631
3633
y2 - textDescent () - textLeading * (lineCount - 1 );
3632
3634
for (int i = 0 ; i < lineCount ; i ++) {
3633
3635
textLineAlignImpl (textBuffer , textBreakStart [i ], textBreakStop [i ], lineX , y );
3634
3636
y += sign * textLeading ;
3635
3637
}
3636
3638
3637
3639
} else { // TOP or BASELINE just go to the default
3638
- float y = glCoordsEnabled ? y2 - textAscent () : y1 + textAscent ();
3640
+ float y = cameraUp ? y2 - textAscent () : y1 + textAscent ();
3639
3641
for (int i = 0 ; i < lineCount ; i ++) {
3640
3642
textLineAlignImpl (textBuffer , textBreakStart [i ], textBreakStop [i ], lineX , y );
3641
3643
y += sign * textLeading ;
@@ -3767,7 +3769,7 @@ protected void textCharImpl(char ch, float x, float y) {
3767
3769
3768
3770
// The default text setting assumes an Y axis pointing down, so
3769
3771
// inverting in the the case Y points up
3770
- int sign = glCoordsEnabled ? -1 : +1 ;
3772
+ int sign = cameraUp ? -1 : +1 ;
3771
3773
3772
3774
float x1 = x + lextent * textSize ;
3773
3775
float y1 = y - sign * textent * textSize ;
@@ -4627,6 +4629,12 @@ public void printCamera() {
4627
4629
}
4628
4630
4629
4631
4632
+ @ Override
4633
+ public void cameraUp () {
4634
+ cameraUp = true ;
4635
+ }
4636
+
4637
+
4630
4638
protected void defaultCamera () {
4631
4639
camera ();
4632
4640
}
@@ -6067,7 +6075,7 @@ protected void loadTextureImpl(int sampling, boolean mipmap) {
6067
6075
Texture .Parameters params = new Texture .Parameters (ARGB ,
6068
6076
sampling , mipmap );
6069
6077
texture = new Texture (this , pixelWidth , pixelHeight , params );
6070
- texture .invertedY (glCoordsEnabled );
6078
+ texture .invertedY (cameraUp );
6071
6079
texture .colorBuffer (true );
6072
6080
setCache (this , texture );
6073
6081
}
@@ -6078,7 +6086,7 @@ protected void createPTexture() {
6078
6086
updatePixelSize ();
6079
6087
if (texture != null ) {
6080
6088
ptexture = new Texture (this , pixelWidth , pixelHeight , texture .getParameters ());
6081
- ptexture .invertedY (glCoordsEnabled );
6089
+ ptexture .invertedY (cameraUp );
6082
6090
ptexture .colorBuffer (true );
6083
6091
}
6084
6092
}
@@ -6218,7 +6226,7 @@ public void filter(PShader shader) {
6218
6226
if (filterTexture == null || filterTexture .contextIsOutdated ()) {
6219
6227
filterTexture = new Texture (this , texture .width , texture .height ,
6220
6228
texture .getParameters ());
6221
- filterTexture .invertedY (glCoordsEnabled );
6229
+ filterTexture .invertedY (cameraUp );
6222
6230
filterImage = wrapTexture (filterTexture );
6223
6231
}
6224
6232
filterTexture .set (texture );
@@ -6288,7 +6296,7 @@ public void copy(int sx, int sy, int sw, int sh,
6288
6296
loadTexture ();
6289
6297
if (filterTexture == null || filterTexture .contextIsOutdated ()) {
6290
6298
filterTexture = new Texture (this , texture .width , texture .height , texture .getParameters ());
6291
- filterTexture .invertedY (glCoordsEnabled );
6299
+ filterTexture .invertedY (cameraUp );
6292
6300
filterImage = wrapTexture (filterTexture );
6293
6301
}
6294
6302
filterTexture .put (texture , sx , height - (sy + sh ), sw , height - sy );
@@ -6608,7 +6616,7 @@ protected Texture addTexture(PImage img, Texture.Parameters params) {
6608
6616
img .parent = parent ;
6609
6617
}
6610
6618
Texture tex = new Texture (this , img .pixelWidth , img .pixelHeight , params );
6611
- tex .invertedY (!glCoordsEnabled ); // Pixels are read upside down
6619
+ tex .invertedY (!cameraUp ); // Pixels are read upside down
6612
6620
setCache (img , tex );
6613
6621
return tex ;
6614
6622
}
@@ -6972,7 +6980,7 @@ protected void setGLSettings() {
6972
6980
// polygons are CCW in window coordinates, whereas are CW
6973
6981
// in the left-handed system that is Processing's default (with
6974
6982
// its Y axis pointing down)
6975
- pgl .frontFace (glCoordsEnabled ? PGL .CCW : PGL .CW );
6983
+ pgl .frontFace (cameraUp ? PGL .CCW : PGL .CW );
6976
6984
pgl .disable (PGL .CULL_FACE );
6977
6985
6978
6986
// Processing uses only one texture unit.
0 commit comments