Ejemplo n.º 1
0
void display()
{
	// Compute the MVP (Model View Projection matrix)
	glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
	glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Window.TranlationCurrent.y));
	glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Window.RotationCurrent.y, glm::vec3(1.f, 0.f, 0.f));
	glm::mat4 View = glm::rotate(ViewRotateX, Window.RotationCurrent.x, glm::vec3(0.f, 1.f, 0.f));
	glm::mat4 Model = glm::mat4(1.0f);
	glm::mat4 MVP = Projection * View * Model;

	glViewport(0, 0, Window.Size.x, Window.Size.y);
	glClearBufferfv(GL_COLOR, 0, &glm::vec4(1.0f, 0.5f, 0.0f, 1.0f)[0]);
	glBindVertexArray(VertexArrayName);
	glActiveTexture(GL_TEXTURE0);

	{
		std::size_t ViewportIndex(0); 
		glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

		glUseProgram(ProgramName[program::UINT]);
		glUniform1i(UniformDiffuse[program::UINT], 0);
		glUniformMatrix4fv(UniformMVP[program::UINT], 1, GL_FALSE, &MVP[0][0]);

		glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA8UI]);

		glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
	}

	{
		std::size_t ViewportIndex(1); 
		glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

		glUseProgram(ProgramName[program::NORMALIZED]);
		glUniform1i(UniformDiffuse[program::NORMALIZED], 0);
		glUniformMatrix4fv(UniformMVP[program::NORMALIZED], 1, GL_FALSE, &MVP[0][0]);

		glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA16F]);

		glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
	}

	{
		std::size_t ViewportIndex(2); 
		glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

		glUseProgram(ProgramName[program::NORMALIZED]);
		glUniform1i(UniformDiffuse[program::NORMALIZED], 0);
		glUniformMatrix4fv(UniformMVP[program::NORMALIZED], 1, GL_FALSE, &MVP[0][0]);

		glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA8]);

		glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
	}

	{
		std::size_t ViewportIndex(3); 
		glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

		glUseProgram(ProgramName[program::NORMALIZED]);
		glUniform1i(UniformDiffuse[program::NORMALIZED], 0);
		glUniformMatrix4fv(UniformMVP[program::NORMALIZED], 1, GL_FALSE, &MVP[0][0]);

		glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA8_SNORM]);

		glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
	}

	glf::checkError("display");
	glf::swapBuffers();
}
Ejemplo n.º 2
0
	bool render()
	{
		glm::ivec2 WindowSize(this->getWindowSize());

		glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f);
		glm::mat4 Model = glm::mat4(1.0f);
		glm::mat4 MVP = Projection * this->view() * Model;

		glViewport(0, 0, WindowSize.x, WindowSize.y);
		glClearBufferfv(GL_COLOR, 0, &glm::vec4(1.0f, 0.5f, 0.0f, 1.0f)[0]);
		glBindVertexArray(VertexArrayName);
		glActiveTexture(GL_TEXTURE0);

		{
			std::size_t ViewportIndex(0); 
			glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

			glUseProgram(ProgramName[program::UINT]);
			glUniform1i(UniformDiffuse[program::UINT], 0);
			glUniformMatrix4fv(UniformMVP[program::UINT], 1, GL_FALSE, &MVP[0][0]);

			glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA8UI]);

			glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
		}

		{
			std::size_t ViewportIndex(1); 
			glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

			glUseProgram(ProgramName[program::NORMALIZED]);
			glUniform1i(UniformDiffuse[program::NORMALIZED], 0);
			glUniformMatrix4fv(UniformMVP[program::NORMALIZED], 1, GL_FALSE, &MVP[0][0]);

			glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA16F]);

			glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
		}

		{
			std::size_t ViewportIndex(2); 
			glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

			glUseProgram(ProgramName[program::NORMALIZED]);
			glUniform1i(UniformDiffuse[program::NORMALIZED], 0);
			glUniformMatrix4fv(UniformMVP[program::NORMALIZED], 1, GL_FALSE, &MVP[0][0]);

			glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA8]);

			glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
		}

		{
			std::size_t ViewportIndex(3); 
			glViewport(Viewport[ViewportIndex].x, Viewport[ViewportIndex].y, Viewport[ViewportIndex].z, Viewport[ViewportIndex].w);

			glUseProgram(ProgramName[program::NORMALIZED]);
			glUniform1i(UniformDiffuse[program::NORMALIZED], 0);
			glUniformMatrix4fv(UniformMVP[program::NORMALIZED], 1, GL_FALSE, &MVP[0][0]);

			glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGBA8_SNORM]);

			glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
		}

		return true;
	}