JOGL 2.4,2.3,2.2,.. GLCanvas problem :

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

JOGL 2.4,2.3,2.2,.. GLCanvas problem :

RobertM
Good day

Sorry for my English, i am not nature speaker. I have problem with object GLCanvas, it show me horrible view.
I try few type drivers my graphics card, i have ntb with 2 graphics : Intel UHD 620, Geforce MX130

Here is my simple source :

import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import javax.swing.*;
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.*;
import com.jogamp.opengl.glu.*;
import com.jogamp.opengl.util.*;

import static com.jogamp.opengl.GL.*;
import static com.jogamp.opengl.GL2.*;
import static com.jogamp.opengl.GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT;
import static com.jogamp.opengl.fixedfunc.GLLightingFunc.GL_SMOOTH;

class GrafSceneX02 implements GLEventListener {
        private GLU glu; // for the GL Utility
        private float anglePyramid = 0; // rotational angle in degree for pyramid
        private float angleCube = 0; // rotational angle in degree for cube
        private float speedPyramid = 2.0f; // rotational speed for pyramid
        private float speedCube = -1.5f; // rotational speed for cub

        public void init(GLAutoDrawable drawable) {
                GL2 gl = drawable.getGL().getGL2();
                glu = new GLU();
                gl.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
                gl.glClearDepthf(1.0f);
                gl.glEnable(GL_DEPTH_TEST);
                gl.glDepthFunc(GL_LEQUAL);  
                gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
                gl.glShadeModel(GL_SMOOTH);
                ((Component) drawable).addKeyListener(new StiskKlavesy());
        }
        private void vykresliPyramidu(GL2 gl) {
              // ----- Render the Pyramid -----
              gl.glLoadIdentity();                
              gl.glTranslatef(-1.6f, 0.0f, -6.0f);
              gl.glRotatef(anglePyramid, -0.2f, 1.0f, 0.0f);
         
              gl.glBegin(GL_TRIANGLES); // of the pyramid
         
              // Font-face triangle
              gl.glColor3f(1.0f, 0.0f, 0.0f); // Red
              gl.glVertex3f(0.0f, 1.0f, 0.0f);
              gl.glColor3f(0.0f, 1.0f, 0.0f); // Green
              gl.glVertex3f(-1.0f, -1.0f, 1.0f);
              gl.glColor3f(0.0f, 0.0f, 1.0f); // Blue
              gl.glVertex3f(1.0f, -1.0f, 1.0f);
         
              // Right-face triangle
              gl.glColor3f(1.0f, 0.0f, 0.0f); // Red
              gl.glVertex3f(0.0f, 1.0f, 0.0f);
              gl.glColor3f(0.0f, 0.0f, 1.0f); // Blue
              gl.glVertex3f(1.0f, -1.0f, 1.0f);
              gl.glColor3f(0.0f, 1.0f, 0.0f); // Green
              gl.glVertex3f(1.0f, -1.0f, -1.0f);
         
              // Back-face triangle
              gl.glColor3f(1.0f, 0.0f, 0.0f); // Red
              gl.glVertex3f(0.0f, 1.0f, 0.0f);
              gl.glColor3f(0.0f, 1.0f, 0.0f); // Green
              gl.glVertex3f(1.0f, -1.0f, -1.0f);
              gl.glColor3f(0.0f, 0.0f, 1.0f); // Blue
              gl.glVertex3f(-1.0f, -1.0f, -1.0f);
         
              // Left-face triangle
              gl.glColor3f(1.0f, 0.0f, 0.0f); // Red
              gl.glVertex3f(0.0f, 1.0f, 0.0f);
              gl.glColor3f(0.0f, 0.0f, 1.0f); // Blue
              gl.glVertex3f(-1.0f, -1.0f, -1.0f);
              gl.glColor3f(0.0f, 1.0f, 0.0f); // Green
              gl.glVertex3f(-1.0f, -1.0f, 1.0f);
         
              gl.glEnd(); // of the pyramid
        }
        private void vykresliKrychly(GL2 gl) {
              // ----- Render the Color Cube -----
              gl.glLoadIdentity();                
              gl.glTranslatef(1.6f, 0.0f, -7.0f);
              gl.glRotatef(angleCube, 1.0f, 1.0f, 1.0f);
         
              gl.glBegin(GL_QUADS); // of the color cube
         
              // Top-face
              gl.glColor3f(0.0f, 1.0f, 0.0f); // green
              gl.glVertex3f(1.0f, 1.0f, -1.0f);
              gl.glVertex3f(-1.0f, 1.0f, -1.0f);
              gl.glVertex3f(-1.0f, 1.0f, 1.0f);
              gl.glVertex3f(1.0f, 1.0f, 1.0f);
         
              // Bottom-face
              gl.glColor3f(1.0f, 0.5f, 0.0f); // orange
              gl.glVertex3f(1.0f, -1.0f, 1.0f);
              gl.glVertex3f(-1.0f, -1.0f, 1.0f);
              gl.glVertex3f(-1.0f, -1.0f, -1.0f);
              gl.glVertex3f(1.0f, -1.0f, -1.0f);
         
              // Front-face
              gl.glColor3f(1.0f, 0.0f, 0.0f); // red
              gl.glVertex3f(1.0f, 1.0f, 1.0f);
              gl.glVertex3f(-1.0f, 1.0f, 1.0f);
              gl.glVertex3f(-1.0f, -1.0f, 1.0f);
              gl.glVertex3f(1.0f, -1.0f, 1.0f);
         
              // Back-face
              gl.glColor3f(1.0f, 1.0f, 0.0f); // yellow
              gl.glVertex3f(1.0f, -1.0f, -1.0f);
              gl.glVertex3f(-1.0f, -1.0f, -1.0f);
              gl.glVertex3f(-1.0f, 1.0f, -1.0f);
              gl.glVertex3f(1.0f, 1.0f, -1.0f);
         
              // Left-face
              gl.glColor3f(0.0f, 0.0f, 1.0f); // blue
              gl.glVertex3f(-1.0f, 1.0f, 1.0f);
              gl.glVertex3f(-1.0f, 1.0f, -1.0f);
              gl.glVertex3f(-1.0f, -1.0f, -1.0f);
              gl.glVertex3f(-1.0f, -1.0f, 1.0f);
         
              // Right-face
              gl.glColor3f(1.0f, 0.0f, 1.0f); // magenta
              gl.glVertex3f(1.0f, 1.0f, -1.0f);
              gl.glVertex3f(1.0f, 1.0f, 1.0f);
              gl.glVertex3f(1.0f, -1.0f, 1.0f);
              gl.glVertex3f(1.0f, -1.0f, -1.0f);
         
              gl.glEnd(); // of the color cube
        }
        public void display(GLAutoDrawable drawable) {
              GL2 gl = drawable.getGL().getGL2();  
              gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
         
              vykresliPyramidu(gl);
              vykresliKrychly(gl);
             
              anglePyramid += speedPyramid;
              angleCube += speedCube;
        }

