问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
#include <detail/type_mat.hpp>
#include <detail/type_mat4x4.hpp>
#include "GLSampleBase.h"
#include <Matrix.h>
#include <esShapes.h>
#include <esTransform.h>
#include <GLUtils.h>
void BeatingHeartSample::initMVP(int m_Width, int m_Height) {
ESMatrix perspective;
ESMatrix ortho;
ESMatrix modelView;
ESMatrix model;
ESMatrix view;
float aspect;
// Compute the window aspect ratio
aspect = (GLfloat)m_Width / (GLfloat)m_Height;
// Generate a perspective matrix with a 45 degree FOV for the scene rendering
esMatrixLoadIdentity(&perspective);
esPerspective(&perspective, 45.0f, aspect, 0.1f, 100.0f);
// 用光源位置建立一个MVP矩阵
// 通过连接 正交投影、模型和视图变换矩阵生成的MVP变换矩阵
// Generate an orthographic projection matrix for the shadow map rendering
esMatrixLoadIdentity(&ortho);
esOrtho(&ortho, -10, 10, -10, 10, -30, 30);
// GROUND
// Generate a model view matrix to rotate/translate the ground
esMatrixLoadIdentity(&model);
// Center the ground
esTranslate(&model, -2.0f, -2.0f, 0.0f);
esScale(&model, 10.0f, 10.0f, 10.0f);
esRotate(&model, 90.0f, 1.0f, 0.0f, 0.0f);
// ---------- 用眼睛位置建立MVP矩阵 ---------- 开始
// Create view matrix transformation from the eye position
esMatrixLookAt(&view,
eyePosition[0], eyePosition[1], eyePosition[2],
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
esMatrixMultiply(&modelView, &model, &view);
// Compute the final ground MVP for the scene rendering by multiplying the
// modelview and perspective matrices together
esMatrixMultiply(&groundMvpMatrix, &modelView, &perspective);
// Create view matrix transformation from the light position
esMatrixLookAt(&view,
lightPosition[0], lightPosition[1], lightPosition[2],
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
esMatrixMultiply(&modelView, &model, &view);
// Compute the final ground MVP for the shadow map rendering by multiplying the
// modelview and ortho matrices together
esMatrixMultiply(&groundMvpLightMatrix, &modelView, &ortho);
// ---------- 用眼睛位置建立MVP矩阵 ---------- 结束
// CUBE
// position the cube
esMatrixLoadIdentity(&model);
esTranslate(&model, 5.0f, -0.4f, -3.0f);
esScale(&model, 1.0f, 2.5f, 1.0f);
esRotate(&model, -15.0f, 0.0f, 1.0f, 0.0f);
// Create view matrix transformation from the eye position
esMatrixLookAt(&view,
eyePosition[0], eyePosition[1], eyePosition[2],
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
esMatrixMultiply(&modelView, &model, &view);
// Compute the final cube MVP for scene rendering by multiplying the
// modelview and perspective matrices together
esMatrixMultiply(&cubeMvpMatrix, &modelView, &perspective);
// Create view matrix transformation from the light position
esMatrixLookAt(&view,
lightPosition[0], lightPosition[1], lightPosition[2],
0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f);
esMatrixMultiply(&modelView, &model, &view);
// Compute the final cube MVP for shadow map rendering by multiplying the
// modelview and ortho matrices together
esMatrixMultiply(&cubeMvpLightMatrix, &modelView, &ortho);
}
int BeatingHeartSample::initShadowMap() {
GLenum none = GL_NONE;
GLint defaultFramebuffer = 0;
// use 1K by 1K texture for shadow map
shadowMapTextureWidth = shadowMapTextureHeight = 1024;
glGenTextures(1, &shadowMapTextureId);
glBindTexture(GL_TEXTURE_2D, shadowMapTextureId);
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);
// setup fbo
glGenFramebuffers(1, &shadowMapBufferId);
glBindFramebuffer(GL_FRAMEBUFFER, shadowMapBufferId);
glDrawBuffers(1, &none);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_TEXTURE_2D, shadowMapTextureId, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, shadowMapTextureId);
if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
return GL_FALSE;
}
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
return GL_TRUE;
}
运行结果及报错内容
我的解答思路和尝试过的方法
#include <esTransform.h> 我该有得头文件都包含了。为什么老是报这种找不到没有定义得错误呢
undefined reference to `esMatrixLoadIdentity(ESMatrix*)'