110scope.vert 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #version 110
  2. int f(int a, int b, int c)
  3. {
  4. int a = b; // ERROR, redefinition
  5. {
  6. float a = float(a) + 1.0; // okay
  7. }
  8. return a;
  9. }
  10. int f(int a, int b, int c); // okay to redeclare
  11. bool b;
  12. float b(int a); // okay, b and b() are different
  13. float c(int a);
  14. bool c; // okay, and c() are different
  15. float f; // okay f and f() are different
  16. float tan; // okay, hides built-in function
  17. float sin(float x); // okay, can redefine built-in functions
  18. float cos(float x) // okay, can redefine built-in functions
  19. {
  20. return 1.0;
  21. }
  22. bool radians(bool x) // okay, can overload built-in functions
  23. {
  24. return true;
  25. }
  26. int gi = f(1,2,3); // ERROR, can't call user-defined function from global scope
  27. void main()
  28. {
  29. int g(); // okay
  30. g();
  31. float sin; // okay
  32. sin;
  33. sin(0.7); // okay
  34. f(1,2,3);
  35. float f;
  36. f = 3.0;
  37. gl_Position = vec4(f);
  38. for (int f = 0; f < 10; ++f)
  39. ++f;
  40. int x = 1;
  41. {
  42. float x = 2.0, /* 2nd x visible here */ y = x; // y is initialized to 2
  43. int z = z; // ERROR: z not previously defined.
  44. }
  45. {
  46. int x = x; // x is initialized to '1'
  47. }
  48. struct S
  49. {
  50. int x;
  51. };
  52. {
  53. S S = S(0); // 'S' is only visible as a struct and constructor
  54. S.x; // 'S' is now visible as a variable
  55. }
  56. int degrees;
  57. degrees(3.2);
  58. {
  59. S s;
  60. s.x = 3;
  61. struct S { // okay, hides S
  62. bool b;
  63. };
  64. S t;
  65. t.b = true;
  66. struct S { // ERROR, redefinition of struct S
  67. float f;
  68. };
  69. }
  70. }