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

AntiAlias not working in OpenGL #8

Open eljeffeg opened 14 years ago

eljeffeg commented 14 years ago

The AntiAlias does not work correctly in OpenGL (both FullScreen & SoftFullScreen) smooth() and gl.glEnable(gl.GL_LINE_SMOOTH); have no effect.

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

void setup(){
  size(300, 300, OPENGL);
  fs = new FullScreen(this);
  hint(DISABLE_OPENGL_2X_SMOOTH);
  hint(ENABLE_OPENGL_2X_SMOOTH);
  fs.enter(); 
  pgl         = (PGraphicsOpenGL) g;
  gl          = pgl.gl;
  gl.glEnable(gl.GL_LINE_SMOOTH);
}

void draw(){
  background(0);
  ellipse(150,150,150,150);
}
eljeffeg commented 14 years ago

This thread may be helpful. http://processing.org/discourse/yabb2/YaBB.pl?num=1250870750

kritzikratzi commented 14 years ago

seems to be a problem with the opengl context (AGAIN!!!) i get the best results by just using: @hint(ENABLE_OPENGL_4X_SMOOTH);@

I've been digging into it for a while, but couldn't really locate the source of the problem. Let's hope this (along with all the other opengl issues) will go away automatically in the next version...

eljeffeg commented 14 years ago

Just wondering if this has made any progress... This is the only drawback I'm having with the library and I'd be ecstatic to see it resolved.

eljeffeg commented 14 years ago

I did try 4x smooth and it did look better than the 2x I was using. However, I'm a bit concerned about the possible performance impact on lower end machines with using 4x, since it applies to the entire scene. With "gl.glEnable(gl.GL_LINE_SMOOTH);" I can selectively enable it for certain portions of the scene. At least that's my thought process... I could be wrong.

kritzikratzi commented 14 years ago

nope, unfortunately no progress yet. the problem is that i haven't even found out why gl.glEnable(gl.GL_LINE_SMOOTH); doesn't work after switching to fullscreen. this might be solvable using a custom glEventListener.

on a sidenote: maybe i explained this already, but when i talk about "this might go away in the next version": i'm playing around with a completely different approach where i never recreate the original sketch context. i only hide the original sketch window, let it draw to the background and copy the results to a new window. this way all the texture-problems, as well as this issue, go away. i'm only worried about performance (esp. with non-gl renderers), haven't done much testing yet...

eljeffeg commented 14 years ago

Thanks for the clarification.. when you said next version, I thought you were referring to Processing (1.10 or something).

eljeffeg commented 14 years ago

Should be fixed with this commit for version 0.98.4 (at least partially - I can get it to work if we order it correctly in the sketch).
http://github.com/jeffg2k/fullscreen-p5/commit/3f020076f0661da56aeb188b56cf16ff84269434

eljeffeg commented 14 years ago

My recent "fix" caused an error and ended up breaking my minimization. However, I found out that if you call the disable hint in between the creating the frame and entering fullscreen, all works well.

fs = new SoftFullScreen(this); hint(DISABLE_OPENGL_2X_SMOOTH); fs.enter();

Perhaps this could still be worked into the code somehow.. but at least we have a workaround.

kritzikratzi commented 14 years ago

interesting. using this, does gl.GL_LINE_SMOOTH work?

eljeffeg commented 14 years ago

Yes.. that's what I use.. but you have to put it in the draw. Taking from the original post. This works:

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

void setup(){
  size(300, 300, OPENGL);
  fs = new FullScreen(this);
  hint(DISABLE_OPENGL_2X_SMOOTH);
  fs.enter(); 
  pgl         = (PGraphicsOpenGL) g;
  gl          = pgl.gl;
}

void draw(){
  background(0);
  gl.glEnable(gl.GL_LINE_SMOOTH);
  ellipse(150,150,150,150);
}