当前位置: 首页>>代码示例>>C++>>正文


C++ Trackball::getFar方法代码示例

本文整理汇总了C++中Trackball::getFar方法的典型用法代码示例。如果您正苦于以下问题:C++ Trackball::getFar方法的具体用法?C++ Trackball::getFar怎么用?C++ Trackball::getFar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Trackball的用法示例。


在下文中一共展示了Trackball::getFar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:MarcelBock,项目名称:GeKo,代码行数:101,代码来源:main.cpp


注:本文中的Trackball::getFar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。