Ejemplo n.º 1
0
void Scene2::Render()
{
    // clear color every frame
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    Mtx44 translate, rotate, scale;
    Mtx44 model;
    Mtx44 view;
    Mtx44 projection;
    Mtx44 MVP;

    translate.SetToIdentity();
    rotate.SetToIdentity();
    scale.SetToIdentity();
    model.SetToIdentity();
    view.SetToIdentity();//camera set at world origin

    projection.SetToOrtho(-40, +40, -30, +30, -10, +10); //define the world in a cube by these boundaries

    glEnableVertexAttribArray(0); //1st attri buffer: vertices
    glEnableVertexAttribArray(1);

    scale.SetToScale(10, 10, 10);
    rotate.SetToRotation(45, 0, 0, 1);
    translate.SetToTranslation(5, 5, 0);
    model = translate * rotate *scale; //scale, fcollowed by rotate then translate
    MVP = projection * view * model;
    glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update new shader w MVP
    glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_1]);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_1]);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
    //draw triangle

    glDrawArrays(GL_TRIANGLES, 0, 6); //starting from vertex 0; 3 vertices = 1 triangle
    glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_1]);
    glVertexAttribPointer
        (
        0, //Attribute 0. Must match layout in shader. usually 0 is for vertex
        3, //size
        GL_FLOAT, //type
        GL_FALSE, //normalised
        0,        //stride
        0         //array buffer offset
        );
    glEnableVertexAttribArray(1);//2nd attr buffer: colors
    glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_1]);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
    

    glDisableVertexAttribArray(1);

    glDisableVertexAttribArray(0);

   

   
    
}
Ejemplo n.º 2
0
void Scene3::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//Temp variables
	Mtx44 translate, rotate, scale;
	Mtx44 MVP;

	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	//Set all matrices to identity
	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();

	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
					);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane

	model.SetToIdentity();
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	meshList[GEO_AXES]->Render();
	

	rotate.SetToRotation(rotateAngle, 0, 0, 1);
	model = rotate;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	/*meshList[GEO_CUBE]->Render();*/
	meshList[GEO_SPHERE]->Render();

	/*model.SetToIdentity();
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);*/
	/*meshList[GEO_CIRCLE]->Render();*/
	/*meshList[GEO_RING]->Render();*/
	
}
Ejemplo n.º 3
0
void SceneGalaxy::Render()
{
    // Render VBO here
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    //Temp variables
    Mtx44 translate, rotate, scale;
    Mtx44 MVP;

    //These will be replaced by matrix stack soon
    Mtx44 model;
    Mtx44 view;
    Mtx44 projection;

    //Set all matrices to identity
    translate.SetToIdentity();
    rotate.SetToIdentity();
    scale.SetToIdentity();
    model.SetToIdentity();

    //Set view matrix using camera settings
    viewStack.LoadIdentity();
    viewStack.LookAt(
        camera.position.x, camera.position.y, camera.position.z,
        camera.target.x, camera.target.y, camera.target.z,
        camera.up.x, camera.up.y, camera.up.z
    );

    //Set projection matrix to perspective mode
    projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 10000.0f); //FOV, Aspect Ratio, Near plane, Far plane
    modelStack.PushMatrix();
    modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
    modelStack.Scale(0.1f, 0.1f, 0.1f);
    renderMesh(meshList[GEO_LIGHTBALL], false);
    modelStack.PopMatrix();


    /*modelStack.PushMatrix();
    renderMesh(meshList[GEO_AXES], false);
    modelStack.PopMatrix();*/

    modelStack.PushMatrix();
    modelStack.Translate(0, 496.9f, 0);
    RenderSkybox();
    modelStack.PopMatrix();

    RenderXwing();
    RenderAsteroid();
    RenderMissile();
    QuestDetail();

    RenderTextOnScreen(meshList[GEO_TEXT], "+", Color(0, 1, 0), 3, 13.1, 9);
    std::stringstream playerPos;
    playerPos << "X = " << camPosX << " Y = " << camPosY << " Z = " << camPosz;
    //RenderTextOnScreen(meshList[GEO_TEXT], playerPos.str(), Color(1, 0, 0), 2, 0, 18);
    std::stringstream ss;
    ss << "FPS:" << fps << "         " << playerPos.str();
    RenderTextOnScreen(meshList[GEO_TEXT], ss.str(), Color(0, 1, 0), 3, 0, 19);

}
Ejemplo n.º 4
0
void SceneNode::DrawChild(SceneManager *sceneManager, Mesh* debugMesh)
{
	sceneManager->RenderPush(gameObject3D->getProperties().modelProperties);

#if _DEBUG
	if (debugMesh != NULL)
	{
		Properties trs;
		Mtx44 overall;
		overall.SetToIdentity();
		trs.scale.SetToScale(Vector3(gameObject3D->getHitbox().getLength(), gameObject3D->getHitbox().getHeight(), gameObject3D->getHitbox().getDepth()));
		trs.modelProperties = overall * trs.translation * trs.rotation * trs.scale;
		sceneManager->RenderPush(trs.modelProperties);
		sceneManager->Render3DMesh(debugMesh, false);
		sceneManager->RenderPop();
	}
#endif

	sceneManager->Render3DMesh(gameObject3D->getMesh(), gameObject3D->getReflectLight());

	for (unsigned i = 0; i < childNodes.size(); ++i)
	{
		this->childNodes[i]->DrawChild(sceneManager, debugMesh);
	}

	sceneManager->RenderPop();
}
Ejemplo n.º 5
0
Properties GameObject::getProperties(void)
{
	Mtx44 overall;
	overall.SetToIdentity();

	TRS.modelProperties = overall * TRS.translation * TRS.rotation * TRS.scale;

	return TRS;
}
Ejemplo n.º 6
0
void SceneSkyBox::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();

	Position lightPosition_cameraspace = viewStack.Top() * light[0].position;
	glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);


	RenderMesh(meshList[GEO_AXES], false);

	modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	/*modelStack.PushMatrix();
	modelStack.Scale(10, 10, 10);
	RenderMesh(meshList[GEO_QUAD], false);
	modelStack.PopMatrix();*/
	//Loads the Skybox
	RenderSkyBox();
	//Mario
	modelStack.PushMatrix();
	modelStack.Scale(10, 10, 10);
	modelStack.Translate(0.0f, 1.f, -0.4f);
	modelStack.Rotate(90, 0.f, 1.f, 0.f);
	modelStack.Rotate(90, 0.f, 0.f, 1.f);
	RenderMesh(meshList[GEO_MARIO], false);
	modelStack.PopMatrix();


}
Ejemplo n.º 7
0
void CCharacter::Init(const Vector3& pos, const Vector3& target, const Vector3& up)
{
	this->setTranslate(pos);
	this->setScale(Vector3(1,1,1));
	Mtx44 R;
	R.SetToIdentity();
	this->setRotate(R);
	this->m_CurrentWeapon = NULL;
	this->health = 100;

	m_camera.Init(pos, target, up);
}
Ejemplo n.º 8
0
Mtx44 Camera::GetRotationMatrix(bool x, bool y, bool z) const
{
	Mtx44 rotationMatrix;
	rotationMatrix.SetToIdentity();
	if(z)
	{
		rotationMatrix = rotationMatrix * transform.rotate.MatrixZ();
	}
	if(y)
	{
		rotationMatrix = rotationMatrix * transform.rotate.MatrixY();
	}
	if(x)
	{
		rotationMatrix = rotationMatrix * transform.rotate.MatrixX();
	}
	return rotationMatrix;
}
Ejemplo n.º 9
0
void MAINMENU::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();
	float i = 3;
	for (st = menuList.rbegin(); st != menuList.rend(); ++st)
	{ 
		RenderTextOnScreen(meshList[TEXT], *st, Color(1, 1, 1), 3, 3, i ++);
	}
	if (c_UserInterface::GetEnum()->UI == START)
	{
		RenderTextOnScreen(meshList[TEXT], ">", Color(1, 1, 1), 3, 2, 5);
	}
	if (c_UserInterface::GetEnum()->UI == OPTIONS)
	{
		RenderTextOnScreen(meshList[TEXT], ">", Color(1, 1, 1), 3, 2, 4);
	}
	if (c_UserInterface::GetEnum()->UI == EXIT)
	{
		RenderTextOnScreen(meshList[TEXT], ">", Color(1, 1, 1), 3, 2, 3);
	}
}
Ejemplo n.º 10
0
void PLANET3::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();

	Position lightPosition_cameraspace = viewStack.Top() * light[0].position;
	glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);
	Vector3 lightDir(light[1].position.x, light[1].position.y, light[1].position.z);
	Vector3 lightDirection_cameraspace2 = viewStack.Top() * lightDir;
	glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightDirection_cameraspace2.x);


	RenderMesh(meshList[GEO_AXES], false);

	modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	RenderSkyBox();
}
Ejemplo n.º 11
0
void Assignment1::Render()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	Mtx44 translate, rotate, scale;
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;
	Mtx44 MVP;

	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();
	view.SetToIdentity(); //no need camera for now, set it at World's origin
	projection.SetToOrtho(-40, 40, -30, 30, -10, 10); //Our world is a cube defined by these boundaries
	glEnableVertexAttribArray(0);
	glEnableVertexAttribArray(1);

	for (int i = 0; i < 100; i++)
	{
		//Blood Rain
		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		scale.SetToScale(0.2, 1, 0);
		rotate.SetToRotation(0, 0, 0, 1);
		translate.SetToTranslation(rainpositionx[i], rainpositiony[i], 1);
		model = translate * rotate * scale;
		MVP = projection * view * model;
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
		glDrawArrays(GL_TRIANGLES, 0, 6);
	}

	//Bird Body
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_BIRD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BIRD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX2 + 3, 15, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//Bird Beak
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_BIRD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BIRD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(2, 1, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX2 + 6, 15, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//Bird Body 2
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_BIRD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BIRD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX2 + 9, 10, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//Bird Beak 2
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_BIRD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BIRD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(2, 1, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX2 + 12, 10, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//Moon
	for (int numTriangles = 0; numTriangles < 360; numTriangles++)
	{
		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_1]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_1]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		scale.SetToScale(scaleAll, scaleAll, 0);
		rotate.SetToRotation(static_cast<float>(numTriangles), 0, 0, 1);
		translate.SetToTranslation(35, 25, 0);
		model = translate * rotate * scale; //scale, followed by rotate, then lastly translate
		MVP = projection * view * model; // Remember, matrix multiplication is the other way round
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
		glDrawArrays(GL_TRIANGLES, 0, 3);
	}

	//Cloud
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX - 17, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 2
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX - 11, 18, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 3
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 4
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX + 6, 18, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 5
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX + 17, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 6
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX + 23, 18, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 7
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX + 34, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Cloud 8
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CLOUD]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CLOUD]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(11, 5, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX + 40, 18, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Black Square (Main Body)
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(33, 30, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-20, -30, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Black Rectangle above main body	
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(30, 14, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-18, 0, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Black triangle (right)	
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(20, 15, 0);
	rotate.SetToRotation(90, 0, 0, 1);
	translate.SetToTranslation(28, -6, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//Black triangle (left)	
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(15, 20, 0);
	rotate.SetToRotation(180, 0, 0, 1);
	translate.SetToTranslation(-20, 14, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//small square for roof
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(15, 25, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(10, -30, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//small square (left)
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(15, 25, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-30, -30, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//small square (right)
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(10, 10, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(0, 10, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Black triangle for roof	
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(15, 15, 0);
	rotate.SetToRotation(315, 0, 0, 1);
	translate.SetToTranslation(-5.5, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 3);

	//DOOR
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(10, 20, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-8, -30, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Window 1
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-14, -10, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Window 2
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-14, -15, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Window 3
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-19, -15, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Window 4
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-19, -10, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//long window 1
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 10, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(5, -20, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//long window 2
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_DOOR]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_DOOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	scale.SetToScale(3, 10, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(9, -20, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
	glDrawArrays(GL_TRIANGLES, 0, 6);

	//Grass
	for (int numTriangles = -40; numTriangles < 40; numTriangles++)
	{
		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_TRIANGLE_2]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TRIANGLE_2]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		scale.SetToScale(3, 3, 0);
		rotate.SetToRotation(rotateAngle, 0, 0, 1);
		translate.SetToTranslation(static_cast<float>(numTriangles), -30, 0);
		model = translate * rotate * scale; //scale, followed by rotate, then lastly translate
		MVP = projection * view * model; // Remember, matrix multiplication is the other way round
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); //update the shader with the new mvp
		glDrawArrays(GL_TRIANGLES, 1, 3);
	}

	glDisableVertexAttribArray(1);
	glDisableVertexAttribArray(0);
}
Ejemplo n.º 12
0
void Assignment3::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//Temp variables
	Mtx44 translate, rotate, scale;
	Mtx44 MVP;

	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	//Set all matrices to identity
	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();

	//Set view matrix using camera settings
	viewStack.LoadIdentity();
	viewStack.LookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 10000.0f); //FOV, Aspect Ratio, Near plane, Far plane
	lighting();
	lighting2();
	modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	modelStack.Scale(0.1f, 0.1f, 0.1f);
	renderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();
	

	/*modelStack.PushMatrix();
	renderMesh(meshList[GEO_AXES], false);
	modelStack.PopMatrix();*/

	modelStack.PushMatrix();
	modelStack.Translate(boxX, 496.9, boxZ);
	RenderSkybox();
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(snowWallCoord.x, 0, snowWallCoord.z);
	modelStack.Rotate(-90, 0, 1, 0);
	//modelStack.Scale(10, 10, 10);
	renderMesh(meshList[GEO_SNOWWALL], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(snowBallCoord.x, snowBallCoord.y, snowBallCoord.z);
	modelStack.Scale(0.2, 0.2, 0.2);
	renderMesh(meshList[GEO_SNOWBALLPILE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(snowBallCoord1.x, snowBallCoord1.y, snowBallCoord1.z);
	modelStack.Scale(0.2, 0.2, 0.2);
	renderMesh(meshList[GEO_SNOWBALLPILE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(snowBallCoord2.x, snowBallCoord2.y, snowBallCoord2.z);
	modelStack.Scale(0.2, 0.2, 0.2);
	renderMesh(meshList[GEO_SNOWBALLPILE], true);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(snowBallCoord5.x, snowBallCoord5.y, snowBallCoord5.z);
	modelStack.Scale(0.2, 0.2, 0.2);
	renderMesh(meshList[GEO_SNOWBALLPILE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(snowBallCoord6.x, snowBallCoord6.y, snowBallCoord6.z);
	modelStack.Scale(0.2, 0.2, 0.2);
	renderMesh(meshList[GEO_SNOWBALLPILE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(robbyCoord.x, robbyCoord.y, robbyCoord.z);
	modelStack.Scale(0.5, 0.5, 0.5);
	modelStack.Rotate(robbyRotate, 0, 1, 0);
	modelStack.Rotate(-90, 0, 1, 0);
	renderMesh(meshList[GEO_ROBBY], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(0, -1, 0);
	modelStack.Rotate(-90, 0, 1, 0);
	modelStack.Scale(1500, 1500, 1500);
	renderMesh(meshList[GEO_BOTTOM], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(snowBarricadeCoord.x, snowBarricadeCoord.y, snowBarricadeCoord.z);
	renderMesh(meshList[GEO_SNOWBARRICADE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	//modelStack.Translate(snowBarricadeCoord.x, snowBarricadeCoord.y, snowBarricadeCoord.z);
	modelStack.Scale(7.5, 7.5, 7.5);
	renderMesh(meshList[GEO_SNOWFORT], true);
	modelStack.PopMatrix();

	if (throwSnowball == true)
	{
		modelStack.PushMatrix();
		modelStack.Translate(ballCoord.x, ballCoord.y, ballCoord.z);
		modelStack.Scale(0.2, 0.2, 0.2);
		renderMesh(meshList[GEO_SPHERE], true);
		modelStack.PopMatrix();
	}
	

	std::stringstream playerPos;
	playerPos << "X = " << camPosX << " Y = " << camPosY << " Z = " << camPosz;
	//RenderTextOnScreen(meshList[GEO_TEXT], playerPos.str(), Color(1, 0, 0), 2, 0, 18);
	std::stringstream ss;
	ss << "FPS:" << fps<<"         "<<playerPos.str();
	RenderTextOnScreen(meshList[GEO_TEXT], ss.str(), Color(0, 1, 0), 3, 0, 19);
	std::stringstream snowballcount;
	snowballcount << "Snow Ball Count: " << snowBallCount;
	RenderTextOnScreen(meshList[GEO_TEXT], snowballcount.str(), Color(0, 1, 0), 3, 0, 1);
	
	if (showdialog1 == true)
	{
		RenderTextOnScreen(meshList[GEO_TEXT], "Hi Pingu, can you get me 1 snowball?", Color(1, 0, 1), 2, 0, 15);
	}
	if (showdialog2 == true)
	{
		RenderTextOnScreen(meshList[GEO_TEXT], "Thank You!", Color(1, 0, 1), 2, 0, 15);
	}
	if (showdialog3 == true || showdialog5 == true || showdialog7 == true || showdialog13 == true || showdialog15 == true)
	{
		RenderTextOnScreen(meshList[GEO_TEXT], "Gained 1 Snow Ball, Max capacity", Color(1, 0, 1), 2, 0, 15);
	}
	if (showdialog4 == true || showdialog6 == true || showdialog8 == true || showdialog14 == true || showdialog16 == true)
	{
		RenderTextOnScreen(meshList[GEO_TEXT], "You can only hold 1 Snow Ball!", Color(1, 0, 1), 2, 0, 15);
	}
	if (isHit == true)
	{
		RenderTextOnScreen(meshList[GEO_TEXT], "NICE SHOT", Color(1, 0, 1), 3, 0, 18);
	}
}
Ejemplo n.º 13
0
void PLANET5::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	model.SetToIdentity();
	//Set view matrix using camera settings
	view.SetToLookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane


	viewStack.LoadIdentity();
	viewStack.LookAt(camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z);
	modelStack.LoadIdentity();

	Position lightPosition_cameraspace = viewStack.Top() * light[0].position;
	glUniform3fv(m_parameters[U_LIGHT0_POSITION], 1, &lightPosition_cameraspace.x);
	Vector3 lightDir(light[1].position.x, light[1].position.y, light[1].position.z);
	Vector3 lightDirection_cameraspace2 = viewStack.Top() * lightDir;
	glUniform3fv(m_parameters[U_LIGHT1_POSITION], 1, &lightDirection_cameraspace2.x);


	RenderMesh(meshList[GEO_AXES], false);

	/*modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	RenderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	/*	modelStack.PushMatrix();
	modelStack.Translate(0.f, 0.f, 0.f);
	RenderMesh(meshList[ASTEROID], false);
	modelStack.PopMatrix();*/

	std::ostringstream fps;
	fps << camera.position.x << " " << camera.position.y << " " << camera.position.z;
	std::ostringstream fpss;
	fpss << camera.target.x << " " << camera.target.y << " " << camera.target.z;
	RenderSkyBox();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, -35.0f, 0.f);
	modelStack.Rotate(rotatespin - 45, 0, 1, 0);
	modelStack.Scale(22.0f, 24.0f, 22.0f);
	RenderMesh(meshList[SPIN], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, 8.0f, 0.f);
	modelStack.Scale(10.0f, 10.f, 10.f);
	RenderMesh(meshList[SPINCAP], false);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(5.0f, translateButton - 6.f, 43.5f);
	modelStack.Rotate(25.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(5.0f, -6.0f, 45.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	//////////////////////GEMS ARE OUTRAGREOUS//////////////////////////


	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, translategem1 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, flygem1, -90.0f);
	modelStack.Rotate(rotategem1, 0, 1, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-50.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, translategem2 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, flygem2, -90.0f);
	modelStack.Rotate(rotategem2, 0, 1, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM2], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-25.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();



	modelStack.PushMatrix();
	modelStack.Translate(0.0f, translategem3 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, flygem3, -90.0f);
	modelStack.Rotate(rotategem3, 0, 1, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM3], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(25.0f, translategem4 - 5.7f, -81.5f);
	modelStack.Rotate(22.0f, 1, 0, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[BUTTON], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(25.0f, -6.0f, -80.0f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(2.0f, 2.0f, 2.0f);
	RenderMesh(meshList[BUTTONSTAND], false);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(25.0f, flygem4, -90.0f);
	modelStack.Rotate(rotategem4, 0, 2, 0);
	modelStack.Scale(2.f, 3.0f, 2.f);
	RenderMesh(meshList[GEM4], true);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(25.0f, -5.0f, -90.0f);
	modelStack.Scale(2.f, 2.0f, 2.f);
	RenderMesh(meshList[GEMCASE], true);
	modelStack.PopMatrix();
	//////////////////////THEY ARE TRULY, TRULY, TRULY OUTRAGREOUS//////////////////////////


	modelStack.PushMatrix();
	modelStack.Translate(-10.0f, translateEND, -123.0f);
	modelStack.Scale(scaleFinish, scaleFinish, scaleFinish);
	RenderMesh(meshList[END], true);
	modelStack.PopMatrix();


	modelStack.PushMatrix();
	modelStack.Translate(124.0f, 12.0f, -40.f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(124.0f, 12.0f, 40.f);
	modelStack.Rotate(-90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-124.0f, 12.0f, -40.f);
	modelStack.Rotate(90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(-124.0f, 12.0f, 40.f);
	modelStack.Rotate(90.0f, 0, 1, 0);
	modelStack.Scale(10.0f, 10.0f, 3.0f);
	RenderMesh(meshList[PICFRAME], false);
	modelStack.PopMatrix();

	RenderHandOnScreen();

	RenderTextOnScreen(meshList[POSITION], fps.str(), Color(0, 1, 1), 3, 10, 10);
	RenderTextOnScreen(meshList[POSITION], fpss.str(), Color(0, 1, 1), 3, 10, 7);

}
Ejemplo n.º 14
0
void Assignment1::Render()
{
	// Render VBO here
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	Mtx44 translate, rotate, scale;
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;
	Mtx44 MVP;

	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();
	view.SetToIdentity();

	projection.SetToOrtho(-40, 40, -30, 30, -10, 10);

	glEnableVertexAttribArray(0);// 1st attribute buffer: vertices 
	glEnableVertexAttribArray(1); // 2nd attribute buffer : colors
	//<landscape>
	scale.SetToScale(125, 125, 125);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(0,-125,1);
	model = translate * rotate * scale; 
	MVP = projection * view * model; 
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 5);

	model.SetToIdentity();

	scale.SetToScale(20, 20, 20);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(25, 0, 0);
	model = translate * rotate * scale; 
	MVP = projection * view * model; 
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 5);

	model.SetToIdentity();

	scale.SetToScale(50, 20, 20);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(10, -5, -0.5);
	model = translate * rotate * scale; 
	MVP = projection * view * model; 
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); 
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[LANDSCAPE_1]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 5);
	//</landscape>

	//<cloud>
	scale.SetToScale(10, 10, 10);
	rotate.SetToRotation(25, 0, 0, 1);
	translate.SetToTranslation(cloudMovement , 25, 0.5f);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CLOUDS_2]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CLOUDS_2]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 12);

	//</cloud>
	//<sun>
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(rotateAngle, 0, 0, 1);
	translate.SetToTranslation(-25, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[SUN_3]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[SUN_3]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 9);
	
	//</sun>
	//<explosion>
	scale.SetToScale(explosionSize, explosionSize, explosionSize);
	rotate.SetToRotation(explosionRotation, 0, 0, 1);
	translate.SetToTranslation(-25, 20, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[EXPLOSION_4]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[EXPLOSION_4]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLES, 0, 12);
	//</explosion>
	//<cactus>
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-25, 0, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CACTUS_5]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CACTUS_5]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 13);

	model.SetToIdentity();

	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(15, -5, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CACTUS_5]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CACTUS_5]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 13);

	model.SetToIdentity();

	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(7, 5, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CACTUS_5]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CACTUS_5]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 13);

	model.SetToIdentity();
	
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(180, 0, 1, 0);
	translate.SetToTranslation(25, 0, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CACTUS_5]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CACTUS_5]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 13);
	

	model.SetToIdentity();

	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(180, 0, 1, 0);
	translate.SetToTranslation(-15, -5, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CACTUS_5]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CACTUS_5]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 13);

	model.SetToIdentity();

	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(180, 0, 1, 0);
	translate.SetToTranslation(-7, 5, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]);
	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[CACTUS_5]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[CACTUS_5]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glDrawArrays(GL_TRIANGLE_FAN, 0, 13);
	//</cactus>
	glDisableVertexAttribArray(0);
	glDisableVertexAttribArray(1);
}
Ejemplo n.º 15
0
void SceneLight2::Render()
{
	// Render VBO here
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//Temp variables
	Mtx44 translate, rotate, scale;
	Mtx44 MVP;

	//These will be replaced by matrix stack soon
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;

	//Set all matrices to identity
	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();

	//Set view matrix using camera settings
	viewStack.LoadIdentity();
	viewStack.LookAt(
		camera.position.x, camera.position.y, camera.position.z,
		camera.target.x, camera.target.y, camera.target.z,
		camera.up.x, camera.up.y, camera.up.z
		);

	//Set projection matrix to perspective mode
	projection.SetToPerspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.0f); //FOV, Aspect Ratio, Near plane, Far plane
	lighting();
	lighting2();
	modelStack.PushMatrix();
	modelStack.Translate(light[0].position.x, light[0].position.y, light[0].position.z);
	modelStack.Scale(0.5f, 0.5f, 0.5f);
	renderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(light[1].position.x, light[1].position.y, light[1].position.z);
	modelStack.Scale(0.5f, 0.5f, 0.5f);
	renderMesh(meshList[GEO_LIGHTBALL], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0, 0, 0);
	renderMesh(meshList[GEO_SPHERE], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(2, 0, 0);
	renderMesh(meshList[GEO_SPHERE1], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(-2, 0, 0);
	renderMesh(meshList[GEO_SPHERE2], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(2, 0, 2);
	renderMesh(meshList[GEO_SPHERE3], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(-2, 0, 2);
	renderMesh(meshList[GEO_SPHERE4], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(0, 0, 2);
	renderMesh(meshList[GEO_SPHERE5], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(0, 0, -2);
	renderMesh(meshList[GEO_SPHERE6], true);
	modelStack.PopMatrix();
	modelStack.PushMatrix();
	modelStack.Translate(2, 0, -2);
	renderMesh(meshList[GEO_SPHERE7], true);
	modelStack.PopMatrix();
	/*modelStack.PushMatrix();
	modelStack.Translate(-2, 0, -2);
	renderMesh(meshList[GEO_CYLINDER], true);
	modelStack.PopMatrix();*/

	//modelStack.PopMatrix();
	modelStack.PushMatrix();
	renderMesh(meshList[GEO_AXES], false);
	modelStack.PopMatrix();

	modelStack.PushMatrix();
	modelStack.Translate(0, -1, 0);
	modelStack.Scale(10, 10, 10);
	renderMesh(meshList[GEO_QUAD], true);
	modelStack.PopMatrix();
}
Ejemplo n.º 16
0
void Assignment1::Render()
{
	// Clear color buffer & depth every frame
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	Mtx44 translate, rotate, scale;
	Mtx44 model;
	Mtx44 view;
	Mtx44 projection;
	Mtx44 MVP;

	translate.SetToIdentity();
	rotate.SetToIdentity();
	scale.SetToIdentity();
	model.SetToIdentity();
	view.SetToIdentity(); // no need camera for now, set it at World's origin
	projection.SetToOrtho(-40, +40, -30, +30, -10, +10); // Our world is a cube defined by these boundaries
	glEnableVertexAttribArray(0); // 1st attribute buffer : vertices
	glEnableVertexAttribArray(1); // 2nd attribute buffer : colors
	////////////////////This Section Places the Objects////////////////////
	//Ground();
	{
		scale.SetToScale(50, 50, 50);
		rotate.SetToRotation(0, 0, 0, 1);
		translate.SetToTranslation(-40, -48, -1);
		model = translate * rotate * scale;
		MVP = projection * view * model;
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_RECTANGLE]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		// Draw the Rectangle
		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

		scale.SetToScale(50, 50, 50);
		rotate.SetToRotation(0, 0, 0, 1);
		translate.SetToTranslation(-40, -60, -0);
		model = translate * rotate * scale;
		MVP = projection * view * model;
		glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

		glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
		glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
		glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BLUECOLOR]);
		glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
		// Draw the Rectangle
		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	}
/////////////////////////////////////////////////////////////////////////////////
	//Mountains();
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-40, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3); 

	
	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-36, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-32, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	//Mountains();
	scale.SetToScale(8, 8, 8);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-30, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	scale.SetToScale(7, 7, 7);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-25, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-18,-9 , -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(9, 9, 9);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-16, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);


	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-3, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(7, 7, 7);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(3, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(4, 4, 4);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(12, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	
	scale.SetToScale(8, 8, 8);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(17, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(28, -9, -2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Tower HP bar
	scale.SetToScale(3, 3, 3);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(29, -23, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_LINE_LOOP, 0, 4);
	//till here 

	scale.SetToScale(3, 3, 3);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(29, -23, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_REDCOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	//till here 
/////////////////////////////////////////////////////////////////////////////////////////////////////////

	//Tower 1
	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(8, -20, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TOWER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	//till here 

	scale.SetToScale(3, 3, 3);
	rotate.SetToRotation(62, 0, 0, 1);
	translate.SetToTranslation(11, -6, 3);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_REDCOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	//till here 

	scale.SetToScale(2, 2, 2);
	rotate.SetToRotation(62, 0, 0, 1);
	translate.SetToTranslation(11, -6, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	//till here 

	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(90, 0, 0, 1);
	translate.SetToTranslation(16, -19, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TOWER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	//till here 


	scale.SetToScale(6, 2, 6);
	rotate.SetToRotation(225, 0, rotateAngle, 1);
	translate.SetToTranslation(10, -2.5, 0);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_REDCOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	scale.SetToScale(6, 6, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(14, 0, 3);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CIRCLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CIRCLE]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 36);
	//till here 
////////////////////////////////////////////////////////////////////////////////////////////////////
	//Tower 2
	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(28, -20, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TOWER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);
	//till here 

	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(90, 0, 0, 1);
	translate.SetToTranslation(35, -19, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TOWER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
	//till here 

	scale.SetToScale(6, 6, 6);
	rotate.SetToRotation(90, 0, 0, 1);
	translate.SetToTranslation(38, -19, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TOWER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	scale.SetToScale(3, 3, 3);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(33, -2, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_TOWER]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(3, 3, 3);
	rotate.SetToRotation(180 , 0, 0, 1);
	translate.SetToTranslation(37, -10, 2);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_REDCOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(1.5, 1.5, 1.5);
	rotate.SetToRotation(180, 0, 0, 1);
	translate.SetToTranslation(35.5, -11, 3);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_YELLOWCOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(1, 1, 1);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(35.1, -10, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

	scale.SetToScale(1, 1, 1);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(31, -10, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLES, 0, 3);

/////////////////////////////////////////////////////////////////////////
	//Stickman()
	scale.SetToScale(5, 5, 5);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-25, -15, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_STICKMAN]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_REDCOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_LINE_LOOP, 0, 20);


	scale.SetToScale(2, 2, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-25, -13, 5);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_CIRCLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_CIRCLE]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 36);
	//till here 

	//Magic arrows
	scale.SetToScale(1, 1, 6);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX, -15.5, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BLUECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	scale.SetToScale(1, 1, 6);
	rotate.SetToRotation(270, 0, 0, 1);
	translate.SetToTranslation(translateX, -14, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BLUECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	scale.SetToScale(1, 1, 6);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(translateX, -13.5, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_RECTANGLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BLUECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	scale.SetToScale(1, 1, 6);
	rotate.SetToRotation(270, 0, 0, 1);
	translate.SetToTranslation(translateX, -12, 1);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_MOUNTAINS]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_BLUECOLOR]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

	//Clouds

	scale.SetToScale(3,3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-7, 15, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_WHITECIRCLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECIRCLE]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 36);
	//till here 

	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-10, 15, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_WHITECIRCLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECIRCLE]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 36);
	//till here 

	scale.SetToScale(3, 3, 0);
	rotate.SetToRotation(0, 0, 0, 1);
	translate.SetToTranslation(-4, 15, 4);
	model = translate * rotate * scale;
	MVP = projection * view * model;
	glUniformMatrix4fv(m_parameters[U_MVP], 1, GL_FALSE, &MVP.a[0]); // update the shader with new MVP

	glBindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer[GEO_WHITECIRCLE]);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
	glBindBuffer(GL_ARRAY_BUFFER, m_colorBuffer[GEO_WHITECIRCLE]);
	glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
	// Draw the Triangles
	glDrawArrays(GL_TRIANGLE_FAN, 0, 36);
	//till here 


 
	/*---------------------------------------------------------------------------------------------------------*/
	glDisableVertexAttribArray(1);
	glDisableVertexAttribArray(0);

}
Ejemplo n.º 17
0
MS::MS() {
	Mtx44 mat;
	mat.SetToIdentity();
	ms.push(mat);
}
Ejemplo n.º 18
0
void MS::LoadIdentity() {
	Mtx44 mat;
	mat.SetToIdentity();
	ms.top() = mat;
}