Hello community.
I am a beginner of Processing and Android Mode. If I am doing something stupid, please bear with me.
I am trying to run a sketch on my android phone, however, Processing console told me "sketch launched on the device,,,,,OpenGL error 1280 at bot beginDraw(): invalid enum"
I then looked at the android device (the device is on Android 6.0), sketch is not runing. Everytime I tapped the sketch icon on the android device, Processing console keeps telling me "OpenGL error 1280 at bot beginDraw(): invalid enum"
Anyone had this problem?
P.S: I can run other other sketch on the same android device without problem. Processing v3.2.3 Android SDK API 7.1.1 (25);
Thank you for your help in advance.
here is the code which I am trying to run.
import controlP5.*;
float scale_factor = 1, depth;
Photo2Mesh pm;
int resolution;
ControlP5 cp5;
void setup() {
size(600, 600, P3D);
cp5 = new ControlP5(this);
cp5.addSlider("depth").setPosition(20, 20).setRange(1, 50).setLabel("Depth");
cp5.addSlider("resolution").setPosition(20, 80).setRange(2, 15).setLabel("Resolution").setValue(15);
pm = new Photo2Mesh();
}
void draw() {
background(0);
hint(ENABLE_DEPTH_TEST);
pushMatrix();
translate(width/2, height/2);
rotateX(radians(mouseX));
rotateY(radians(mouseY));
scale(scale_factor, scale_factor, scale_factor);
pm.render_mesh(depth, resolution);
popMatrix();
hint(DISABLE_DEPTH_TEST);
camera();
}
Here is the class
class Photo2Mesh {
PImage img;
int cols, rows, resolution, x_pos, y_pos, loc;
float z, z_pos;
color c;
Photo2Mesh() {
img = loadImage("https://processing.org/img/processing-handbook-second-edition.jpg");
img.loadPixels();
}
void render_mesh(float z, int resolution) {
this.z = z;
this.resolution = resolution; // box size
cols = img.width/resolution;
rows = img.height/resolution;
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
x_pos = x * resolution + resolution/2;
y_pos = y * resolution + resolution/2;
loc = x_pos + y_pos*img.width;
c = img.pixels[loc];
z_pos = map(brightness(img.pixels[loc]), 0, 255, 0, z);
pushMatrix();
translate(-width/2, -height/2);
translate(x_pos, y_pos, z_pos);
fill(c);
noStroke();
box(resolution, resolution, 160);
popMatrix();
}
}
}
}