SetModelMatrix calculates and sets the specified matrix with the model matrix for this panel
(gl *gls.GLS, mm *math32.Matrix4)
| 867 | |
| 868 | // SetModelMatrix calculates and sets the specified matrix with the model matrix for this panel |
| 869 | func (p *Panel) SetModelMatrix(gl *gls.GLS, mm *math32.Matrix4) { |
| 870 | |
| 871 | // Get scale of window (for HiDPI support) |
| 872 | sX, sY := Manager().win.GetScale() |
| 873 | |
| 874 | // Get the current viewport width and height |
| 875 | _, _, width, height := gl.GetViewport() |
| 876 | |
| 877 | // Compute common factors |
| 878 | fX := 2 * float32(sX) / float32(width) |
| 879 | fY := 2 * float32(sY) / float32(height) |
| 880 | |
| 881 | // Calculate the model matrix |
| 882 | // Convert pixel coordinates to standard OpenGL clip coordinates and scale the quad for the viewport |
| 883 | mm.Set( |
| 884 | fX*float32(p.width), 0, 0, fX*p.pospix.X-1, |
| 885 | 0, fY*float32(p.height), 0, 1-fY*p.pospix.Y, |
| 886 | 0, 0, 1, p.Position().Z, |
| 887 | 0, 0, 0, 1, |
| 888 | ) |
| 889 | } |
no test coverage detected