简体   繁体   English

我的Android OpenGL着色器代码有什么问题

[英]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? 你能在着色器中使用2D数组吗?
  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. 我试图将这样的数组传入每像素片段着色器,但是现在我只是看到这条线是否会起作用,我的程序崩溃了。

You cannot use multidimensional arrays in GLSL and you cannot use shorts either. 您不能在GLSL中使用多维数组,也不能使用短路。

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 这是解释这些方法的一个很好的答案https://stackoverflow.com/a/7958008/139927

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM