How do I find out, if a specific OpenGL feature is supported by hardware or not? In my case I want to know, if two-sided lighting is available in hardware. An approach using OpenInventor would be just as well.
Asked
Active
Viewed 141 times
1
-
1I'm curious: what do you plan to do if you were to find that it wasn't in hardware? – Nicol Bolas Jan 14 '13 at 08:56
-
@NicolBolas I think he rather just means implementation (thus if supported at all) instead of hardware (and thus driver-emulated if not). And if that is the case there are some means to emulate it yourself (then again in software by you, of course). – Christian Rau Jan 14 '13 at 08:59
-
In case the hardware does not support two-sided lighting, we implemented an approach, where the faces are rendered a second time with the orientation switched (ccw -> counter-ccw). This provided a huge performance gain in case there is no hardware-support for two-sided rendering. Compared to hardware-supported two-sided rendering, this is still slower, so we would like to use the hardware-support, if possible and otherwise switch to our alternative method. – Martin Jan 14 '13 at 09:52
-
1@Martin: For all practical purposes, all hardware you can buy these days is capable of two-sided illumination. Back when GPUs were hardwired this was actually a feature present or not. Today it's just a matter of add a few instructions to the shader program. When you use the fixed function pipeline on modern GPUs, based on the fixed function settings an apropriate shader is created. – datenwolf Jan 14 '13 at 11:04
-
@datenwolf: NVidia explicitly states, that their Quadro series supports two-sided lighting in hardware, whereas this doesn't seem to be the case for the GTS series, at least its not mentioned at all. So maybe, this is just a feature of the corresponding driver, not the hardware itself, but if the driver does not support it, you can't use it without additional effort by writing your own shader programs. – Martin Jan 14 '13 at 11:19
-
1@Martin: Today it's merely a selling point for "old-fashioned" users of CAD software who don't know how modern GPUs work. It could also be, that NVidia does disable two-sided illumination shader generation from fixed pipeline for GeForces, but this had no technical reason then (it's just a mere 3 additional shader instructions). But two sided illumination is a core OpenGL feature since version 1.2 so they must support it one way or another, and not doing this using shaders would be stupid. – datenwolf Jan 14 '13 at 11:26
-
1@Martin: The hardware can do two sided illumination for sure, but the OpenGL drivers may have been crippled deliberately. This is where Christian Rau's comment kicks in: You always want to test the capabilities of the hardware. Anyway two sided illumination is a core feature of OpenGL-1.2 and so every OpenGL implementation above that supports it. – datenwolf Jan 14 '13 at 11:26
-
@datenwolf: I know that OpenGL supports it everywhere, but the performance differs significantly by a factor of about 200 in one case we have investigated. That's why we tried to provide a workaround in case the hardware or the driver seems not to support it or is at least very slow. – Martin Jan 14 '13 at 11:39
-
@Martin: Well, I'd ditch the fixed function pipeline entirely. I don't know how well shaders integrate with OpenInventor, but if you can set custom fragment shaders, then you can use the builtin variable gl_FrontFacing to flip the normal if per-pixel-illumination is used. Or you simply check the sign of the transformed normal's Z component which must be positive for a front face. – datenwolf Jan 14 '13 at 13:31
1 Answers
2
In general, you don't.
If something is part of core OpenGL, then it should be implemented by the OpenGL implementation. Whether this happens "in hardware" or not is not something that you can detect.
For extension based features, you can obviously check for the presence of the extension. But otherwise, there's nothing you can do except better know the hardware your code is running on.

Nicol Bolas
- 449,505
- 63
- 781
- 982