问题相关代码,请勿粘贴截图
bool Renderer::CreateShadowTexture()
{
GLenum none = GL_NONE;
GLint defaultFramebuffer = 0;
glGenTextures(1, &_mShadowTextureID);
//glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, _mShadowTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Setup hardware comparison
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24,
shadowMapTextureWidth, shadowMapTextureHeight,
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFramebuffer);
//Render Buffer Objects (RBO) are used along with FBOs as render targets for offline rendering
//We don't need colors stored in RBO, only the depth component which is an internal type
//we specify the type of storage in glRenderbufferStorage
glGenFramebuffers(1, &_mFBO);
glBindFramebuffer(GL_FRAMEBUFFER, _mFBO);
glDrawBuffers(1, &none);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D, _mShadowTextureID, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, _mShadowTextureID);
if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
return GL_FALSE;
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
return GL_TRUE;
}
运行结果及报错内容
1 warning generated.
[arm64-v8a] Compile++ : AndroidShadowMapping <= jni.cpp
[arm64-v8a] SharedLibrary : libAndroidShadowMapping.so
ld: error: undefined symbol: glDrawBuffers
referenced by Renderer.cpp:231 (jni\Renderer.cpp:231)
./obj/local/arm64-v8a/objs/AndroidShadowMapping/Renderer.o:(Renderer::CreateShadowTexture())
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [H:/NDK/build//../build/core/build-binary.mk:657: obj/local/arm64-v8a/libAndroidShadowMapping.so] Error 1
H:\cpp2>
我的解答思路和尝试过的方法
error: undefined symbol: glDrawBuffers 为什么会提示这个报错呢?