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


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

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


在下文中一共展示了Trackball::setName方法的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;
}
开发者ID:GameEngineKoblenz,项目名称:GeKo,代码行数:63,代码来源:main.cpp

示例2: main

int main()
{
    glfwInit();

    Window testWindow(50, 50, WINDOW_WIDTH, WINDOW_HEIGHT, "Reflections");
    glfwMakeContextCurrent(testWindow.getWindow());
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);


    cam.setRadius(2.0);
    cam.setPosition(glm::vec4(0.0, 1.0, 1.0, 1.0));
    cam.setName("TrackballCam");
    cam.setNearFar(0.1f, 50.0f);
    cam.moveDown();

    iH.setAllInputMaps(cam);
    iH.changeActiveInputMap("Trackball");

    //Callback
    glfwSetKeyCallback(testWindow.getWindow(), key_callback);

    glewInit();

    //our shader
    VertexShader vsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.vert")));
    FragmentShader fsGBuffer(loadShaderSource(SHADERS_PATH + std::string("/GBuffer/GBuffer.frag")));
    ShaderProgram shaderGBuffer(vsGBuffer, fsGBuffer);

    VertexShader vsRLR(loadShaderSource(SHADERS_PATH + std::string("/RealtimeLocalReflections/RealtimeLocalReflections.vert")));
    FragmentShader fsRLR(loadShaderSource(SHADERS_PATH + std::string("/RealtimeLocalReflections/RealtimeLocalReflections.frag")));
    ShaderProgram shaderRLR(vsRLR, fsRLR);

    VertexShader vsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.vert")));
    FragmentShader fsSfq(loadShaderSource(SHADERS_PATH + std::string("/ScreenFillingQuad/ScreenFillingQuad.frag")));
    ShaderProgram shaderSFQ(vsSfq, fsSfq);

    //our renderer
    OpenGL3Context context;
    Renderer renderer(context);

    FBO fboGBuffer(WINDOW_WIDTH, WINDOW_HEIGHT, 3, true, false);
    FBO fboSSR(WINDOW_WIDTH, WINDOW_HEIGHT, 3, false, false);

    //our object
    Cube cube;
    Teapot teapot;
    teapot.loadBufferData();

    Rect plane;
    Rect screenFillingQuad;
    screenFillingQuad.loadBufferData();

    //our textures
    Texture bricks((char*)RESOURCES_PATH "/brick.bmp");
    Texture marble((char*)RESOURCES_PATH "/seamless_marble.jpg");
    Texture chrome((char*)RESOURCES_PATH "/chrome.jpg");

    //Scene creation
    Level testLevel("testLevel");
    Scene testScene("testScene");
    testLevel.addScene(&testScene);
    testLevel.changeScene("testScene");

    //Add Camera to scenegraph
    testScene.getScenegraph()->addCamera(&cam);
    testScene.getScenegraph()->getCamera("TrackballCam");
    testScene.getScenegraph()->setActiveCamera("TrackballCam");

    Node cube1("cube1");
    cube1.addGeometry(&cube);
    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)));
//.........这里部分代码省略.........
开发者ID:MarcelBock,项目名称:GeKo,代码行数:101,代码来源:main.cpp


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