0

My program crashes when I add this line of code:

uniform short colors[262144][3];

How many things am I doing wrong here?

  1. Can you use shorts in the shader?
  2. Can you use 2D arrays in the shader?
  3. Is the array much too large?
  4. Is my syntax for the declaration incorrect?

I am trying to pass in an array like this into the per pixel fragment shader, but for now I am just seeing if this line will work and my program crashes.

keaukraine
  • 5,315
  • 29
  • 54
MikeShiny
  • 284
  • 6
  • 15

1 Answers1

2

You cannot use multidimensional arrays in GLSL and you cannot use shorts either.

You could mimic the functionality of a multidimensional array like this though:

uniform float colors[50*3];

// Then access it like this

float t = colors[row * 50 + column];

I would imagine you are trying to send too much data as well, I would personally pass that much data using a texture or a buffer instead.

This is a great answer which explains these methods https://stackoverflow.com/a/7958008/139927

Community
  • 1
  • 1
Kane Wallmann
  • 2,292
  • 15
  • 10