Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (530)
games submitted by our members
Games in WIP (512)
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  Java Game APIs & Engines / JOGL Development / Crash with glMultiDrawElements() and vertex arrays on: 2007-08-24 14:08:59
Hello,

I am having a similar case with a JVM crash, but when using glMultiDrawElements() and vertex arrays. I checked all the things that Keith mentioned above and all seem to be done right. It is very strange, because the crash occurs on 2 Windows machines and doesn't occur on the Linux-Mashine. I don't know if it is some kind of bug, or if my code is incorrect.

The method that is producing the error is 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  
41  
42  
43  
44  
45  
46  
47  
48  
    public void renderPrimitives(GL gl)
    {
        // position world
       gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glPushMatrix();

        // rotate and translate view
       gl.glMultMatrixf(viewMatrix, 0);

        // enable backface culling
       gl.glEnable(GL.GL_CULL_FACE);
        gl.glCullFace(GL.GL_BACK);

        // enable vertex arrays
       gl.glEnableClientState(GL.GL_VERTEX_ARRAY);

        // send vertex data
       float[] varray = new float[vertices.length * 3];
        int k = 0;
        for (Vector3DVO v : vertices)
        {
            varray[k++] = v.x;
            varray[k++] = v.z;
            varray[k++] = -v.y;
        }
        FloatBuffer verticesBuffer = BufferUtil.newFloatBuffer(vertices.length * 3);
        verticesBuffer.put(varray);
        verticesBuffer.rewind();
        gl.glVertexPointer(3, GL.GL_FLOAT, 0, verticesBuffer);

        int[] counts = new int[faces_vertices.length];
        IntBuffer[] indices = new IntBuffer[faces_vertices.length];
        for (int i = 0; i < faces_vertices.length; i++)
        {
            counts[i] = faces_vertices[i].length;
            indices[i] = BufferUtil.newIntBuffer(faces_vertices[i].length);
            indices[i].put(faces_vertices[i]);
            indices[i].rewind();
        }
        // ===== HERE COMES THE CRASH =====
       gl.glMultiDrawElements(GL.GL_POLYGON, counts, 0, GL.GL_UNSIGNED_INT,
                               indices, faces_vertices.length);

        gl.glDisableClientState(GL.GL_VERTEX_ARRAY);

        // restore view
       gl.glPopMatrix();
    }


On the Ubuntu Machine (JDK 1.6, ATI Radeon X1600 with the ATI driver xorg-driver-fglrx 7.1.0-8.34) it runs normally.

On the first Windows Machine (JDK 1.6, ATI Radeon 9600 with the latest drivers 8.401.0.0) it crashes with this message:

1  
2  
3  
4  
5  
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6936eae5, pid=1460, tid=444
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_02-b06 mixed mode, sharing)
# Problematic frame:
# C  [atioglxx.dll+0x36eae5]


On the second Windows Machine (JDK 1.6 or JDK 1.5, NVIDIA GeForce 6200SE TurboCache with 6.14.10.9371 drivers) it also crashes with a similar message:

1  
2  
3  
4  
5  
6  
7  
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x695e320a, pid=3708, tid=2388
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_01-b06 mixed mode, sharing)
# Problematic frame:
# C  [nvoglnt.dll+0xe320a]


I also noticed, that this is somehow related with intensive IO - it crashes at the start of the application, when a lot of files are being read from the disk (in another thread). When I suspend the rendering thread with a Breakpoint for some seconds, until no more files are being read, the application doesn't crash. Does anybody have a clue of what is going on?

Best Regards,
Ivan
2  Java Game APIs & Engines / JOGL Development / Using Overlay to draw a Swing GUI over a GLCanvas on: 2007-08-23 15:37:56
Greetings everybody

We are developing a 3D game with JOGL with its user interface made completely in Swing [1]. The widgets are also made translucent by the look-and-feel. The 3D scene is placed in a GLJPanel and the GUI widgets are placed in a JLayeredPane on top of the scene, like a HUD. Unfortunately the game is running very very slow - just about 10 fps [2].

Now we want to use the GLCanvas for the 3D scene and because GLCanvas is heavyweight, we want use the Overlay class for drawing the Swing components on it. Is there a best-practice on how the overlay class is used? Currently it works, but it doesn't display translucent widgets correctly - the content of some widgets is drawn multiple times in the other widgets. I suppose the problem lies in the custom RepaintManager that we use. I would be very thankful for any tips on using the Overlay class in general, or in conjunction with translucent components.

Below I have included some parts of the code. The important classes are SceneCanvas (a GLCanvas and GLEventListener), a HUDPane (the JLayeredPane with the Swing Components), and a HUDRepaintManager. We have overriden the paint(Graphics g) method of the HUDPane and call it with a Graphics object created from the Overlay. In the HUDRepaintManager we are tracking the dirty region that must be re-drawn (with markDirty()) on the Overlay.

[1]: I have read that it is better to use pure OpenGL like FengGUI does, but the GUI is already implemented and it would be very hard to port it. Furthermore we use a very customized look and feel and I don't know if FengGUI supports that.
[2]: We tried with the OpenGL pipeline, but it worked correctly only on a few machines, on the rest the game and some demo apps with the pipeline enabled were not displaying correctly.

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  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
class SceneCanvas extends GLCanvas implements GLEventListener 
{
    // initializes the GUI
   // creates the Overlay
   // starts an Animator

    public void init(GLAutoDrawable gld)
    {
         // initialize the GL
        ...
    }

    public void display(GLAutoDrawable gld)
    {
        ...

        Graphics2D g2d = (Graphics2D) overlay.createGraphics();
 
        if (overlay.contentsLost())
        {
            // clear the background
           g2d.setBackground(TRANSPARENT_BLACK);
            g2d.clearRect(0, 0, getWidth(), getHeight());

            // get the dirty region from the custom RepaintManager
           Rectangle dirty = hudRepaintManager.getAndResetDirtyRegion();
            g2d.setClip(dirty);
           
            // paint the GUI components
           hudPane.paint(g2d);
           
            overlay.markDirty(dirty.x, dirty.y, dirty.width, dirty.height);
        }

        g2d.dispose();

        // reset texture units for before drawing the overlay
       GLTextureManager.reset(gl);
        gl.glColor4f(1, 1, 1, 1);

        // show the overlay
       overlay.drawAll();
    }
}

class HUDPane extends JLayeredPane
{
    public void paint(Graphics g)
    {
        // we paint only if we are called from the GL-context
       if (GLContext.getCurrent() != null)
        {
            // the Graphics object comes from the Overlay
           // draw everything into overlay
           super.paint(g); // paints the child-components too
       }
    }
}

class HUDRepaintManager extends RepaintManager
{
    private boolean hasDirtyRegion = false;
    private int dirtyMinX = Integer.MAX_VALUE;
    private int dirtyMaxX = Integer.MIN_VALUE;
    private int dirtyMinY = Integer.MAX_VALUE;
    private int dirtyMaxY = Integer.MIN_VALUE;

    private HUDPane hudPane;

    public HUDRepaintManager(HUDPane hudPane)
    {
        super();
        this.hudPane = hudPane;
    }

    public Rectangle getAndResetDirtyRegion()
    {
        Rectangle dirty = hasDirtyRegion ? getDirtyRectangle() : null;

        dirtyMinX = Integer.MAX_VALUE;
        dirtyMaxX = Integer.MIN_VALUE;
        dirtyMinY = Integer.MAX_VALUE;
        dirtyMaxY = Integer.MIN_VALUE;
        hasDirtyRegion = false;

        return dirty;
    }

    public boolean hasDirtyRegion() { return hasDirtyRegion; }

    @Override
    public void addDirtyRegion(JComponent c, int x, int y, int w, int h)
    {
        super.addDirtyRegion(c, x, y, w, h);

        // check if component is part of hudPane component tree
       if (!isPartOfComponentTree(c, hudPane))
            return;

        // translate to container
       Rectangle rect = SwingUtilities.convertRectangle(
                c, new Rectangle(x, y, w, h), hudPane);
        x = rect.x;
        y = rect.y;
        w = rect.width;
        h = rect.height;

        // set min, max
       if (x < dirtyMinX)
        {
            dirtyMinX = x;
            hasDirtyRegion = true;
        }
        if (y < dirtyMinY)
        {
            dirtyMinY = y;
            hasDirtyRegion = true;
        }
        int xW = x + w;
        if (xW > dirtyMaxX)
        {
            dirtyMaxX = xW;
            hasDirtyRegion = true;
        }
        int yH = y + h;
        if (yH > dirtyMaxY)
        {
            dirtyMaxY = yH;
            hasDirtyRegion = true;
        }
    }

    private Rectangle getDirtyRectangle()
    {
        return new Rectangle(dirtyMinX, dirtyMinY,
                (dirtyMaxX - dirtyMinX),
                (dirtyMaxY - dirtyMinY));
    }

    private boolean isPartOfComponentTree(Component c, Component pane)
    {
        if (c == pane) return true;

        if (pane instanceof Container)
        {
            if (((Container) pane).getComponentCount() == 0) return false;

            for (Component cc : ((Container) pane).getComponents())
            {
                if (cc == c) return true;

                boolean b = isPartOfComponentTree(c, cc);

                if (b) return true;
            }
        }
        return false;
    }
}
3  Java Game APIs & Engines / JOGL Development / Re: OpenGL pipeline on a linux platform bombs out when enabled. on: 2007-08-23 12:58:04
The demo doesn't show the cube on my PC (Ubuntu 7.04, Java 1.6.0, ATI X1600 with the proprietary driver xorg-driver-fglrx 7.1.0-8.34.Cool. The other tests I did were with windows PCs and the demo-apps that come with the JDK - with the pipeline enabled, either the rotating cubes didn't show at all, or the screen flashed white the whole time. It seems that it is extremely important to have the right graphics card and the right drivers. It doesn't look like the pipline could be a stable solution yet.
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.

xsi3rr4x (72 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (79 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (80 views)
2014-04-14 15:48:38

tom_mai78101 (104 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!