MikeShiny
MikeShiny

Reputation: 284

What is wrong with my Android OpenGL shader code

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.

Upvotes: 0

Views: 192

Answers (1)

Kane Wallmann
Kane Wallmann

Reputation: 2322

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

Upvotes: 2

Related Questions