0

I'm learning GLSL, and I thought it might be a fun project to build a simple raytracer. I can't figure out why I get a weird syntax error on this function:

vec3 rayAt(in ray r, in float t)
{
    return r.o + t*r.d;
}

For context, r.o and r.d are components of this struct:

struct ray
{
    vec3 o;
    vec3 d;
}

Edit: I'm writing this on shadertoy, and the specific error I get is 'vec3' : syntax error

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • 1
    What's the error? – Nicol Bolas Jan 09 '23 at 18:11
  • 'vec3' : syntax error - What is the line of code directly before `vec3`? – Rabbid76 Jan 09 '23 at 18:32
  • @Rabbid76 Here is the full code: https://pastebin.com/hkN8uPPf –  Jan 10 '23 at 21:55
  • 1
    missing `;` (`struct { ... } ;`) – Rabbid76 Jan 10 '23 at 21:59
  • I'm sorry, but what does this mean? which line exactly? –  Jan 10 '23 at 22:25
  • @Kai What Rabbid76 is pointing out is that every `class`,`struct` or `union` declaration in C/C++ needs to end with `;` because C/C++ is expected variable list declarations before the `;` if you write `struct T { int a; }` the C/C++ is considering whatever that follows to be a variable of type `T` until next `;` Your `struct ray` is missing the `;` after its ending bracket `}` so just put a `;` there `};` For compiler its the same as difference between `int i` and `int i;` – Spektre Jan 11 '23 at 10:27

0 Answers0