Merge branch 'master' of github.com:processing/processing

This commit is contained in:
Ben Fry
2015-05-17 09:35:07 -04:00
4 changed files with 35 additions and 23 deletions
+10 -11
View File
@@ -132,11 +132,6 @@ public abstract class PGL {
* order to make sure the lines are always on top of the fill geometry */
protected static float STROKE_DISPLACEMENT = 0.999f;
// ........................................................
// Retina support
int pixel_scale = 1;
// ........................................................
@@ -566,9 +561,10 @@ public abstract class PGL {
x = (int)offsetX;
y = (int)offsetY;
}
float scale = pg.getPixelScale();
drawTexture(TEXTURE_2D, glColorTex.get(frontTex), fboWidth, fboHeight,
x, y, pg.width, pg.height,
0, 0, pixel_scale * pg.width, pixel_scale * pg.height,
0, 0, (int)(scale * pg.width), (int)(scale * pg.height),
0, 0, pg.width, pg.height);
}
@@ -663,10 +659,11 @@ public abstract class PGL {
x = (int)offsetX;
y = (int)offsetY;
}
float scale = pg.getPixelScale();
drawTexture(TEXTURE_2D, glColorTex.get(backTex),
fboWidth, fboHeight,
x, y, pg.width, pg.height,
0, 0, pixel_scale * pg.width, pixel_scale * pg.height,
0, 0, (int)(scale * pg.width), (int)(scale * pg.height),
0, 0, pg.width, pg.height);
// Swapping front and back textures.
@@ -720,12 +717,14 @@ public abstract class PGL {
private void createFBOLayer() {
String ext = getString(EXTENSIONS);
float scale = pg.getPixelScale();
if (-1 < ext.indexOf("texture_non_power_of_two")) {
fboWidth = pixel_scale * pg.width;
fboHeight = pixel_scale * pg.height;
fboWidth = (int)(scale * pg.width);
fboHeight = (int)(scale * pg.height);
} else {
fboWidth = nextPowerOfTwo(pixel_scale * pg.width);
fboHeight = nextPowerOfTwo(pixel_scale * pg.height);
fboWidth = nextPowerOfTwo((int)(scale * pg.width));
fboHeight = nextPowerOfTwo((int)(scale * pg.height));
}
int maxs = maxSamples();
@@ -43,6 +43,9 @@ public class PGraphicsOpenGL extends PGraphics {
/** Font cache for texture objects. */
protected WeakHashMap<PFont, FontTexture> fontMap;
// just to get things running properly, need to
protected PSurfaceJOGL surfaceJOGL;
// ........................................................
// Basic rendering parameters:
@@ -668,8 +671,8 @@ public class PGraphicsOpenGL extends PGraphics {
@Override
public PSurface createSurface() { // ignore
return new PSurfaceJOGL(this);
// return new PSurfaceNEWT(this);
surfaceJOGL = new PSurfaceJOGL(this);
return surfaceJOGL;
}
@@ -696,6 +699,11 @@ public class PGraphicsOpenGL extends PGraphics {
}
public float getPixelScale() {
return surfaceJOGL.getPixelScale();
}
//////////////////////////////////////////////////////////////
+4 -2
View File
@@ -1892,7 +1892,8 @@ public class PJOGL extends PGL {
@Override
public void viewport(int x, int y, int w, int h) {
gl.glViewport(pixel_scale * x, pixel_scale * y, pixel_scale * w, pixel_scale * h);
float scale = pg.getPixelScale();
gl.glViewport((int)scale * x, (int)(scale * y), (int)(scale * w), (int)(scale * h));
// gl.glViewport(x, y, w, h);
}
@@ -2415,7 +2416,8 @@ public class PJOGL extends PGL {
@Override
public void scissor(int x, int y, int w, int h) {
gl.glScissor(pixel_scale * x, pixel_scale * y, pixel_scale * w, pixel_scale * h);
float scale = pg.getPixelScale();
gl.glScissor((int)scale * x, (int)(scale * y), (int)(scale * w), (int)(scale * h));
// gl.glScissor(x, y, w, h);
}
+11 -8
View File
@@ -62,7 +62,7 @@ public class PSurfaceJOGL implements PSurface {
NewtCanvasAWT canvas;
float[] hasSurfacePixelScale = {0, 0};
float[] currentPixelScale = {0, 0};
public PSurfaceJOGL(PGraphics graphics) {
this.graphics = graphics;
@@ -226,12 +226,10 @@ public class PSurfaceJOGL implements PSurface {
// Retina
reqSurfacePixelScale = new float[] { ScalableSurface.AUTOMAX_PIXELSCALE,
ScalableSurface.AUTOMAX_PIXELSCALE };
pgl.pixel_scale = 2;
} else {
// Non-retina
reqSurfacePixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE,
ScalableSurface.IDENTITY_PIXELSCALE };
// pgl.pixel_scale = 1;
}
window.setSurfaceScale(reqSurfacePixelScale);
@@ -475,6 +473,11 @@ public class PSurfaceJOGL implements PSurface {
}
}
public float getPixelScale() {
window.getCurrentSurfaceScale(currentPixelScale);
return currentPixelScale[0];
}
public Component getComponent() {
return canvas;
}
@@ -543,7 +546,7 @@ public class PSurfaceJOGL implements PSurface {
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
// final float[] valReqSurfacePixelScale = window.getRequestedSurfaceScale(new float[2]);
window.getCurrentSurfaceScale(hasSurfacePixelScale);
window.getCurrentSurfaceScale(currentPixelScale);
// final float[] nativeSurfacePixelScale = window.getMaximumSurfaceScale(new float[2]);
// System.err.println("[set PixelScale post]: "+
// valReqSurfacePixelScale[0]+"x"+valReqSurfacePixelScale[1]+" (val) -> "+
@@ -560,7 +563,7 @@ public class PSurfaceJOGL implements PSurface {
// } else {
// setSize(w, h);
// }
setSize((int)(w/hasSurfacePixelScale[0]), (int)(h/hasSurfacePixelScale[1]));
setSize((int)(w/currentPixelScale[0]), (int)(h/currentPixelScale[1]));
}
}
@@ -688,9 +691,9 @@ public class PSurfaceJOGL implements PSurface {
peCount = nativeEvent.getClickCount();
}
window.getCurrentSurfaceScale(hasSurfacePixelScale);
int sx = (int)(nativeEvent.getX()/hasSurfacePixelScale[0]);
int sy = (int)(nativeEvent.getY()/hasSurfacePixelScale[1]);
window.getCurrentSurfaceScale(currentPixelScale);
int sx = (int)(nativeEvent.getX()/currentPixelScale[0]);
int sy = (int)(nativeEvent.getY()/currentPixelScale[1]);
if (presentMode) {
if (peAction == KeyEvent.RELEASE &&
20 < sx && sx < 20 + 100 &&