GamedevFramework / gf

A C++17 framework for 2D games

Home Page:https://gamedevframework.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom shader and builtin variables

Jmgr opened this issue · comments

Hi,

I am trying to write a shader (taken from there, see attachment) to display a grid (as an alternative to gf::SquareGrid) but I get a bunch of OpenGL errors every frame.

[2019-01-24 13:35:11.362051][Warn] Uniform not found: 'u_texture'
[2019-01-24 13:35:11.362092][Warn] Attribute not found: 'a_color'
[2019-01-24 13:35:11.362108][Error] Error in OpenGL call:
	Location: /xxx/gf/library/graphics/RenderTarget.cc:273
	Expression: glEnableVertexAttribArray(colorLoc)
	Error: GL_INVALID_VALUE
	Description: A numeric argument is out of range.
[2019-01-24 13:35:11.362121][Error] Error in OpenGL call:
	Location: /xxx/gf/library/graphics/RenderTarget.cc:281
	Expression: glVertexAttribPointer(colorLoc, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), colorPointer)
	Error: GL_INVALID_VALUE
	Description: A numeric argument is out of range.
[2019-01-24 13:35:11.362148][Error] Error in OpenGL call:
	Location: /xxx/gf/library/graphics/RenderTarget.cc:291
	Expression: glDisableVertexAttribArray(locations.colorLoc)
	Error: GL_INVALID_VALUE
	Description: A numeric argument is out of range.

They originate from the fact that I don't use u_texture in the fragment shader, so while this uniform is present in the shader code, it is probably removed by the GLSL compiler. So, when GF sets the uniform every frame, it fails. The same issue also occurs with the vertex shader and a_color.

Could GF only set these uniforms if they are present in the compiled shader code?

OS: Ubuntu 18.04
GF version: v0.11.0

PS: the contribution guidelines indicate that I should add the "Bug" tag to this issue, but I would need write permissions on this repository to do that.
PS: this framework is great!

shader.vert.txt
shader.frag.txt

Hi!

It's been a long time since I know I will have to face this kind of request :)

Could GF only set these uniforms if they are present in the compiled shader code?

Yes, that's the solution I have imagined but not yet implemented. I will try to fix this as soon as possible.

PS: this framework is great!

Nice to hear.

It should be fixed in the develop branch. Please could you check if your example works now?

Yes, that fixed the issue, everything works now. Thank you very much!