Ejemplo n.º 1
0
void renderObjects()
{
	// Set Modeling transformation for the reference plane
	modelingTransformation = glm::translate(glm::vec3(0.0f, -3.0f, 0.0f));
	refPlane.draw();

	// Set modeling transformation for the front left pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.5f, -2.5f, 3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the back right pyramid
	modelingTransformation = glm::translate(glm::vec3(3.5f, -2.5f, -3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(0.0f, 1.0f, 0.0f));
	pyramid.draw(color(1.0f, 0.0f, 0.0f, 1.0f));

	// Set modeling transformation for the right hand pyramid
	modelingTransformation = glm::translate(glm::vec3(3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(1.0f, 0.0f, 0.0f));
	sphere.draw(color(1.0f, 1.0f, 0.0f, 1.0f));

	// Set modeling transformation for the left hand pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(glm::vec3(2.0f, 2.0f, 2.0f));
	pyramid.draw(color(1.0f, 0.0f, 1.0f, 1.0f));

}
Ejemplo n.º 2
0
/**
* Acts as the display function for the window.
*/
static void RenderSceneCB()
{
	vector<glm::vec4> transformedVertices;

	// Clear the color buffer
	colorBuffer.clearColorBuffer();

	static float angle = glm::radians(45.0f);

	angle += glm::radians(1.0f);

	// Set Modeling transformation for the reference plane
	modelingTransformation = glm::translate(glm::vec3(0.0f, -3.0f, 0.0f));
	refPlane.draw();

	// Set modeling transformation for the front left pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.5f, -2.5f, 3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the back right pyramid
	modelingTransformation = glm::translate(glm::vec3(3.5f, -2.5f, -3.5f));
	pyramid.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.0f, 0.0f, 0.0f)) * glm::rotate(angle,glm::vec3(0.0f, 1.0f, 0.0f));
	pyramid.draw(color(1.0f, 0.0f, 0.0f, 1.0f));

	// Set modeling transformation for the right hand pyramid
	modelingTransformation = glm::translate(glm::vec3(3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(1.0f, 0.0f, 0.0f));
	sphere.draw( color(1.0f, 1.0f, 0.0f, 1.0f));

	// Set modeling transformation for the left hand pyramid
	modelingTransformation = glm::translate(glm::vec3(-3.0f, 0.0f, 0.0f)) * glm::rotate(angle, glm::vec3(0.0f, 0.0f, 1.0f)) * glm::scale(glm::vec3(2.0f, 2.0f, 2.0f));
	pyramid.draw( color(1.0f, 0.0f, 1.0f, 1.0f));

	// Set modeling transformation for the orbiting pyramid
	modelingTransformation = glm::rotate(angle, glm::vec3(0.0f, 1.0f, 0.0f))* glm::translate(glm::vec3(10.0f, 3.0f, 0.0f)) *glm::rotate(-angle, glm::vec3(1.0f, 0.0f, 0.0f));
	pyramid.draw( color(1.0f, 1.0f, 1.0f, 1.0f));

	// Display the color buffer
	colorBuffer.showColorBuffer();

} // end RenderSceneCB
Ejemplo n.º 3
0
int main() {
	sf::ContextSettings set;
	set.antialiasingLevel = 8;
	sf::Window w(sf::VideoMode(700, 700), "ogl", sf::Style::Default, set);
	glewExperimental = true;
	glewInit();
	Context gl;
	gl.ClearColor(0.0, 0.0, 0.0, 1.0);
	gl.Enable(Capability::DepthTest);
	gl.Enable(Capability::CullFace);
	gl.Enable(Capability::Blend);
	w.setMouseCursorVisible(false);

	Pyramid pyramid { w };

	bool running = true;
	while(running) {
		sf::Event e;
		while(w.pollEvent(e)){
			if(e.type == sf::Event::Closed){ running = false; }
			if(e.type == sf::Event::KeyPressed) {
				switch(e.key.code) {
				case sf::Keyboard::Escape:
					running = false;
					break;
				case sf::Keyboard::W: case sf::Keyboard::Up:
					camera.forward();
					break;
				case sf::Keyboard::A: case sf::Keyboard::Left:
					camera.left();
					break;
				case sf::Keyboard::S: case sf::Keyboard::Down:
					camera.back();
					break;
				case sf::Keyboard::D: case sf::Keyboard::Right:
					camera.right();
					break;
				default:
					break;
				}
				}
			if(e.type == sf::Event::MouseMoved) {
					//idk
			}
		}

		pyramid.update();
		pyramid.draw(gl);
		gl.Clear().ColorBuffer().DepthBuffer();
		w.display();
	}
	return 0;
}
Ejemplo n.º 4
0
/**
* Acts as the display function for the window.
*/
static void RenderSceneCB()
{
	vector<glm::vec4> transformedVertices;

	// Clear the color buffer
	colorBuffer.clearColorBuffer();

	static float angle = glm::radians(45.0f);

	angle += glm::radians(0.1f);

	// Set Modeling transformation for the reference plane
	modelingTransformation = glm::translate(glm::vec3(0.0f, -3.0f, 0.0f));
	gameBoard.draw();




	// Set modeling transformation for the back right pyramid on top of cube
	modelingTransformation = glm::translate(glm::vec3(3.5f, -1.5f, -3.5f));
	pyramid.draw(color(0.502f, 0.0f, 0.502f, 1.0f));

	//cube under pyramid
	modelingTransformation = glm::translate(glm::vec3(3.5f, -2.5f, -3.5f));
	cube.draw(color(0.502f, 0.0f, 0.502f, 1.0f));




	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(-0.5f, -2.5f, -0.5f));
	cube.draw(color(0.0f, 1.0f, 0.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.5f, -2.5f, -0.5f));
	cube.draw(color(1.0f, 1.0f, 0.0f, 1.0f));

	// red cube
	modelingTransformation = glm::translate(glm::vec3(0.0f, -2.5f, 0.5f));
	cube.draw(color(1.0f, 0.0f, 0.0f, 1.0f));

	// Set modeling transformation for the center pyramid
	modelingTransformation = glm::translate(glm::vec3(0.0f, -1.5f, 0.0f))*glm::rotate(4.0f, glm::vec3(0.0f, 1.0f, 0.0f));;
	cube.draw(color(0.0f, 0.0f, 1.0f, 1.0f));

	// Display the color buffer
	colorBuffer.showColorBuffer();

} // end RenderSceneCB