Archived

This topic is now archived and is closed to further replies.

Enabling fog gives no fog or lights!

This topic is 5577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a basic heightmap that i've generated to test out a few openGL basics, and managed to get coords, colours and normals generated properly. However i've got a few problems: When i enable lighting, the light works correctly, but the vertex colours are now ignored How do i set openGL to blend the vertex and light colours when rendering? Light setup:
  
(ambient/diffuse are dark/light grey, position is updating correctly)
	gl.lightfv(GL.LIGHT1, GL.AMBIENT, pAmbient);
	gl.lightfv(GL.LIGHT1, GL.DIFFUSE, pDiffuse);
	gl.lightfv(GL.LIGHT1, GL.POSITION,pPosition);
	gl.lightf(GL.LIGHT1, GL.LINEAR_ATTENUATION, 0.1f);
	gl.lightf(GL.LIGHT1, GL.QUADRATIC_ATTENUATION, 0.001f);
	
	gl.enable(GL.LIGHT1);
  
Even more oddly, when i try and enable fog, the light dissapears, and theres no fog drawn either. Even the fog colour (white) is nowhere to be seen. (note, just tried this without lights and it seems to kill the heighmap to black regardless). Fog setup:
  
	FloatBuffer fogBuffer = createFloatBuffer(4);
	fogBuffer.put(new float[] {1.0f, 1.0f, 1.0f, 1.0f} );
	int pFogColour = Sys.getDirectBufferAddress(fogBuffer);
		
	gl.fogi(GL.FOG_MODE, GL.EXP);
	gl.fogf(GL.FOG_DENSITY, 0.35f);
	gl.fogf(GL.FOG_START, 1f);
	gl.fogf(GL.FOG_END, 5f);
	gl.hint(GL.FOG, GL.DONT_CARE); // This might be the reason, i've no idea its just from the Red Book..

	
	gl.fogf(GL.FOG_COLOR, pFogColour);
	
	gl.enable(GL.FOG);
  
Any pointers appreciated [edited by - OrangyTang on September 10, 2002 2:33:54 PM]

Share this post


Link to post
Share on other sites
int pFogColour = Sys.getDirectBufferAddress(fogBuffer);
gl.fogf(GL.FOG_COLOR, pFogColour);

int + float !!

also start+end is for linear
exp + exp2 is for density

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites