kritzikratzi / fullscreen-p5

Fullscreen-API for the Processing programming language
http://www.superduper.org/processing/fullscreen_api/
MIT License
15 stars 7 forks source link

Framerate issue when resolution = screen size #10

Closed eljeffeg closed 14 years ago

eljeffeg commented 14 years ago

If you set the size of the sketch to the exact size of the screen, it decreased the framerate to 30fps. If I change it by 1 pixel it is back to normal. Also, the OpenGL command "gl.setSwapInterval(1);" seems to have no effect.

Runs at 30fps

size(int(screen.width), int(screen.height), OPENGL );

Runs at 500fps

size(int(screen.width), int(screen.height)-1, OPENGL );

Runs at 500fps

size(int(screen.width)-1, int(screen.height), OPENGL );

Any size that is not the exact resolution of the screen. So something is going on here when the size is equal.

Example sketch:

import fullscreen.*; 
import processing.opengl.*;
import javax.media.opengl.GL;
PGraphicsOpenGL pgl;
GL gl;
FullScreen fs;

void setup(){
  size((int)screen.width, (int)screen.height, OPENGL);
  fs = new FullScreen(this);
  fs.enter(); 
  pgl         = (PGraphicsOpenGL) g;
  gl          = pgl.gl;
  frameRate(2000);
}

void draw(){
  background(0);
  fill(255);
  ellipse(150,150,150,150);
  println(frameRate);
}
kritzikratzi commented 14 years ago

Wow, somehow I completely missed that one. One thing I noticed: When you use SoftFullScreen instead of FullScreen mode and bring another application to the foreground, the sketch runs at full speed. This might be the oddest thing I've ever seen...

kritzikratzi commented 14 years ago

Okay, this really seems to be a macos+java+opengl issue. Try this sketch in present-mode (apple+shift+r): import processing.opengl.*; import javax.media.opengl.GL;

void setup(){ size(screen.width, screen.height, OPENGL); frameRate(2000); }

void draw(){ noStroke(); fill( 0, 5 ); rect( 0, 0, width, height ); stroke(0, 255, 0); line(0, frameCount%height, width, frameCount%height ); println( frameRate ); }

it also runs just at 30fps on my computer. The profiler tell's me that 93% of all time is wasted in com.sun.opengl.impl.macosx.CGL.flushBuffer(long), but I have no idea how to fix this...

kritzikratzi commented 14 years ago

Seems to be a java+opengl issue, try this:

import processing.opengl.*;

void setup(){ size((int)screen.width, (int)screen.height, OPENGL); frameRate(2000); }

void draw(){ background(0); fill(255); ellipse(150,150,150,150); println(frameRate); }

in present mode, it will also just run at 30fps

eljeffeg commented 14 years ago

Yes, in both the sketches you posted. The frame rate dropped to 30fps.

kritzikratzi commented 14 years ago

sorry, i double-posted because my first post didn't show up instantly for some reason. anyway, i forwarded the report to processing.org: http://dev.processing.org/bugs/show_bug.cgi?id=1425

This bug here propably won't close until the processing people fix it...

kritzikratzi commented 14 years ago

Okay, the problem is definitely fixable in processing, but there's still some work left to do for me...

It's fixed for the fullscreen-exclusive mode and you can download the temporary fixed library here if you want: http://cloud.github.com/downloads/kritzikratzi/fullscreen-p5/fullscreen-0.98.4-testing.zip

however, softfullscreen mode (which is imho much much more important) still has the same flaws...

kritzikratzi commented 14 years ago

i'm scared to close this one, but my unit tests ran fine a couple of times.

eljeffeg commented 14 years ago

Ran fine for me too.