LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Javapunk on October 31, 2004, 20:34:59

Title: Z order and Serializable Fonts.
Post by: Javapunk on October 31, 2004, 20:34:59
Two questions. First my z order is flipped. I.E. Draw image #2 behind image number one... initGl() code.

GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glClearDepth(1.0f);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
GLU.gluPerspective(45.0f, (float) Display.getDisplayMode().getWidth()
/ (float) Display.getDisplayMode().getHeight(), 0.1f, 100.0f);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glEnable(GL11.GL_BLEND);


Also, if I try to serialize a com.shavenpuppy.jglib.Font I get a null pointer exception at com.shavenpuppy.jglib.Image.writeObject(Image.java:220)
It is trying to rewind the ByteBuffer data which is a null object.

Thanks!
Title: Z order and Serializable Fonts.
Post by: Niels on November 01, 2004, 17:25:11
What do you mean by image #1 and image #2 - your call sequence does not imply a Z-order. Unless you explicitly specify Z-coords, all your primitive will be at the same depth and could be displayed in any order (even different order from frame to frame).
Title: Z order and Serializable Fonts.
Post by: Javapunk on November 01, 2004, 19:26:37
So what is the best solution? Specify z cordinates of .001f less then the previous?
Title: Z order and Serializable Fonts.
Post by: elias on November 01, 2004, 20:57:11
Or disable the z-buffer while rendering the images.

- elias
Title: Z order and Serializable Fonts.
Post by: Javapunk on November 02, 2004, 01:27:53
Disabling the z-buffer does not seam to change a thing as does translatef(0,0,0,1);
If I GL11.glDisable(GL11.GL_BLEND); everything stacks as it should, but my transparency stops working!
Title: Z order and Serializable Fonts.
Post by: Niels on November 02, 2004, 11:22:39
I believe lesser Z are deeper (You're looking down the negative Z-axis by default).

And yes, I would rely on Z rather than disabling it since it allow you to separate drawing order from execution order at no real cost (apart from the memory overhead, HW Z buffering is as cheap as it comes).

How do you set your blending options when Blend is enabled - maybe this is not really a Z order problem?