Index: Include/abgl.ab
===================================================================
--- Include/abgl.ab	(revision 78)
+++ Include/abgl.ab	(revision 80)
@@ -17,4 +17,8 @@
 Class Vector2f
 Public /* constructor */
+	Sub Vector2f()
+		This.X=0.0 As GLfloat
+		This.Y=0.0 As GLfloat
+	End Sub
 	Sub Vector2f(x As GLfloat, y As GLfloat)
 		This.X=x
@@ -41,24 +45,40 @@
 
 Public /* operator */
-	Sub Operator = (ByRef vec As Vector2f)
-		This.X=vec.X
-		This.Y=vec.Y
-	End Sub
-	Function Operator + (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
-		Return Add(vec1,vec2)
-	End Function
-	Function Operator - (ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
-		Return Substract(vec1,vec2)
-	End Function
-/*	Function Operator * (vec1 As Vector2f, vec2 As Vector2f) As Vector2f
-		Return Dot(vec1,vec2)
+	Sub Operator = (ByRef SrcVec As Vector2f)
+		This.X=SrcVec.X
+		This.Y=SrcVec.Y
+	End Sub
+	Function Operator + (SrcVec As Vector2f) As Vector2f
+		Return Add(This,SrcVec)
+	End Function
+	Function Operator - (SrcVec As Vector2f) As Vector2f
+		Return Substract(This,SrcVec)
+	End Function
+/*	Function Operator * (SrcVec As Vector2f) As Vector2f
+		Return Dot(This,SrcVec)
 	End Function
 */
-	Function Operator * (ByRef vec As Vector2f, sca As GLfloat) As Vector2f
-		Dim ret As Vector2f(vec.X*sca,vec.Y*sca)
-		Return ret
-	End Function
-	Function Operator / (ByRef vec As Vector2f, sca As GLfloat) As Vector2f
-		Dim ret As Vector2f(vec.X/sca,vec.Y/sca)
+	Function Operator * (Src As GLint) As Vector2f
+		Dim ret As Vector2f(This.X*Src,This.Y*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLfloat) As Vector2f
+		Dim ret As Vector2f(This.X*Src,This.Y*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLdouble) As Vector2f
+		Dim ret As Vector2f(This.X*Src As GLfloat,This.Y*Src As GLfloat)
+		Return ret
+	End Function
+	Function Operator / (Src As GLint) As Vector2f
+		Dim ret As Vector2f(This.X/Src,This.Y/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLfloat) As Vector2f
+		Dim ret As Vector2f(This.X/Src,This.Y/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLdouble) As Vector2f
+		Dim ret As Vector2f(This.X/Src,This.Y/Src)
 		Return ret
 	End Function
@@ -66,15 +86,15 @@
 
 Public /* method */
-	Function Add(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
-		Dim ret As Vector2f(vec1.X+vec2.X,vec1.Y+vec2.Y)
-		Return ret
-	End Function
-	Function Distance(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat
+	Static Function Add(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As Vector2f
+		Dim ret As Vector2f(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y)
+		Return ret
+	End Function
+	Static Function Distance(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat
 		Dim ret As Vector2f
-		ret=vec1-vec2
+		ret=SrcVec1-SrcVec2
 		Return ret.Magnitude
 	End Function
-	Function Dot(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As GLfloat
-		Return vec1.X*vec2.X+vec1.Y*vec2.Y
+	Static Function Dot(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As GLfloat
+		Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y
 	End Function
 	Function Magnitude() As GLfloat
@@ -89,6 +109,6 @@
 		Return ret
 	End Function
-	Function Substract(ByRef vec1 As Vector2f, ByRef vec2 As Vector2f) As Vector2f
-		Dim ret As Vector2f(vec1.X-vec2.X,vec1.Y-vec2.Y)
+	Static Function Substract(SrcVec1 As Vector2f, SrcVec2 As Vector2f) As Vector2f
+		Dim ret As Vector2f(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y)
 		Return ret
 	End Function
@@ -108,4 +128,8 @@
 Class Vector2d
 Public /* constructor */
+	Sub Vector2d()
+		This.X=0.0 As GLdouble
+		This.Y=0.0 As GLdouble
+	End Sub
 	Sub Vector2d(x As GLdouble, y As GLdouble)
 		xy.x=x
@@ -132,24 +156,40 @@
 
 Public /* operator */
-	Sub Operator = (ByRef vec As Vector2d)
-		This.X=vec.X
-		This.Y=vec.Y
-	End Sub
-	Function Operator + (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
-		Return Add(vec1,vec2)
-	End Function
-	Function Operator - (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
-		Return Substract(vec1,vec2)
-	End Function
-/*	Function Operator * (ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
-		Return Dot(vec1,vec2)
+	Sub Operator = (ByRef SrcVec As Vector2d)
+		This.X=SrcVec.X
+		This.Y=SrcVec.Y
+	End Sub
+	Function Operator + (SrcVec As Vector2d) As Vector2d
+		Return Add(This,SrcVec2)
+	End Function
+	Function Operator - (SrcVec As Vector2d) As Vector2d
+		Return Substract(This,SrcVec2)
+	End Function
+/*	Function Operator * (SrcVec As Vector2d) As Vector2d
+		Return Dot(This,SrcVec2)
 	End Function*/
 
-	Function Operator * (vec As Vector2d, sca As GLfloat) As Vector2d
-		Dim ret As Vector2d(vec.X*sca,vec.Y*sca)
-		Return ret
-	End Function
-	Function Operator / (vec As Vector2d, sca As GLfloat) As Vector2d
-		Dim ret As Vector2d(vec.X/sca,vec.Y/sca)
+	Function Operator * (Src As GLint) As Vector2d
+		Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLfloat) As Vector2d
+		Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLdouble) As Vector2d
+		Dim ret As Vector2d(This.X*Src,SrcVec.Y*Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLint) As Vector2d
+		Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLfloat) As Vector2d
+		Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLdouble) As Vector2d
+		Dim ret As Vector2d(This.X/Src,SrcVec.Y/Src)
 		Return ret
 	End Function
@@ -157,15 +197,15 @@
 
 Public /* method */
-	Function Add(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
-		Dim ret As Vector2d(vec1.X+vec2.X,vec1.Y+vec2.Y)
-		Return ret
-	End Function
-	Function Distance(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble
+	Function Add(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As Vector2d
+		Dim ret As Vector2d(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y)
+		Return ret
+	End Function
+	Function Distance(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble
 		Dim ret As Vector2d
-		ret=vec1-vec2
+		ret=SrcVec1-SrcVec2
 		Return ret.Magnitude
 	End Function
-	Function Dot(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As GLdouble
-		Return vec1.X*vec2.X+vec1.Y*vec2.Y
+	Function Dot(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As GLdouble
+		Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y
 	End Function
 	Function Magnitude() As GLdouble
@@ -180,6 +220,6 @@
 		Return ret
 	End Function
-	Function Substract(ByRef vec1 As Vector2d, ByRef vec2 As Vector2d) As Vector2d
-		Dim ret As Vector2d(vec1.X-vec2.X,vec1.Y-vec2.Y)
+	Function Substract(SrcVec1 As Vector2d, SrcVec2 As Vector2d) As Vector2d
+		Dim ret As Vector2d(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y)
 		Return ret
 	End Function
@@ -193,5 +233,5 @@
 	End Function
 
-Protected
+Public
 	xz As XY_DOUBLE
 End Class
@@ -212,4 +252,9 @@
 Class Vector3f
 Public /* constructor */
+	Sub Vector3f()
+		This.X=0.0 As GLfloat
+		This.Y=0.0 As GLfloat
+		This.Z=0.0 As GLfloat
+	End Sub
 	Sub Vector3f(x As GLfloat, y As GLfloat, z As GLfloat)
 		xyz.x=x
@@ -243,27 +288,43 @@
 
 Public /* operator */
-	Sub Operator = (vec As Vector3f)
-		This.X=vec.X
-		This.Y=vec.Y
-	End Sub
-	Function Operator + (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Return Add(vec1,vec2)
-	End Function
-	Function Operator - (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Return Substract(vec1,vec2)
-	End Function
-/*	Function Operator * (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Return Dot(vec1,vec2)
+	Sub Operator = (ByRef SrcVec As Vector3f)
+		This.X=SrcVec.X
+		This.Y=SrcVec.Y
+	End Sub
+	Function Operator + (SrcVec As Vector3f) As Vector3f
+		Return Add(This,SrcVec)
+	End Function
+	Function Operator - (SrcVec As Vector3f) As Vector3f
+		Return Substract(This,SrcVec)
+	End Function
+/*	Function Operator * (SrcVec As Vector3f) As Vector3f
+		Return Dot(This,SrcVec)
 	End Function*/
-	Function Operator ^ (vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Return Cross(vec1,vec2)
-	End Function
-
-	Function Operator * (vec As Vector3f, sca As GLfloat) As Vector3f
-		Dim ret As Vector3f(vec.X*sca,vec.Y*sca)
-		Return ret
-	End Function
-	Function Operator / (vec As Vector3f, sca As GLfloat) As Vector3f
-		Dim ret As Vector3f(vec.X/sca,vec.Y/sca)
+	Function Operator ^ (SrcVec As Vector3f) As Vector3f
+		Return Cross(This,SrcVec)
+	End Function
+
+	Function Operator * (Src As GLint) As Vector3f
+		Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLfloat) As Vector3f
+		Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLdouble) As Vector3f
+		Dim ret As Vector3f(This.X*Src,This.Y*Src,This.Z*Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLint) As Vector3f
+		Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLfloat) As Vector3f
+		Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLdouble) As Vector3f
+		Dim ret As Vector3f(This.X/Src,This.Y/Src,This.Z/Src)
 		Return ret
 	End Function
@@ -271,19 +332,19 @@
 
 Public /* method */
-	Function Add(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Dim ret As Vector3f(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Z-vec2.Z)
-		Return ret
-	End Function
-	Function Cross(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Dim ret As Vector3f(vec1.Y*vec2.Z-vec1.Z*vec2.Y,vec1.Z*vec2.X-vec1.X*vec2.Z,vec1.X*vec2.Y-vec1.Y*vec2.X)
-		Return ret
-	End Function
-	Function Distance(vec1 As Vector3f, vec2 As Vector3f) As GLfloat
+	Function Add(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
+		Dim ret As Vector3f(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
+		Return ret
+	End Function
+	Function Cross(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
+		Dim ret As Vector3f(SrcVec1.Y*SrcVec2.Z-SrcVec1.Z*SrcVec2.Y,SrcVec1.Z*SrcVec2.X-SrcVec1.X*SrcVec2.Z,SrcVec1.X*SrcVec2.Y-SrcVec1.Y*SrcVec2.X)
+		Return ret
+	End Function
+	Function Distance(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat
 		Dim ret As Vector3f
-		ret=vec1-vec2
+		ret=SrcVec1-SrcVec2
 		Return ret.Magnitude
 	End Function
-	Function Dot(vec1 As Vector3f, vec2 As Vector3f) As GLfloat
-		Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z
+	Function Dot(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As GLfloat
+		Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z
 	End Function
 	Function Magnitude() As GLfloat
@@ -298,6 +359,6 @@
 		Return ret
 	End Function
-	Function Substract(vec1 As Vector3f, vec2 As Vector3f) As Vector3f
-		Dim ret As Vector3f(vec1.X-vec2.X,vec1.Y-vec2.Y,vec1.Z-vec2.Z)
+	Function Substract(SrcVec1 As Vector3f, SrcVec2 As Vector3f) As Vector3f
+		Dim ret As Vector3f(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
 		Return ret
 	End Function
@@ -311,5 +372,5 @@
 	End Function
 
-Protected
+Public
 	xyz As XYZ_FLOAT
 End Class
@@ -317,4 +378,9 @@
 Class Vector3d
 Public /* constructor */
+	Sub Vector3d()
+		This.X=0.0 As GLdouble
+		This.Y=0.0 As GLdouble
+		This.Z=0.0 As GLdouble
+	End Sub
 	Sub Vector3d(x As GLdouble, y As GLdouble, z As GLdouble)
 		xyz.x=x
@@ -350,27 +416,43 @@
 
 Public /* operator */
-	Sub Operator = (vec As Vector3d)
-		This.X=vec.X
-		This.Y=vec.Y
-	End Sub
-	Function Operator + (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Return Add(vec1,vec2)
-	End Function
-	Function Operator - (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Return Substract(vec1,vec2)
-	End Function
-/*	Function Operator * (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Return Dot(vec1,vec2)
+	Sub Operator = (ByRef SrcVec As Vector3d)
+		This.X=SrcVec.X
+		This.Y=SrcVec.Y
+	End Sub
+	Function Operator + (SrcVec As Vector3d) As Vector3d
+		Return Add(This,SrcVec)
+	End Function
+	Function Operator - (SrcVec As Vector3d) As Vector3d
+		Return Substract(This,SrcVec)
+	End Function
+/*	Function Operator * (SrcVec As Vector3d) As Vector3d
+		Return Dot(This,SrcVec)
 	End Function*/
-	Function Operator ^ (vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Return Cross(vec1,vec2)
-	End Function
-
-	Function Operator * (vec As Vector3d, sca As GLdouble) As Vector3d
-		Dim ret As Vector3d(vec.X*sca,vec.Y*sca)
-		Return ret
-	End Function
-	Function Operator / (vec As Vector3d, sca As GLdouble) As Vector3d
-		Dim ret As Vector3d(vec.X/sca,vec.Y/sca)
+	Function Operator ^ (SrcVec As Vector3d) As Vector3d
+		Return Cross(This,SrcVec)
+	End Function
+
+	Function Operator * (Src As GLint) As Vector3d
+		Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLfloat) As Vector3d
+		Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
+		Return ret
+	End Function
+	Function Operator * (Src As GLdouble) As Vector3d
+		Dim ret As Vector3d(This.X*Src,This.Y*Src,This.Z*Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLint) As Vector3d
+		Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLfloat) As Vector3d
+		Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
+		Return ret
+	End Function
+	Function Operator / (Src As GLdouble) As Vector3d
+		Dim ret As Vector3d(This.X/Src,This.Y/Src,This.Z/Src)
 		Return ret
 	End Function
@@ -378,19 +460,19 @@
 
 Public /* method */
-	Function Add(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Dim ret As Vector3d(vec1.X+vec2.X,vec1.Y+vec2.Y,vec1.Z-vec2.Z)
-		Return ret
-	End Function
-	Function Cross(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Dim ret As Vector3d(vec1.Y*vec2.Z-vec1.Z*vec2.Y,vec1.Z*vec2.X-vec1.X*vec2.Z,vec1.X*vec2.Y-vec1.Y*vec2.X)
-		Return ret
-	End Function
-	Function Distance(vec1 As Vector3d, vec2 As Vector3d) As GLdouble
+	Function Add(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
+		Dim ret As Vector3d(SrcVec1.X+SrcVec2.X,SrcVec1.Y+SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
+		Return ret
+	End Function
+	Function Cross(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
+		Dim ret As Vector3d(SrcVec1.Y*SrcVec2.Z-SrcVec1.Z*SrcVec2.Y,SrcVec1.Z*SrcVec2.X-SrcVec1.X*SrcVec2.Z,SrcVec1.X*SrcVec2.Y-SrcVec1.Y*SrcVec2.X)
+		Return ret
+	End Function
+	Function Distance(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble
 		Dim ret As Vector3d
-		ret=vec1-vec2
+		ret=SrcVec1-SrcVec2
 		Return ret.Magnitude
 	End Function
-	Function Dot(vec1 As Vector3d, vec2 As Vector3d) As GLdouble
-		Return vec1.X*vec2.X+vec1.Y*vec2.Y+vec1.Z*vec2.Z
+	Function Dot(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As GLdouble
+		Return SrcVec1.X*SrcVec2.X+SrcVec1.Y*SrcVec2.Y+SrcVec1.Z*SrcVec2.Z
 	End Function
 	Function Magnitude() As GLdouble
@@ -405,6 +487,6 @@
 		Return ret
 	End Function
-	Function Substract(vec1 As Vector3d, vec2 As Vector3d) As Vector3d
-		Dim ret As Vector3d(vec1.X-vec2.X,vec1.Y-vec2.Y,vec1.Z-vec2.Z)
+	Function Substract(SrcVec1 As Vector3d, SrcVec2 As Vector3d) As Vector3d
+		Dim ret As Vector3d(SrcVec1.X-SrcVec2.X,SrcVec1.Y-SrcVec2.Y,SrcVec1.Z-SrcVec2.Z)
 		Return ret
 	End Function
@@ -418,6 +500,5 @@
 	End Function
 
-
-Protected
+Public
 	xyz As XYZ_DOUBLE
 End Class
@@ -456,5 +537,5 @@
 	End Function
 	Function B() As GLfloat
-		Return rgb.r
+		Return rgb.b
 	End Function
 	Sub R(r As GLfloat)
@@ -469,7 +550,4 @@
 
 Public /* operator */
-	Function operator () As Color3f
-		Return This
-	End Function
 	Sub operator = (c As Color3f)
 		This.R=c.R
@@ -519,16 +597,17 @@
 		Return ret
 	End Function
-	Static Function FromHSB(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f
+	Static Function FromHSV(h As GLfloat, s As GLfloat, v As GLfloat) As Color3f
 		Dim r As GLfloat
 		Dim g As GLfloat
 		Dim b As GLfloat
 		If h<0 Then h+=360.0
-		Select Case (h\60)
+		If h>360.0 Then h-=360.0
+		Select Case (h/60) As Long
 			Case 0
 				r=v
-				g=v*(1-s*(1-(h/60-h\60)))
+				g=v*(1-s*(1-(h/60-(h/60) As Long)))
 				b=v*(1-s)
 			Case 1
-				r=v*(1-s*(h/60-h\60))
+				r=v*(1-s*(h/60-(h/60) As Long))
 				g=v
 				b=v*(1-s)
@@ -536,11 +615,11 @@
 				r=v*(1-s)
 				g=v
-				b=v*(1-s*(1-(h/60-h\60)))
+				b=v*(1-s*(1-(h/60-(h/60) As Long)))
 			Case 3
 				r=v*(1-s)
-				g=v*(1-s*(h/60-h\60))
+				g=v*(1-s*(h/60-(h/60) As Long))
 				b=v
 			Case 4
-				r=v*(1-s*(1-(h/60-h\60)))
+				r=v*(1-s*(1-(h/60-(h/60) As Long)))
 				g=v*(1-s)
 				b=v
@@ -548,5 +627,9 @@
 				r=v
 				g=v*(1-s)
-				b=v*(1-s*(h/60-h\60))
+				b=v*(1-s*(h/60-(h/60) As Long))
+			Case 6
+				r=v
+				g=v*(1-s*(1-(h/60-(h/60) As Long)))
+				b=v*(1-s)
 		End Select
 
@@ -555,5 +638,5 @@
 	End Function
 
-Protected
+Public
 	rgb As RGB_FLOAT
 End Class
@@ -579,5 +662,5 @@
 	End Function
 	Function B() As GLdouble
-		Return rgb.r
+		Return rgb.b
 	End Function
 	Sub R(r As GLdouble)
@@ -591,5 +674,86 @@
 	End Sub
 
-Protected
+Public /* method */
+	' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にした
+	' Drawwing\Color.abをさらに参考にしました。
+	Function GetHue() As GLdouble
+		Dim max As GLdouble, min As GLdouble, d As GLdouble
+		max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
+		min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
+		d = max - min
+		If rgb.g = max Then
+			Return ((rgb.b - rgb.r) As Double / d * 60.0 + 120.0) As GLfloat
+		ElseIf rgb.b = max Then
+			Return ((rgb.r - rgb.g) As Double / d * 60.0 + 240.0) As GLfloat
+		ElseIf rgb.g < rgb.b Then
+			Return ((rgb.g - rgb.b) As Double / d * 60.0 + 360.0) As GLfloat
+		Else
+			Return ((rgb.g - rgb.b) As Double / d * 60.0) As GLfloat
+		EndIf
+	End Function
+
+	Function GetSaturation() As GLdouble
+		Dim max As GLdouble, min As GLdouble
+		max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
+		min = Math.Min(Math.Min(rgb.r, rgb.g), rgb.b)
+		Return (max - min) / max
+	End Function
+
+	Function GetVolue() As GLdouble
+		Dim max As GLdouble
+		max = Math.Max(Math.Max(rgb.r, rgb.g), rgb.b)
+		Return max
+	End Function
+
+Public /* static method */
+	Static Function FromRGB(r As GLbyte, g As GLbyte, b As GLbyte) As Color3d
+		Dim ret As Color3d(r/255,g/255,b/255)
+		Return ret
+	End Function
+	Static Function FromCOLORREF(c As COLORREF) As Color3d
+		Dim ret As Color3d((c and &hff)/255,(c>>8 and &hff)/255,(c>>16 and &hff)/255)
+		Return ret
+	End Function
+	Static Function FromHSV(h As GLdouble, s As GLdouble, v As GLdouble) As Color3f
+		Dim r As GLdouble
+		Dim g As GLdouble
+		Dim b As GLfloat
+		If h<0 Then h+=360.0
+		If h>360.0 Then h-=360.0
+		Select Case (h/60) As Long
+			Case 0
+				r=v
+				g=v*(1-s*(1-(h/60-(h/60) As Long)))
+				b=v*(1-s)
+			Case 1
+				r=v*(1-s*(h/60-(h/60) As Long))
+				g=v
+				b=v*(1-s)
+			Case 2
+				r=v*(1-s)
+				g=v
+				b=v*(1-s*(1-(h/60-(h/60) As Long)))
+			Case 3
+				r=v*(1-s)
+				g=v*(1-s*(h/60-(h/60) As Long))
+				b=v
+			Case 4
+				r=v*(1-s*(1-(h/60-(h/60) As Long)))
+				g=v*(1-s)
+				b=v
+			Case 5
+				r=v
+				g=v*(1-s)
+				b=v*(1-s*(h/60-(h/60) As Long))
+			Case 6
+				r=v
+				g=v*(1-s*(1-(h/60-(h/60) As Long)))
+				b=v*(1-s)
+		End Select
+
+		Dim ret As Color3d(r,g,b)
+		Return ret
+	End Function
+Public
 	rgb As RGB_DOUBLE
 End Class
@@ -630,5 +794,5 @@
 	End Function
 	Function B() As GLfloat
-		Return rgba.r
+		Return rgba.b
 	End Function
 	Function A() As GLfloat
@@ -648,5 +812,5 @@
 	End Sub
 
-Protected
+Public
 	rgba As RGBA_FLOAT
 End Class
@@ -674,5 +838,5 @@
 	End Function
 	Function B() As GLdouble
-		Return rgba.r
+		Return rgba.b
 	End Function
 	Function A() As GLdouble
@@ -692,5 +856,5 @@
 	End Sub
 
-Protected
+Public
 	rgba As RGBA_DOUBLE
 End Class
@@ -700,5 +864,5 @@
 Class Light
 Private
-	Number As GLenum
+	Const Number As GLenum
 
 Public
@@ -730,5 +894,5 @@
 		glLightfv(Number,GL_AMBIENT,amb)
 	End Sub
-	Sub SetAmbient(color As Color4f)
+	Sub SetAmbient(ByRef color As Color4f)
 		Dim amb[3] As GLfloat
 		amb[0]=color.R
@@ -750,5 +914,5 @@
 		glLightfv(Number,GL_DIFFUSE,dif)
 	End Sub
-	Sub SetDiffuse(color As Color4f)
+	Sub SetDiffuse(ByRef color As Color4f)
 		Dim dif[3] As GLfloat
 		amb[0]=color.R
@@ -770,5 +934,5 @@
 		glLightfv(Number,GL_SPECULAR,spc)
 	End Sub
-	Sub SetSpecular(color As Color4f)
+	Sub SetSpecular(ByRef color As Color4f)
 		Dim spc[3] As GLfloat
 		amb[0]=color.R
@@ -799,5 +963,5 @@
 		glMaterialfv(face,GL_AMBIENT,amb)
 	End Sub
-	Sub Ambient(color As Color4f)
+	Sub Ambient(ByRef color As Color4f)
 		Dim face As GLenum
 		glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
@@ -823,5 +987,5 @@
 		glMaterialfv(face,GL_DIFFUSE,dif)
 	End Sub
-	Sub Diffuse(color As Color4f)
+	Sub Diffuse(ByRef color As Color4f)
 		Dim face As GLenum
 		glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
@@ -847,5 +1011,5 @@
 		glMaterialfv(face,GL_SPECULAR,spc)
 	End Sub
-	Sub Specular(color As Color4f)
+	Sub Specular(ByRef color As Color4f)
 		Dim face As GLenum
 		glGetIntegerv(GL_COLOR_MATERIAL_FACE,VarPtr(face))
@@ -1014,11 +1178,11 @@
 Class LightModel
 Public
-/*	Function Ambient () As GLenum
-		Dim amb As GLenum
-		glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
-		Return func
-	End Function*/
-	Sub Ambient(amb As *GLfloat)
-		glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb))
+	Function Ambient () As Color4f
+		Dim amb As Color4f
+		glGetFloatv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb.rgba))
+		Return amb
+	End Function
+	Sub Ambient(amb As Color4f)
+		glLightModelfv(GL_LIGHT_MODEL_AMBIENT,VarPtr(amb.rgba))
 	End Sub
 
@@ -1510,5 +1674,5 @@
 	End Sub
 	Sub Color(c As Color3f)
-		glColor3fv(c)
+		glColor3fv(VarPtr(c.rgb))
 	End Sub
 	Sub Color(red As GLfloat, green As GLfloat, blue As GLfloat, alpha As GLfloat)
