Ejemplo n.º 1
0
	bool TextureOverlay::CreateGeometry()
	{
		m_pGeometry						= m_pRenderManager->CreateGeometryData();
		if(m_pGeometry == nullptr)
		{
			return false;
		}

		struct Vertex
		{
			math::Vector3			pos;
			math::Vector2			uv;
		};
		Vertex verts[] = 
		{
			{math::Vector3(0, 0, 0),		math::Vector2(0, 0)},
			{math::Vector3(1, 0, 0),		math::Vector2(1, 0)},
			{math::Vector3(1, 1, 0),		math::Vector2(1, 1)},
			{math::Vector3(0, 1, 0),		math::Vector2(0, 1)},
			{math::Vector3(0, 0, 0),		math::Vector2(0, 0)},
			{math::Vector3(1, 1, 0),		math::Vector2(1, 1)},
		};

		VertexLayout layout;
		layout.AddAttribute(G_FORMAT_R32G32B32_FLOAT);
		layout.AddAttribute(G_FORMAT_R32G32_FLOAT);

		m_pGeometry->BeginGeometry(PT_TRIANGLE_LIST);
		{
			m_pGeometry->AllocVertexBuffer(sizeof(Vertex) * 6, verts, false, layout);
		}

		m_pGeometry->EndGeometry();
		return true;
	}
Ejemplo n.º 2
0
//----------------------------------------------------------------------
bool FontManager::Initialise(const glm::ivec2& screenResolution)
{
  this->screenResolution = screenResolution;

  if (!effect.Load("assets\\effects\\fonteffect.glsl", "RenderFont"))
  {
    LOG("did not load font rendering effect\n");
    return false;
  }
  // Since the screen resolution does not change at runtime, set this now...
  effect.ScreenSize->Set(glm::vec2(screenResolution));
  effect.GlyphTexture->Set(GlyphTextureSlot);

  sampler = boost::make_shared<Sampler2D>();
  sampler->SetMagFilter(GL_LINEAR);
  sampler->SetMinFilter(GL_LINEAR);
  sampler->SetWrapS(GL_CLAMP_TO_EDGE);
  sampler->SetWrapT(GL_CLAMP_TO_EDGE);

  VertexLayout vertexLayout;
  vertexLayout.AddAttribute(vertexAttribute);

  // Initialise vertex buffers for dynamic update...
  for (size_t i = 0; i < bufferCount; ++i)
  {
    boost::shared_ptr<VertexBuffer> vertexBuffer(new VertexBuffer());
    vertexBuffer->Initialise(vertexLayout, VerticesInBuffer, GL_DYNAMIC_DRAW);
    geometry[i].Initialise(vertexBuffer);
  }

  return true;
}
Ejemplo n.º 3
0
		bool Impl_SkyDome::CreateSkyDome()
		{
			std::vector<math::Vector3>	vb;
			std::vector<uint32>			ib;
			MeshUtil::CreateUnitIcoSphere(5, vb, ib, true);

			if(vb.size() == 0)
			{
				return false;
			}

			VertexLayout layout;
			layout.AddAttribute(G_FORMAT_R32G32B32_FLOAT);

			m_pRD = m_pManager->alloc_object<RenderData>();

			m_pRD->geometry = m_pManager->GetRenderManager()->CreateGeometryData();

			m_pRD->geometry->BeginGeometry(PT_TRIANGLE_LIST);
			{
				if(false == m_pRD->geometry->AllocVertexBuffer(sizeof(math::Vector3) * vb.size(), vb.data(), false, layout))
				{
					return false;
				}
				if(false == m_pRD->geometry->AllocIndexBuffer(sizeof(uint32) * ib.size(), ib.data(), false, G_FORMAT_R32_UINT))
				{
					return false;
				}
			}
			m_pRD->geometry->EndGeometry();

			m_pRD->base_vertex = 0;
			m_pRD->vertex_count = vb.size();
			
			m_pRD->start_index = 0;
			m_pRD->index_count = ib.size();
			m_pRD->world_matrix.MakeIdentity();

			m_pRD->material = m_pManager->GetRenderManager()->CreateMaterialFromFile("./assets/atmosphere/material/skydome.material");

			m_pWorldPos = m_pRD->material->GetParameterByName("world_pos");
			return true;
		}
