Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean isGLSLSupported(VersionNumber vn) {
- boolean[] container = new boolean[] {false};
- try {
- EventQueue.invokeAndWait(() -> {
- JFrame foo = new JFrame("version text");
- GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL3));
- GLCanvas glCanvas = new GLCanvas(caps);
- glCanvas.addGLEventListener(new GLEventListener() {
- @Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- }
- @Override
- public void init(GLAutoDrawable drawable) {
- container[0] = drawable.getContext().getGLSLVersionNumber().compareTo(vn) > -1;
- }
- @Override
- public void dispose(GLAutoDrawable drawable) {
- }
- @Override
- public void display(GLAutoDrawable drawable) {
- }
- });
- foo.add(glCanvas);
- foo.setUndecorated(true);
- foo.setSize(1, 1);
- foo.setVisible(true);
- glCanvas.display();
- foo.setVisible(false);
- foo.dispose();
- });
- } catch (Exception ex) {
- System.out.println("Error trying to detect OpenGL version:");
- ex.printStackTrace();
- }
- return container[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement