MCPcopy Index your code
hub / github.com/g3n/engine / SetModelMatrix

Method SetModelMatrix

gui/panel.go:869–889  ·  view source on GitHub ↗

SetModelMatrix calculates and sets the specified matrix with the model matrix for this panel

(gl *gls.GLS, mm *math32.Matrix4)

Source from the content-addressed store, hash-verified

867
868// SetModelMatrix calculates and sets the specified matrix with the model matrix for this panel
869func (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}

Callers 4

RenderSetupMethod · 0.95
RenderSetupMethod · 0.80
RenderSetupMethod · 0.80
RenderSetupMethod · 0.80

Calls 5

ManagerFunction · 0.85
GetScaleMethod · 0.65
PositionMethod · 0.65
GetViewportMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected