本文整理汇总了C++中Trackball::getProjectionMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ Trackball::getProjectionMatrix方法的具体用法?C++ Trackball::getProjectionMatrix怎么用?C++ Trackball::getProjectionMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trackball
的用法示例。
在下文中一共展示了Trackball::getProjectionMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
glfwInit();
GLFWwindow* window;
window = glfwCreateWindow(800, 600, "TrackballTest", NULL, NULL);
glfwMakeContextCurrent(window);
// You can set the Trackball camera to another position and give it a name
cam.setPosition(glm::vec4(0.0,0.0,10.0,1.0));
cam.setName("TrackballCam");
cam.setNearFar(0.01f, 100.0f);
// Set all InputMaps and set one InputMap active
iH.setAllInputMaps(cam);
iH.changeActiveInputMap("Trackball");
// Callback
glfwSetKeyCallback(window, key_callback);
glewInit();
// Shader
VertexShader vs(loadShaderSource(SHADERS_PATH + std::string("/ColorShader3D/ColorShader3D.vert")));
FragmentShader fs(loadShaderSource(SHADERS_PATH + std::string("/ColorShader3D/colorShader3D.frag")));
ShaderProgram shader(vs, fs);
// Renderer
OpenGL3Context context;
Renderer renderer(context);
// Object
Teapot teapot;
teapot.loadBufferData();
// getting the start time
double startTime = glfwGetTime();
while (!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// You have to compute the delta time
cam.setSensitivity(glfwGetTime() - startTime);
startTime = glfwGetTime();
shader.bind();
// You have to send the uniform matrices of the Trackball camera to the shader
shader.sendMat4("viewMatrix", cam.getViewMatrix());
shader.sendMat4("projectionMatrix", cam.getProjectionMatrix());
teapot.renderGeometry();
shader.unbind();
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
示例2: main
//.........这里部分代码省略.........
cube1.addTexture(&bricks);
cube1.setModelMatrix(glm::translate(cube1.getModelMatrix(), glm::vec3(-0.3, 0.25, 0.2)));
cube1.setModelMatrix(glm::scale(cube1.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3)));
Node cube2("cube2");
cube2.addGeometry(&cube);
cube2.addTexture(&bricks);
cube2.setModelMatrix(glm::translate(cube2.getModelMatrix(), glm::vec3(0.7, 0.25, 0.3)));
cube2.setModelMatrix(glm::scale(cube2.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3)));
Node wallNode1("wall1");
wallNode1.addGeometry(&plane);
wallNode1.addTexture(&marble);
wallNode1.setModelMatrix(glm::translate(wallNode1.getModelMatrix(), glm::vec3(0.0, 0.1, 0.2)));
wallNode1.setModelMatrix(glm::rotate(wallNode1.getModelMatrix(), 90.0f, glm::vec3(1.0, 0.0, 0.0)));
wallNode1.setModelMatrix(glm::scale(wallNode1.getModelMatrix(), glm::vec3(1.5, 1.5, 1.5)));
Node wallNode2("wall2");
wallNode2.addGeometry(&plane);
wallNode2.addTexture(&marble);
wallNode2.setModelMatrix(glm::translate(wallNode2.getModelMatrix(), glm::vec3(0.0, 1.0, -0.2)));
wallNode2.setModelMatrix(glm::scale(wallNode2.getModelMatrix(), glm::vec3(1.5, 1.5, 1.5)));
Node teaNode("teaNode");
teaNode.addGeometry(&teapot);
teaNode.addTexture(&chrome);
teaNode.setModelMatrix(glm::translate(teaNode.getModelMatrix(), glm::vec3(0.2, 0.3, 0.7)));
teaNode.setModelMatrix(glm::scale(teaNode.getModelMatrix(), glm::vec3(0.3, 0.3, 0.3)));
//Creating a scenegraph
testScene.getScenegraph()->getRootNode()->addChildrenNode(&wallNode1);
testScene.getScenegraph()->getRootNode()->addChildrenNode(&wallNode2);
testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube1);
testScene.getScenegraph()->getRootNode()->addChildrenNode(&cube2);
testScene.getScenegraph()->getRootNode()->addChildrenNode(&teaNode);
double startTime = glfwGetTime();
//Renderloop
while (!glfwWindowShouldClose(testWindow.getWindow()))
{
// You have to compute the delta time
cam.setSensitivity(glfwGetTime() - startTime);
startTime = glfwGetTime();
fboGBuffer.bind();
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderGBuffer.bind();
shaderGBuffer.sendMat4("viewMatrix", cam.getViewMatrix());
shaderGBuffer.sendMat4("projectionMatrix", cam.getProjectionMatrix());
shaderGBuffer.sendInt("useTexture", 1);
testScene.render(shaderGBuffer);
shaderGBuffer.unbind();
fboGBuffer.unbind();
fboSSR.bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderRLR.bind();
shaderRLR.sendSampler2D("positionTexture", fboGBuffer.getColorTexture(0), 0);
shaderRLR.sendSampler2D("normalTexture", fboGBuffer.getColorTexture(1), 1);
shaderRLR.sendSampler2D("colorTexture", fboGBuffer.getColorTexture(2), 2);
shaderRLR.sendSampler2D("depthBuffer", fboGBuffer.getDepthTexture(), 3);
shaderRLR.sendMat4("projectionMatrix", cam.getProjectionMatrix());
shaderRLR.sendInt("screenWidth", WINDOW_WIDTH);
shaderRLR.sendInt("screenHeight", WINDOW_HEIGHT);
shaderRLR.sendFloat("zNear", cam.getNear());
shaderRLR.sendFloat("zFar", cam.getFar());
shaderRLR.sendFloat("reflectivity", 0.2f);
screenFillingQuad.renderGeometry();
shaderRLR.unbind();
fboSSR.unbind();
//ScreenFillingQuad Render Pass
shaderSFQ.bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderSFQ.sendSampler2D("fboTexture", fboSSR.getColorTexture(2));
screenFillingQuad.renderGeometry();
shaderSFQ.unbind();
glfwSwapBuffers(testWindow.getWindow());
glfwPollEvents();
}
glfwDestroyWindow(testWindow.getWindow());
glfwTerminate();
return 0;
}