Z order and Serializable Fonts.

Started by Javapunk, October 31, 2004, 20:34:59

Previous topic - Next topic

Javapunk

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!
ude!!!

Niels

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).

Javapunk

So what is the best solution? Specify z cordinates of .001f less then the previous?
ude!!!

elias

Or disable the z-buffer while rendering the images.

- elias

Javapunk

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!
ude!!!

Niels

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?