Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  Application crashes on ati video cards, uses java, jogl, and textures.  (Read 817 times)
0 Members and 1 Guest are viewing this topic.
Offline vextorspace

Junior Newbie





« Posted 2011-06-27 18:38:40 »

I have an application that runs flawlessly (well nearly so) on nvidia video cards, but on ati cards, some time after a texture has been placed on a surface, the jvm crashes, and it blames either the ati driver, or a kernel sys call.  I managed to recreate it in a relatively simple bit of code:  note I am using display lists for better performance.  If you take the following code (up/down rotates, enter flops the textures) and run it spinning and flopping it for a couple minutes, it crashes.

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  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
package org.yourorghere;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureIO;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;



/**
 * SimpleJOGL.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */

public class SimpleJOGL implements GLEventListener, KeyListener {

    GLCanvas canvas;
    int lists;
    float angle = 0.f;
    boolean needsRotate = false;
    boolean needsTexture = false;
    Texture texture1;
    Texture texture2;
       
    Color c1 = Color.red;
    Color c2 = Color.green;
   
    public SimpleJOGL(GLCanvas canvas) {
        this.canvas = canvas;
    }

    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        SimpleJOGL sjogl = new SimpleJOGL(canvas);
        canvas.addKeyListener(sjogl);
       
        canvas.addGLEventListener(sjogl);
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
               // make sure the call to Animator.stop() completes before
               // exiting
               new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });
        // Center frame
       frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
       // drawable.setGL(new DebugGL(drawable.getGL()));

        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
       gl.setSwapInterval(1);

        // double buffer
       gl.glEnable(GL.GL_DOUBLEBUFFER);
        drawable.setAutoSwapBufferMode(false);
       
        // Enable VSync
       gl.setSwapInterval(1);
       
        // Setup the drawing area and shading mode
       gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
       
        gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
        gl.glEnable(GL.GL_TEXTURE_2D);
        gl.glDisable(GL.GL_BLEND);
       
                // -- lighting --
       gl.glEnable(GL.GL_COLOR_MATERIAL);
        gl.glLightModelf(GL.GL_LIGHT_MODEL_TWO_SIDE, 1.0f);
        gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
        gl.glEnable(GL.GL_MAP1_VERTEX_3);
        gl.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST);
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[]{.3f,.3f,.3f,1.f},0);
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, new float[]{.55f,.55f,.55f,1.f},0);
        gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, new float[]{.05f,.05f,.05f,1.f}, 0);
        gl.glFrontFace(GL.GL_CCW);
        gl.glEnable(GL.GL_LIGHT0);
        gl.glEnable(GL.GL_LIGHTING);
        gl.glEnable(GL.GL_DEPTH_TEST);

        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE, new float[]{.5f,.5f,.5f,1.0f}, 0);
        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, new float[]{.05f, .05f, .05f, 1.0f}, 0);
        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, new float[]{0.01f, 0.01f, 0.01f, 1.f}, 0);
        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, new float[]{30}, 0);
        gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_COLOR_INDEXES, new float[]{1.0f, 0.0f, 0.0f, 1.0f}, 0);
       
        gl.glCullFace(GL.GL_BACK);
        gl.glDisable(GL.GL_BLEND);
        gl.glEnable(GL.GL_RESCALE_NORMAL);

       
        lists = gl.glGenLists(3);
        this.needsRotate = true;
        this.needsTexture = true;
    }
   
    private void reTexture(GL gl) {
        BufferedImage image1 = makeImage(c1);
        BufferedImage image2 = makeImage(c2);
        makeShape(gl, image1, image2);
    }
    private BufferedImage makeImage(Color c) {
        int y = 1200;
        int x = 1024;
        BufferedImage image = new BufferedImage(y, y, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = image.createGraphics();
        g.setBackground(Color.white);
        g.clearRect(0, 0, y,y);
        Rectangle2D r = new Rectangle2D.Float(128,128,x-256,x-256);
        g.setColor(c);
        g.fill(r);
        g.dispose();
        return image;
    }

    private void makeShape(GL gl, BufferedImage image1, BufferedImage image2) {
        float x = 1024.f/1200.f;

        texture1 = TextureIO.newTexture(image1, false) ;
        texture2 = TextureIO.newTexture(image2, false) ;
       
        gl.glNewList(lists+1, GL.GL_COMPILE);
               
        gl.glColor3f(0f, .8f, .4f);
        // Drawing Using Triangles

        gl.glBegin(GL.GL_POLYGON);
            gl.glTexCoord2f(0, 0);
            gl.glVertex3f(0.0f, 0.0f, 0.0f);   // Top
           gl.glNormal3f(0, 0, 1);
           
            gl.glTexCoord2f(x, 0);
            gl.glVertex3f(1.0f, 0.0f, 0.0f); // Bottom Left
           gl.glNormal3f(0, 0, 1);
           
            gl.glTexCoord2f(x, x);
            gl.glVertex3f(1.0f, 1.0f, 0.0f);  // Bottom Right
           gl.glNormal3f(0, 0, 1);
           
            gl.glTexCoord2f(0, x);
            gl.glVertex3f(0f, 1.0f, 0.0f);  // Bottom Right
           gl.glNormal3f(0, 0, 1);
        gl.glEnd();
        texture1.disable();
       
        gl.glEndList();
       
        gl.glNewList(lists+2, GL.GL_COMPILE);
       
        texture2.enable();
        texture2.bind();
        gl.glBegin(GL.GL_POLYGON);
            gl.glTexCoord2f(0, 0);
            gl.glVertex3f(0.0f, 0.0f, 0.0f);   // Top
           gl.glNormal3f(0, 0, 1);
           
            gl.glTexCoord2f(x, 0);
            gl.glVertex3f(1.0f, 0.0f, 0.0f); // Bottom Left
           gl.glNormal3f(0, 0, 1);
           
            gl.glTexCoord2f(x, x);
            gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
           gl.glNormal3f(0, 0, 1);
           
            gl.glTexCoord2f(0, x);
            gl.glVertex3f(0f, -1.0f, 0.0f);  // Bottom Right
           gl.glNormal3f(0, 0, 1);
        gl.glEnd();
        texture2.disable();
       
        gl.glEndList();


    }
   
    public void rotate(GL gl) {
        gl.glNewList(lists, GL.GL_COMPILE);

        gl.glLoadIdentity();
        gl.glTranslatef(-2.f, 0.f, -6.f);
        gl.glRotatef(angle, 1.0f, 0.f, 0.f);
               
        gl.glCallList(lists+1);
       
        gl.glRotatef(-45, 1.f, 0.f, 0.f);
       
        gl.glCallList(lists+2);        
        gl.glEndList();
    }
   
    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        GLU glu = new GLU();

        if (height <= 0) { // avoid a divide by zero error!
       
            height = 1;
        }
        final float h = (float) width / (float) height;
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();
        glu.gluPerspective(45.0f, h, 1.0, 20.0);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
       
        if (needsTexture) {
            reTexture(gl);
            needsTexture = false;
        }

       
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[]{1.f, 1.f, 1.f, 0.f}, 0);

       
        gl.glLoadIdentity();
        gl.glTranslatef(-2.f, 0.f, -6.f);
        gl.glRotatef(angle, 1.0f, 0.f, 0.f);
               
                texture1.enable();
        texture1.bind();
        gl.glCallList(lists+1);
        texture1.disable();
       
        gl.glRotatef(-45, 1.f, 0.f, 0.f);
       
        gl.glCallList(lists+2);      
       
