I am having difficulty running an OpenGL application in Eclipse using JOGL (Java OpenGL). I have carefully followed the setup instructions and verified that my code is correctly implemented. However, when running the application, the window appears blank and only briefly shows the rendered content before disappearing.
I've checked my configuration in Eclipse and it appears to be set correctly. Additionally, I have tested the same application on my college lab computers and it works fine, which makes me think the problem could be related to my personal configuration or hardware. My computer has an AMD Ryzen 5 3400G processor. I am attaching the code I am using below: import javax.swing.JFrame; import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; public class Principal extends JFrame implements GLEventListener{ private static final long serialVersionUID = 1L; public static void main(String[] args) { // TODO Auto-generated method stub Principal ren= new Principal(); } public Principal() { super("Programación Gráfica - OpenGL"); this.setSize(640,480); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setResizable(false); GLProfile profile = GLProfile.get(GLProfile.GL2); GLCapabilities caps = new GLCapabilities(profile); GLCanvas canvas = new GLCanvas(caps); canvas.addGLEventListener(this); this.add(canvas); this.setVisible(true); canvas.requestFocusInWindow(); } @Override public void display(GLAutoDrawable drawable) { // TODO Auto-generated method stub GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(0.0f, 0.0f, 1.0f, 0.0f); gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); gl.glFlush(); } @Override public void dispose(GLAutoDrawable drawable) { // TODO Auto-generated method stub } @Override public void init(GLAutoDrawable drawable) { // TODO Auto-generated method stub GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(0.392f, 0.584f, 0.929f, 1.0f); } @Override public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { // TODO Auto-generated method stub } } I would greatly appreciate any help or suggestions on how to fix this issue. Are there any specific settings I should check on my computer with an AMD processor? Has anyone else experienced a similar problem when trying to run OpenGL applications on AMD hardware? Thank you in advance for your help! |
Administrator
|
Hello
Please confirm that you use at least JOGL 2.5.0. If you use a laptop or a computer with several GPUs, configure AMD Switchable Graphics so that it doesn't switch GPUs at runtime. Please use this example: https://jogamp.org/wiki/index.php/Rudimentary_standalone_example_using_the_fixed_pipeline_by_Julien_Gouesse Don't forget to use an animator ;)
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |