Bug 581

Summary: gluUnProject multiplies matrices in wrong order
Product: [JogAmp] Jogl Reporter: Wade Walker <wwalker3>
Component: coreAssignee: Sven Gothel <sgothel>
Severity: normal CC: sgothel
Priority: ---    
Version: 2   
Hardware: All   
OS: all   
Type: --- SCM Refs:
cbc77718f01a8190e1a8aa0e9afdc2a3a3403358 7f85501bd448afc9ba52f6abbe5f049d673d824d
Workaround: ---

Description Wade Walker 2012-05-07 22:00:34 CEST
gluUnProject() and gluUnProject4() in ProjectFloat.java and ProjectDouble.java multiply the model and projection matrices in the wrong order.

This seems to be because calls to gluMultMatricesf() and __gluMultMatricesd() (which multiply in column-row order) were replaced by calls to FloatUtil.multMatrixf() and FloatUtil.multMatrixd() (which multiply in row-column order).

This problem appeared in RC6, and was first reported by user "lukej" on the forum at http://forum.jogamp.org/Problems-with-gluUnProject-td3954975.html.
Comment 1 Sven Gothel 2012-05-11 22:48:14 CEST

Fix regression of commit 
ProjectFloat Matrix Multiplication of gluUnProject(..) impl.

ProjectFloat's previous gluMultMatricesf(..) used row-major order,
but the replacement multMatrixf(..) uses column-major order (like OpenGL, ..).

Note: The replaced 'gluMultMatrixVecf' by multMatrixVecf() already
           used column-major order.

Fix: Reverse the arguments of matrix multiplication
    m1 x m2 -> m2 x m1
Comment 2 Sven Gothel 2012-05-12 04:13:49 CEST

Added further unit test w/ actual gluUnProject(..) usage.

Remark: FloatUtil's multMatrixf(..) does column-major multiplication,
i.e. expect the linear matrix layout to be in column order.

In case the implementation does not follow the above statement (you find a bug),
pls re-open this bug report.