We are about to switch to a new forum software. Until then we have removed the registration on this forum.
// Example of virtual resolution por Processing 3.0.1.
// Author: Luis lopez martinez - Erkosone. 2016.
int virtualWidth = 320;
int virtualHeight= 200;
PGraphics buffer;
//------------------------------------------------------------------
void settings(){
size(displayWidth, displayHeight, P3D);
fullScreen();
}
//------------------------------------------------------------------
void setup(){
buffer = createGraphics(virtualWidth, virtualHeight, P3D);
}
//------------------------------------------------------------------
void draw(){
// Start draw in buffer with (320x200) fixed resolution..
buffer.beginDraw();
Main();
buffer.endDraw();
// End of draw in buffer..
// Now dump video Buffer on main video..
beginShape();
texture(buffer);
vertex(0,0, 0,0);
vertex(displayWidth,0, virtualWidth,0);
vertex(displayWidth, displayHeight, virtualWidth,virtualHeight);
vertex(0, displayHeight, 0,virtualHeight);
endShape();
}
//------------------------------------------------------------------
void Main(){
// Write your program here..
buffer.background(0);
buffer.fill(255);
buffer.textAlign(CENTER);
buffer.text("VIRTUAL RESOLUTION BY ERKOSONE!", 160, 20);
}
Comments
displayWidth & displayHeight should only be used as args for size().
For the rest of the sketch, width & height only, so it respects the actual canvas' dimensions, in case we've chosen another resolution @ size(). :-B
Given that both virtualWidth & virtualHeight are immutable constants, Java conventions dictate they should be all-caps names separated by underline: VIRTUAL_WIDTH & VIRTUAL_HEIGHT.
Preferably also tagged as
final
and evenstatic
: ~O)Thanks ;)