//        
//        if (needsRotate) {
//            rotate(gl);
//            needsRotate = false;
//        }
//        
//        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
//
//        gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, new float[]{1.f, 1.f, 1.f, 0.f}, 0);

       
//        gl.glCallList(lists);
       

        // Flush all drawing operations to the graphics card
       drawable.swapBuffers();
    }

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

    public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_DOWN) {
            angle -= 5;
            needsRotate = true;

        }
        if (e.getKeyCode() == KeyEvent.VK_UP) {
            angle += 5;
            needsRotate = true;
        }
        if (e.getKeyCode() == KeyEvent.VK_ENTER) {
            Color c = c1;
            c1 = c2;
            c2 = c;
            needsTexture = true;
        }
    }

    public void keyReleased(KeyEvent e) {
    }

    public void keyTyped(KeyEvent e) {
        canvas.repaint();
    }
   
   
}

thank you!
--Douglas
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #1 - Posted 2011-06-28 08:05:52 »

I could not compile this without libraries, and asking for us to run things without providing the tools is too much hassle Tongue

Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2011-06-28 10:12:29 »

Everyone knows ATI can't make proper drivers to save their lives.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline vextorspace

Junior Newbie





« Reply #3 - Posted 2011-06-28 16:59:37 »

The only libraries I am using are the JOGL pack, and I don't get to choose the graphics cards people run my application on.  I figure I'm setting something up wrong since it can't possibly be that display lists and textures are incompatible on all ATI cards.
Online princec

JGO Kernel


Medals: 364
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2011-06-28 20:52:25 »

Avoid display lists at all costs.

Cas Smiley

Offline gouessej
« Reply #5 - Posted 2011-06-29 10:23:05 »

Hi

Rather use JOGL 2.0 and anyway, princec is right, avoid using display lists. Even on a very few NVIDIA consumer graphics cards (not those of the Quadro FX series) you might have the same problem. You should have posted this question in the JOGL section.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

TehJavaDev (13 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (31 views)
2014-08-16 06:45:27

Tekkerue (31 views)
2014-08-16 06:22:17

Tekkerue (19 views)
2014-08-16 06:20:21

Tekkerue (29 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (42 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
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!