OpenGL doesn't do fog??!?

Started by
17 comments, last by NuffSaid 22 years, 5 months ago
I''m pretty new to this 3D stuff, and recently, someone I know (whom I kinda respect) mentioned that OpenGL doesn''t do fog. I kindly corrected him, telling him the there is a function called glFog() (and others like glFogi, etc). Then he went on to some sort of BS about OpenGL doesn''t natively supporting fog(?), unlike Direct3D8. The point is, being a 3D newbie, I''m pretty confused and I need clarification.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Advertisement
Simple Demonstration

GLfloat colours[4] = {(GLfloat) 0.75, (GLfloat) 0.75, (GLfloat) 1, (GLfloat) 0.25};

//*** TEST FOG
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogfv(GL_FOG_COLOR, colours); // same as clear colour
glFogf(GL_FOG_START, 8.0);
glFogf(GL_FOG_END, 30.0);
glFogf(GL_FOG_DENSITY, 0.2);
glEnable(GL_FOG);
then maybe you should READ the OpenGL and Direct3D specifications to clarify.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
That''s bullsh*t. OpenGL definately does fog, and can also do everything Direct3D can (arguably more through the extension mechanism); such features will either be part of OpenGL itself or extensions.

Also, we must not forget that since nobody but Microsoft makes an OpenGL binding on Windows, Windows platforms are stuck at API version 1.1, while 1.3 hardware compliance already exists...
merlin9x9: that''s why people should stop answering these kinds of POST''s. if the original poster knows that there are functions such as "glFog" incorporated into the OpenGL API, then why would they ask if OpenGL has support for fogging. yeah, i thought "glFog" was for vertex arrays or something the first time i saw that function, and "glVertex" is for texture coordinates. furthermore, if the original poster, read any of the OpenGL programmer''s guide, reference guide, or any OpenGL documentation at all then they would have been able to conclude the answer to that question on their own. unfortunately, the world seems to think that becoming a professional programmer does NOT require years of training, practicing and most of all, THINKING. that''s it, everyone, keep jumpin'' on the programming bandwagon.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
Jenova ... I agree with you

Nuffsaid ... I don''t mean this unkindly, but try searching Google or similar for glFog ... you''ll get all the answers you need
In fact - just to add to the above ...

The graphics cards themselves support many advanced rendering techniques - NOT the API. The API only exposes the functionality of the cards. Which is why (in many respects - no flame wars please) OpenGL is better - this advanced functionality is exposed very quickly via OpenGL extensions - whereas Microsoft DriectX fans have to wait for a new version of DirectX!
The thing I need clarification isn''t whether OpenGL does fog (which I know as I posted about glFog, etc), I just need some explanation about the BS bit like OpenGL doesn''t do fog natively(?).

This friend of mine said something like OpenGL uses the Alpha channel to do fog which is like a cheap hack, and is different from the way D3D does, and he went on to a long lecture about some stuff that I''ve never even heard off.

Sorry if I pissed anyone off, the title should have been something like "OpenGL doesn''t support fog natively?". I''ve searched Google, opengl.org and the MSDN about this, and I''ve come up zip, or with stuff that''s way over my head.
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
To answer your question, yes OpenGL supports fog natively and it does not use the alpha chanel (as far as I know). It uses the z-buffer value in a formula that calculates the amount of fog then multiplys that to the fog color and finally adds that to the pixel color to get the final result. (the exact same way D3D does it).
In fact if the hardware supports fog then both OpenGL and D3D will be useing the same hardware calls to do the fog.
Nothing personal and not to start flames but your friend sounds like a microsoft zombie. any BS that ms puts out he believes. He''s one of those OpenGL is an obsolete API that can''t do anything people because that''s what MS say''s. I''d like to see them sit down and learn OpenGL once to see that it can do everything d3D can and usually is easyer to program.
I like meating people like that and busting there bubbles Maybe you should send him over to my house so I can set him straight?
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
Yes, it has native support for fog. That is, fog is supported in all versions of OpenGL ( 1.1, 1.2, 1.3 ) without having to use an extension. What''s true however is that if your hardware doesn''t support fogging, it will get emulated by OpenGL, probably with that alpha-blending trick you mentionned. I think that''s what happens with old Vaudoos. But well, if there is no hardware support, D3D is no way different then.

Y.

This topic is closed to new replies.

Advertisement