Hugo
Hugo

Reputation: 31

OpenGL Shaders and constants

I need to access a bunch of constant values in my GLSL geometry shader. I tried it this way:

const int lookup[HUGE_NUMBER] = int[HUGE_NUMBER](1,32,...)

This works... for some hardware. On ATI cards I'm getting warnings that the size of my geometry shader may cause poor performance (sounds reasonable). On other cards (NV) the shader won't link because of insufficient memory. Defining constant arrays seems to be a unsupported hack.

So - what's the way to go? I've read of "constant buffers" in the DirectX pipeline. Is there anything similar? Or do I have to use textures?

Upvotes: 3

Views: 1305

Answers (1)

kvark
kvark

Reputation: 5351

You can go with at least any of the following interfaces:

  1. Texture
  2. Uniform buffer object
  3. Texture buffer

Upvotes: 5

Related Questions