Exemplo n.º 1
0
void IGLUShaderVariable::operator= ( float2 val )
{
	// Check for a valid shader index
	if ( m_varIdx < 0 ) return;

	// Check for type mismatches
	if ( m_isAttribute )
	{
		AssignmentToAttribute( "vec2" );
		return;
	}
	if ( m_varType != GL_FLOAT_VEC2 && m_varType != GL_DOUBLE_VEC2 )
		TypeMismatch( "vec2" );
	
	// Ensure this program is currently bound, or setting shader values fails!
	m_parent->PushProgram();

	// For types of variable that can be assigned from our input value, assign them here
	if ( m_varType == GL_FLOAT_VEC2 )
		glUniform2fv( m_varIdx, 1, val.GetConstDataPtr() );
	if ( m_varType == GL_DOUBLE_VEC2 )
		glUniform2d( m_varIdx, val.X(), val.Y() );

	// We have a short "program stack" so make sure to pop off.
	m_parent->PopProgram();
}
Exemplo n.º 2
0
float PerspectiveCamera::GenerateRay( const float2& rasterSample, const float2& lensSample, Ray* ray )
{
	float3 ptRaster(rasterSample.X(), rasterSample.Y(), 0.0f);
	float3 ptCamera = TransformCoord(ptRaster, mRasterToCamera);

	ray->tMin = 0.0f;
	ray->tMax = Mathf::INFINITY;

	ray->Origin = Transform(float3(0,0,0), mCameraToWorld);
	ray->Direction = Normalize(TransformDirection(ptCamera, mCameraToWorld));
	
	return 1.0f;
}