2
我正在使用OpenGL 3.3和延期着色。設置GL_TEXTURE_MAX_ANISOTROPY_EXT導致下一幀崩潰
當我爲我的幀之間的採樣設置各向異性值時,下一幀將導致在在glClear下一幀崩潰。
以下是我設置我的各向異性值:
bool OpenGLRenderer::SetAnisotropicFiltering(const float newAnisoLevel)
{
if (newAnisoLevel < 0.0f || newAnisoLevel > GetMaxAnisotropicFiltering())
return false;
mCurrentAnisotropy = newAnisoLevel;
// the sampler used for geometry pass
GLCALL(glSamplerParameterf(mTextureSampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, mCurrentAnisotropy));
// the sampler used in shading pass
GLCALL(glSamplerParameterf(mGBuffer.mTextureSampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, mCurrentAnisotropy));
return true;
}
幾何通具有以下漫/正常貼圖,並設置這樣的:
GLCALL(glUseProgram(mGeometryProgram.mProgramHandle));
GLCALL(glGenSamplers(1, &mTextureSampler));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_WRAP_S, GL_REPEAT));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_WRAP_T, GL_REPEAT));
GLCALL(glUniform1i(glGetUniformLocation(mGeometryProgram.mProgramHandle, "unifDiffuseTexture"), OpenGLTexture::TEXTURE_UNIT_DIFFUSE));
GLCALL(glUniform1i(glGetUniformLocation(mGeometryProgram.mProgramHandle, "unifNormalTexture"), OpenGLTexture::TEXTURE_UNIT_NORMAL));
GLCALL(glBindSampler(OpenGLTexture::TEXTURE_UNIT_DIFFUSE, mTextureSampler));
GLCALL(glBindSampler(OpenGLTexture::TEXTURE_UNIT_NORMAL, mTextureSampler));
GLCALL(glUseProgram(0));
陰影通具有以下紋理照明計算:
GLCALL(glUseProgram(shadingProgramID));
GLCALL(glGenSamplers(1, &mTextureSampler));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
GLCALL(glSamplerParameteri(mTextureSampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
GLCALL(glUniform1i(glGetUniformLocation(shadingProgramID, "unifPositionTexture"), GBuffer::GBUFFER_TEXTURE_POSITION));
GLCALL(glUniform1i(glGetUniformLocation(shadingProgramID, "unifNormalTexture"), GBuffer::GBUFFER_TEXTURE_NORMAL));
GLCALL(glUniform1i(glGetUniformLocation(shadingProgramID, "unifDiffuseTexture"), GBuffer::GBUFFER_TEXTURE_DIFFUSE));
GLCALL(glBindSampler(GBuffer::GBUFFER_TEXTURE_POSITION, mTextureSampler));
GLCALL(glBindSampler(GBuffer::GBUFFER_TEXTURE_NORMAL, mTextureSampler));
GLCALL(glBindSampler(GBuffer::GBUFFER_TEXTURE_DIFFUSE, mTextureSampler));
GLCALL(glUseProgram(0));
然後在下一幀它cra當進行幾何輪廓時立即在glClear函數上s
void OpenGLRenderer::GeometryPass(const RenderQueue& renderQueue)
{
GLCALL(glUseProgram(mGeometryProgram.mProgramHandle));
GLCALL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mGBuffer.mFramebuffer));
GLCALL(glDepthMask(GL_TRUE));
GLCALL(glEnable(GL_DEPTH_TEST));
// clear GBuffer fbo
GLCALL(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)); // <----- crash!
// both containers are assumed to be sorted by MeshID ascending
auto meshIterator = mMeshes.begin();
for (const Renderable& renderable : renderQueue)
{
// lots of draw code.....
}
GLCALL(glDisable(GL_DEPTH_TEST));
GLCALL(glDepthMask(GL_FALSE));
GLCALL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0));
GLCALL(glUseProgram(0));
}
這裏有什麼問題?
就是這樣,實際上,它適用於此。讓它成爲答案,我會標記它,謝謝! – KaiserJohaan