Skip to content

What is the behavior of binding to "o_Color" when OpenGL 2.1 uses "gl_FragColor"? #261

@bvssvni

Description

@bvssvni

https://github.com/PistonDevelopers/opengl_graphics/blob/master/src/back_end.rs#L90

Here, we bind to "o_Color" even when the OpenGL version is 2.1.

let c_o_color = CString::new("o_Color").unwrap();
if cfg!(not(target_os = "emscripten")) {
    gl::BindFragDataLocation(program, 0, c_o_color.as_ptr());
}
drop(c_o_color);

https://github.com/PistonDevelopers/shaders/blob/master/graphics2d/colored/120.glslf#L5

The GLSL version for OpenGL 2.1 is 120, but this shader has no "o_Color", but uses "gl_FragColor" instead, a built-in variable.

#version 120
varying vec4 v_Color;

void main() {
    gl_FragColor = v_Color;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions