openframeworks / openframeworks/openFrameworks

ofShader: vertex attribute arrays need to be disabled on end()

Open
#6,465 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

I have recently experienced that using vertex attribute arrays from setAttribute3fv results in strange behavior on the Nvidia driver, but not on Intel. When the vertex attribute pointer was set - it caused strange yellowish drawing of all other content following the call.

After a lot of digging I found that the vertex attribute pointer need to be disabled after using the shader - otherwise it will affect subsequent drawing. Basically the glEnableVertexAttribArray need to be complemented with a call to glDisableVertexAttribArray.

Solutions:

  1. As a minimum we could add a function called ofShader::disableAttributePointer.

  2. Or, more advanced, setAttribute3fv should update a map with attributePointers that should be disabled on end();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing ofShader::setAttribute3fv and ofShader::end(), focusing on where glEnableVertexAttribArray is called. Verify how enabled vertex attribute arrays affect subsequent drawing, then determine whether the affected attributes can be disabled during end() or through a separate disableAttributePointer entry point. Done means later drawing is no longer affected after using the shader.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.