LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: CaptainJester on May 16, 2004, 03:29:12

Title: OpenGLException
Post by: CaptainJester on May 16, 2004, 03:29:12
The following code used to work under v0.8:

// Create Nearest Filtered Texture
GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tex.getWidth(), tex.getHeight(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);
 
// Create Linear Filtered Texture
GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(1));
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tex.getWidth(), tex.getHeight(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);
 
// Create MipMapped Texture
GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(2));
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);
GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, tex.getWidth(), tex.getHeight(), GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);


When I try to run it under v0.9 I get the following exception:

org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
at org.lwjgl.opengl.Util.checkGLError(Unknown Source)
at org.lwjgl.opengl.Window.update(Unknown Source)
at Lesson07.run(Lesson07.java:73)
at Lesson07.main(Lesson07.java:64)


The problem line appears to be:
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);

When I change it to GL11.GL_LINEAR or GL11.GL_NEAREST the program runs fine, but it no longer has a working mipmap.
Title: OpenGLException
Post by: elias on May 16, 2004, 05:14:54
I think you've swapped the enums. Mipmapping is only used for minification, not magnification (which can only use LINEAR).

- elias
Title: OpenGLException
Post by: CaptainJester on May 16, 2004, 12:36:51
Yes, that did it.  Thanks.

I don't know how I switched those. :oops:
Title: OpenGLException
Post by: princec on May 16, 2004, 13:01:51
I have to say I preferred the way the old LWJGL found errors in debug mode (immediately when the function was called). Much quicker finding bugs. What's the performance overhead if we put this into Java-side code?
eg.

public static native void glBegin(int type);

becomes

public static void glBegin(int type) {
nglBegin(type);
if (Sys.DEBUG) {
Util.checkGLError();
}
}


Cas :)
Title: OpenGLException
Post by: elias on May 16, 2004, 13:55:03
I'd say it's too much work for little gain. And I'd like to have just as strict checking in normal mode as in debug mode.

- elias