Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: How do I force redraw of GLCanvas from another thread? on: 2011-04-11 16:08:31
Thank you very much. It works with build 367.
2  Game Development / Newbie & Debugging Questions / Re: How do I force redraw of GLCanvas from another thread? on: 2011-04-11 13:03:53
I'm using jogl-2.0-b23-20110303 build.

I added and started animator just to check if it's gonna be of any use, and no, nothing new happend. Sad I'm newbie to jogl, so here is updated code so you can check if I had done everything OK.

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  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
public class OpenGLCanvas implements GLEventListener, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener {
  MainFrame frame;
  GLCanvas glCanvas;
  Animator animator;
 
  public OpenGLCanvas(MainFrame frame) {
        this.frame = frame;
        initContent();
    }
 
    private void initContent() {
        GLProfile glprofile = GLProfile.getDefault();
        GLCapabilities glcapabilities = new GLCapabilities(glprofile);
        glCanvas = new GLCanvas(glcapabilities);
        glCanvas.addGLEventListener(this);
        glCanvas.addKeyListener(this);
        glCanvas.addMouseListener(this);
        glCanvas.addMouseMotionListener(this);
        glCanvas.addMouseWheelListener(this);
        animator = new Animator(glCanvas);
        animator.start();
    }
 
    public GLCanvas getGlCanvas() {
        return glCanvas;
    }
 
   public void init(GLAutoDrawable glAutoDrawable) {
      ...
   }
 
   public void display(GLAutoDrawable glAutoDrawable) {
      ...
   }
 
   public void dispose(GLAutoDrawable glAutoDrawable) {
      ...
      animator.stop();
   }
 
   public void reshape(GLAutoDrawable glAutoDrawable, int x, int y, int width, int height) {
      ...
   }
 
   ...
 
}
3  Game Development / Newbie & Debugging Questions / Re: How do I force redraw of GLCanvas from another thread? on: 2011-04-11 09:49:45
At first, if you need some help on JOGL, rather post on jogamp.org.

I posted here because I have read this in official JOGL Userguide:
Quote
The JOGL forum on javagaming.org is the best place to ask questions about the library. Many users, as well as the Jogl developers, read this forum frequently, and the archived threads contain a lot of useful information (which still needs to be distilled into documentation).

Yes, I would appreciate on more complete example, but first I'll be more concrete with my problem. Maybe you''ll figure out what I did wrong.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public class MainFrame extends JFrame implements ActionListener {
  JButton jb_refresh = new JButton("Refresh");
  OpenGLCanvas openGLCanvas;
  ...
  public MainFrame() {
        openGLCanvas = new OpenGLCanvas(this);
        ...
        jb_refresh.addActionListener(this);
        getContentPane().add(jb_refresh, BorderLayout.NORTH);
        getContentPane().add(openGLCanvas.getGlCanvas(), BorderLayout.CENTER);
  }
  ...
  public void actionPerformed(ActionEvent e) {
    // some calcs to set new values in
   ...
    openGLCanvas.getGl_canvas().display();
    openGLCanvas.getGl_canvas().requestFocusInWindow();
  }
  ...
  // main method etc.
}

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  
38  
39  
40  
41  
42  
43  
public class OpenGLCanvas implements GLEventListener, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener {
  MainFrame frame;
  GLCanvas glCanvas;

  public OpenGLCanvas(MainFrame frame) {
        this.frame = frame;
        initContent();
    }

    private void initContent() {
        GLProfile glprofile = GLProfile.getDefault();
        GLCapabilities glcapabilities = new GLCapabilities(glprofile);
        glCanvas = new GLCanvas(glcapabilities);
        glCanvas.addGLEventListener(this);
        glCanvas.addKeyListener(this);
        glCanvas.addMouseListener(this);
        glCanvas.addMouseMotionListener(this);
        glCanvas.addMouseWheelListener(this);
    }

    public GLCanvas getGlCanvas() {
        return glCanvas;
    }

   public void init(GLAutoDrawable glAutoDrawable) {
      ...
   }

   public void display(GLAutoDrawable glAutoDrawable) {
      ...
   }

   public void dispose(GLAutoDrawable glAutoDrawable) {
      ...
   }

   public void reshape(GLAutoDrawable glAutoDrawable, int x, int y, int width, int height) {
      ...
   }

   ...

}
4  Game Development / Newbie & Debugging Questions / How do I force redraw of GLCanvas from another thread? on: 2011-04-11 08:30:24
I'm developing a scientific application using jogl 2.0. I don't need permanent/animator looping in OGL. GLCanvas has to be redrawn/repainted only on user demand, i.e. the user clicks on the JButton (e.g. Refresh) in main application and GLCanvas gets repainted.

I have read that jogl 2.0 event thread is synchronized with AWT event queue thread, so if I understood it well, I could call e.g.
1  
glCanvas.display();
from main application loop (outside of any GLEventLIsteners) without any problems. I did it that way. Compiled without errors, but nothing happens. It seems that call to dispaly() is ignored.

What is the problem? How can I resolve this?
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!