Ejemplo n.º 4
0
	GeometryDataPtr EngineApp::CreateCube(float size)
	{
		struct Vertex
		{
			math::Vector3 pos;
			math::Vector3 normal;
			math::Vector2 uv;
			
		};

		size = size / 2.0f;
		Vertex pVerts[] = 
		{
			// front
			{math::Vector3(-size, size, -size), math::Vector3(0, 0, -1), math::Vector2(0, 0), },
			{math::Vector3(size, size, -size), math::Vector3(0, 0, -1), math::Vector2(2, 0),},
			{math::Vector3(size, -size, -size), math::Vector3(0, 0, -1), math::Vector2(2, 2),},
			{math::Vector3(-size, -size, -size), math::Vector3(0, 0, -1), math::Vector2(0, 2),},

			// back
			{math::Vector3(-size, size, size), math::Vector3(0, 0, 1), math::Vector2(0, 0),},
			{math::Vector3(size, size, size), math::Vector3(0, 0, 1), math::Vector2(1, 0),},
			{math::Vector3(size, -size, size), math::Vector3(0, 0, 1), math::Vector2(1, 1),},
			{math::Vector3(-size, -size, size), math::Vector3(0, 0, 1), math::Vector2(0, 1),},

			// top
			{math::Vector3(-size, size, size), math::Vector3(0, 1, 0), math::Vector2(0, 0),},
			{math::Vector3(size, size, size), math::Vector3(0, 1, 0), math::Vector2(1, 0),},
			{math::Vector3(size, size, -size), math::Vector3(0, 1, 0), math::Vector2(1, 1),},
			{math::Vector3(-size, size, -size), math::Vector3(0, 1, 0), math::Vector2(0, 1),},
			// bottom
			{math::Vector3(-size, -size, size), math::Vector3(0, -1, 0), math::Vector2(0, 0),},
			{math::Vector3(size, -size, size), math::Vector3(0, -1, 0), math::Vector2(1, 0),},
			{math::Vector3(size, -size, -size), math::Vector3(0, -1, 0), math::Vector2(1, 1),},
			{math::Vector3(-size, -size, -size), math::Vector3(0, -1, 0), math::Vector2(0, 1),},

			// left
			{math::Vector3(-size, size, size), math::Vector3(-1, 0, 0), math::Vector2(0, 0),},
			{math::Vector3(-size, size, -size), math::Vector3(-1, 0, 0), math::Vector2(1, 0),},
			{math::Vector3(-size, -size, -size), math::Vector3(-1, 0, 0), math::Vector2(1, 1),},
			{math::Vector3(-size, -size, size), math::Vector3(-1, 0, 0), math::Vector2(0, 1),},
			// right
			{math::Vector3(size, size, size), math::Vector3(1, 0, 0), math::Vector2(0, 0),},
			{math::Vector3(size, size, -size), math::Vector3(1, 0, 0), math::Vector2(1, 0),},
			{math::Vector3(size, -size, -size), math::Vector3(1, 0, 0), math::Vector2(1, 1),},
			{math::Vector3(size, -size, size), math::Vector3(1, 0, 0), math::Vector2(0, 1),},
		};

		uint32 pIndice[] = 
		{
			// front
			0, 1, 2,
			0, 2, 3,

			// back
			4, 6, 5, 
			4, 7, 6,


			//top
			8, 9, 10,
			8, 10, 11,

			// bottom
			12, 14, 13,
			12, 15, 14,

			// left
			16, 17, 18,
			16, 18, 19,

			// right
			20, 22, 21,
			20, 23, 22,

		};

		GeometryDataPtr pGeom = m_pGraphics->CreateGeometryData();

		VertexLayout layout;
		layout.AddAttribute(G_FORMAT_R32G32B32_FLOAT);
		layout.AddAttribute(G_FORMAT_R32G32B32_FLOAT);
		layout.AddAttribute(G_FORMAT_R32G32_FLOAT);

		pGeom->BeginGeometry(PT_TRIANGLE_LIST);
		{
			pGeom->AllocIndexBuffer(sizeof(uint32) * 36, pIndice, false, G_FORMAT_R32_UINT);
			pGeom->AllocVertexBuffer(sizeof(Vertex) * 24, pVerts, false, layout);
		}
		pGeom->EndGeometry();

		return pGeom;
	}
