glCopyTexImage2D error - GL_INVALID_ENUM
Posted by Mac70 on Jan 19, 2014; 9:24pm
URL: https://forum.jogamp.org/glCopyTexImage2D-error-GL-INVALID-ENUM-tp4031251.html
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?