LWJGL 0.9 released!

Started by Matzon, April 13, 2004, 20:30:03

Previous topic - Next topic

Matzon

LWJGL 0.9 has been released.

http://www.lwjgl.org/

stuff changed from 0.89 of the top of my head:
* bug fixes
* setGrabbed support for grabbing cursor, or showing OS cursor
* Software OpenGL support via flag (mental note, document these)
* win32 cursor animation (still only 1 bit cursor transparency on win32, will fix soon)
* input now accumulates over multiple Window.updates
* more extensions
* automatic read of input, now you only need to call Window.update

One gotcha, due to the accumelated delta's on devices, you can only call getD* once. A second call will return 0, untill the device has actually moved.

more comments to come, perhaps :)

ps. due to a small f*ckup, the Version string is still 0.9pre. This isn't a biggie, and would require a full recompile on all platforms, which I am not in the mood for, so I'll let it slip.

elias

GL/AL changes include splitting each extension out into separate classes, like ARBVertexProgram instead of the usual GL. This works the same way as the core GL which is split into GL11/GL12/GL13/GL14/GL15. This was probably in 0.89 too, but it's still important to note in order to hinder confusion...

- elias

spasi


Matzon

w00t, I posted it last night :)

cfmdobbie

Request: More helpful messages in BufferOverflowExceptions.  Example, from GL11.java:

public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer pixels) {
		if (pixels.remaining() < BufferChecks.calculateImageStorage(format, type, width, height, 1)) {
			throw new BufferOverflowException();
		}
		nglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels, pixels.position());
	}


There are a huge number of blocks almost identical to this one.  Maybe they should be refactored together and given a nicely formatted exception message?
ellomynameis Charlie Dobbie.

princec

Most annoyingly BufferOverflowException doesn't have a String constructor for an error message :( Sorry.

Cas :)

cfmdobbie

Wha...? *blink*  What a bunch of muppets! :x

That's the second time this week I've cursed the ground the Sun engineers walk on.  (The first time was for the entire java.awt.imaging API.)

Sigh...
ellomynameis Charlie Dobbie.

AndersD

Well, as you're already limited to >= 1.4 you could use a chained runtime exception to get a more user friendly error message:
throw new RuntimeException("BLABLABLA", new BufferOverflowException());


Which will first print the error message and then the cause (bufferoverflow in this case)

elias

How about an IllegalArgumentException as it is done in BufferChecks.java already?

- elias

princec

Yeah, seems a bit cleaner than a chained exception.

Cas :)

AndersD

yep, even better  :oops:

tomb

I think I've found a bug in gluBuild2DMipmaps. I get artifacts when I use non power of two textures.

I'll investigate further and post a fix if I find the bug.

tomb

Found it. The scaling algo was only designed to sale images down not up. Here is the fix. It's to class org.lwjgl.opengl.glu.MipMap, line 219:
for (int iy = 0; iy < heightOut; iy++) {
			for (int ix = 0; ix < widthOut; ix++) {
				int x0 = (int) (ix * sx);
				int x1 = (int) ((ix + 1) * sx);
				int y0 = (int) (iy * sy);
				int y1 = (int) ((iy + 1) * sy);

				int readPix = 0;

				// reset weighted pixel
				for (int ic = 0; ic < components; ic++) {
					c[ic] = 0;
				}

				// create weighted pixel
				for (int ix0 = x0; ix0 < x1; ix0++) {
					for (int iy0 = y0; iy0 < y1; iy0++) {

						src = (iy0 * widthIn + ix0) * components;

						for (int ic = 0; ic < components; ic++) {
							c[ic] += tempin[src + ic];
						}

						readPix++;
					}
				}

				// store weighted pixel
				dst = (iy * widthOut + ix) * components;

				if (readPix == 0) {
					// BUGFIX: Image is sized up, caused by non power of two texture as input
					src = (y0 * widthIn + x0) * components;
					for (int ic = 0; ic < components; ic++) {
						tempout[dst++] = tempin[src + ic];
					}
				} else {
					for (k = 0; k < components; k++) {
						tempout[dst++] = c[k] / readPix;
					}
				}
			}
		}

tomb

Another possible bug in gluBuild2DMipmaps. The following code causes a
java.lang.IndexOutOfBoundsException in org.lwjgl.opengl.glu.MipMap.gluScaleImage.
public class GLUMipMap {
	public static void main(String args[]) {
		try {
			org.lwjgl.opengl.Window.create("", 600, 0, 40, 40, 1, 0, 16, 0);
			int width  = 383;
			int height = 226;
			ByteBuffer buf = ByteBuffer.allocateDirect(width*height*3);
			IntBuffer intBuf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
			GL11.glGenTextures(intBuf);
			GL11.glBindTexture(GL11.GL_TEXTURE_2D, intBuf.get(0));
			int error = GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, GL11.GL_RGB, width, height, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buf);
		} catch (Throwable t) {
			t.printStackTrace();
		} finally {
			org.lwjgl.opengl.Window.destroy();
		}
	}
}


The problem has got something to do with PixelStoreState as the rowstride do not match imagewidth*3. It works in the old GLU so I think it's a bug.

Matzon

regarding GLU, I am sure erikd will pop in - he did the basic GLU port from native to java.
We changed from requiring native GLU to a java GLU implementation - certain to be some bugs to iron out :)