Exemple #1
0
void Program::setUniform(int nLoc, uint32_t type, const mat3& value, bool forced)
{
	if (nLoc == -1) return;
	
	(void)type;
	assert(type == GL_FLOAT_MAT3);
	assert(loaded());
	
	if (forced || ((_mat3Cache.count(nLoc) == 0) || (_mat3Cache[nLoc] != value)))
	{
		_mat3Cache[nLoc] = value;
		glUniformMatrix3fv(nLoc, 1, 0, value.data());
	}
	
	checkOpenGLError("setUniform - mat3");
}
Exemple #2
0
void Program::setUniform(int nLoc, uint32_t type, const mat3& value, bool forced)
{
#if !defined(ET_CONSOLE_APPLICATION)
	if (nLoc == -1) return;
	
	(void)type;
	ET_ASSERT(type == GL_FLOAT_MAT3);
	ET_ASSERT(apiHandleValid());
	
	if (forced || ((_mat3Cache.count(nLoc) == 0) || (_mat3Cache[nLoc] != value)))
	{
		_mat3Cache[nLoc] = value;
		glUniformMatrix3fv(nLoc, 1, 0, value.data());
		checkOpenGLError("glUniformMatrix3fv");
	}
	
#endif
}
Exemple #3
0
vec3 eulerFromMatrix ( const mat3& m )
{
	const float * data = m.data ();
	vec3          angle;
	float		  c;
	
	angle.x = -asinf ( data [2] );
	c       =  cosf  ( angle.x  );

	if ( fabsf ( c ) > EPS )
	{
		angle.y = atan2f ( data [5] / c, data [8] / c );		// m12, m22
		angle.z = atan2f ( data [1] / c, data [0] / c );
	} 
	else
	{
		angle.y = 0.0f;
		angle.z = atan2f ( data [3], data [4] );
	}

	return angle;
}