100scope.vert 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #version 100
  2. int f(int a, int b, int c)
  3. {
  4. int a = b; // ERROR, redefinition
  5. {
  6. float a = float(a) + 1.0;
  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); // ERROR: redefinition
  13. float c(int a);
  14. bool c; // ERROR: redefinition
  15. float f; // ERROR: redefinition
  16. float tan; // okay, built-in is in an outer scope
  17. float sin(float x); // ERROR: can't redefine built-in functions
  18. float cos(float x) // ERROR: can't 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. invariant gl_Position;
  27. void main()
  28. {
  29. int g(); // ERROR: no local function declarations
  30. g();
  31. float sin; // okay
  32. sin;
  33. sin(0.7); // ERROR, use of hidden function
  34. f(1,2,3);
  35. float f; // hides 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); // ERROR, use of hidden built-in function
  58. }
  59. varying struct SSS { float f; } s; // ERROR