Does anyone know how to use OPENGL with PGraphics.
in
Programming Questions
•
2 years ago
Does anyone know how to use OPENGL with PGraphics.
I got a little progress but the screen is flickering. Any ideas?
Here is the code
-
PGraphics pg;
int w,h;
PImage a;
import processing.opengl.*;
void setup(){
w=255;
h=255;
size(w,h,P3D);
frameRate(14);pg = createGraphics(w,h,OPENGL);
a=createImage(w,h,ARGB);
}
void draw(){
pg.beginDraw();
pg.loadPixels();
pg.background(-1,128);pg.stroke(1);
for (int x=0;x<pg.width;x++){
for (int y =0;y<pg.height;y++){
int pos = x+pg.width*y;
pg.pixels[pos]=color(mouseY-y,x-y,width-mouseX);
}
}
pg.rect(mouseX-30,mouseY-30,12,12);pg.translate(mouseX,mouseY,0);
pg.fill(255,0,0);
pg.box(10);
pg.endDraw();
image(pg,0,0);}
1
