Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3952 > unrolled thread

Using OpenGL in Java2d se

Started by"Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this>
First post2011-04-27 15:47 +0000
Last post2011-04-27 15:47 +0000
Articles 5 — 4 participants

Back to article view | Back to comp.lang.java.gui


Contents

  Using OpenGL in Java2d se "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
    Re: Using OpenGL in Java2 "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
    Re: Using OpenGL in Java2 "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
    Re: Using OpenGL in Java2 "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000
      Re: Using OpenGL in Java2 "Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this> - 2011-04-27 15:47 +0000

#3952 — Using OpenGL in Java2d se

From"Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectUsing OpenGL in Java2d se
Message-ID<48a087c5$0$16970$7836cce5@newsrazor.net>
  To: comp.lang.java.gui
It seems to me that the following (SSCCE provided below) should draw a 
little yellow circle where the user has moved the mouse. It works fine 
if I don't enable opengl, but it doesn't work when I do enable it.

What happens for me: A window appears with decoration, but its contents 
are "see through". E.g. it looks like only the decoration was drawn, not 
any of the contents.  If I move the frame around, it appears that some 
sort of double buffer is used, but it never gets updated with the 
contents that I provide.

Is this a bug with:
a) my code
b) the JDK
c) The latest GeForce Go 6150 Vista 32-bit drivers from HP (downloaded 
and installed yesterday).
d) Something else gone wrong?

<SSCCE filename="OpenGLTest" please-snip-in-reply="true">

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Ellipse2D;

public class OpenGLTest {
     // To see "correct" behavior, set to false.
     private static final boolean USE_OPENGL = true;

     public static void main(String[] args) {
         if (USE_OPENGL) {
             System.out.println("Using OpenGL");
             System.setProperty("sun.java2d.opengl", "True");
         } else {
             System.out.println("Not using OpenGL");
         }
         EventQueue.invokeLater(new Initter());
     }

     private static void draw(Graphics2D g2d, Point mousePosition) {
         g2d.setPaint(Color.blue);
         g2d.fill(new Rectangle(0, 0, 640, 480));
         Ellipse2D.Double circle = new Ellipse2D.Double();
         if (mousePosition != null) {
             g2d.setPaint(Color.yellow);
             circle.setFrame(mousePosition, new Dimension(10, 10));
             g2d.fill(circle);
         }
     }

     private static class Initter implements Runnable {
         public void run() {
             System.out.println("Constructing frame");
             JFrame frame = new JFrame("Hello");
             final JPanel pane = new PaintlessPanel();
             pane.setPreferredSize(new Dimension(640, 480));
             pane.addMouseMotionListener(new MouseUpdater(pane));
             frame.getContentPane().add(pane);
             frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
             frame.pack();
             frame.setVisible(true);
             System.out.println("Done constructing frame.");
         }

         private static class MouseUpdater extends MouseMotionAdapter {
             private final JPanel pane;

             public MouseUpdater(JPanel pane) {
                 this.pane = pane;
             }

             public void mouseMoved(MouseEvent e) {
                 System.out.println("Mouse moved to: " + e.getPoint());
                 Graphics graphics = pane.getGraphics();
                 draw((Graphics2D) graphics, e.getPoint());
                 graphics.dispose();
             }
         }

         private static class PaintlessPanel extends JPanel {
             public void paint(Graphics g) {
                 System.out.println("Paint even called and ignored.");
//                draw((Graphics2D) g, getMousePosition(true));
             }
         }
     }
}

</SSCCE>

Thanks,
Daniel.
-- 
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#3953 — Re: Using OpenGL in Java2

From"Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Using OpenGL in Java2
Message-ID<g7q3rd$7e2$1@registered.motzarella.org>
In reply to#3952
  To: comp.lang.java.gui
On 11/08/2008 18:21, Daniel Pitts allegedly wrote:
> It seems to me that the following (SSCCE [snipped] below) should draw a 
> little yellow circle where the user has moved the mouse. It works fine 
> if I don't enable opengl, but it doesn't work when I do enable it.

Works for me.

$ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

Win32 XP - ATI Radeon HD 2600 Pro

-- 
DF.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3954 — Re: Using OpenGL in Java2

From"RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Using OpenGL in Java2
Message-ID<m-ednQjlPJTEAz3VnZ2dnUVZ8vKdnZ2d@bt.com>
In reply to#3952
  To: comp.lang.java.gui
Daniel Pitts wrote:
> It seems to me that the following (SSCCE provided below) should draw a 
> little yellow circle where the user has moved the mouse. It works fine 
> if I don't enable opengl, but it doesn't work when I do enable it.
> 
> What happens for me: A window appears with decoration, but its contents 
> are "see through". E.g. it looks like only the decoration was drawn, not 
> any of the contents.  If I move the frame around, it appears that some 
> sort of double buffer is used, but it never gets updated with the 
> contents that I provide.
> 

I get the see-through window you describe.
No odd effects when I move the frame around.
If I resize the frame it turns opaque white.
When releasing the resize handle, it turns slightly darker off-white!
It stays that way when dragged or when resized again.

Athlon 64 x2
Windows Vista Home Premium 32-bit. SP1.
Nvidia GeForce 8600 GT.
Nvidia driver 7.15.11.6371

-- 
RGB

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3955 — Re: Using OpenGL in Java2

From"tar" <tar@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Using OpenGL in Java2
Message-ID<ymibpzzdzjs.fsf@blackcat.isi.edu>
In reply to#3952
  To: comp.lang.java.gui
Daniel Pitts <newsgroup.spamfilter@virtualinfinity.net> writes:

> It seems to me that the following (SSCCE provided below) should draw a
> little yellow circle where the user has moved the mouse. It works fine
> if I don't enable opengl, but it doesn't work when I do enable it.
> 
> Is this a bug with:
> a) my code
> b) the JDK
> c) The latest GeForce Go 6150 Vista 32-bit drivers from HP (downloaded
> and installed yesterday).
> d) Something else gone wrong?

Probably not a.

I just tested this on a Mac with Java 1.4, 1.5 and 1.6.
They all worked both with and without enabling OpenGL.

-- 
Thomas A. Russ,  USC/Information Sciences Institute

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#3958 — Re: Using OpenGL in Java2

From"Daniele Futtorovic" <daniele.futtorovic@THRWHITE.remove-dii-this>
Date2011-04-27 15:47 +0000
SubjectRe: Using OpenGL in Java2
Message-ID<g7qh54$1l5$1@registered.motzarella.org>
In reply to#3955
  To: comp.lang.java.gui
On 11/08/2008 23:14, Thomas A. Russ allegedly wrote:
> Daniel Pitts <newsgroup.spamfilter@virtualinfinity.net> writes:
> 
>> It seems to me that the following (SSCCE provided below) should draw a
>> little yellow circle where the user has moved the mouse. It works fine
>> if I don't enable opengl, but it doesn't work when I do enable it.
>>
>> Is this a bug with:
>> a) my code
>> b) the JDK
>> c) The latest GeForce Go 6150 Vista 32-bit drivers from HP (downloaded
>> and installed yesterday).
>> d) Something else gone wrong?
> 
> Probably not a.

Nor b).

Would seem like Vista's the culprit. Now who'd have thought? ;)

-- 
DF.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web