        public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
                GL2 gl = drawable.getGL().getGL2();
                if (height <= 0) height = 1;
                float aspect = (float) width/height;
                gl.glViewport(0, 0, width, height);
                gl.glMatrixMode(GL_PROJECTION);
                gl.glLoadIdentity();
                glu.gluPerspective(45.0, aspect, 0.1, 100.0);
                gl.glMatrixMode(GL_MODELVIEW);
                gl.glLoadIdentity();
        }
       
        public void dispose(GLAutoDrawable drawable) { }
        class StiskKlavesy extends KeyAdapter {
            public void keyPressed(KeyEvent paramKeyEvent) {
            if (paramKeyEvent.getKeyCode() == 27) // ESC = 27 - ukonceni programu
            System.exit(0); }
        }
}

public class X02_TEST extends JFrame {
        private static final long serialVersionUID = 6837023455928341424L;
        protected static final int FPS = 60;

        private void NastaveniKonstruktoruOkna() {
                super.setTitle("Zde vykreslime 2x 3D objekty samostatne rotujici ...ESC konec programu");
                this.setSize(700, 600);
                this.setLocation(600, 350);
                this.getContentPane().setLayout(new BorderLayout());
                JFrame.setDefaultLookAndFeelDecorated(true);
                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }

        private X02_TEST() {
                NastaveniKonstruktoruOkna();
               
                GLCanvas scena = new  GLCanvas();
                GrafSceneX02 grafika = new GrafSceneX02();
                final FPSAnimator animace = new FPSAnimator(scena, FPS, true);
                animace.start();
                this.getContentPane().add(scena);
                scena.addGLEventListener(grafika);
               
        }

        public static void main(String[] args) {
                SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                                X02_TEST  fo = new X02_TEST();
                                fo.setVisible(true);
                        }
                });
        }
}

When i use  GLCanvas  i have this view :



When i use GLPanel i have this correct view.




Where is problem in GLCanvas? And i can not use GLPanel because it have problem with blending.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.4,2.3,2.2,.. GLCanvas problem :

gouessej
Administrator
Hello

Please fill a bug report. I can create a bugzilla account for you. You'll have to provide detailed information to give us a chance to fix this bug.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.4,2.3,2.2,.. GLCanvas problem :

gouessej
Administrator
In reply to this post by RobertM
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.4,2.3,2.2,.. GLCanvas problem :

RobertM
Thank you for this example.

I can not reproduce this problem if i use it on my program. So i see ti as solved. The scene now working perfect.

Really thank you and thank you for fast response.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL 2.4,2.3,2.2,.. GLCanvas problem :

gouessej
Administrator
You're welcome. Thank you for the feedback.
Julien Gouesse | Personal blog | Website