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


C++ TextRenderer::RenderText方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
		currentZ = cameraPos.z;

		cameraPos += yVelocity * front;
		cameraPos -= glm::normalize(glm::cross(cameraFront, cameraUp)) * xVelocity;

		// Collision detection, reset to previous position if wall boundary is crossed
		if ( (cameraPos.x-wallDistanceMargin) < -corridorWidth | (cameraPos.x + wallDistanceMargin)> corridorWidth)
			cameraPos.x = currentX;
		if ((cameraPos.z-wallDistanceMargin) < -corridorDepth | (cameraPos.z + wallDistanceMargin) > corridorDepth)
			cameraPos.z = currentZ;

		// Check reward zone entries
		if (!inRewardZone && (cameraPos.z > rewardZoneLowZ && cameraPos.z < rewardZoneHighZ))
		{
			inRewardZone = true;
			cout << "Reward zone ENTRY detected." << endl;
		}
		if (inRewardZone && (cameraPos.z < rewardZoneLowZ || cameraPos.z > rewardZoneHighZ))
		{
			inRewardZone = false;
			cout << "Reward zone EXIT detected." << endl;
		}

		view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp);


		// Draw the complete screen to the offscreen framebuffer
		glfwMakeContextCurrent(initGlfw.window);
		glBindFramebuffer(GL_FRAMEBUFFER, frameBufferObject);
		glViewport(0, 0, fullWidth, initGlfw.windowInfo.height);
			glEnable(GL_DEPTH_TEST);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			
			if (showFPS)
				textRenderer.RenderText(textShaderProgram, fpsString, 0.0f, GLfloat(initGlfw.windowInfo.height - 20), 1.0, glm::vec3(0.8, 0.6, 0.6));

			glUseProgram(defaultShaderProgram);
			glUniformMatrix4fv(viewLocation, 1, GL_FALSE, glm::value_ptr(view));
			glUniformMatrix4fv(projectionLocation, 1, GL_FALSE, glm::value_ptr(proj1));
			glUniformMatrix4fv(modelLocation, 1, GL_FALSE, glm::value_ptr(idm));
			glBindTexture(GL_TEXTURE_2D, texture);
			frontWall.Draw();
			backWall.Draw();
			leftWall.Draw();
			rightWall.Draw();
			floorSquare.Draw();
			glBindTexture(GL_TEXTURE_2D, blankTexture);
			rewardZone.Draw();
			glBindTexture(GL_TEXTURE_2D, 0);
		glBindFramebuffer(GL_FRAMEBUFFER, 0);


		// First monitor drawing calls
		//glfwMakeContextCurrent(initGlfw.window);
		glClear(GL_COLOR_BUFFER_BIT);
		glDisable(GL_DEPTH_TEST);
		glViewport(0, 0, initGlfw.windowInfo.width, initGlfw.windowInfo.height);
		glUseProgram(simpleShaderProgram);
		glBindTexture(GL_TEXTURE_2D, frameBufferTexture);
		glBindBuffer(GL_ARRAY_BUFFER, rightScreenVBO);
			glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (GLvoid*)0);
			glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (GLvoid*)(2 * sizeof(GLfloat)));
			glEnableVertexAttribArray(0);
			glEnableVertexAttribArray(1);
			glDrawArrays(GL_TRIANGLES, 0, 6);
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glfwSwapBuffers(initGlfw.window);

		// Second monitor drawing calls
		glfwMakeContextCurrent(initGlfw.window2);
		glClear(GL_COLOR_BUFFER_BIT);
		glDisable(GL_DEPTH_TEST);
		glUseProgram(simpleShaderProgram);
		glBindTexture(GL_TEXTURE_2D, frameBufferTexture);
		glBindBuffer(GL_ARRAY_BUFFER, leftScreenVBO);
			glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (GLvoid*)0);
			glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (GLvoid*)(2 * sizeof(GLfloat)));
			glEnableVertexAttribArray(0);
			glEnableVertexAttribArray(1);
			glDrawArrays(GL_TRIANGLES, 0, 6);
		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glfwSwapBuffers(initGlfw.window2);

		// Check events
		glfwPollEvents();

		// Output information
		++updateTick;
		if (updateTick % 60 == 0)
		{
			cout << "Camera position: (" << cameraPos.x << ", " << cameraPos.y << ", " << cameraPos.z << ")" << endl;
			updateTick = 0;
		}
	}
	glfwTerminate();

	// Clean up after exiting
	glDeleteFramebuffers(1, &frameBufferObject);
	return 0;
}
开发者ID:benvermaercke,项目名称:Virtual-reality,代码行数:101,代码来源:main.cpp


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