Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从c++;到顶点着色器OpenGL ES 2.0_Android_C++_Ios_Opengl Es - Fatal编程技术网

Android 如何从c++;到顶点着色器OpenGL ES 2.0

Android 如何从c++;到顶点着色器OpenGL ES 2.0,android,c++,ios,opengl-es,Android,C++,Ios,Opengl Es,如何发送到倾倒着色器值​​从c++中,我知道我可以使用统一类型,但这是无效的,因为有必要修改每个顶点中的值,并且统一是常量,我看到有一种“in”和“out”,但不支持OpenGL ES 2.0,您给我发送了一个如何传递这些值的示例​​对于顶点着色器float,我向它们发送我正在使用的部分代码 attribute float cppValue; varying float valueV; void main () { valueV= cppValue; } exampleValueCpp fl

如何发送到倾倒着色器值​​从c++中,我知道我可以使用统一类型,但这是无效的,因为有必要修改每个顶点中的值,并且统一是常量,我看到有一种“in”和“out”,但不支持OpenGL ES 2.0,您给我发送了一个如何传递这些值的示例​​对于顶点着色器float,我向它们发送我正在使用的部分代码

attribute float cppValue;
varying float valueV;

void main ()
{
valueV= cppValue;
}

exampleValueCpp float = 1;
glVertexAttribPointer (0, 1, GL_FLOAT, GL_FALSE, 0, & exampleValueCpp);
更新


我已经看到有一个函数“glVertexAttrib1f”和“glVertexAttrib1fv”来修改属性,但我认为它只能与glBegin和glEnd一起使用,而且这些函数在OpenGLES 2.0或更高版本中已经过时了,对吗?,难道不可能向顶点着色器发送一个非常量值吗?

如果希望每个顶点的每个浮点值都不同,则应在收集它们的位置设置一个数组:

float* exampleValueCpp = new float[numVertex];
for(int i = 0;i<numVertex;i++){
    //fill values
}
glBindBuffer(GL_ARRAY_BUFFER,0);//use application memory
glVertexAttribPointer (0, 1, GL_FLOAT, GL_FALSE, 0, exampleValueCpp);
float*exampleValueCpp=新浮点[numVertex];
对于(int i=0;i
glGenBuffers(1, &cppBuffer);
glBindBuffer(GL_ARRAY_BUFFER, cppBuffer);

float* exampleValueCpp = new float[numVertex];
for(int i = 0;i<numVertex;i++){
    //fill values
}

glBufferData(GL_ARRAY_BUFFER, numVertex*sizeof(float), exampleValueCpp, GL_STATIC_DRAW);
delete[] exampleValueCpp;
glVertexAttribPointer (0, 1, GL_FLOAT, GL_FALSE, 0, 0);//last parameter is offset into the buffer