【发布时间】:2018-07-26 13:17:56
【问题描述】:
有两个着色器,顶点和片段
const char *vShaderstr =
"#version 300 es\n"
"layout(location = 0) in vec4 a_color;\n"
"layout(location = 1) in vec2 a_position;\n"
"out vec4 v_color;\n"
"void main()\n"
"{\n"
" v_color = a_color;\n"
" gl_Position.xy = a_position;\n"
" gl_Position.z = 0.0;\n"
" gl_Position.w = 1.0;\n"
"}";
const char *fShaderstr =
"#version 300 es\n"
"precision lowp float;\n"
"in vec4 v_color;\n"
"out vec4 o_fragColor;\n"
"void main()\n"
"{\n"
" o_fragColor = v_color;\n"
"}";
问题是我没有浮点颜色,而是无符号字节。并在 int 中定位,而不是在 float 中。和 vec,就像我在花车里思考的那样。要将数据发送到管道,我使用此类命令。
glVertexAttribPointer ( 0, 4, GL_UNSIGNED_BYTE, GL_FALSE, 0, pixels );
glVertexAttribPointer ( 1, 2, GL_INT, GL_FALSE, 0, vertices );
glEnableVertexAttribArray ( 0 );
glEnableVertexAttribArray ( 1 );
glDrawArrays ( GL_POINTS, 0, max_draw );
字节中的像素。 int 的顶点。
【问题讨论】:
-
您使用的是 C 还是 C++?
-
我正在使用 c!!!!