   [edited: with pics and exe]the fog in my world looks very strange
  Hello everybody. I have writen a simple "world" ： just a cube on the ground，and I can use the direction keys to move in the world. But after I add fog in the world, when I move in the world it looks very strange. I'm so sorry that I don't known how to express the problem I saw in the world, here is my source code and exe file, can you run it on your pc and help me ? thank you!##########################################################Thank you,AndyEsser,I have edit my post and uploaded my files and screenshot:SourceCode and Exe File:[link]http://files.cnblogs.com/yaohj/myworld.rar[/link]1、press 'g' to enable fog in the program,2、press the direction keys to move in the worldScreenshots:( pls pay attention at the ground and the cube when you move )without fog , it looks good:http://lh4.ggpht.com/_sSVJsyzTBKc/SjYPOJDxdrI/AAAAAAAAAKc/Qr-ZgFqtyf4/withoutfog.JPGhttp://lh4.ggpht.com/_sSVJsyzTBKc/SjYPN8geZWI/AAAAAAAAAKY/3V4-us8VwZU/withoutfog2.JPGwith fog , the colors of the ground and the cube are very strangehttp://lh4.ggpht.com/_sSVJsyzTBKc/SjYPN9b6RgI/AAAAAAAAAKU/sMErM72aAEM/withfog.JPGhttp://lh5.ggpht.com/_sSVJsyzTBKc/SjYPOOqGkrI/AAAAAAAAAKg/WUNoZu9zRAA/withfog2.JPGhttp://lh4.ggpht.com/_sSVJsyzTBKc/SjYPOL6ZJOI/AAAAAAAAAKk/p_TOEo_JQKM/withfog3.JPG[Edited by - yaohj on June 15, 2009 4:37:06 AM]
  Firstly, please don't post huge amounts of source code. Either upload it to a location and provide us with a link (preferably as a ZIP o RAR archive) or use the [ source ] [ /source ] tags (remove the spaces.Secondly, people aren't going to just copy and paste your code, try to figure out what the problem is and spoon-feed it to you.Thirdly, if you can't describe it then the old saying 'a picture is worth a thousan words' is perfectly valid. Post us some screenshots, that will help to narrow down the problem.I've had a quick look at your code, nothing jumps out at me. Except for this:GLfloat textureArray[] = {0,0,width,0,width,width,0,width};Texture coordinates should be in the range 0 to 1, so you need to do some extra calculation. However, I don't think that's related to your problem.As I said, post us some screenshots and we'll do our best to help you.   ;Quote:Original post by AndyEsserFirstly, please don't post huge amounts of source code. Either upload it to a location and provide us with a link (preferably as a ZIP o RAR archive) or use the [ source ] [ /source ] tags (remove the spaces.Secondly, people aren't going to just copy and paste your code, try to figure out what the problem is and spoon-feed it to you.Thirdly, if you can't describe it then the old saying 'a picture is worth a thousan words' is perfectly valid. Post us some screenshots, that will help to narrow down the problem.I've had a quick look at your code, nothing jumps out at me. Except for this:*** Source Snippet Removed ***Texture coordinates should be in the range 0 to 1, so you need to do some extra calculation. However, I don't think that's related to your problem.As I said, post us some screenshots and we'll do our best to help you.Thank you for your reply , I have edited my post ;)   ;  How are you drawing your ground? Fixed-function fog is calculated per-vertex and interpolated - if you're drawing your ground as one big poly with fixed function fog then it's going to look rubbish.Either tessellate your ground into multiple polys, or switch to using per-pixel fog.   ;  Damn you OrangyTang. That was my suggestion. Hehe.   ;Quote:Original post by OrangyTangHow are you drawing your ground? Fixed-function fog is calculated per-vertex and interpolated - if you're drawing your ground as one big poly with fixed function fog then it's going to look rubbish.Either tessellate your ground into multiple polys, or switch to using per-pixel fog.Yes,I draw my ground as a big poly, thank you , OrangyTang ,I think it must be the reason , I'll try your suggestion , thank you ! ;-)   ;Quote:Original post by AndyEsserDamn you OrangyTang. That was my suggestion. Hehe.;-) thank you all the same;  <benevolent-rant>Quote:Original post by AndyEsserDamn you OrangyTang. That was my suggestion. Hehe.------------------------[ neogroup | NeHe OpenGL Tutorials | LinkedIn | Development Journal ][Test Machine:] Windows XP SP2, Intel Celeron 2.5GHz, 1024 Mb RAM, ATi Radeon 9200[Dev Machine:] Windows XP SP2, AMD 3200+, 2048 Mb RAM, nVidia 9800 GTX[Laptop:] Windows XP SP3 32-Bit, 4096 Mb RAM, 2x nVidia 8700M GT SLi, Ageia PhysX[Work Dev Machine:] Windows 32-Bit SP3, 2048 Mb RAM, nVidia 9800 GTX, Decklink Blackmagic HD Pro Broadcast Card------------------------"'Cause It's Fun To Reinvent The Wheel"Wow, 0.5 rows of content, plus 12 rows of signature == 1 / 24.Or let's look at the number of displayed chars: 50 chars of content. 520 chars of signature, which also means your signature is more than a half KiB big. You could store 65 Kd-tree nodes in that!I could rephrase your very first comment:Quote:Firstly, please don't post huge amounts of source code.But right now I am too lazy.<tnar-tneloveneb>   ;  My comments weren't about efficiency or space, there were about getting the point across.My sig provides just the information required with no extra fluff, thus is efficient. It gets the message across exactly as I want it to. The OP's first post did not.Anything else you'd like to say?   ;Quote:Original post by AndyEsserMy sig provides just the information required with no extra fluff, thus is efficient. Even when we assume that your signature is efficient for those who want to know what machines you hack on, your posts also exercise redundancy, because this is the third time you posted your 0.5KiB monster in this thread alone.Quote:Anything else you'd like to say?Yes. When you post a comment, there is a checkbox to enable or disable siggies.------------------------[ompf | homepage | picogen@twitter | picogen@identi.ca | picogen | my dA page | picogen@freshmeat | picogen@fossfor.us | picogen@Arch Linux][Physical Dev Machine:] Debian GNU/Linux Lenny/Testing AMD64, AMD Phenom Quad-Core, 4096 MiB RAM, Radeon HD 3200 [Physical Testbox:] Windows XP 32bit, AMD Phenom Quad-Core, 4096 MiB DDR2-RAM, Radeon HD 3200 [Physical Testbox:] Debian GNU/Linux Lenny/Testing/Unstable 32bit, AMD Athlon XP 2400+, 2048 MiB DDR-RAM, Radeon 9600[Physical Testbox:] Windows XP 32bit, AMD Athlon XP 2400+, 2048 MiB DDR-RAM, Radeon 9600[Virtual Testbox:] Windows XP 32bit, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Linux Mint Gloria, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Linux Mint Elyssa, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Fedora Core, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Debian Sid, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Ubuntu Hardy Heron, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Ubuntu Jaunty Jackalope, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Ubuntu Gutsy Gibon, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] OpenSuse 11.1, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] gNewSense deltah, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] SUSE 11.1, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] OpenSolaris, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Virtual Testbox:] Dragonfly BSD, Varying CPU, Varying MiB DDR2-RAM, Varying Videocard[Work Dev Machine:] Windows XP 64Bit, Intel Core 2 Duo, 2 GiB RAM, nVidia GeForce 7300 LE------------------------"'Cause I think virtual machines are useful."