Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  GLJPanel in Eclipse  (Read 2095 times)
0 Members and 1 Guest are viewing this topic.
Offline flipperke

Junior Devvie





« Posted 2008-02-26 15:19:48 »

Hello,

 I have a strange behaviour. I'm having a GLJPanel in a project in Eclipse, When I run it, everythins is as should be (the (0, 0) co├Ârdinate is at the center of the screen). When I try to run everything from command-line, everything is moved downwards.

If I use a GLCanvas, embedded in a JPanel, they both (Eclipse and command-line) show the (0, 0)-co├Ârdinate in the center of the screen.

Does anybody know what the problem could be??

Thanks in advance,
Nico

Okay, it has something to do with -Dsun.java2d.opengl="true", if I remove that part, the strange behaviour doesn't apear.
Offline flipperke

Junior Devvie





« Reply #1 - Posted 2008-02-27 09:33:47 »

Hello,

I have been searching for a while and made a small testcase.

GLDemo.java
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.media.opengl.*;

public class GLDemo{
   public GLDemo(){
      JFrame frame = new JFrame("test");
      frame.setPreferredSize(new Dimension(800, 600));

      JPanel upperPanel = new JPanel();
      upperPanel.setLayout(null);
      upperPanel.setBackground(Color.GREEN);

      //GLCanvas glpanel = new GLCanvas();
      GLJPanel glpanel = new GLJPanel();
      glpanel.addGLEventListener(new GLDemoRenderer());

      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      glpanel.setSize(450, 450);
      upperPanel.add(glpanel);
      frame.add(upperPanel);

      frame.pack();

      frame.setVisible(true);
   }

   public static void main (String args[]) {
      SwingUtilities.invokeLater(new Runnable(){
         public void run(){
            GLDemo gldemo = new GLDemo();
         }
      });
   }
}


GLDemoRenderer.java
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
import javax.media.opengl.*;
import javax.media.opengl.glu.GLU;
import com.sun.opengl.util.*;

public class GLDemoRenderer implements GLEventListener{

   public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged){
   }

   public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height){
      final GL gl = drawable.getGL();
      gl.glViewport(0, 0, width, height);
      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glLoadIdentity();
      gl.glOrtho(-2, 2, -2, 2,0, 10);
      gl.glMatrixMode(GL.GL_MODELVIEW);
   }

   public void display(GLAutoDrawable drawable){
      final GL gl = drawable.getGL();
      final GLUT glut = new GLUT();

      gl.glClear(GL.GL_COLOR_BUFFER_BIT);
      gl.glLoadIdentity();

      gl.glTranslatef(0.0f, 0.0f, -6.0f);
      glut.glutWireCube(1.0f);
      gl.glLoadIdentity();
   }

   public void init(GLAutoDrawable drawable){
      final GL gl = drawable.getGL();
      gl.glClearColor(0,0,0,0);
   }
}


When, in GLDemo.java,
1  
GLJPanel glpanel = new GLJPanel
is changed into
1  
GLCanvas glpanel = new GLCanvas()
the cube is drawn on an other place.

I'm working on Ubuntu 7.10, java 6, jsr-231-1.1.0

thanks,
Nico
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #2 - Posted 2008-02-29 21:37:28 »

You're ignoring the x and y coming in to your reshape() method. If you pay attention to them you should get the correct results.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline flipperke

Junior Devvie





« Reply #3 - Posted 2008-03-03 09:50:13 »

stupid me...,

Still, strange that it only happens with GLJPanel on the command line with -Dsun.java2d.opengl="true". Or is this just coincidence?

Nico
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #4 - Posted 2008-03-04 20:38:23 »

This is by design and is how the Java 2D / JOGL bridge works.
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1572 views)
2018-06-10 19:43:48

EgonOlsen (1632 views)
2018-06-10 19:43:44

EgonOlsen (1144 views)
2018-06-10 19:43:20

DesertCoockie (1569 views)
2018-05-13 18:23:11

nelsongames (1173 views)
2018-04-24 18:15:36

nelsongames (1638 views)
2018-04-24 18:14:32

ivj94 (2395 views)
2018-03-24 14:47:39

ivj94 (1605 views)
2018-03-24 14:46:31

ivj94 (2691 views)
2018-03-24 14:43:53

Solater (882 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!