gpt4 book ai didi

linux - OpenGL ES 3.0 GL_POINTS 不渲染任何东西

转载 作者:太空宇宙 更新时间:2023-11-04 10:45:46 25 4
gpt4 key购买 nike

下面是一个小型复制器:

  GL_CHECK(glClearColor(0.4f, 0.4f, 0.4f, 1.0f));
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT));
GL_CHECK(glUseProgram(this->pp_->shader_program));
GL_CHECK(glEnable(GL_TEXTURE_2D));
GL_CHECK(glActiveTexture(GL_TEXTURE0));
GL_CHECK(glBindTexture(GL_TEXTURE_2D, this->particle_->id));
GLfloat points[] = { 150.f, 150.f, 10.0f, 150.0f, 175.0f, 10.0f };
GLfloat colors[] = { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f };
shader_pass_set_uniform(this->pp_, HASH("mvp"), glm::value_ptr(this->camera_));
GL_CHECK(glEnableVertexAttribArray(0));
GL_CHECK(glEnableVertexAttribArray(3));
GL_CHECK(glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, &points[0]));
GL_CHECK(glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, 0, &colors[0]));
GL_CHECK(glDrawArrays(GL_POINTS, 0, 2));

顶点着色器:

#version 300 es

layout(location = 0) in highp vec3 vertex;
layout(location = 3) in highp vec4 color;

out lowp vec4 vcolor;

uniform mat4 mvp;

void main()
{
vcolor = color;
gl_Position = mvp * vec4(vertex.xy, 0.0, 1.0);
gl_PointSize = vertex.z;
}

片段着色器:

#version 300 es

uniform sampler2D stexture;
in lowp vec4 vcolor;

layout(location = 0) out lowp vec4 ocolor;

void main()
{
ocolor = texture(stexture, gl_PointCoord) * vcolor;
}

屏幕上没有任何渲染,可以找到我的 glxinfo in this pastebin .当我将相同的纹理渲染到三角形上时,它起作用了。

这也是使用 apitrace 捕获的渲染循环:

250155 glClearColor(red = 0.5, green = 0.5, blue = 0.5, alpha = 1)
250157 glClear(mask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
250159 glUseProgram(program = 9)
250161 glEnable(cap = GL_TEXTURE_2D)
250163 glActiveTexture(texture = GL_TEXTURE0)
250165 glBindTexture(target = GL_TEXTURE_2D, texture = 2)
250167 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {0.001953125, 0, 0, 0, 0, 0.002604167, 0, 0, 0, 0, -1, 0, -1, -1, -0, 1})
250168 glEnableVertexAttribArray(index = 0)
250170 glEnableVertexAttribArray(index = 3)
250174 glVertexAttribPointer(index = 0, size = 3, type = GL_FLOAT, normalized = GL_FALSE, stride = 0, pointer = blob(24))
250175 glVertexAttribPointer(index = 3, size = 4, type = GL_FLOAT, normalized = GL_FALSE, stride = 0, pointer = blob(32))
250176 glDrawArrays(mode = GL_POINTS, first = 0, count = 2)
250178 glXSwapBuffers(dpy = 0x1564010, drawable = 50331661)

最佳答案

我想这可能意味着,您的 GLES 实现支持的磅值范围可能不是您所期望的。你可以尝试这样的事情:

GLint range[2];
glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, range); // for example, (1, 511) in my implementation

检查一下。任何实现都保证 range[1] 至少为 1.0gl_PointSize 的值被限制在范围内,因此在最坏的情况下,您将无法设置大小大于 1 的点。在这种情况下,gl_PointCoord 似乎在将为每个点绘制的唯一片段处评估为 (1, 0)(根据规范中的公式)。在纹理的环绕模式开始发挥作用后,(1, 0) 可能会变成 (0, 0),例如,如果您正在使用 GL_REPEAT 作为纹理的环绕模式。如果您想安全地绘制边长大于 1 的点,您应该尝试使用普通方法绘制正方形(例如使用四个顶点和 GL_TRIANGLE_FANGL_TRIANGLE_STRIP 模式)。

关于linux - OpenGL ES 3.0 GL_POINTS 不渲染任何东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33181859/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com