示例#1
0
	void GLText::Draw(ShaderProgram &program, GLCamera &camera) const {
		program.Bind();
		glUniformMatrix4fv(program.getUniformLocation("camera"), 1, GL_FALSE, glm::value_ptr(camera.PVMatrix()));
		glm::mat4 model;
		model = glm::translate(model, position);
		model = glm::rotate(model, glm::radians(rotation.x), { 1,0,0 });
		model = glm::rotate(model, glm::radians(rotation.y+180), { 0,1,0 });
		model = glm::rotate(model, glm::radians(rotation.z), { 0,0,1 });
		model = glm::scale(model, scale);
		glUniformMatrix4fv(program.getUniformLocation("model"), 1, GL_FALSE, glm::value_ptr(model));

		glDisable(GL_CULL_FACE);
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, textureid);

		glBindVertexArray(vao);
		glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); // Draw plane with 36 vertices
		glBindVertexArray(0);

		glBindTexture(GL_TEXTURE_2D, 0);
		glActiveTexture(0);
		glEnable(GL_CULL_FACE);

	}
示例#2
0
// Draw the skybox using the skybox shader
void Skybox::draw(ShaderProgram& s){


  GLint posAttrib = s.getAttribLocation( "position" );

  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_CUBE_MAP,tex);
  GLint cube = s.getUniformLocation("cubeMap");
  glUniform1i(cube,0);

  glEnableVertexAttribArray(posAttrib);
	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	glVertexAttribPointer( posAttrib, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 );

  glDrawArrays (GL_TRIANGLES, 0, 36);

  glBindBuffer(GL_ARRAY_BUFFER,0);




}