// Convert sf::Transform to float array inline void createTransform(const sf::Transform& transform, float* converted) { const float* m = transform.getMatrix(); converted[0] = m[0]; converted[1] = m[4]; converted[2] = m[12]; converted[3] = m[1]; converted[4] = m[5]; converted[5] = m[13]; converted[6] = m[3]; converted[7] = m[7]; converted[8] = m[15]; }
inline void serialize(JsonBox::Value & o, const sf::Transform & t) { const float * v = t.getMatrix(); JsonBox::Array a; a.resize(16); for(u32 i = 0; i < 16; ++i) { a[i] = v[i]; } o = a; }
void Shader::setParameter(const std::string& name, const sf::Transform& transform) { if (m_shaderProgram) { ensureGlContext(); // Enable program GLhandleARB program = glGetHandleARB(GL_PROGRAM_OBJECT_ARB); glCheck(glUseProgramObjectARB(m_shaderProgram)); // Get parameter location and assign it new values GLint location = getParamLocation(name); if (location != -1) glCheck(glUniformMatrix4fvARB(location, 1, GL_FALSE, transform.getMatrix())); // Disable program glCheck(glUseProgramObjectARB(program)); } }