void Graphics::setMatrix(ConstantLocation location, const mat4& value) { if (location.shaderType == -1) return; float floats[16]; for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { floats[y * 4 + x] = value.get(y, x); } } if (location.shaderType == 0) device->SetVertexShaderConstantF(location.reg.regindex, floats, 4); else device->SetPixelShaderConstantF(location.reg.regindex, floats, 4); }
mat4 mat4::operator*( const mat4& o ) const { mat4 res; #ifdef SLMATH_SIMD #define VTMP(i,j) SLMATH_MUL_PS( m_m128[i], SLMATH_LOAD_PS1(&o[j][i]) ) m128_t* const o128 = res.m128(); o128[0] = SLMATH_ADD_PS( SLMATH_ADD_PS(VTMP(0,0),VTMP(1,0)), SLMATH_ADD_PS(VTMP(2,0),VTMP(3,0)) ); o128[1] = SLMATH_ADD_PS( SLMATH_ADD_PS(VTMP(0,1),VTMP(1,1)), SLMATH_ADD_PS(VTMP(2,1),VTMP(3,1)) ); o128[2] = SLMATH_ADD_PS( SLMATH_ADD_PS(VTMP(0,2),VTMP(1,2)), SLMATH_ADD_PS(VTMP(2,2),VTMP(3,2)) ); o128[3] = SLMATH_ADD_PS( SLMATH_ADD_PS(VTMP(0,3),VTMP(1,3)), SLMATH_ADD_PS(VTMP(2,3),VTMP(3,3)) ); #undef VTMP #else // note: above SIMD-macro version works also on non-SIMD platforms, this is much faster if there is no SIMD support const vec4* const mp = &get(0); const vec4* const op = &o.get(0); vec4* const resp = res.v4(); MAT4_MUL_MAT4( resp, mp, op ); #endif SLMATH_VEC_ASSERT( check(res) ); return res; }
void RendererOpenGL::setModelMatrix(const mat4& model) { GraphicsDevice::setModelMatrix(model); if(m_activeShader) m_activeShader->setUniformMatrix("model", model.get()); }
void RendererOpenGL::setViewMatrix(const mat4& view) { GraphicsDevice::setViewMatrix(view); if(m_activeShader) m_activeShader->setUniformMatrix("view", view.get()); }
void RendererOpenGL::setProjectionMatrix(const mat4& projection) { GraphicsDevice::setProjectionMatrix(projection); if(m_activeShader) m_activeShader->setUniformMatrix("projection", projection.get()); }