# Meaning of “bindable uniform vec4 vertices[%d]&#65307;”

In the OpenGL SDK 10’s example :Instanced Tessellation,i found the fellowing GPU code, i do not understand the meaning of vertices[%d]. What is the actual size of vertices array?
%d equals to what? Where can i set it?

// Vertex shader.
static const char * s_tessellationVertexShaderText =
"#version 120
"
"#extension GL_EXT_bindable_uniform : enable
"
"#extension GL_EXT_gpu_shader4 : enable
"
"
"
"bindable uniform vec4 vertices[%d];
"
"
"
"varying vec3 v_Normal;
"
"
"
"void main(void)
"
"{
"
" vec3 p[16];
"
"
"
" for (int i = 0; i < 16; i++) {
"
" p[i] = vertices[gl_InstanceID * 16 + i].xyz;
"
" }
"
"
"
" vec2 uv = gl_Vertex.xy;
"
"
"
" vec2 B0 = (1 - uv) * (1 - uv) * (1 - uv);
"
" vec2 B1 = 3 * uv * (1 - uv) * (1 - uv);
"
" vec2 B2 = 3 * uv * uv * (1 - uv);
"
" vec2 B3 = uv * uv * uv;
"
"
"
" vec3 pos =
"
" (B0.x * p[ 0] + B1.x * p[ 1] + B2.x * p[ 2] + B3.x * p[ 3]) * B0.y +
"
" (B0.x * p[ 4] + B1.x * p[ 5] + B2.x * p[ 6] + B3.x * p[ 7]) * B1.y +
"
" (B0.x * p[ 8] + B1.x * p[ 9] + B2.x * p[10] + B3.x * p[11]) * B2.y +
"
" (B0.x * p[12] + B1.x * p[13] + B2.x * p[14] + B3.x * p[15]) * B3.y;
"
"
"
" vec2 T0 = (1 - uv) * (1 - uv);
"
" vec2 T1 = 2 * uv * (1 - uv);
"
" vec2 T2 = uv * uv;
"
"
"
" vec3 dv =
"
" (B0.x * (p[ 4]-p[0]) + B1.x * (p[ 5]-p[1]) + B2.x * (p[ 6]-p[ 2]) + B3.x * (p[ 7]-p[ 3])) * T0.y +
"
" (B0.x * (p[ 8]-p[4]) + B1.x * (p[ 9]-p[5]) + B2.x * (p[10]-p[ 6]) + B3.x * (p[11]-p[ 7])) * T1.y +
"
" (B0.x * (p[12]-p[8]) + B1.x * (p[13]-p[9]) + B2.x * (p[14]-p[10]) + B3.x * (p[15]-p[11])) * T2.y;
"
"
"
" vec3 du =
"
" (T0.x * (p[ 1]-p[ 0]) + T1.x * (p[ 2]-p[ 1]) + T2.x * (p[ 3]-p[ 2])) * B0.y +
"
" (T0.x * (p[ 5]-p[ 4]) + T1.x * (p[ 6]-p[ 5]) + T2.x * (p[ 7]-p[ 6])) * B1.y +
"
" (T0.x * (p[ 9]-p[ 8]) + T1.x * (p[10]-p[ 9]) + T2.x * (p[11]-p[10])) * B2.y +
"
" (T0.x * (p[13]-p[12]) + T1.x * (p[14]-p[13]) + T2.x * (p[15]-p[14])) * B3.y;
"
"
"
" gl_Position = gl_ModelViewProjectionMatrix * vec4(pos, 1.0);
"
// " gl_TexCoord[0].xy = uv;
"
" vec3 nor = cross(du, dv);
"
" nor = (length(nor) != 0) ? normalize(nor) : vec3(0.0);
"
" v_Normal = gl_NormalMatrix * nor;
"
"}
"
"
";

It’s probably run through printf() to hardcode the number of vertices in the shader source. There is no %d syntax in GLSL.

You are right，Thank you。 i found that code

sprintf(vertexShaderText, s_tessellationVertexShaderText, c_teapotIndexCount);

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.