Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error, unexpected IF #22

Open
gsingh93 opened this issue Jun 27, 2015 · 2 comments
Open

Syntax error, unexpected IF #22

gsingh93 opened this issue Jun 27, 2015 · 2 comments

Comments

@gsingh93
Copy link
Contributor

Am I doing something wrong here:

let fragment_shader_src = glassful! {
    #![version="140"]

    #[varying] static v_coord: vec3 = UNINIT;

    fn main() {
        if (abs(v_coord.z) == 0.25) {
            gl_FragColor = vec4(0., 1., 0., 1.);
        } else if (abs(v_coord.x) == 0.25) {
            gl_FragColor = vec4(0., 0., 1., 1.);
        } else if (abs(v_coord.y) == 0.25) {
            gl_FragColor = vec4(1., 0., 0., 1.);
        }
    }
};

I get:

thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: CompilationError("0:5(8): error: syntax error, unexpected IF\n")', ../src/libcore/result.rs:731```
@gsingh93
Copy link
Contributor Author

For reference, here's the original shader:

#version 140

in vec3 v_coord;
out vec4 color;

void main() {
    if (abs(v_coord.z) == 0.25) {
        color = vec4(0., 1., 0., 1.);
    } else if (abs(v_coord.x) == 0.25) {
        color = vec4(0., 0., 1., 1.);
    } else if (abs(v_coord.y) == 0.25) {
        color = vec4(1., 0., 0., 1.);
    }
}

@gsingh93
Copy link
Contributor Author

To be clear, this happens at runtime when creating a Program and unwrapping the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant