OpenGL 3D graphics seems to be a very attractive feature for many potential users of the language. This concerns not only newbies that come and go seeking possible fields of application for their yet undeveloped skills but also some mature individuals like our fellow Fbsl-ers including your humble servant.

Taobert's explorations described HERE have made me think about implementing a compact high-speed math library within the Fbsl source code in order to make some calculations run much faster than they can actually run if performed in a pure Fbsl script.

Computerised 3D virtuality is largely built around fast arithmetical operations with member fields of compound basic entities (user-defined types a.k.a. structures in non-Basic languages) which can be described in Fbsl, for example, as follows:

- Code: Select all
`Type VECTOR3F ' This is a vector (1-dimensional matrix) of three single-precision numeric values`

x As Single

y As Single

z As Single

End Type

Type MATRIX2F ' This is a two-dimensional matrix

m0 As VECTOR3F

m1 As VECTOR3F

End Type

Type MATRIX3F ' This is a three-dimensional matrix

m0 As VECTOR3F

m1 As VECTOR3F

m2 As VECTOR3F

End Type ' et cetera, et cetera, et cetera ...

In fact, vectors and up to 4-dimensional matrices are normally used to calculate all the translations, rotations, colors, normals and texture coordinates of an object in its 3D world. Vector and matrix mathematics involves addition to, subtraction from, multiplication by, etc. of all or individual member fields with one another, or with member fields of other matrices, or with user-supplied numeric literals. This functionality is not hardcoded into the OpenGL dll and is the responsibility of end-user's code.

In Fbsl, this implies e.g. the following explicit calculations:

- Code: Select all
`Function VectorMultiply(vector1, vector2)`

Dim ret As VECTOR3F

ret.x = vector1.x * vector2.x

ret.y = vector1.y * vector2.y

ret.z = vector1.z * vector2.z

Return ret

End Function

A clever way would be to move this function entirely to within the Fbsl source code and expose its name as a new Fbsl keyword (intrinsic function).

A still cleverer way would be to make VECTOR3F, MATRIX2I, MATRIX3D etc. intrinsic Fbsl types and allow the following example expressions:

- Code: Select all
`Dim result As VECTOR3F, vector1 As VECTOR3F, vector2 As VECTOR3F`

' ........ actual vector1 and vector2 value assignments follow here

result = vector1 * vector2 ' That's it!

This functionality can be 'mimic'ed' (don't know how to spell this one correctly to make it sound 'mimikd' rather than 'mimisd' , Yankees please help!... ) in the current Fbsl implementations with overloadable operators in class definitions. But declaring vectors and matrices as classes would make the virtual machine run still slower because classes need additional processing. However, this is true for all languages, interpreted or not.

OpenGL-friendliness is not just another fancy feature. It is a necessity today, an indispensable requirement of a mature language. This is what has made Lua and Python what they currently are.

I'm not polling this question yet. This is a serious challenge and I think we should discuss it far and wide beforehand.