Beispiel #1
0
void CTexturedLineRData::Render(const SOverlayTexturedLine& line, const CShaderProgramPtr& shader)
{
	if (!m_VB || !m_VBIndices)
		return; // might have failed to allocate

	// -- render main line quad strip ----------------------

	const int streamFlags = shader->GetStreamFlags();

	shader->BindTexture("baseTex", line.m_TextureBase->GetHandle());
	shader->BindTexture("maskTex", line.m_TextureMask->GetHandle());
	shader->Uniform("objectColor", line.m_Color);

	GLsizei stride = sizeof(CTexturedLineRData::SVertex);
	CTexturedLineRData::SVertex* vertexBase = reinterpret_cast<CTexturedLineRData::SVertex*>(m_VB->m_Owner->Bind());

	if (streamFlags & STREAM_POS)
		shader->VertexPointer(3, GL_FLOAT, stride, &vertexBase->m_Position[0]);

	if (streamFlags & STREAM_UV0)
		shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, stride, &vertexBase->m_UVs[0]);

	if (streamFlags & STREAM_UV1)
		shader->TexCoordPointer(GL_TEXTURE1, 2, GL_FLOAT, stride, &vertexBase->m_UVs[0]);

	u8* indexBase = m_VBIndices->m_Owner->Bind();

	shader->AssertPointersBound();
	glDrawElements(GL_TRIANGLES, m_VBIndices->m_Count, GL_UNSIGNED_SHORT, indexBase + sizeof(u16)*m_VBIndices->m_Index); 

	g_Renderer.GetStats().m_DrawCalls++;
	g_Renderer.GetStats().m_OverlayTris += m_VBIndices->m_Count/3; 
}
Beispiel #2
0
int ShaderRenderModifier::BeginPass(int pass)
{
	m_Technique.BeginPass(pass);

	CShaderProgramPtr shader = m_Technique.GetShader(pass);

	if (GetShadowMap() && shader->HasTexture("shadowTex"))
	{
		shader->BindTexture("shadowTex", GetShadowMap()->GetTexture());
		shader->Uniform("shadowTransform", GetShadowMap()->GetTextureMatrix());

		const float* offsets = GetShadowMap()->GetFilterOffsets();
		shader->Uniform("shadowOffsets1", offsets[0], offsets[1], offsets[2], offsets[3]);
		shader->Uniform("shadowOffsets2", offsets[4], offsets[5], offsets[6], offsets[7]);
	}

	if (GetLightEnv())
	{
		shader->Uniform("ambient", GetLightEnv()->m_UnitsAmbientColor);
		shader->Uniform("sunDir", GetLightEnv()->GetSunDir());
		shader->Uniform("sunColor", GetLightEnv()->m_SunColor);
	}

	if (shader->HasTexture("losTex"))
	{
		CLOSTexture& los = g_Renderer.GetScene().GetLOSTexture();
		shader->BindTexture("losTex", los.GetTexture());
		// Don't bother sending the whole matrix, we just need two floats (scale and translation)
		shader->Uniform("losTransform", los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
	}

	m_BindingInstancingTransform = shader->GetUniformBinding("instancingTransform");
	m_BindingShadingColor = shader->GetUniformBinding("shadingColor");
	m_BindingObjectColor = shader->GetUniformBinding("objectColor");
	m_BindingPlayerColor = shader->GetUniformBinding("playerColor");

	return shader->GetStreamFlags();
}