Ejemplo n.º 5
0
	bool Impl_SkyBox::OnAttach()
	{
		m_pRD = m_pManager->alloc_object<RenderData>();

		
		VertexLayout layout;
		layout.AddAttribute(G_FORMAT_R32G32B32_FLOAT);
		
		float size = 1.0f;
		int nVerts = 36;

		math::Vector3 verts[] = 
		{
			math::Vector3(-size, size, -size),
			math::Vector3(size, -size, -size),
			math::Vector3(size, size, -size),

			math::Vector3(-size, size, -size),
			math::Vector3(-size, -size, -size),
			math::Vector3(size, -size, -size),

			math::Vector3(-size, size, size),
			math::Vector3(size, size, size),
			math::Vector3(size, -size, size),

			math::Vector3(-size, size, size),
			math::Vector3(size, -size, size),
			math::Vector3(-size, -size, size),


			math::Vector3(-size, size, size),
			math::Vector3(size, size, -size),
			math::Vector3(size, size, size),

			math::Vector3(-size, size, size),
			math::Vector3(-size, size, -size),
			math::Vector3(size, size, -size),


			math::Vector3(-size, -size, size),
			math::Vector3(size, -size, size),
			math::Vector3(size, -size, -size),

			math::Vector3(-size, -size, size),
			math::Vector3(size, -size, -size),
			math::Vector3(-size, -size, -size),


			math::Vector3(-size, size, size),
			math::Vector3(-size, -size, -size),
			math::Vector3(-size, size, -size),

			math::Vector3(-size, size, size),
			math::Vector3(-size, -size, size),
			math::Vector3(-size, -size, -size),


			math::Vector3(size, size, size),
			math::Vector3(size, size, -size),
			math::Vector3(size, -size, -size),

			math::Vector3(size, size, size),
			math::Vector3(size, -size, -size),
			math::Vector3(size, -size, size),

		};

		m_pRD->geometry = m_pManager->GetRenderManager()->CreateGeometryData();

		m_pRD->geometry->BeginGeometry(PT_TRIANGLE_LIST);
		{
			m_pRD->geometry->AllocVertexBuffer(sizeof(math::Vector3) * 36, verts, false, layout);
		}
		m_pRD->geometry->EndGeometry();

		m_pRD->base_vertex = 0;
		m_pRD->index_count = 0;
		m_pRD->start_index = 0;
		m_pRD->vertex_count = 36;
		m_pRD->world_matrix.MakeIdentity();

		m_pRD->material = m_pManager->GetRenderManager()->CreateMaterialFromFile("./assets/standard/material/skybox.material");

		m_hFrustumCull = m_pManager->AddEventHandler(EV_FRUSTUM_CULL, boost::bind(&Impl_SkyBox::on_event_frustum_cull, this, _1));


		m_pTex = m_pManager->GetRenderManager()->CreateTextureFromFile("./assets/standard/texture/001.dds");

		MaterialParameterPtr pParam = m_pRD->material->GetParameterByName("sky_map");
		
		pParam->SetParameterTexture(m_pTex);
		
		m_pWorldPos = m_pRD->material->GetParameterByName("world_pos");
		return true;
	}