jogl 2.0 build 270 GLException

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

jogl 2.0 build 270 GLException

bcothren
Up until today I've been using the following piece of code with build 223 with no problems...

                try {
                        floorTexture = TextureIO.newTexture(new File(filename), false);
                        floorTexture.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
                        floorTexture.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
                } catch (IOException e) {
                        System.err.println("Error loading " + filename);
                }

I switched today to the latest autobuild, 270, and I'm now getting no texture showing up (it's all white).  When I turn on GL debugging, I see this error:

glGetError() returned the following error codes after a call to glTexImage2D(<int> 0xDE1, <int> 0x0, <int> 0x1907, <int> 0x2D0, <int> 0x2D0, <int> 0x0, <int> 0x80E0, <int> 0x1401, <java.nio.Buffer>): GL_INVALID_VALUE ( 1281 0x501),

And, when I turn on the trace, it shows me:

glTexImage2D(<int> 0xDE1, <int> 0x0, <int> 0x1907, <int> 0x2D0, <int> 0x2D0, <int> 0x0, <int> 0x80E0, <int> 0x1401, <java.nio.Buffer> null)Exception in thread "AWT-EventQueue-0-AWTAnimator-1" javax.media.opengl.GLException: javax.media.opengl.GLException: Thread[AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glTexImage2D(<int> 0xDE1, <int> 0x0, <int> 0x1907, <int> 0x2D0, <int> 0x2D0, <int> 0x0, <int> 0x80E0, <int> 0x1401, <java.nio.Buffer>): GL_INVALID_VALUE ( 1281 0x501),

This seems like it could be related to not setting GL_TEXTURE_MIN_FILTER to GL_LINEAR, but I have that.

Sorry, I know there's a better way to include code snippets, but I don't know how.

Any ideas?

Thanks,

bcothren
Reply | Threaded
Open this post in threaded view
|

Re: jogl 2.0 build 270 GLException

Wade Walker
Administrator
I'll try creating a test case for this tomorrow. I've already got another one that I can base it on.
Reply | Threaded
Open this post in threaded view
|

Re: jogl 2.0 build 270 GLException

Wade Walker
Administrator
In reply to this post by bcothren
I set up a quick unit test for this, and it seems to work fine. I'm running against the latest build on CentOS 5.4. Here's the code (Just substitute the filename of your texture in there):

import com.jogamp.opengl.test.junit.util.UITestCase;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES1;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;

import com.jogamp.opengl.util.texture.Texture;
import com.jogamp.opengl.util.texture.TextureCoords;
import com.jogamp.opengl.util.texture.TextureIO;

import java.awt.Frame;

import java.io.IOException;
import java.io.InputStream;

import org.junit.Assert;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Unit test for user problem in forum.
 * @author Wade Walker
 */
public class TestTextureMinMagFilterAWT extends UITestCase {
    static GLProfile glprofile;
    static GLCapabilities glcapabilities;
    InputStream inputstreamTexture;

    @BeforeClass
    public static void initClass() {
        GLProfile.initSingleton(true);
        glprofile = GLProfile.get(GLProfile.GL2GL3);
        Assert.assertNotNull(glprofile);
        glcapabilities = new GLCapabilities(glprofile);
        Assert.assertNotNull(glcapabilities);
    }

    @Before
    public void initTest() {
        inputstreamTexture = TestTextureMinMagFilterAWT.class.getResourceAsStream( "grayscale_texture.png" );
        Assert.assertNotNull(inputstreamTexture);
    }

    @After
    public void cleanupTest() {
        inputstreamTexture=null;
    }

    @Test
    public void test1() throws InterruptedException {
        GLCanvas glcanvas = new GLCanvas(glcapabilities);

        Frame frame = new Frame("Texture Test");
        Assert.assertNotNull(frame);
        frame.add(glcanvas);
        frame.setSize( 256, 128 );

        // load texture from file inside current GL context to match the way
        // the bug submitter was doing it
        glcanvas.addGLEventListener(new GLEventListener() {
            private GLU glu = new GLU();
            private Texture texture;

            @Override
            public void init(GLAutoDrawable drawable) {
                try {
                    texture = TextureIO.newTexture( inputstreamTexture, true, TextureIO.PNG );
                    texture.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
                    texture.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
                }
                catch(GLException glexception) {
                    glexception.printStackTrace();
                    Assume.assumeNoException(glexception);
                }
                catch(IOException ioexception) {
                    ioexception.printStackTrace();
                    Assume.assumeNoException(ioexception);
                }
            }

            @Override
            public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
                GL2 gl = drawable.getGL().getGL2();
                gl.glMatrixMode(GL2ES1.GL_PROJECTION);
                gl.glLoadIdentity();
                glu.gluOrtho2D(0, 1, 0, 1);
                gl.glMatrixMode(GL2ES1.GL_MODELVIEW);
                gl.glLoadIdentity();
            }

            @Override
            public void dispose(GLAutoDrawable drawable) {
                GL2 gl = drawable.getGL().getGL2();
                if(null!=texture) {
                    texture.disable();
                    texture.destroy(gl);
                }
            }

            @Override
            public void display(GLAutoDrawable drawable) {
                GL2 gl = drawable.getGL().getGL2();
           
                // Now draw one quad with the texture
                if(null!=texture) {
                    texture.enable();
                    texture.bind();
                    gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
                    TextureCoords coords = texture.getImageTexCoords();
                    gl.glBegin(GL2.GL_QUADS);
                    gl.glTexCoord2f(coords.left(), coords.bottom());
                    gl.glVertex3f(0, 0, 0);
                    gl.glTexCoord2f(coords.right(), coords.bottom());
                    gl.glVertex3f(1, 0, 0);
                    gl.glTexCoord2f(coords.right(), coords.top());
                    gl.glVertex3f(1, 1, 0);
                    gl.glTexCoord2f(coords.left(), coords.top());
                    gl.glVertex3f(0, 1, 0);
                    gl.glEnd();
                    texture.disable();
                }
            }
        });

        frame.setVisible(true);
        Thread.sleep(5000); // 500 ms
        frame.setVisible(false);
        frame.remove(glcanvas);
        glcanvas=null;
        Assert.assertNotNull(frame);
        frame.dispose();
        frame=null;
    }

    public static void main(String args[]) throws IOException {
        org.junit.runner.JUnitCore.main(TestTextureMinMagFilterAWT.class.getName());
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: jogl 2.0 build 270 GLException

Wade Walker
Administrator
In reply to this post by bcothren
I've confirmed this also works on Windows XP with the latest JOGL.
Reply | Threaded
Open this post in threaded view
|

Re: jogl 2.0 build 270 GLException

bcothren
Thanks Wade.

I have the same issue with your test.  The texture doesn't show up (well, it's all white) and when I turn on the GLDebugging i get that same error.

I'm on a Windows 7, 64-bit box with a Radeon 5770 grahics card.

I'm going to verify that I have the most up to date drivers and I'll get back with yall.

Thanks,

bcothren
Reply | Threaded
Open this post in threaded view
|

Re: jogl 2.0 build 270 GLException

bcothren
Ok, so I upgraded to the latest drivers for my card and all is well.

Sorry to have wasted your time, Wade.  Thanks for the help.

bcothren
Reply | Threaded
Open this post in threaded view
|

Re: jogl 2.0 build 270 GLException

Wade Walker
Administrator
No problem -- I needed to develop a better texture test anyway  I'm sure I'll reuse that code in another unit test soon.

Just let us know if you have any more problems!