瀏覽代碼

cleanup/docs/golint

danaugrs 7 年之前
父節點
當前提交
29a5ff33c8

+ 8 - 1
audio/listener.go

@@ -11,11 +11,12 @@ import (
 	"github.com/g3n/engine/math32"
 )
 
-// Listener embeds a core.Node and
+// Listener is an audio listener positioned in space
 type Listener struct {
 	core.Node
 }
 
+// NewListener returns a pointer to a new Listener object.
 func NewListener() *Listener {
 
 	l := new(Listener)
@@ -23,32 +24,38 @@ func NewListener() *Listener {
 	return l
 }
 
+// SetVelocity sets the velocity of the listener with x, y, z components
 func (l *Listener) SetVelocity(vx, vy, vz float32) {
 
 	al.Listener3f(al.Velocity, vx, vy, vz)
 }
 
+// SetVelocityVec sets the velocity of the listener with a vector
 func (l *Listener) SetVelocityVec(v *math32.Vector3) {
 
 	al.Listener3f(al.Velocity, v.X, v.Y, v.Z)
 }
 
+// Velocity returns the velocity of the listener as x, y, z components
 func (l *Listener) Velocity() (float32, float32, float32) {
 
 	return al.GetListener3f(al.Velocity)
 }
 
+// VelocityVec returns the velocity of the listener as a vector
 func (l *Listener) VelocityVec() math32.Vector3 {
 
 	vx, vy, vz := al.GetListener3f(al.Velocity)
 	return math32.Vector3{vx, vy, vz}
 }
 
+// SetGain sets the gain of the listener
 func (l *Listener) SetGain(gain float32) {
 
 	al.Listenerf(al.Gain, gain)
 }
 
+// Gain returns the gain of the listener
 func (l *Listener) Gain() float32 {
 
 	return al.GetListenerf(al.Gain)

+ 2 - 2
audio/player.go

@@ -195,7 +195,7 @@ func (p *Player) SetMinGain(gain float32) {
 	al.Sourcef(p.source, al.MinGain, gain)
 }
 
-// MinGain returns the current maximum gain of this player
+// MaxGain returns the current maximum gain of this player
 func (p *Player) MaxGain() float32 {
 
 	return al.GetSourcef(p.source, al.MaxGain)
@@ -282,7 +282,7 @@ func (p *Player) VelocityVec() math32.Vector3 {
 	return math32.Vector3{vx, vy, vz}
 }
 
-// SetRollofFactor sets this player rolloff factor user to calculate
+// SetRolloffFactor sets this player rolloff factor user to calculate
 // the gain attenuation by distance
 func (p *Player) SetRolloffFactor(rfactor float32) {
 

+ 2 - 1
core/node.go

@@ -11,7 +11,7 @@ import (
 	"github.com/g3n/engine/math32"
 )
 
-// Interface for all node types
+// INode is the interface for all node types
 type INode interface {
 	GetNode() *Node
 	UpdateMatrixWorld()
@@ -20,6 +20,7 @@ type INode interface {
 	Dispose()
 }
 
+// Node is an object that can be positioned in space and also within a hierarchy of Node objects.
 type Node struct {
 	Dispatcher                    // Embedded event dispatcher
 	loaderID    string            // ID used by loader

+ 2 - 0
geometry/torus.go

@@ -10,6 +10,7 @@ import (
 	"math"
 )
 
+// Torus represents a torus geometry
 type Torus struct {
 	Geometry                // embedded geometry
 	Radius          float64 // Torus radius
@@ -19,6 +20,7 @@ type Torus struct {
 	Arc             float64 // Central angle
 }
 
+// NewTorus returns a pointer to a new torus geometry
 func NewTorus(radius, tube float64, radialSegments, tubularSegments int, arc float64) *Torus {
 
 	t := new(Torus)

+ 5 - 5
gls/vbo.go

@@ -88,7 +88,7 @@ func (vbo *VBO) Dispose() {
 	vbo.gs = nil
 }
 
-// Sets the VBO buffer
+// SetBuffer sets the VBO buffer
 func (vbo *VBO) SetBuffer(buffer math32.ArrayF32) *VBO {
 
 	vbo.buffer = buffer
@@ -96,7 +96,7 @@ func (vbo *VBO) SetBuffer(buffer math32.ArrayF32) *VBO {
 	return vbo
 }
 
-// Sets the expected usage pattern of the buffer.
+// SetUsage sets the expected usage pattern of the buffer.
 // The default value is GL_STATIC_DRAW.
 func (vbo *VBO) SetUsage(usage uint32) {
 
@@ -109,7 +109,7 @@ func (vbo *VBO) Buffer() *math32.ArrayF32 {
 	return &vbo.buffer
 }
 
-// Updates sets the update flag to force the VBO update
+// Update sets the update flag to force the VBO update
 func (vbo *VBO) Update() {
 
 	vbo.update = true
@@ -144,8 +144,8 @@ func (vbo *VBO) Transfer(gs *GLS) {
 		// Calculates stride
 		stride := vbo.Stride()
 		// For each attribute
-		var items uint32 = 0
-		var offset uint32 = 0
+		var items uint32
+		var offset uint32
 		elsize := int32(unsafe.Sizeof(float32(0)))
 		for _, attrib := range vbo.attribs {
 			// Get attribute location in the current program

+ 1 - 0
graphic/line_strip.go

@@ -12,6 +12,7 @@ import (
 	"github.com/g3n/engine/math32"
 )
 
+// LineStrip is a Graphic which is rendered as a collection of connected lines
 type LineStrip struct {
 	Graphic             // Embedded graphic object
 	uniMVP  gls.Uniform // Model view projection matrix uniform location cache

+ 6 - 3
graphic/mesh.go

@@ -12,6 +12,7 @@ import (
 	"github.com/g3n/engine/math32"
 )
 
+// Mesh is a Graphic with uniforms for the model, view, projection, and normal matrices.
 type Mesh struct {
 	Graphic             // Embedded graphic
 	uniMVM  gls.Uniform // Model view matrix uniform location cache
@@ -19,9 +20,9 @@ type Mesh struct {
 	uniNM   gls.Uniform // Normal matrix uniform cache
 }
 
-// NewMesh creates and returns a pointer to a mesh with the specified geometry and material
+// NewMesh creates and returns a pointer to a mesh with the specified geometry and material.
 // If the mesh has multi materials, the material specified here must be nil and the
-// individual materials must be add using "AddMateria" or AddGroupMaterial"
+// individual materials must be add using "AddMaterial" or AddGroupMaterial".
 func NewMesh(igeom geometry.IGeometry, imat material.IMaterial) *Mesh {
 
 	m := new(Mesh)
@@ -29,6 +30,7 @@ func NewMesh(igeom geometry.IGeometry, imat material.IMaterial) *Mesh {
 	return m
 }
 
+// Init initializes the Mesh and its uniforms
 func (m *Mesh) Init(igeom geometry.IGeometry, imat material.IMaterial) {
 
 	m.Graphic.Init(igeom, gls.TRIANGLES)
@@ -44,12 +46,13 @@ func (m *Mesh) Init(igeom geometry.IGeometry, imat material.IMaterial) {
 	}
 }
 
+// AddMaterial adds a material for the specified subset of vertices
 func (m *Mesh) AddMaterial(imat material.IMaterial, start, count int) {
 
 	m.Graphic.AddMaterial(m, imat, start, count)
 }
 
-// Add group material
+// AddGroupMaterial adds a material for the specified geometry group
 func (m *Mesh) AddGroupMaterial(imat material.IMaterial, gindex int) {
 
 	m.Graphic.AddGroupMaterial(m, imat, gindex)

+ 14 - 12
graphic/skybox.go

@@ -13,12 +13,7 @@ import (
 	"github.com/g3n/engine/texture"
 )
 
-type SkyboxData struct {
-	DirAndPrefix string
-	Extension    string
-	Suffixes     [6]string
-}
-
+// Skybox is the Graphic that represents a skybox
 type Skybox struct {
 	Graphic             // embedded graphic object
 	uniMVM  gls.Uniform // model view matrix uniform location cache
@@ -26,7 +21,14 @@ type Skybox struct {
 	uniNM   gls.Uniform // normal matrix uniform cache
 }
 
-// NewSkybox creates and returns a pointer to a skybox with the specified textures
+// SkyboxData contains the data necessary to locate the textures for a Skybox in a concise manner.
+type SkyboxData struct {
+	DirAndPrefix string
+	Extension    string
+	Suffixes     [6]string
+}
+
+// NewSkybox creates and returns a pointer to a Skybox with the specified textures.
 func NewSkybox(data SkyboxData) (*Skybox, error) {
 
 	skybox := new(Skybox)
@@ -43,7 +45,12 @@ func NewSkybox(data SkyboxData) (*Skybox, error) {
 		matFace.AddTexture(tex)
 		matFace.SetSide(material.SideBack)
 		matFace.SetUseLights(material.UseLightAmbient)
+
+		// Disable writes to the depth buffer (call glDepthMask(GL_FALSE)).
+		// This will cause every other object to draw over the skybox, making it always appear behind everything else.
+		// It doesn't matter how small/big the skybox is as long as it's visible by the camera (within near/far planes).
 		matFace.SetDepthMask(false)
+
 		skybox.AddGroupMaterial(skybox, matFace, i)
 	}
 
@@ -60,11 +67,6 @@ func NewSkybox(data SkyboxData) (*Skybox, error) {
 // the model matrices.
 func (skybox *Skybox) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo) {
 
-	// TODO
-	// Disable writes to the depth buffer (call glDepthMask(GL_FALSE)).
-	// This will cause every other object to draw over the skybox, making it always appear "behind" everything else.
-	// Since writes to the depth buffer are off, it doesn't matter how small the skybox is as long as it's larger than the camera's near clip plane.
-
 	var mvm math32.Matrix4
 	mvm.Copy(&rinfo.ViewMatrix)
 

+ 9 - 9
gui/button.go

@@ -55,15 +55,15 @@ func NewButton(text string) *Button {
 	b.Panel = NewPanel(0, 0)
 
 	// Subscribe to panel events
-	b.Panel.Subscribe(OnKeyDown, b.onKey)
-	b.Panel.Subscribe(OnKeyUp, b.onKey)
-	b.Panel.Subscribe(OnMouseUp, b.onMouse)
-	b.Panel.Subscribe(OnMouseDown, b.onMouse)
-	b.Panel.Subscribe(OnCursor, b.onCursor)
-	b.Panel.Subscribe(OnCursorEnter, b.onCursor)
-	b.Panel.Subscribe(OnCursorLeave, b.onCursor)
-	b.Panel.Subscribe(OnEnable, func(name string, ev interface{}) { b.update() })
-	b.Panel.Subscribe(OnResize, func(name string, ev interface{}) { b.recalc() })
+	b.Subscribe(OnKeyDown, b.onKey)
+	b.Subscribe(OnKeyUp, b.onKey)
+	b.Subscribe(OnMouseUp, b.onMouse)
+	b.Subscribe(OnMouseDown, b.onMouse)
+	b.Subscribe(OnCursor, b.onCursor)
+	b.Subscribe(OnCursorEnter, b.onCursor)
+	b.Subscribe(OnCursorLeave, b.onCursor)
+	b.Subscribe(OnEnable, func(name string, ev interface{}) { b.update() })
+	b.Subscribe(OnResize, func(name string, ev interface{}) { b.recalc() })
 
 	// Creates label
 	b.Label = NewLabel(text)

+ 4 - 0
gui/docklayout.go

@@ -4,9 +4,11 @@
 
 package gui
 
+// DockLayout is the layout for docking panels to the internal edges of their parent.
 type DockLayout struct {
 }
 
+// DockLayoutParams specifies the edge to dock to.
 type DockLayoutParams struct {
 	Edge int
 }
@@ -19,11 +21,13 @@ const (
 	DockCenter
 )
 
+// NewDockLayout returns a pointer to a new DockLayout.
 func NewDockLayout() *DockLayout {
 
 	return new(DockLayout)
 }
 
+// Recalc (which satisfies the ILayout interface) recalculates the positions and sizes of the children panels.
 func (dl *DockLayout) Recalc(ipan IPanel) {
 
 	pan := ipan.GetPanel()

+ 1 - 0
gui/filllayout.go

@@ -4,6 +4,7 @@
 
 package gui
 
+// FillLayout is the simple layout where the assigned panel "fills" its parent in the specified dimension(s)
 type FillLayout struct {
 	width  bool
 	height bool

+ 13 - 10
gui/panel.go

@@ -95,6 +95,7 @@ type Panel struct {
 	}
 }
 
+// PanelStyle contains all the styling attributes of a Panel.
 type PanelStyle struct {
 	Margin      RectBounds
 	Border      RectBounds
@@ -103,6 +104,8 @@ type PanelStyle struct {
 	BgColor     math32.Color4
 }
 
+// BasicStyle extends PanelStyle by adding a foreground color.
+// Many GUI components can be styled using BasicStyle or redeclared versions thereof (e.g. ButtonStyle)
 type BasicStyle struct {
 	PanelStyle
 	FgColor     math32.Color4
@@ -423,7 +426,7 @@ func (p *Panel) SetBordersColor4(color *math32.Color4) {
 	p.SetChanged(true)
 }
 
-// BorderColor4 returns current border color
+// BordersColor4 returns current border color
 func (p *Panel) BordersColor4() math32.Color4 {
 
 	return p.udata.bordersColor
@@ -735,16 +738,16 @@ func (p *Panel) setZ(z, zunb float32) (float32, float32) {
 			z, zunb = ichild.(IPanel).GetPanel().setZ(z, zunb)
 		}
 		return z, zunb
-		// Unbounded panel
-	} else {
-		p.SetPositionZ(zunb)
-		zchild := zunb + deltaZ
-		zunb += deltaZunb
-		for _, ichild := range p.Children() {
-			_, zunb = ichild.(IPanel).GetPanel().setZ(zchild, zunb)
-		}
-		return z, zunb
 	}
+
+	// Unbounded panel
+	p.SetPositionZ(zunb)
+	zchild := zunb + deltaZ
+	zunb += deltaZunb
+	for _, ichild := range p.Children() {
+		_, zunb = ichild.(IPanel).GetPanel().setZ(zchild, zunb)
+	}
+	return z, zunb
 }
 
 // updateBounds is called by UpdateMatrixWorld() and calculates this panel

+ 3 - 44
gui/scroller.go

@@ -36,7 +36,7 @@ const (
 	ScrollBoth       = ScrollMode(ScrollVertical | ScrollHorizontal) // Both vertical and horizontal scrolling allowed
 )
 
-// ScrollBarInterlocking specifies what happens where the vertical and horizontal scrollbars meet.
+// ScrollbarInterlocking specifies what happens where the vertical and horizontal scrollbars meet.
 type ScrollbarInterlocking int
 
 const (
@@ -85,7 +85,7 @@ const ScrollPreference = ScrollVertical
 // ScrollModifierKey is the Key that changes the scrolling direction to the non-preferred direction
 const ScrollModifierKey = window.KeyLeftShift
 
-// newScroller creates and returns a pointer to a new Scroller with the specified
+// NewScroller creates and returns a pointer to a new Scroller with the specified
 // target IPanel and ScrollMode.
 func NewScroller(width, height float32, mode ScrollMode, target IPanel) *Scroller {
 
@@ -587,54 +587,13 @@ func (s *Scroller) recalcH() {
 	s.hscroll.SetWidth(hscrollWidth)
 }
 
-// update updates the visibility of the scrollbars, corner panel, and then recalculates
+// Update updates the visibility of the scrollbars, corner panel, and then recalculates
 func (s *Scroller) Update() {
 
 	s.updateScrollbarsVisibility()
 	s.recalc()
 }
 
-//if s.cursorOver {
-//	s.applyStyle(&s.styles.Over)
-//	return
-//}
-//if s.focus {
-//	s.applyStyle(&s.styles.Focus)
-//	return
-//}
-//s.applyStyle(&s.styles.Normal)
-
-//// applyStyle sets the specified style
-//func (s *Scroller) applyStyle(st *ScrollerStyle) {
-//
-//	s.Panel.ApplyStyle(&st.PanelStyle)
-//}
-
-
-
-//
-//// SetStyles sets the scroller styles overriding the default style
-//func (s *Scroller) SetStyles(ss *ScrollerStyles) {
-//
-//	s.styles = ss
-//	s.Update()
-//}
-//
-//// ApplyStyle applies the specified style to the Scroller
-//func (s *Scroller) ApplyStyle(style int) {
-//
-//	switch style {
-//	case StyleOver:
-//		s.applyStyle(&s.styles.Over)
-//	case StyleFocus:
-//		s.applyStyle(&s.styles.Focus)
-//	case StyleNormal:
-//		s.applyStyle(&s.styles.Normal)
-//	case StyleDef:
-//		s.update()
-//	}
-//}
-
 // TODO - if the style is changed this needs to be called to update the scrollbars and corner panel
 func (s *Scroller) applyStyle(ss *ScrollerStyle) {
 

+ 1 - 0
gui/window.go

@@ -61,6 +61,7 @@ type WindowStyles struct {
 	Disabled WindowStyle
 }
 
+// ResizeBorders specifies which window borders can be resized
 type ResizeBorders int
 
 const (

+ 1 - 0
light/point.go

@@ -12,6 +12,7 @@ import (
 	"github.com/g3n/engine/math32"
 )
 
+// Point is an omnidirectional light source
 type Point struct {
 	core.Node              // Embedded node
 	color     math32.Color // Light color

+ 1 - 1
loader/collada/animation.go

@@ -241,7 +241,7 @@ func actionScaleZ(at *AnimationTarget, v float32) {
 	at.target.GetNode().SetScaleZ(v)
 }
 
-// NewSampler creates and returns a pointer to a new SamplerInstance built
+// NewSamplerInstance creates and returns a pointer to a new SamplerInstance built
 // with data from the specified Collada animation and URI
 func NewSamplerInstance(ca *Animation, uri string) (*SamplerInstance, error) {
 

+ 8 - 8
renderer/shaders/shaders.go

@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Package shader contains the several shaders used by the engine
+// Package shaders contains the several shaders used by the engine
 package shaders
 
 // Generates shaders sources from this directory and include directory *.glsl files
@@ -25,7 +25,7 @@ func AddInclude(name string, source string) {
 	includeMap[name] = source
 }
 
-// AddShaders add a shader to default shaders registry.
+// AddShader add a shader to default shaders registry.
 // The specified name can be used when adding programs to the registry
 func AddShader(name string, source string) {
 
@@ -66,14 +66,14 @@ func AddProgram(name string, vertex string, frag string, others ...string) {
 func Includes() []string {
 
 	list := make([]string, 0)
-	for name, _ := range includeMap {
+	for name := range includeMap {
 		list = append(list, name)
 	}
 	return list
 }
 
-// GetInclude returns the source code of the specified shader include chunk.
-// If the name is not found an empty string is returned
+// IncludeSource returns the source code of the specified shader include chunk.
+// If the name is not found an empty string is returned.
 func IncludeSource(name string) string {
 
 	return includeMap[name]
@@ -83,7 +83,7 @@ func IncludeSource(name string) string {
 func Shaders() []string {
 
 	list := make([]string, 0)
-	for name, _ := range shaderMap {
+	for name := range shaderMap {
 		list = append(list, name)
 	}
 	return list
@@ -100,13 +100,13 @@ func ShaderSource(name string) string {
 func Programs() []string {
 
 	list := make([]string, 0)
-	for name, _ := range programMap {
+	for name := range programMap {
 		list = append(list, name)
 	}
 	return list
 }
 
-// GetProgram returns ProgramInfo struct for the specified program name
+// GetProgramInfo returns ProgramInfo struct for the specified program name
 // in the default shaders registry
 func GetProgramInfo(name string) ProgramInfo {
 

+ 361 - 360
renderer/shaders/sources.go

@@ -1,6 +1,7 @@
 // File generated by G3NSHADERS. Do not edit.
 // To regenerate this file install 'g3nshaders' and execute:
 // 'go generate' in this folder.
+
 package shaders
 
 const include_attributes_source = `//
@@ -14,6 +15,94 @@ layout(location = 4) in  float VertexDistance;
 layout(location = 5) in  vec4  VertexTexoffsets;
 
 
+`
+
+const include_lights_source = `//
+// Lights uniforms
+//
+
+// Ambient lights uniforms
+#if AMB_LIGHTS>0
+    uniform vec3 AmbientLightColor[AMB_LIGHTS];
+#endif
+
+// Directional lights uniform array. Each directional light uses 2 elements
+#if DIR_LIGHTS>0
+    uniform vec3 DirLight[2*DIR_LIGHTS];
+    // Macros to access elements inside the DirectionalLight uniform array
+    #define DirLightColor(a)		DirLight[2*a]
+    #define DirLightPosition(a)		DirLight[2*a+1]
+#endif
+
+// Point lights uniform array. Each point light uses 3 elements
+#if POINT_LIGHTS>0
+    uniform vec3 PointLight[3*POINT_LIGHTS];
+    // Macros to access elements inside the PointLight uniform array
+    #define PointLightColor(a)			PointLight[3*a]
+    #define PointLightPosition(a)		PointLight[3*a+1]
+    #define PointLightLinearDecay(a)	PointLight[3*a+2].x
+    #define PointLightQuadraticDecay(a)	PointLight[3*a+2].y
+#endif
+
+#if SPOT_LIGHTS>0
+    // Spot lights uniforms. Each spot light uses 5 elements
+    uniform vec3  SpotLight[5*SPOT_LIGHTS];
+    
+    // Macros to access elements inside the PointLight uniform array
+    #define SpotLightColor(a)			SpotLight[5*a]
+    #define SpotLightPosition(a)		SpotLight[5*a+1]
+    #define SpotLightDirection(a)		SpotLight[5*a+2]
+    #define SpotLightAngularDecay(a)	SpotLight[5*a+3].x
+    #define SpotLightCutoffAngle(a)		SpotLight[5*a+3].y
+    #define SpotLightLinearDecay(a)		SpotLight[5*a+3].z
+    #define SpotLightQuadraticDecay(a)	SpotLight[5*a+4].x
+#endif
+
+`
+
+const include_material_source = `//
+// Material properties uniform
+//
+
+// Material parameters uniform array
+uniform vec3 Material[6];
+// Macros to access elements inside the Material array
+#define MatAmbientColor		Material[0]
+#define MatDiffuseColor     Material[1]
+#define MatSpecularColor    Material[2]
+#define MatEmissiveColor    Material[3]
+#define MatShininess        Material[4].x
+#define MatOpacity          Material[4].y
+#define MatPointSize        Material[4].z
+#define MatPointRotationZ   Material[5].x
+
+#if MAT_TEXTURES > 0
+    // Texture unit sampler array
+    uniform sampler2D MatTexture[MAT_TEXTURES];
+    // Texture parameters (3*vec2 per texture)
+    uniform vec2 MatTexinfo[3*MAT_TEXTURES];
+    // Macros to access elements inside the MatTexinfo array
+    #define MatTexOffset(a)		MatTexinfo[(3*a)]
+    #define MatTexRepeat(a)		MatTexinfo[(3*a)+1]
+    #define MatTexFlipY(a)		bool(MatTexinfo[(3*a)+2].x)
+    #define MatTexVisible(a)	bool(MatTexinfo[(3*a)+2].y)
+#endif
+
+// GLSL 3.30 does not allow indexing texture sampler with non constant values.
+// This macro is used to mix the texture with the specified index with the material color.
+// It should be called for each texture index. It uses two externally defined variables:
+// vec4 texColor
+// vec4 texMixed
+#define MIX_TEXTURE(i)                                                                       \
+    if (MatTexVisible(i)) {                                                                  \
+        texColor = texture(MatTexture[i], FragTexcoord * MatTexRepeat(i) + MatTexOffset(i)); \
+        if (i == 0) {                                                                        \
+            texMixed = texColor;                                                             \
+        } else {                                                                             \
+            texMixed = mix(texMixed, texColor, texColor.a);                                  \
+        }                                                                                    \
+    }
+
 `
 
 const include_phong_model_source = `/***
@@ -134,191 +223,144 @@ void phongModel(vec4 position, vec3 normal, vec3 camDir, vec3 matAmbient, vec3 m
 
 `
 
-const include_lights_source = `//
-// Lights uniforms
-//
-
-// Ambient lights uniforms
-#if AMB_LIGHTS>0
-    uniform vec3 AmbientLightColor[AMB_LIGHTS];
-#endif
-
-// Directional lights uniform array. Each directional light uses 2 elements
-#if DIR_LIGHTS>0
-    uniform vec3 DirLight[2*DIR_LIGHTS];
-    // Macros to access elements inside the DirectionalLight uniform array
-    #define DirLightColor(a)		DirLight[2*a]
-    #define DirLightPosition(a)		DirLight[2*a+1]
-#endif
-
-// Point lights uniform array. Each point light uses 3 elements
-#if POINT_LIGHTS>0
-    uniform vec3 PointLight[3*POINT_LIGHTS];
-    // Macros to access elements inside the PointLight uniform array
-    #define PointLightColor(a)			PointLight[3*a]
-    #define PointLightPosition(a)		PointLight[3*a+1]
-    #define PointLightLinearDecay(a)	PointLight[3*a+2].x
-    #define PointLightQuadraticDecay(a)	PointLight[3*a+2].y
-#endif
-
-#if SPOT_LIGHTS>0
-    // Spot lights uniforms. Each spot light uses 5 elements
-    uniform vec3  SpotLight[5*SPOT_LIGHTS];
-    
-    // Macros to access elements inside the PointLight uniform array
-    #define SpotLightColor(a)			SpotLight[5*a]
-    #define SpotLightPosition(a)		SpotLight[5*a+1]
-    #define SpotLightDirection(a)		SpotLight[5*a+2]
-    #define SpotLightAngularDecay(a)	SpotLight[5*a+3].x
-    #define SpotLightCutoffAngle(a)		SpotLight[5*a+3].y
-    #define SpotLightLinearDecay(a)		SpotLight[5*a+3].z
-    #define SpotLightQuadraticDecay(a)	SpotLight[5*a+4].x
-#endif
-
-`
-
-const include_material_source = `//
-// Material properties uniform
-//
-
-// Material parameters uniform array
-uniform vec3 Material[6];
-// Macros to access elements inside the Material array
-#define MatAmbientColor		Material[0]
-#define MatDiffuseColor     Material[1]
-#define MatSpecularColor    Material[2]
-#define MatEmissiveColor    Material[3]
-#define MatShininess        Material[4].x
-#define MatOpacity          Material[4].y
-#define MatPointSize        Material[4].z
-#define MatPointRotationZ   Material[5].x
-
-#if MAT_TEXTURES > 0
-    // Texture unit sampler array
-    uniform sampler2D MatTexture[MAT_TEXTURES];
-    // Texture parameters (3*vec2 per texture)
-    uniform vec2 MatTexinfo[3*MAT_TEXTURES];
-    // Macros to access elements inside the MatTexinfo array
-    #define MatTexOffset(a)		MatTexinfo[(3*a)]
-    #define MatTexRepeat(a)		MatTexinfo[(3*a)+1]
-    #define MatTexFlipY(a)		bool(MatTexinfo[(3*a)+2].x)
-    #define MatTexVisible(a)	bool(MatTexinfo[(3*a)+2].y)
-#endif
-
-// GLSL 3.30 does not allow indexing texture sampler with non constant values.
-// This macro is used to mix the texture with the specified index with the material color.
-// It should be called for each texture index. It uses two externally defined variables:
-// vec4 texColor
-// vec4 texMixed
-#define MIX_TEXTURE(i)                                                                       \
-    if (MatTexVisible(i)) {                                                                  \
-        texColor = texture(MatTexture[i], FragTexcoord * MatTexRepeat(i) + MatTexOffset(i)); \
-        if (i == 0) {                                                                        \
-            texMixed = texColor;                                                             \
-        } else {                                                                             \
-            texMixed = mix(texMixed, texColor, texColor.a);                                  \
-        }                                                                                    \
-    }
-
-`
-
-const sprite_fragment_source = `//
-// Fragment shader for sprite
+const basic_fragment_source = `//
+// Fragment Shader template
 //
 
-#include <material>
-
-// Inputs from vertex shader
 in vec3 Color;
-in vec2 FragTexcoord;
-
-// Output
 out vec4 FragColor;
 
 void main() {
 
-    // Combine all texture colors and opacity
-    vec4 texCombined = vec4(1);
-#if MAT_TEXTURES>0
-    for (int i = 0; i < {{.MatTexturesMax}}; i++) {
-        vec4 texcolor = texture(MatTexture[i], FragTexcoord * MatTexRepeat(i) + MatTexOffset(i));
-        if (i == 0) {
-            texCombined = texcolor;
-        } else {
-            texCombined = mix(texCombined, texcolor, texcolor.a);
-        }
-    }
-#endif
-
-    // Combine material color with texture
-    FragColor = min(vec4(Color, MatOpacity) * texCombined, vec4(1));
+    FragColor = vec4(Color, 1.0);
 }
 
 `
 
-const sprite_vertex_source = `//
-// Vertex shader for sprites
+const basic_vertex_source = `//
+// Vertex shader basic
 //
-
 #include <attributes>
 
-// Input uniforms
+// Model uniforms
 uniform mat4 MVP;
 
-#include <material>
-
-// Outputs for fragment shader
+// Final output color for fragment shader
 out vec3 Color;
-out vec2 FragTexcoord;
 
 void main() {
 
-    // Applies transformation to vertex position
+    Color = VertexColor;
     gl_Position = MVP * vec4(VertexPosition, 1.0);
-
-    // Outputs color
-    Color = MatDiffuseColor;
-
-    // Flips texture coordinate Y if requested.
-    vec2 texcoord = VertexTexcoord;
-#if MAT_TEXTURES>0
-    if (MatTexFlipY[0]) {
-        texcoord.y = 1 - texcoord.y;
-    }
-#endif
-    FragTexcoord = texcoord;
 }
 
-`
 
-const point_vertex_source = `#include <attributes>
+`
 
-// Model uniforms
-uniform mat4 MVP;
+const panel_fragment_source = `//
+// Fragment Shader template
+//
 
-// Material uniforms
-#include <material>
+// Texture uniforms
+uniform sampler2D	MatTexture;
+uniform vec2		MatTexinfo[3];
 
-// Outputs for fragment shader
-out vec3 Color;
-flat out mat2 Rotation;
+// Macros to access elements inside the MatTexinfo array
+#define MatTexOffset		MatTexinfo[0]
+#define MatTexRepeat		MatTexinfo[1]
+#define MatTexFlipY	    	bool(MatTexinfo[2].x) // not used
+#define MatTexVisible	    bool(MatTexinfo[2].y) // not used
 
-void main() {
+// Inputs from vertex shader
+in vec2 FragTexcoord;
 
-    // Rotation matrix for fragment shader
-    float rotSin = sin(MatPointRotationZ);
-    float rotCos = cos(MatPointRotationZ);
-    Rotation = mat2(rotCos, rotSin, - rotSin, rotCos);
+// Input uniform
+uniform vec4 Panel[8];
+#define Bounds			Panel[0]		  // panel bounds in texture coordinates
+#define Border			Panel[1]		  // panel border in texture coordinates
+#define Padding			Panel[2]		  // panel padding in texture coordinates
+#define Content			Panel[3]		  // panel content area in texture coordinates
+#define BorderColor		Panel[4]		  // panel border color
+#define PaddingColor	Panel[5]		  // panel padding color
+#define ContentColor	Panel[6]		  // panel content color
+#define TextureValid	bool(Panel[7].x)  // texture valid flag
 
-    // Sets the vertex position
-    vec4 pos = MVP * vec4(VertexPosition, 1.0);
-    gl_Position = pos;
+// Output
+out vec4 FragColor;
 
-    // Sets the size of the rasterized point decreasing with distance
-    gl_PointSize = (1.0 - pos.z / pos.w) * MatPointSize;
 
-    // Outputs color
-    Color = MatEmissiveColor;
+/***
+* Checks if current fragment texture coordinate is inside the
+* supplied rectangle in texture coordinates:
+* rect[0] - position x [0,1]
+* rect[1] - position y [0,1]
+* rect[2] - width [0,1]
+* rect[3] - height [0,1]
+*/
+bool checkRect(vec4 rect) {
+
+    if (FragTexcoord.x < rect[0]) {
+        return false;
+    }
+    if (FragTexcoord.x > rect[0] + rect[2]) {
+        return false;
+    }
+    if (FragTexcoord.y < rect[1]) {
+        return false;
+    }
+    if (FragTexcoord.y > rect[1] + rect[3]) {
+        return false;
+    }
+    return true;
+}
+
+
+void main() {
+
+    // Discard fragment outside of received bounds
+    // Bounds[0] - xmin
+    // Bounds[1] - ymin
+    // Bounds[2] - xmax
+    // Bounds[3] - ymax
+    if (FragTexcoord.x <= Bounds[0] || FragTexcoord.x >= Bounds[2]) {
+        discard;
+    }
+    if (FragTexcoord.y <= Bounds[1] || FragTexcoord.y >= Bounds[3]) {
+        discard;
+    }
+
+    // Check if fragment is inside content area
+    if (checkRect(Content)) {
+        // If no texture, the color will be the material color.
+        vec4 color = ContentColor;
+		if (TextureValid) {
+            // Adjust texture coordinates to fit texture inside the content area
+            vec2 offset = vec2(-Content[0], -Content[1]);
+            vec2 factor = vec2(1/Content[2], 1/Content[3]);
+            vec2 texcoord = (FragTexcoord + offset) * factor;
+            vec4 texColor = texture(MatTexture, texcoord * MatTexRepeat + MatTexOffset);
+            // Mix content color with texture color ???
+            //color = mix(color, texColor, texColor.a);
+            color = texColor;
+		}
+        FragColor = color;
+        return;
+    }
+
+    // Checks if fragment is inside paddings area
+    if (checkRect(Padding)) {
+        FragColor = PaddingColor;
+        return;
+    }
+
+    // Checks if fragment is inside borders area
+    if (checkRect(Border)) {
+        FragColor = BorderColor;
+        return;
+    }
+
+    // Fragment is in margins area (always transparent)
+    FragColor = vec4(1,1,1,0);
 }
 
 `
@@ -349,21 +391,22 @@ void main() {
 
 `
 
-const standard_fragment_source = `//
+const phong_fragment_source = `//
 // Fragment Shader template
 //
-#include <material>
 
-// Inputs from Vertex shader
-in vec3 ColorFrontAmbdiff;
-in vec3 ColorFrontSpec;
-in vec3 ColorBackAmbdiff;
-in vec3 ColorBackSpec;
+// Inputs from vertex shader
+in vec4 Position;       // Vertex position in camera coordinates.
+in vec3 Normal;         // Vertex normal in camera coordinates.
+in vec3 CamDir;         // Direction from vertex to camera
 in vec2 FragTexcoord;
 
-// Output
-out vec4 FragColor;
+#include <lights>
+#include <material>
+#include <phong_model>
 
+// Final fragment color
+out vec4 FragColor;
 
 void main() {
 
@@ -381,22 +424,28 @@ void main() {
         MIX_TEXTURE(2)
     #endif
 
-    vec4 colorAmbDiff;
-    vec4 colorSpec;
-    if (gl_FrontFacing) {
-        colorAmbDiff = vec4(ColorFrontAmbdiff, MatOpacity);
-        colorSpec = vec4(ColorFrontSpec, 0);
-    } else {
-        colorAmbDiff = vec4(ColorBackAmbdiff, MatOpacity);
-        colorSpec = vec4(ColorBackSpec, 0);
+    // Combine material with texture colors
+    vec4 matDiffuse = vec4(MatDiffuseColor, MatOpacity) * texMixed;
+    vec4 matAmbient = vec4(MatAmbientColor, MatOpacity) * texMixed;
+
+    // Inverts the fragment normal if not FrontFacing
+    vec3 fragNormal = Normal;
+    if (!gl_FrontFacing) {
+        fragNormal = -fragNormal;
     }
-    FragColor = min(colorAmbDiff * texMixed + colorSpec, vec4(1));
+
+    // Calculates the Ambient+Diffuse and Specular colors for this fragment using the Phong model.
+    vec3 Ambdiff, Spec;
+    phongModel(Position, fragNormal, CamDir, vec3(matAmbient), vec3(matDiffuse), Ambdiff, Spec);
+
+    // Final fragment color
+    FragColor = min(vec4(Ambdiff + Spec, matDiffuse.a), vec4(1.0));
 }
 
 `
 
-const standard_vertex_source = `//
-// Vertex shader standard
+const phong_vertex_source = `//
+// Vertex Shader
 //
 #include <attributes>
 
@@ -405,38 +454,29 @@ uniform mat4 ModelViewMatrix;
 uniform mat3 NormalMatrix;
 uniform mat4 MVP;
 
-#include <lights>
 #include <material>
-#include <phong_model>
 
-
-// Outputs for the fragment shader.
-out vec3 ColorFrontAmbdiff;
-out vec3 ColorFrontSpec;
-out vec3 ColorBackAmbdiff;
-out vec3 ColorBackSpec;
+// Output variables for Fragment shader
+out vec4 Position;
+out vec3 Normal;
+out vec3 CamDir;
 out vec2 FragTexcoord;
 
 void main() {
 
-    // Transform this vertex normal to camera coordinates.
-    vec3 normal = normalize(NormalMatrix * VertexNormal);
+    // Transform this vertex position to camera coordinates.
+    Position = ModelViewMatrix * vec4(VertexPosition, 1.0);
 
-    // Calculate this vertex position in camera coordinates
-    vec4 position = ModelViewMatrix * vec4(VertexPosition, 1.0);
+    // Transform this vertex normal to camera coordinates.
+    Normal = normalize(NormalMatrix * VertexNormal);
 
     // Calculate the direction vector from the vertex to the camera
     // The camera is at 0,0,0
-    vec3 camDir = normalize(-position.xyz);
-
-    // Calculates the vertex Ambient+Diffuse and Specular colors using the Phong model
-    // for the front and back
-    phongModel(position,  normal, camDir, MatAmbientColor, MatDiffuseColor, ColorFrontAmbdiff, ColorFrontSpec);
-    phongModel(position, -normal, camDir, MatAmbientColor, MatDiffuseColor, ColorBackAmbdiff, ColorBackSpec);
+    CamDir = normalize(-Position.xyz);
 
-    vec2 texcoord = VertexTexcoord;
-#if MAT_TEXTURES > 0
     // Flips texture coordinate Y if requested.
+    vec2 texcoord = VertexTexcoord;
+#if MAT_TEXTURES>0
     if (MatTexFlipY(0)) {
         texcoord.y = 1 - texcoord.y;
     }
@@ -492,189 +532,123 @@ void main() {
 
 `
 
-const basic_fragment_source = `//
-// Fragment Shader template
-//
-
-in vec3 Color;
-out vec4 FragColor;
-
-void main() {
-
-    FragColor = vec4(Color, 1.0);
-}
-
-`
-
-const phong_vertex_source = `//
-// Vertex Shader
-//
-#include <attributes>
+const point_vertex_source = `#include <attributes>
 
 // Model uniforms
-uniform mat4 ModelViewMatrix;
-uniform mat3 NormalMatrix;
 uniform mat4 MVP;
 
+// Material uniforms
 #include <material>
 
-// Output variables for Fragment shader
-out vec4 Position;
-out vec3 Normal;
-out vec3 CamDir;
-out vec2 FragTexcoord;
+// Outputs for fragment shader
+out vec3 Color;
+flat out mat2 Rotation;
 
 void main() {
 
-    // Transform this vertex position to camera coordinates.
-    Position = ModelViewMatrix * vec4(VertexPosition, 1.0);
-
-    // Transform this vertex normal to camera coordinates.
-    Normal = normalize(NormalMatrix * VertexNormal);
+    // Rotation matrix for fragment shader
+    float rotSin = sin(MatPointRotationZ);
+    float rotCos = cos(MatPointRotationZ);
+    Rotation = mat2(rotCos, rotSin, - rotSin, rotCos);
 
-    // Calculate the direction vector from the vertex to the camera
-    // The camera is at 0,0,0
-    CamDir = normalize(-Position.xyz);
+    // Sets the vertex position
+    vec4 pos = MVP * vec4(VertexPosition, 1.0);
+    gl_Position = pos;
 
-    // Flips texture coordinate Y if requested.
-    vec2 texcoord = VertexTexcoord;
-#if MAT_TEXTURES>0
-    if (MatTexFlipY(0)) {
-        texcoord.y = 1 - texcoord.y;
-    }
-#endif
-    FragTexcoord = texcoord;
+    // Sets the size of the rasterized point decreasing with distance
+    gl_PointSize = (1.0 - pos.z / pos.w) * MatPointSize;
 
-    gl_Position = MVP * vec4(VertexPosition, 1.0);
+    // Outputs color
+    Color = MatEmissiveColor;
 }
 
 `
 
-const panel_fragment_source = `//
-// Fragment Shader template
+const sprite_fragment_source = `//
+// Fragment shader for sprite
 //
 
-// Texture uniforms
-uniform sampler2D	MatTexture;
-uniform vec2		MatTexinfo[3];
-
-// Macros to access elements inside the MatTexinfo array
-#define MatTexOffset		MatTexinfo[0]
-#define MatTexRepeat		MatTexinfo[1]
-#define MatTexFlipY	    	bool(MatTexinfo[2].x) // not used
-#define MatTexVisible	    bool(MatTexinfo[2].y) // not used
+#include <material>
 
 // Inputs from vertex shader
+in vec3 Color;
 in vec2 FragTexcoord;
 
-// Input uniform
-uniform vec4 Panel[8];
-#define Bounds			Panel[0]		  // panel bounds in texture coordinates
-#define Border			Panel[1]		  // panel border in texture coordinates
-#define Padding			Panel[2]		  // panel padding in texture coordinates
-#define Content			Panel[3]		  // panel content area in texture coordinates
-#define BorderColor		Panel[4]		  // panel border color
-#define PaddingColor	Panel[5]		  // panel padding color
-#define ContentColor	Panel[6]		  // panel content color
-#define TextureValid	bool(Panel[7].x)  // texture valid flag
-
 // Output
 out vec4 FragColor;
 
+void main() {
 
-/***
-* Checks if current fragment texture coordinate is inside the
-* supplied rectangle in texture coordinates:
-* rect[0] - position x [0,1]
-* rect[1] - position y [0,1]
-* rect[2] - width [0,1]
-* rect[3] - height [0,1]
-*/
-bool checkRect(vec4 rect) {
-
-    if (FragTexcoord.x < rect[0]) {
-        return false;
-    }
-    if (FragTexcoord.x > rect[0] + rect[2]) {
-        return false;
-    }
-    if (FragTexcoord.y < rect[1]) {
-        return false;
-    }
-    if (FragTexcoord.y > rect[1] + rect[3]) {
-        return false;
+    // Combine all texture colors and opacity
+    vec4 texCombined = vec4(1);
+#if MAT_TEXTURES>0
+    for (int i = 0; i < {{.MatTexturesMax}}; i++) {
+        vec4 texcolor = texture(MatTexture[i], FragTexcoord * MatTexRepeat(i) + MatTexOffset(i));
+        if (i == 0) {
+            texCombined = texcolor;
+        } else {
+            texCombined = mix(texCombined, texcolor, texcolor.a);
+        }
     }
-    return true;
+#endif
+
+    // Combine material color with texture
+    FragColor = min(vec4(Color, MatOpacity) * texCombined, vec4(1));
 }
 
+`
 
-void main() {
+const sprite_vertex_source = `//
+// Vertex shader for sprites
+//
 
-    // Discard fragment outside of received bounds
-    // Bounds[0] - xmin
-    // Bounds[1] - ymin
-    // Bounds[2] - xmax
-    // Bounds[3] - ymax
-    if (FragTexcoord.x <= Bounds[0] || FragTexcoord.x >= Bounds[2]) {
-        discard;
-    }
-    if (FragTexcoord.y <= Bounds[1] || FragTexcoord.y >= Bounds[3]) {
-        discard;
-    }
+#include <attributes>
 
-    // Check if fragment is inside content area
-    if (checkRect(Content)) {
-        // If no texture, the color will be the material color.
-        vec4 color = ContentColor;
-		if (TextureValid) {
-            // Adjust texture coordinates to fit texture inside the content area
-            vec2 offset = vec2(-Content[0], -Content[1]);
-            vec2 factor = vec2(1/Content[2], 1/Content[3]);
-            vec2 texcoord = (FragTexcoord + offset) * factor;
-            vec4 texColor = texture(MatTexture, texcoord * MatTexRepeat + MatTexOffset);
-            // Mix content color with texture color ???
-            //color = mix(color, texColor, texColor.a);
-            color = texColor;
-		}
-        FragColor = color;
-        return;
-    }
+// Input uniforms
+uniform mat4 MVP;
 
-    // Checks if fragment is inside paddings area
-    if (checkRect(Padding)) {
-        FragColor = PaddingColor;
-        return;
-    }
+#include <material>
 
-    // Checks if fragment is inside borders area
-    if (checkRect(Border)) {
-        FragColor = BorderColor;
-        return;
-    }
+// Outputs for fragment shader
+out vec3 Color;
+out vec2 FragTexcoord;
 
-    // Fragment is in margins area (always transparent)
-    FragColor = vec4(1,1,1,0);
+void main() {
+
+    // Applies transformation to vertex position
+    gl_Position = MVP * vec4(VertexPosition, 1.0);
+
+    // Outputs color
+    Color = MatDiffuseColor;
+
+    // Flips texture coordinate Y if requested.
+    vec2 texcoord = VertexTexcoord;
+#if MAT_TEXTURES>0
+    if (MatTexFlipY[0]) {
+        texcoord.y = 1 - texcoord.y;
+    }
+#endif
+    FragTexcoord = texcoord;
 }
 
 `
 
-const phong_fragment_source = `//
+const standard_fragment_source = `//
 // Fragment Shader template
 //
+#include <material>
 
-// Inputs from vertex shader
-in vec4 Position;       // Vertex position in camera coordinates.
-in vec3 Normal;         // Vertex normal in camera coordinates.
-in vec3 CamDir;         // Direction from vertex to camera
+// Inputs from Vertex shader
+in vec3 ColorFrontAmbdiff;
+in vec3 ColorFrontSpec;
+in vec3 ColorBackAmbdiff;
+in vec3 ColorBackSpec;
 in vec2 FragTexcoord;
 
-#include <lights>
-#include <material>
-#include <phong_model>
-
-// Final fragment color
+// Output
 out vec4 FragColor;
 
+
 void main() {
 
     // Mix material color with textures colors
@@ -691,70 +665,97 @@ void main() {
         MIX_TEXTURE(2)
     #endif
 
-    // Combine material with texture colors
-    vec4 matDiffuse = vec4(MatDiffuseColor, MatOpacity) * texMixed;
-    vec4 matAmbient = vec4(MatAmbientColor, MatOpacity) * texMixed;
-
-    // Inverts the fragment normal if not FrontFacing
-    vec3 fragNormal = Normal;
-    if (!gl_FrontFacing) {
-        fragNormal = -fragNormal;
+    vec4 colorAmbDiff;
+    vec4 colorSpec;
+    if (gl_FrontFacing) {
+        colorAmbDiff = vec4(ColorFrontAmbdiff, MatOpacity);
+        colorSpec = vec4(ColorFrontSpec, 0);
+    } else {
+        colorAmbDiff = vec4(ColorBackAmbdiff, MatOpacity);
+        colorSpec = vec4(ColorBackSpec, 0);
     }
-
-    // Calculates the Ambient+Diffuse and Specular colors for this fragment using the Phong model.
-    vec3 Ambdiff, Spec;
-    phongModel(Position, fragNormal, CamDir, vec3(matAmbient), vec3(matDiffuse), Ambdiff, Spec);
-
-    // Final fragment color
-    FragColor = min(vec4(Ambdiff + Spec, matDiffuse.a), vec4(1.0));
+    FragColor = min(colorAmbDiff * texMixed + colorSpec, vec4(1));
 }
 
 `
 
-const basic_vertex_source = `//
-// Vertex shader basic
+const standard_vertex_source = `//
+// Vertex shader standard
 //
 #include <attributes>
 
 // Model uniforms
+uniform mat4 ModelViewMatrix;
+uniform mat3 NormalMatrix;
 uniform mat4 MVP;
 
-// Final output color for fragment shader
-out vec3 Color;
+#include <lights>
+#include <material>
+#include <phong_model>
+
+
+// Outputs for the fragment shader.
+out vec3 ColorFrontAmbdiff;
+out vec3 ColorFrontSpec;
+out vec3 ColorBackAmbdiff;
+out vec3 ColorBackSpec;
+out vec2 FragTexcoord;
 
 void main() {
 
-    Color = VertexColor;
+    // Transform this vertex normal to camera coordinates.
+    vec3 normal = normalize(NormalMatrix * VertexNormal);
+
+    // Calculate this vertex position in camera coordinates
+    vec4 position = ModelViewMatrix * vec4(VertexPosition, 1.0);
+
+    // Calculate the direction vector from the vertex to the camera
+    // The camera is at 0,0,0
+    vec3 camDir = normalize(-position.xyz);
+
+    // Calculates the vertex Ambient+Diffuse and Specular colors using the Phong model
+    // for the front and back
+    phongModel(position,  normal, camDir, MatAmbientColor, MatDiffuseColor, ColorFrontAmbdiff, ColorFrontSpec);
+    phongModel(position, -normal, camDir, MatAmbientColor, MatDiffuseColor, ColorBackAmbdiff, ColorBackSpec);
+
+    vec2 texcoord = VertexTexcoord;
+#if MAT_TEXTURES > 0
+    // Flips texture coordinate Y if requested.
+    if (MatTexFlipY(0)) {
+        texcoord.y = 1 - texcoord.y;
+    }
+#endif
+    FragTexcoord = texcoord;
+
     gl_Position = MVP * vec4(VertexPosition, 1.0);
 }
 
-
 `
 
 // Maps include name with its source code
 var includeMap = map[string]string{
 
 	"attributes":  include_attributes_source,
-	"phong_model": include_phong_model_source,
 	"lights":      include_lights_source,
 	"material":    include_material_source,
+	"phong_model": include_phong_model_source,
 }
 
 // Maps shader name with its source code
 var shaderMap = map[string]string{
 
+	"basic_fragment":    basic_fragment_source,
+	"basic_vertex":      basic_vertex_source,
+	"panel_fragment":    panel_fragment_source,
+	"panel_vertex":      panel_vertex_source,
+	"phong_fragment":    phong_fragment_source,
+	"phong_vertex":      phong_vertex_source,
+	"point_fragment":    point_fragment_source,
+	"point_vertex":      point_vertex_source,
 	"sprite_fragment":   sprite_fragment_source,
 	"sprite_vertex":     sprite_vertex_source,
-	"point_vertex":      point_vertex_source,
-	"panel_vertex":      panel_vertex_source,
 	"standard_fragment": standard_fragment_source,
 	"standard_vertex":   standard_vertex_source,
-	"point_fragment":    point_fragment_source,
-	"basic_fragment":    basic_fragment_source,
-	"phong_vertex":      phong_vertex_source,
-	"panel_fragment":    panel_fragment_source,
-	"phong_fragment":    phong_fragment_source,
-	"basic_vertex":      basic_vertex_source,
 }
 
 // Maps program name with Proginfo struct with shaders names

+ 6 - 6
tools/g3nicodes/main.go

@@ -25,14 +25,14 @@ const (
 	VMINOR   = 1
 )
 
-type ConstInfo struct {
+type constInfo struct {
 	Name  string
 	Value string
 }
 
-type TemplateData struct {
+type templateData struct {
 	Packname string
-	Consts   []ConstInfo
+	Consts   []constInfo
 }
 
 func main() {
@@ -64,7 +64,7 @@ func main() {
 	}
 
 	// Parse input file
-	var td TemplateData
+	var td templateData
 	td.Packname = *oPackage
 	err = parse(finput, &td)
 	if err != nil {
@@ -99,7 +99,7 @@ func main() {
 	fout.Write(p)
 }
 
-func parse(fin io.Reader, td *TemplateData) error {
+func parse(fin io.Reader, td *templateData) error {
 
 	// Read words from input reader and builds words map
 	scanner := bufio.NewScanner(fin)
@@ -131,7 +131,7 @@ func parse(fin io.Reader, td *TemplateData) error {
 		if unicode.IsDigit(runes[0]) {
 			finalName = "N" + finalName
 		}
-		td.Consts = append(td.Consts, ConstInfo{Name: finalName, Value: "0x" + code})
+		td.Consts = append(td.Consts, constInfo{Name: finalName, Value: "0x" + code})
 	}
 	return nil
 }

+ 1 - 0
tools/g3nshaders/main.go

@@ -42,6 +42,7 @@ const (
 const TEMPLATE = `// File generated by G3NSHADERS. Do not edit.
 // To regenerate this file install 'g3nshaders' and execute:
 // 'go generate' in this folder.
+
 package {{.Pkg}}
 
 {{range .Includes}}