whether string isa valid identifier to be used in glsl
| 474 | |
| 475 | // whether string isa valid identifier to be used in glsl |
| 476 | bool isValidIdentifier(const char* str) { |
| 477 | std::string idn(str); |
| 478 | |
| 479 | if (idn.length() == 0) { |
| 480 | return false; |
| 481 | } |
| 482 | |
| 483 | if (idn.length() >= 3 && idn.substr(0, 3) == "gl_") { |
| 484 | // identifiers startin with "gl_" are reserved |
| 485 | return false; |
| 486 | } |
| 487 | |
| 488 | if (!isNonDigit(idn[0])) { |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | for (unsigned int i = 1; i < idn.length(); ++i) { |
| 493 | if (!(isdigit(idn[i]) || isNonDigit(idn[i]))) { |
| 494 | return false; |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | return true; |
| 499 | } |
| 500 | |
| 501 | // Process settings for either the global buffer block or global unfirom block |
| 502 | // of the form: |
no test coverage detected