Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 6 7 [8] 9 10
 71 
 on: 2014-07-30 17:32:44 
Started by princec - Last post by kappa
Then, what is it? JMonkeyEngine showcase
http://jmonkeyengine.org/showcase/
Most of those listed there are tech demo's, using old engine code, abandoned, unfinished or WIP's.

 72 
 on: 2014-07-30 17:21:49 
Started by Tekkerue - Last post by BurntPizza
I don't see any de-syncing here:

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  
public static void main(String[] a) throws InterruptedException {
   JFrame frame = new JFrame();
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(400, 400);
   frame.setLocationRelativeTo(null);
   
   JPanel panel = new JPanel(); // JPanel is double buffered by default
  frame.add(panel);
   panel.setLayout(new GridBagLayout());
   
   JLabel label1 = new JLabel("Label 1");
   JLabel label2 = new JLabel("Label 2");
   JLabel label3 = new JLabel("Label 3");
   JLabel label4 = new JLabel("Label 4");
   label1.setOpaque(true);
   label2.setOpaque(true);
   label3.setOpaque(true);
   label4.setOpaque(true);
   panel.add(label1);
   panel.add(label2);
   panel.add(label3);
   panel.add(label4);
   
   frame.setVisible(true);
   
   int count = 0;
   int color = 0;
   
   Color[] colors = new Color[] { Color.white, Color.lightGray };
   
   while (true) {
      if (count++ % 30 == 0) {
         label1.setBackground(colors[++color & 1]);
         label2.setBackground(colors[color + 1 & 1]);
         label3.setBackground(colors[color & 1]);
         label4.setBackground(colors[color & 1]);
      }
      Thread.sleep(16);
   }
}


In fact I don't even see it when the labels are added straight to the JFrame without a JPanel.

 73 
 on: 2014-07-30 17:14:55 
Started by Tekkerue - Last post by Tekkerue
Wow...you guys are quick! Cheesy Thanks everyone!

To everyone: Basically what I'm trying to do is prevent one of the label displays from getting updated slightly before the other one. This is for a metronome application and sometimes (especially at faster speeds) one display will change just slightly before the other one when they should both change at precisely the same time. That's basically what I'm trying to prevent from happening with my double buffering method. I know double buffering is usually used to prevent "flickering", but I figured that approach might work for what I need also.

KevinWorkman, I've read up on painting but I still don't fully understand some of the "magic" that happens behind the painting methods. I found an example of double buffering using Graphics that moved an oval around the screen with the arrow keys and I tried replacing the "draw oval" part with a "draw Image" which I'm trying to get from the JPanel. If drawing an oval works (and it does when I add that into my example code), then drawing an image should theoretically work as well as long as I get the get the Image correctly from the JPanel...which unfortunately isn't working.

 74 
 on: 2014-07-30 17:05:18 
Started by princec - Last post by gouessej
Oops, you're right, sorry Longor1996. I took the wrong image.

 75 
 on: 2014-07-30 16:55:15 
Started by princec - Last post by Longor1996
and this? A few games using Ardor3D


Isn't that Manic-Digger (which is written in C++)?
It looks just like it, and if its not MD, what game is that?

 76 
 on: 2014-07-30 16:53:41 
Started by Tekkerue - Last post by BurntPizza
The method setIgnoreRepaint(true) tells Swing/AWT to ignore the repaint-messages from the operating-system, but does not disable the repaint()-calls that are made in setText(). See here: http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#setIgnoreRepaint(boolean)

Indeed, you're quite right. Forgot about that distinction.

@OP I think everyone would appreciate an sscce of what it is you're actually trying to do.

 77 
 on: 2014-07-30 16:50:09 
Started by Tekkerue - Last post by KevinWorkman
This whole approach doesn't make a lot of sense to me.

Swing is already double-buffered. Why do you think you need to handle double-buffering yourself?

Why are you updating a JLabel "off-screen"? All changes to Swing components must be done on the EDT anyway, so I'm not sure what kind of performance gain you're expecting from this.

In any case, when do you draw the JPanel to the BufferedImage?

 78 
 on: 2014-07-30 16:49:34 
Started by Tekkerue - Last post by Longor1996
Why would you want to force the JLabel's to repaint at the same time?
It's just JLabels, so there shouldn't be any performance issues with letting Swing repaint them automatically.

If the labels calling additional repaints() is actually your problem, why not this:

1  
2  
3  
4  
5  
6  
7  
loop {
    canvas.setIgnoreRepaint(true);
    app.update();
    canvas.setIgnoreRepaint(false);
    canvas.repaint();
    sleep();
}


The method setIgnoreRepaint(true) tells Swing/AWT to ignore the repaint-messages from the operating-system, but does not disable the repaint()-calls that are made in setText(). See here: http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html#setIgnoreRepaint(boolean)

 79 
 on: 2014-07-30 16:47:24 
Started by princec - Last post by gouessej
The development of the above mentioned 3d java engines aren't really driven by any (or many) actual products or companies that use them.
Then, what is it? JMonkeyEngine showcase

http://jmonkeyengine.org/showcase/

Fleshsnatcher uses JMonkeyEngine too (its author is registered here Wink ).

and this? A few games using Ardor3D

http://www.youtube.com/watch?v=iWikbwTPP8g

 80 
 on: 2014-07-30 16:44:56 
Started by Tekkerue - Last post by BurntPizza
If the labels calling additional repaints() is actually your problem, why not this:

1  
2  
3  
4  
5  
6  
7  
loop {
    canvas.setIgnoreRepaint(true);
    app.update();
    canvas.setIgnoreRepaint(false);
    canvas.repaint();
    sleep();
}

Pages: 1 ... 6 7 [8] 9 10
 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (14 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!