# Transform Feedback Varyings - strange error occurs when I add more than 4

**URL:** <https://discourse.libcinder.org/t/transform-feedback-varyings-strange-error-occurs-when-i-add-more-than-4/987>\
**Category:** Using Cinder\
**Created:** [December 11, 2017, 4:25am UTC](https://discourse.libcinder.org/t/transform-feedback-varyings-strange-error-occurs-when-i-add-more-than-4/987 "2017-12-11T04:25:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sortofsleepy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/sortofsleepy/32/267_2.png) [@sortofsleepy](https://discourse.libcinder.org/u/sortofsleepy)\
**Post date:** [December 11, 2017, 4:25am UTC](https://discourse.libcinder.org/t/transform-feedback-varyings-strange-error-occurs-when-i-add-more-than-4/987/1 "2017-12-11T04:25:49Z")

</div>

Hey all,

Running into an odd error when trying to set up a transform feedback particle system. I was running into issues where my vertex shader code simply wasn’t doing anything; after a little while of trying to debug, it seems like the issue might be in how I’m trying to load the transform feedback shader itself.

Not sure if it’s a bug or me just being dumb but as a simple test case

```
 std::vector<std::string> feedbackVaryings({
	"position",
	"phi",
	"theta",
	"a",
	"b"
});

gl::GlslProg::Format tfmt;
tfmt.vertex(app::loadAsset("simulation.glsl"));
tfmt.feedbackFormat(GL_SEPARATE_ATTRIBS);
tfmt.feedbackVaryings(feedbackVaryings);
gl::GlslProgRef shader = gl::GlslProg::create(tfmt); 

```

lets imagine simulation.glsl looks like this

```
layout (location = 0) in vec3 iPosition;
layout (location = 1) in float iPhi;			
layout (location = 2) in float iTheta;		

out vec3 position;
out float phi;
out float theta;
void main(){

	
	position = iPosition;
	phi = iPhi;
	theta = iTheta;

	position = vec3(0.);
}

```

Since “a” and “b” aren’t declared as varyings in the simulation.glsl, compilation should fail correct? Believe it or not, this still compiles for me and I can launch my app regardless.

At first I thought it was something in my app setup but after trying things in a fresh project, I’m seeing the same result (╯°□°）╯︵ ┻━┻

Strangely enough, if I take out “b” from my varyings vector, I get a compilation error as expected.

any ideas? Maybe something I forgot to do?

Many thanks!

---

<div class="post-metadata">

**Author:** ![sortofsleepy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/sortofsleepy/32/267_2.png) [@sortofsleepy](https://discourse.libcinder.org/u/sortofsleepy)\
**Post date:** [December 11, 2017, 2:32pm UTC](https://discourse.libcinder.org/t/transform-feedback-varyings-strange-error-occurs-when-i-add-more-than-4/987/2 "2017-12-11T14:32:34Z")

</div>

Interesting discovery this morning - if I change `GL_SEPARATE_ATTRIBS` to `GL_INTERLEAVED_ATTRIBS`, then things work as expected; since “a” and “b” aren’t declared, shader compilation fails.

That being said I was looking to use `GL_SEPARATE_ATTRIBS` haha (╯°□°）╯︵ ┻━┻

---

<div class="post-metadata">

**Author:** ![sortofsleepy](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/sortofsleepy/32/267_2.png) [@sortofsleepy](https://discourse.libcinder.org/u/sortofsleepy)\
**Post date:** [December 12, 2017, 3:38am UTC](https://discourse.libcinder.org/t/transform-feedback-varyings-strange-error-occurs-when-i-add-more-than-4/987/3 "2017-12-12T03:38:50Z")

</div>

Ah… after messing around a bit, I’m not 100% certain but I think the reason I’m having trouble is cause I actually do have a max of 4 varying values I can use when using `GL_SEPARATE_ATTRIBS`, I guess I’m too used to WebGL and was just logging the constant `GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS` vs using `glGetIntegerv` which returned very different values.

Anyways I guess my question is resolved.
