Enabling fog gives no fog or lights!

Started by
2 comments, last by OrangyTang 21 years, 7 months ago
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]
Advertisement
well...try adding glEnable(GL_COLOR_MATERIAL); that should solve ur lighting problem
Thanks, i added that an my lighting is blending nicely with the base colour now. Shame the fog still gives me pure black polys though.
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

This topic is closed to new replies.

Advertisement