我有4个侧面vert(X,Y,A,B),我想把6个单独的2D块地(XxY,XxA,XxB, YxA,......)
My vertices are defined as follows:
GLint data[MAX_N_POINT][4];
I can draw the first (X,Y) of the 2D plots just fine with:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_INT, 4*sizeof(GLint), &data[0][0]);
glDrawArrays(GL_POINTS, 0, MAX_N_POINT-1);
glDisableclientState(GL_VERTEX_ARRAY);
To draw the other 2D plots (XxA, AxB, etc...) I ve decided to use a shader that swizzles the X,Y,Z,W dimensions of the vertices depending on which dimensions I want to draw.:
uniform int axes;
void main()
{
vec2 point;
if (axes == 0) {
point = gl_Vertex.xy;
} else if (axes == 1) {
point = gl_Vertex.xz;
} else if (axes == 2) {
point = gl_Vertex.xw;
} else if (axes == 3) {
point = gl_Vertex.yz;
} else if (axes == 4) {
point = gl_Vertex.yw;
} else if (axes == 5) {
point = gl_Vertex.zw;
}
gl_Position = gl_ModelViewProjectionMatrix * vec4(point.xy, 0.0, 1.0);
gl_FrontColor = gl_Color;
gl_BackColor = gl_Color;
}
我成功地装满、汇编、加进方案,并将方案联系起来。
现在,我没有制定分方案,不清楚如何利用该方案,从而影响到我空洞阵列的划定方式。 我先尝试如下,但似乎没有任何效果,因为它所引出的正是没有沙子的东西:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(4, GL_INT, 4*sizeof(GLint), &data1[0][0]);
//New shader code here
glUseProgram(shaderProg);
int plotAxes = rand()%4;
GLint axes = glGetUniformLocation(shaderProg, "axes");
glUniform1i(axes, plotAxes);
glDrawArrays(GL_POINTS, 0, MAX_N_POINT-1);
glDisableClientState(GL_VERTEX_ARRAY);
glUseProgram(0);
是否有我失踪或不能正确理解的基本条件?
www.un.org/Depts/DGACM/index_spanish.htm 这里是最后的摇篮:
uniform int axes;
void main()
{
vec4 point;
if (axes == 0) {
point = gl_Vertex;
} else if (axes == 1) {
point = gl_Vertex.xzyw;
} else if (axes == 2) {
point = gl_Vertex.xwzy;
} else if (axes == 3) {
point = gl_Vertex.yzxw;
} else if (axes == 4) {
point = gl_Vertex.ywxz;
} else if (axes == 5) {
point = gl_Vertex.zwxy;
}
point.z = 0.0;
point.w = 1.0;
// eliminate w point
gl_Position = gl_ModelViewProjectionMatrix * point;
gl_FrontColor = gl_Color;
gl_BackColor = gl_Color;
}