gpt4 book ai didi

opengl - glTexEnv 返回无法解释的 INVALID_OPERATION 错误

转载 作者:行者123 更新时间:2023-12-01 04:15:00 32 4
gpt4 key购买 nike

问题:

紧接在“glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);”之后我收到了 GL 错误 #1282(INVALID_OPERATION)。

然后在查阅OpenGL 2.1 Reference时,在glTexEnv下说:如果glTexEnv在glBegin的执行和glEnd的相应执行之间执行,则生成GL_INVALID_OPERATION。 但是这不是我的情况,因为我使用的是顶点数组。

这是我的代码的一部分:

void RBFS::render_pass1_point_sprites(Shader &shader1, int width, int height, float t)
{
shader1.bind();

glActiveTexture(GL_TEXTURE0);{
glBindTexture(GL_TEXTURE_1D, m_texRBFData[0]);
MyCheckErrorGL();
}
glActiveTexture(GL_TEXTURE1);{
glBindTexture(GL_TEXTURE_1D, m_texRBFData[1]);
MyCheckErrorGL();
}
glActiveTexture(GL_TEXTURE2);{
glBindTexture(GL_TEXTURE_3D, m_texSDF);
MyCheckErrorGL();
}
glActiveTexture(GL_TEXTURE3);{
glBindTexture(GL_TEXTURE_3D, m_texLabels[0]);
MyCheckErrorGL();
}
glActiveTexture(GL_TEXTURE4);{
glBindTexture(GL_TEXTURE_3D, m_texLabels[1]);
MyCheckErrorGL();
}
glActiveTexture(GL_TEXTURE5);{
glBindTexture(GL_TEXTURE_1D, m_texHG);
MyCheckErrorGL();
}
glActiveTexture(GL_TEXTURE9);{
glBindTexture(GL_TEXTURE_2D, m_texCircle);
MyCheckErrorGL();
}

// upload t
GLuint loc_t = my_glGetUniformLocation(shader1.id(), "tSlice");
glUniform1f(loc_t, t);
MyCheckErrorGL();

// SET POINT_SPRITE
glEnable(GL_POINT_SPRITE);
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);// so we can set different point size in VShader
float sizes[2];
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, sizes);
glPointParameterf(GL_POINT_SIZE_MIN, sizes[0]);
glPointParameterf(GL_POINT_SIZE_MAX, sizes[1]);
MyCheckErrorGL();
glTexEnvi( GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);// means tex-coord iteration
MyCheckErrorGL();
glPointParameterfARB(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);// set origin-y
MyCheckErrorGL();
glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST);
MyCheckErrorGL();

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_density);{

glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, width, height);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

glClearColor(0.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
MyCheckErrorGL();

glDrawArrays(GL_POINTS, 0, numRBFs);//3rd parameter: number of points
MyCheckErrorGL();

glDisable(GL_BLEND);
glPopMatrix();
glPopAttrib();
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

// turn off switches for PSprite
glDisable(GL_POINT_SPRITE);
glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);

MyCheckErrorGL();

glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_1D, 0);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_3D, 0);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_3D, 0);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_3D, 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_1D, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_1D, 0);

shader1.unbind();
MyCheckErrorGL();
}

因为我是 OpenGL 的新手。如果您对我的代码有其他建议,请不要犹豫告诉我。:-)

最佳答案

听起来您的 OpenGL 设备根本不支持 POINT_SPRITE。

GL 2.0 规范已集成点 Sprite 作为核心功能。您的设备支持什么 GL 版本?

关于opengl - glTexEnv 返回无法解释的 INVALID_OPERATION 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4276109/

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