Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why only set the precision if GL_ES is defined?

When writing code for a fragment shader, it starts as follows:

#ifdef GL_ES
precision mediump float;
#endif

Why does the precision mediump float; line have to depend on whether GL_ES was defined or not?

like image 420
I got a question for ya Avatar asked Oct 20 '25 14:10

I got a question for ya


1 Answers

It doesn't "have to"; it simply does.

Desktop GL will ignore any precision declarations. So there's no need to ifdef around it.

That being said, if one wants to share GLSL code with very old versions of desktop GLSL (1.20 or before), then the #ifdef is useful, as such versions did not allow the precision declaration.

like image 51
Nicol Bolas Avatar answered Oct 23 '25 07:10

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!