use of com.jogamp.opengl.GLCapabilities in project jmonkeyengine by jMonkeyEngine.
the class JoglAbstractDisplay method initGLCanvas.
protected void initGLCanvas() {
device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GLCapabilities caps;
if (settings.getRenderer().equals(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE)) {
caps = new GLCapabilities(GLProfile.getMaxProgrammable(true));
} else {
caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true));
}
caps.setHardwareAccelerated(true);
caps.setDoubleBuffered(true);
caps.setStencilBits(settings.getStencilBits());
caps.setDepthBits(settings.getDepthBits());
if (settings.getSamples() > 1) {
caps.setSampleBuffers(true);
caps.setNumSamples(settings.getSamples());
}
canvas = new GLCanvas(caps) {
@Override
public void addNotify() {
super.addNotify();
onCanvasAdded();
}
@Override
public void removeNotify() {
onCanvasRemoved();
super.removeNotify();
}
};
canvas.invoke(false, new GLRunnable() {
public boolean run(GLAutoDrawable glad) {
canvas.getGL().setSwapInterval(settings.isVSync() ? 1 : 0);
return true;
}
});
canvas.setFocusable(true);
canvas.requestFocus();
canvas.setSize(settings.getWidth(), settings.getHeight());
canvas.setIgnoreRepaint(true);
canvas.addGLEventListener(this);
//FIXME not sure it is the best place to do that
renderable.set(true);
}
use of com.jogamp.opengl.GLCapabilities in project processing by processing.
the class PSurfaceJOGL method setSmooth.
public void setSmooth(int level) {
pgl.reqNumSamples = level;
GLCapabilities caps = new GLCapabilities(profile);
caps.setAlphaBits(PGL.REQUESTED_ALPHA_BITS);
caps.setDepthBits(PGL.REQUESTED_DEPTH_BITS);
caps.setStencilBits(PGL.REQUESTED_STENCIL_BITS);
caps.setSampleBuffers(true);
caps.setNumSamples(pgl.reqNumSamples);
caps.setBackgroundOpaque(true);
caps.setOnscreen(true);
NativeSurface target = window.getNativeSurface();
MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration();
config.setChosenCapabilities(caps);
}
use of com.jogamp.opengl.GLCapabilities in project processing by processing.
the class PSurfaceJOGL method initGL.
protected void initGL() {
// System.out.println("*******************************");
if (profile == null) {
if (PJOGL.profile == 1) {
try {
profile = GLProfile.getGL2ES1();
} catch (GLException ex) {
profile = GLProfile.getMaxFixedFunc(true);
}
} else if (PJOGL.profile == 2) {
try {
profile = GLProfile.getGL2ES2();
} catch (GLException ex) {
profile = GLProfile.getMaxProgrammable(true);
}
} else if (PJOGL.profile == 3) {
try {
profile = GLProfile.getGL2GL3();
} catch (GLException ex) {
profile = GLProfile.getMaxProgrammable(true);
}
if (!profile.isGL3()) {
PGraphics.showWarning("Requested profile GL3 but is not available, got: " + profile);
}
} else if (PJOGL.profile == 4) {
try {
profile = GLProfile.getGL4ES3();
} catch (GLException ex) {
profile = GLProfile.getMaxProgrammable(true);
}
if (!profile.isGL4()) {
PGraphics.showWarning("Requested profile GL4 but is not available, got: " + profile);
}
} else
throw new RuntimeException(PGL.UNSUPPORTED_GLPROF_ERROR);
}
// Setting up the desired capabilities;
GLCapabilities caps = new GLCapabilities(profile);
caps.setAlphaBits(PGL.REQUESTED_ALPHA_BITS);
caps.setDepthBits(PGL.REQUESTED_DEPTH_BITS);
caps.setStencilBits(PGL.REQUESTED_STENCIL_BITS);
// caps.setPBuffer(false);
// caps.setFBO(false);
// pgl.reqNumSamples = PGL.smoothToSamples(graphics.smooth);
caps.setSampleBuffers(true);
caps.setNumSamples(PGL.smoothToSamples(graphics.smooth));
caps.setBackgroundOpaque(true);
caps.setOnscreen(true);
pgl.setCaps(caps);
}
use of com.jogamp.opengl.GLCapabilities in project artisynth_core by artisynth.
the class GL3Sample method newJFrame.
public static JFrame newJFrame(String name, GLEventListener sample, int x, int y, int width, int height) {
JFrame frame = new JFrame(name);
frame.setBounds(x, y, width, height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GLProfile glp = GLProfile.get(GLProfile.GL3);
GLCapabilities glCapabilities = new GLCapabilities(glp);
// GLCanvas canvas = new GLCanvas(glCapabilities);
GLJPanel canvas = new GLJPanel(glCapabilities);
canvas.addGLEventListener(sample);
frame.add(canvas);
return frame;
}
use of com.jogamp.opengl.GLCapabilities in project artisynth_core by artisynth.
the class GLCanvasTest method main.
public static void main(String[] args) {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
final Frame frame = new Frame("AWT Window Test");
frame.setSize(300, 300);
frame.setLocation(30, 30);
frame.add(canvas);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
frame.dispose();
System.exit(0);
}
});
canvas.addGLEventListener(new GLCanvasTest());
FPSAnimator animator = new FPSAnimator(canvas, 60);
animator.start();
}
Aggregations