Hello Guest

Wireframe Problem

  • 2 Replies
Wireframe Problem
« on: October 31, 2012, 15:12:46 »

I've been playing around with LWJGL and trying to get to grips on 3d programming in general.

I have created a little cube world (minecrafty...) and been playing around with trying to make each cube stand out. I've managed to do this, but with on snag, It only appears to work if Lighting is enabled... (i have attached 2 images to show the difference)

Any ideas on why this is happening?

This is my render code:

Code: [Select]
public void render() {

//Enable stuff

//load data
GL11.glNormalPointer(3 << 2, normalBuffer);
GL11.glColorPointer(3, /* stride */3 << 2, colourBuffer);
GL11.glVertexPointer(3, /* stride */3 << 2, vertexBuffer);

//fill mode
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);

//Polygon offset (nice wireframe)
GL11.glPolygonOffset(1, 1);

//render faces
GL11.glDrawArrays(GL11.GL_QUADS, 0, /* elements */(total_objects * 4));

//disable polygon offset

//wireframe mode
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);

//load colour data (all black for wireframe)
GL11.glColorPointer(3, /* stride */3 << 2, lineBuffer);

//draw faces again (but in wireframe mode)
GL11.glDrawArrays(GL11.GL_QUADS, 0, /* elements */(total_objects * 4));

//disable stuff

Re: Wireframe Problem
« Reply #1 on: November 04, 2012, 03:57:01 »
I'm not sure that I understand your question.
[I've] ...been playing around ... trying to make each cube stand out. I've managed to do this, but with one snag, It only appears to work if Lighting is enabled...
This is logical since unlit scenes tend to look very unnatural to the human eye.

Which image do you dislike and why?
What goal are you trying to achieve?

The only difference I see between the two images is that polygon outline mode is enabled in one and disabled in the other.
Both images appear to be are shaded identically.
The second image simply looks a little bit darker in the distance because the polygon outlines are black and the percentage of outline to polygon increases at further distances from the camera since you are using a frustrum view where more polygons can fit on the screen at further distances from the camera.

Are the sides of the blocks colored or are the different colors on different sides of the blocks caused by some type of lighting?

Re: Wireframe Problem
« Reply #2 on: November 06, 2012, 13:45:53 »
I don't know how you are enabling/disabling lighting, but my best guess about what is wrong is that you are still using normals when you are not using lighting.
Maybe take out GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY) when not using lighting?

P.S. GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL) is very inefficient. It's better to make sure that all your polygons are correctly wound so you can just use GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL).
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D