package com.marginallyclever.robotoverlord.renderpanel; import com.jogamp.opengl.*; import com.jogamp.opengl.awt.GLJPanel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.swing.*; import java.awt.*; public class OpenGLTestMinimal { private static final Logger logger = LoggerFactory.getLogger(OpenGLTestMinimal.class); private final JPanel panel = new JPanel(new BorderLayout()); protected final GLJPanel glCanvas; public OpenGLTestMinimal() { super(); logger.info("\n"+ JoglVersion.getInstance()); glCanvas = createCanvas(); panel.setMinimumSize(new Dimension(300, 300)); panel.add(glCanvas, BorderLayout.CENTER); } private GLJPanel createCanvas() { GLJPanel canvas = null; try { GLCapabilities capabilities = getCapabilities(); StringBuilder sb = new StringBuilder(); capabilities.toString(sb); logger.info("capabilities="+sb); canvas = new GLJPanel(capabilities); } catch(GLException e) { logger.error("Failed to get/set Capabilities. Are your native drivers missing?"); } return canvas; } public GLJPanel getGlCanvas() { return glCanvas; } private GLCapabilities getCapabilities() { GLProfile profile = GLProfile.getMaxProgrammable(true); GLCapabilities capabilities = new GLCapabilities(profile); capabilities.setHardwareAccelerated(true); capabilities.setBackgroundOpaque(true); capabilities.setDoubleBuffered(true); return capabilities; } public JPanel getPanel() { return panel; } public static void main(String[] args) { OpenGLTestMinimal opengl = new OpenGLTestMinimal(); // make a frame JFrame frame = new JFrame( OpenGLTestMinimal.class.getSimpleName()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(opengl.getPanel()); frame.setPreferredSize(new Dimension(600,600)); frame.setSize(600,600); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }