dwmkerr / dwmkerr/sharpgl

Odd issue with shader attribute binding

Open
#98 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
804
Forks
294
Avg merge
3d 23h
Merged PRs (30d)
1

Description

Hi,

I'm a beginner with OpenGL so please forgive me if this "issue" is something wrong with my implementation/understanding. I'm building a very simple graph plotter using SharpGL and "modern OpenGL", and I found that the same project was giving two different outputs on two different computers. After some debugging I traced it down to the fact that two of my shader attributes were being assigned to different numbers on the two computers. So if I didn't use `shaderProgram.BindAttributeLocation()` and just read back the ID from the shader, things were working fine. i.e.

```
/* Not Working Code */
attribute_vpos = 0;
attribute_vcol = 1;
...
shaderProgram.BindAttributeLocation(gl, attribute_vpos, "vPosition");
shaderProgram.BindAttributeLocation(gl, attribute_vcol, "vColor");
// Gives expected figure on one PC not on the other
// Replacing the above 2 lines with this works:
attribute_vpos = (uint)gl.GetAttribLocation(shaderProgram.ShaderProgramObject, "vPosition");
attribute_vcol = (uint)gl.GetAttribLocation(shaderProgram.ShaderProgramObject, "vColor");
```

Checking the attribute IDs on the not-working PC, `attribute_vpos` was 0 but `attribute_vcol` was not 1, but some other random (big) integer. So I presume somehow the binding to the `shaderProgram.BindAttributeLocation(gl, attribute_vcol, "vColor")` was not able to bind the vColor attribute to integer 1.

I'm using SharpGL v2.3.0.1

Govind

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.