pixelDensity (OpenGL): fix textures

This commit is contained in:
Jakub Valtar
2017-02-19 01:42:34 +01:00
parent f8bbc3b3fe
commit 9d420740b5
2 changed files with 15 additions and 10 deletions
+6 -1
View File
@@ -3879,6 +3879,11 @@ public class PGraphics extends PImage implements PConstants {
// fillA = 1;
// }
u1 *= img.pixelDensity;
u2 *= img.pixelDensity;
v1 *= img.pixelDensity;
v2 *= img.pixelDensity;
beginShape(QUADS);
texture(img);
vertex(x1, y1, u1, v1);
@@ -7347,7 +7352,7 @@ public class PGraphics extends PImage implements PConstants {
* @param image PImage to set as background (must be same size as the sketch window)
*/
public void background(PImage image) {
if ((image.width != width) || (image.height != height)) {
if ((image.pixelWidth != width) || (image.pixelHeight != height)) {
throw new RuntimeException(ERROR_BACKGROUND_IMAGE_SIZE);
}
if ((image.format != RGB) && (image.format != ARGB)) {
@@ -2147,8 +2147,8 @@ public class PGraphicsOpenGL extends PGraphics {
}
if (textured && textureMode == IMAGE) {
u /= textureImage.width;
v /= textureImage.height;
u /= textureImage.pixelWidth;
v /= textureImage.pixelHeight;
}
inGeo.addVertex(x, y, z,
@@ -5555,10 +5555,10 @@ public class PGraphicsOpenGL extends PGraphics {
@Override
protected void processImageBeforeAsyncSave(PImage image) {
if (image.format == AsyncPixelReader.OPENGL_NATIVE) {
PGL.nativeToJavaARGB(image.pixels, image.width, image.height);
PGL.nativeToJavaARGB(image.pixels, image.pixelWidth, image.pixelHeight);
image.format = ARGB;
} else if (image.format == AsyncPixelReader.OPENGL_NATIVE_OPAQUE) {
PGL.nativeToJavaRGB(image.pixels, image.width, image.height);
PGL.nativeToJavaRGB(image.pixels, image.pixelWidth, image.pixelHeight);
image.format = RGB;
}
}
@@ -6003,7 +6003,7 @@ public class PGraphicsOpenGL extends PGraphics {
@Override
public void mask(PImage alpha) {
updatePixelSize();
if (alpha.width != pixelWidth || alpha.height != pixelHeight) {
if (alpha.pixelWidth != pixelWidth || alpha.pixelHeight != pixelHeight) {
throw new RuntimeException("The PImage used with mask() must be " +
"the same size as the applet.");
}
@@ -6364,8 +6364,8 @@ public class PGraphicsOpenGL extends PGraphics {
if (tex == null) return null;
if (img.isModified()) {
if (img.width != tex.width || img.height != tex.height) {
tex.init(img.width, img.height);
if (img.pixelWidth != tex.width || img.pixelHeight != tex.height) {
tex.init(img.pixelWidth, img.pixelHeight);
}
updateTexture(img, tex);
}
@@ -6491,8 +6491,8 @@ public class PGraphicsOpenGL extends PGraphics {
// avoid initializing the pixels array.
PImage img = new PImage();
img.parent = parent;
img.width = tex.width;
img.height = tex.height;
img.width = img.pixelWidth = tex.width;
img.height = img.pixelHeight = tex.height;
img.format = ARGB;
setCache(img, tex);
return img;