   Fog behaves strangely.
  The fog works fine for me, but when I rotate, it goes wierd. like, it looks normal going forewards and backwards, but rotating makes it really thick and then crystal clear and it shifts afound like that. Here''s the drawing code. pretty basic, but since I''m new to OpenGL I have no idea what is going wrong.fyi:CamXR is camera rotation on the x axisCamYR is camera rotation on the y axisCamZR is camera rotation on the z axis   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  glMatrixMode(GL_MODELVIEW);  glLoadIdentity();  glRotatef (CamXR, 1.0f, 0.0f, 0.0f);  glRotatef (CamYR, 0.0f, 1.0f, 0.0f);  glRotatef (CamZR, 0.0f, 0.0f, 1.0f);  glTranslatef ((GLfloat)CamX, (GLfloat)CamY, (GLfloat)CamZ);  glBindTexture(GL_TEXTURE_2D, GroundID);  glCallList(RoomID);  glTranslatef (-3, 0, 0);  glBindTexture(GL_TEXTURE_2D, TexID);  glCallList(ListID);  glTranslatef (3, 0, 0);  glBindTexture(GL_TEXTURE_2D, TexID);  glCallList(ListID);  glFlush ();  and setting up the fog:   GLfloat FogColor[4] = {0.5f, 0.5f, 0.5f, 1.0f};  glEnable(GL_FOG);  glFogf(GL_FOG_START, 1.0f);  glFogf(GL_FOG_END, 30.0f);  glClearColor(0.5f,0.5f,0.5f,1.0f);  glFogi(GL_FOG_MODE, GL_LINEAR);  glFogfv(GL_FOG_COLOR, FogColor);  glFogf(GL_FOG_DENSITY, 0.45f);  glHint(GL_FOG_HINT, GL_NICEST);  so what''s going wrong?  
  You code should work as far as I can see. Where do you call the fog initialization? Just call it once at the beginning of you app and leave it there. Also, where is your glEnable(GL_FOG)? It should be with the init code. Lastly, try commenting out the glHint function. Hints are known to cause trouble with new drivers. Don''t know why though. If anyone knows why hints cause troubles, please post!    Sander Maréchal[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail];  still acts wierd.Here's the whole relivant header. (All swears have been masked.)#include "3DPlatSK.h"// Header File For 3DPlatSK// Header File For The GLaux Library#ifndef CDS_FULLSCREEN// CDS_FULLSCREEN Is Not Defined By Some#define CDS_FULLSCREEN 4// Compilers. By Defining It This Way,#endif // We Can Avoid Errors#include <SKINI.H>//  DECLARESGLvoid BuildLists(GLvoid);GL_Window*g_window;Keys*g_keys;//Speed Assist Settings//0 is best quality. higher = fasterUI8 SpeedAssist;GLfloat CamX,  CamY,  CamZ; //camera translationsGLfloat   CamXR, CamYR, CamZR; //camera rotationsGLuint TexID; //texture IDGLuint GroundID;AUX_RGBImageRec *ImageData;AUX_RGBImageRec *GroundImageData;GLuint ListID; //ID of list.GLuint RoomID; //ID of room.#define PIOVER180 3.141592653589 / 180// User Defined Variablesintrot1, rot2;// Counter VariablesBOOL Initialize (GL_Window* window, Keys* keys)// Any GL Init Code & User Initialiazation Goes Here{GLint Use;g_window= window;g_keys= keys;//speed assist settings//0 = Best Quality, slow.//1 = Faster, not perfect.//2 = Messed up but fastest.//3 = piece of s***, mesed up, very unplayable.//err Make SpeedAssist into multiple values such as bFog, bBlend, etc.SpeedAssist = 0;SKINIFILE INIFile;SKINISECTION *INISection;SKINIKEY *INIKey;INIFile.Load("Settings.ini");INISection = INIFile.FindSection("SpeedAssist");if(INISection){INIKey = INISection->FindKey("Value");if(INIKey){INIKey->Value.GetValue(&SpeedAssist);}}glClearColor (0.0f, 0.0f, 0.0f, 0.5f);// Black BackgroundglClearDepth (1.0f);// Depth Buffer SetupglDepthFunc (GL_LEQUAL);// The Type Of Depth Testing (Less Or Equal)glEnable (GL_DEPTH_TEST);// Enable Depth TestingglEnable(GL_TEXTURE_2D);glEnable(GL_COLOR_MATERIAL);if(SpeedAssist <= 1) Use = GL_SMOOTH; else Use = GL_FLAT;glShadeModel (Use);// Select Smooth Shadingif(SpeedAssist <= 1) Use = GL_NICEST; else Use = GL_FASTEST;glHint (GL_PERSPECTIVE_CORRECTION_HINT, Use);// Set Perspective Calculations To Most AccurateglColor4f(1.0f,1.0f,1.0f,0.5f);// Full Brightness, 50% Alpha ( NEW )if(SpeedAssist <= 2) glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA,GL_ONE);// Blending Function For Translucency Based On Source Alpha Value ( NEW )ImageData = auxDIBImageLoad("Lava.bmp");glGenTextures(2, &TexID);  //get a numberGroundID = TexID + 1;glBindTexture(GL_TEXTURE_2D, TexID); //call it a 2d texture//put the image data into the textureglTexImage2D(GL_TEXTURE_2D, 0, 3, ImageData->sizeX, ImageData->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, ImageData->data);switch(SpeedAssist){case 1:Use = GL_LINEAR;default:Use = GL_NEAREST;}glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,Use);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,Use);GroundImageData = auxDIBImageLoad("Grass.bmp");glBindTexture(GL_TEXTURE_2D, GroundID);glTexImage2D(GL_TEXTURE_2D, 0, 3, GroundImageData->sizeX, GroundImageData->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, GroundImageData->data);switch(SpeedAssist){case 1:Use = GL_LINEAR;default:Use = GL_NEAREST;}glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,Use);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,Use);if (ImageData){if (ImageData->data)free(ImageData->data);free(ImageData);}if (GroundImageData){if (GroundImageData->data)free(GroundImageData->data);free(GroundImageData);}ListID = glGenLists(2);RoomID = ListID + 1;BuildLists();GLfloat FogColor[4] = {0.5f, 0.5f, 0.5f, 1.0f};glEnable(GL_FOG);// Enables GL_FOGglFogf(GL_FOG_START, 1.0f);// Fog Start DepthglFogf(GL_FOG_END, 30.0f);// Fog End DepthglClearColor(0.5f,0.5f,0.5f,1.0f);// We'll Clear To The Color Of The Fog ( Modified )glFogi(GL_FOG_MODE, GL_LINEAR);// Fog Mode//glFogi(GL_FOG_MODE, GL_EXP2);// Fog ModeglFogfv(GL_FOG_COLOR, FogColor);// Set Fog ColorglFogf(GL_FOG_DENSITY, 0.455f);//.45//if(SpeedAssist==0) Use = GL_NICEST; else Use = GL_FASTEST;//glHint(GL_FOG_HINT, Use);// Fog Hint Value/*This is f***ing ugly, you need mipmapping,GOOD fog, and more than one texture.*///set camera defaults.CamX = 0; CamY = 0; CamZ = -8;CamXR = 0; CamYR = 0; CamZR = 0;return TRUE;// Return TRUE (Initialization Successful)}void Deinitialize (void)// Any User DeInitialization Goes Here{}void Update (DWORD milliseconds)// Perform Motion Updates Here{DWORD ms = milliseconds;//multiply motion by ms;if (g_keys->keyDown [VK_ESCAPE] == TRUE)// Is ESC Being Pressed?{TerminateApplication (g_window);// Terminate The Program}if (g_keys->keyDown [VK_F1] == TRUE)// Is F1 Being Pressed?{ToggleFullscreen (g_window);// Toggle Fullscreen Mode}if (g_keys->keyDown[VK_RIGHT])// Is The Right Arrow Being Pressed?{CamYR += .15*ms;// Rotate The Scene To The Left}if (g_keys->keyDown[VK_LEFT])// Is The Left Arrow Being Pressed?{CamYR -= .15*ms;// Rotate The Scene To The Right}if (g_keys->keyDown[VK_UP])// Is The Up Arrow Being Pressed?{CamX += (float)sin(-CamYR*PIOVER180) * 0.02*ms;// Move On The X-Plane Based On Player DirectionCamZ += (float)cos(-CamYR*PIOVER180) * 0.02*ms;// Move On The Z-Plane Based On Player Direction}if (g_keys->keyDown[VK_DOWN])// Is The Down Arrow Being Pressed?{CamX -= (float)sin(-CamYR*PIOVER180) * 0.02*ms;// Move On The X-Plane Based On Player DirectionCamZ -= (float)cos(-CamYR*PIOVER180) * 0.02*ms;// Move On The Z-Plane Based On Player Direction}//glFogf(GL_FOG_START, CamZ);// Fog Start Depth//glFogf(GL_FOG_END, 30.0f);// Fog End Depth}void Draw (void){glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//glMatrixMode(GL_PROJECTION);//glLoadIdentity();// Clear the view matrix//glMatrixMode(GL_MODELVIEW);glLoadIdentity();glRotatef (CamXR, 1.0f, 0.0f, 0.0f);glRotatef (CamYR, 0.0f, 1.0f, 0.0f);glRotatef (CamZR, 0.0f, 0.0f, 1.0f);glTranslatef ((GLfloat)CamX, (GLfloat)CamY, (GLfloat)CamZ);glBindTexture(GL_TEXTURE_2D, GroundID);glCallList(RoomID);glTranslatef (-3, 0, 0);glBindTexture(GL_TEXTURE_2D, TexID);glCallList(ListID);glTranslatef (3, 0, 0);glBindTexture(GL_TEXTURE_2D, TexID);glCallList(ListID);glFlush ();// Flush The GL Rendering Pipeline}GLvoid BuildLists(GLvoid){// the room!glNewList(RoomID, GL_COMPILE);glBegin(GL_QUADS);// Start Drawing Quads//glBindTexture(GL_TEXTURE_2D, GroundID);// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-30.0f, -1.0f, -30.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 30.0f, -1.0f, -30.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 30.0f, -1.0f,  30.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-30.0f, -1.0f,  30.0f);// Bottom Right Of The Texture and Quad//glBindTexture(GL_TEXTURE_2D, TexID);// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-30.0f, -1.0f,  30.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 30.0f, -1.0f,  30.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 30.0f,  30.0f,  30.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-30.0f,  30.0f,  30.0f);// Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-30.0f, -1.0f, -30.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-30.0f,  30.0f, -30.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 30.0f,  30.0f, -30.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 30.0f, -1.0f, -30.0f);// Bottom Left Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 30.0f, -1.0f, -30.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 30.0f,  30.0f, -30.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 30.0f,  30.0f,  30.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 30.0f, -1.0f,  30.0f);// Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-30.0f, -1.0f, -30.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-30.0f, -1.0f,  30.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-30.0f,  30.0f,  30.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-30.0f,  30.0f, -30.0f);// Top Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-30.0f,  30.0f, -30.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-30.0f,  30.0f,  30.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 30.0f,  30.0f,  30.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 30.0f,  30.0f, -30.0f);// Top Right Of The Texture and QuadglEnd();// Done Drawing QuadsglEndList();// here's your box!glNewList(ListID, GL_COMPILE);glBegin(GL_QUADS);// Start Drawing Quads//glBindTexture(GL_TEXTURE_2D, TexID);// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and Quad// Front FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);// Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);// Bottom Left Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);// Top Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);// Top Right Of The Texture and QuadglEnd();// Done Drawing QuadsglEndList();}    [edited by - SamKlaneski on May 24, 2003 7:52:13 AM];  Just a shot in the dark, but I think your camerastuff is backwards.I don''t think this would affect fog, but itwould make you move opposite to how you intend to move.Try inverting (ie, CamRX becomes -CamRX) the Cam__ valuesyou''re passing to glTranslatef(,,) and the threeglRotatef(,,,) functions in your drawing routine.As it stands now, it would seem that your room is beingdrawn behind the camera, as would the 2 boxes , since thecamera technically is always at the origin, looking down thenegative z axis which is pointing into the screen...I''m not sure what scale you''re using; you may very well beable to see them, but it still maybe be backwards to howyou think it''s being drawn.  ;  I still see a *lot* of glHint functions in your code. They all cause trouble with the newer drivers, not just the foghint. Try removing all the hint functions (PERSPECTIVE_CORRECTION_HINT)    Sander Maréchal[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail];  And i cant see where you change you projection matrix..all lines about that are commented outyou know that you only should puf the gluPerspectiv in the projection matrix, nothing else?;quote:gluPerspectiv in the projection matrix  too advanced for me.... I think I've got a lot of learning to do and few resources to do it with. I was hoping that NeHe would be enough but nowhere does any of the tutorials mention anything about matrices.[edited by - SamKlaneski on May 26, 2003 10:35:08 PM] [edited by - SamKlaneski on May 26, 2003 10:35:30 PM]