glCopyTexImage2D error - GL_INVALID_ENUM

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

glCopyTexImage2D error - GL_INVALID_ENUM

Mac70
I have a problem with glCopyTexImage2D - look at this util method which is cutting previously rendered scene to the texture:

    public static Texture cutRenderToTexture(GL g, int width, int height) {
        IntBuffer buff = Buffers.newDirectIntBuffer(1);
        g.glGenTextures(1, buff);
        int tex = buff.get();
        g.glBindTexture(GL.GL_TEXTURE_2D, tex);
        checkGLError(g);
        g.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 0, 0, width, height, 0);
        checkGLError(g);
        g.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        return TextureIO.newTexture(tex, GL.GL_TEXTURE_2D, width, height, width, height, false);
    }

checkGLError is a simple method which is checking all possible OpenGL errors - in this example I am calling it twice to show that problem can be related only to glCopyTexImage2D call. I am getting GL_INVALID_ENUM error, but target is valid, GL_TEXTURE_2D enabled and OpenGL docs do not specify if this error can happen in any other case.

Any ideas what is wrong?
Reply | Threaded
Open this post in threaded view
|

Re: glCopyTexImage2D error - GL_INVALID_ENUM

gouessej
Administrator
There are some other possible root causes mentioned in the man:
https://www.opengl.org/sdk/docs/man4/xhtml/glCopyTexImage2D.xml
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: glCopyTexImage2D error - GL_INVALID_ENUM

jmaasing
In reply to this post by Mac70
A guess is that you need to tell GL about the mip map levels. After bind texture
gl.glTexParameteri(GL4.GL_TEXTURE_2D, GL4.GL_TEXTURE_BASE_LEVEL, 0);
gl.glTexParameteri(GL4.GL_TEXTURE_2D, GL4.GL_TEXTURE_MAX_LEVEL, 0);

The default for GL is to assume that textures have mip maps and that might trip you up. I don't recall the error I got before I added those lines but it might have been invalid enum.
Reply | Threaded
Open this post in threaded view
|

Re: glCopyTexImage2D error - GL_INVALID_ENUM

Mac70
@gouessej - only one possible cause for GL_INVALID_ENUM is mentioned.

@jmaasing - still the same error

I think this is JOGL-related issue - I wrote similar code in LWJGL and it works.
Reply | Threaded
Open this post in threaded view
|

Re: glCopyTexImage2D error - GL_INVALID_ENUM

Sven Gothel
Administrator
On 01/20/2014 12:39 AM, Mac70 [via jogamp] wrote:
> @gouessej - only one possible cause for GL_INVALID_ENUM is mentioned.
>
> @jmaasing - still the same error
>
> I think this is JOGL-related issue - I wrote similar code in LWJGL and it works.

Dunno ..

Please provide a complete smallest unit-test (copy one of our many),
or standalone test class allowing us to reproduce the issue.

Please attach this to a new bug report if you don't mind helping us
managing this issue well.

Thank you.

~Sven



signature.asc (911 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: glCopyTexImage2D error - GL_INVALID_ENUM

gouessej
Administrator
In reply to this post by Mac70
Mac70 wrote
@gouessej - only one possible cause for GL_INVALID_ENUM is mentioned.
Oops, you're right, only the first one matches.

Mac70 wrote
@jmaasing - still the same error

I think this is JOGL-related issue - I wrote similar code in LWJGL and it works.
Sorry but I use this method in Ardor3D JOGL 2 renderer and it works. Please follow Sven's advice, provide a tiny test case, maybe there is something obviously wrong.
Julien Gouesse | Personal blog | Website