简体   繁体   English

GLSL着色器属性为整数

[英]GLSL Shaders Attributes as ints

I'm just learning OpenGL and I'm running into some issues. 我正在学习OpenGL,但遇到了一些问题。 I'm using OpenGL 3.0 and GLSL 1.2. 我正在使用OpenGL 3.0和GLSL 1.2。

I have an array of matrices which I would like to selectively apply to different vertices. 我有一系列矩阵,我想选择性地应用于不同的顶点。 Instead of copying a matrix each time I want to indicate an index, I would instead like to pass in an integer as an index and use that integer to select the matrix I want. 与其每次我要指示索引而不是复制矩阵,而是想传递一个整数作为索引并使用该整数选择我想要的矩阵。 However, when I try to compile my shader I get the following error: 但是,当我尝试编译着色器时,出现以下错误:

ERROR: 0:5: 'attribute' : cannot be bool or int

I'd appreciate it if anybody could point me in the right direction. 如果有人能指出我正确的方向,我将不胜感激。

Attributes can be ints, but you need to enable a newer version of GLSL to use it. 属性可以是整数,但是您需要启用较新版本的GLSL才能使用它。 Try adding this to the top of your shader: 尝试将其添加到着色器的顶部:

#version 130

Version 130 corresponds to OpenGL 3.0 版本130对应于OpenGL 3.0

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

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