SwiftGL fundamentals are now complete!


(David Turnbull) #1

Behold, the power of Swift:

public func +<T:GLmathScalarType>(x1: T, x2: T) -> T {
    return T(x1, x2, +)
}

This is how the addition operator is implemented in SwiftGL. There's no
gyb, no macros, and no shenanigans. In less than 80 characters we created
an addition operator for 36 types.

SwiftGL fundamentals are now complete. Everything in the OpenGL 4.5 spec is
available in the loader. All the types, operators, and functions in the
GLSL 4.5 spec are available in the math library. This is a strong
foundation for 3D programming with the open source Swift. Nobody is going
to pull the rug out from under you since everything is implemented to a
spec that's been developed for over 20 years.

Funny thing is, even though everything is written to a C spec, it's all
very Swifty. All the types are MutableCollectionType, Hashable, and
Equatable. Almost everything is generic with deep prototypes. Even most of
the functions were already in Swift with exactly the same name. About the
only disconnect is that GLSL types aren't capitalized.

To prove the math library I wrote a new demo. This one has basic lighting
and camera movement with WASD. It will work on Mac and Linux. Give it a try.

Even if you're not interested in 3D programming, if the above example has
you curious there's more where that came from. SwiftGL has over 36000 lines
of code across 49 files. It was all written by one person after Swift
became open source and no, that's not an extra zero.

https://github.com/AE9RB/SwiftGL

There's still plenty to do. Documentation, tutorials, more unit tests,
libraries for resource loading, graph management, and functions that's
aren't in the spec. I'm optimistic that others will see Swift as a great
tool for creative coding and we'll soon have awesome tools.

-David "Expression too complex" Turnbull


(Gavin Eadie) #2

Quick reaction: Amazing!
Second quick reaction: In "glfw3_shim.h" .. 'GLFW/glfw3.h' file not found

This with Xcode 7.2 (therefore Swift 2.1) .. maybe Swift 2.2 is necessary?

···

On Sat, Jan 16, 2016 at 2:52 PM, David Turnbull via swift-users < swift-users@swift.org> wrote:

Behold, the power of Swift:

public func +<T:GLmathScalarType>(x1: T, x2: T) -> T {
    return T(x1, x2, +)
}

This is how the addition operator is implemented in SwiftGL. There's no
gyb, no macros, and no shenanigans. In less than 80 characters we created
an addition operator for 36 types.

SwiftGL fundamentals are now complete. Everything in the OpenGL 4.5 spec
is available in the loader. All the types, operators, and functions in the
GLSL 4.5 spec are available in the math library. This is a strong
foundation for 3D programming with the open source Swift. Nobody is going
to pull the rug out from under you since everything is implemented to a
spec that's been developed for over 20 years.

Funny thing is, even though everything is written to a C spec, it's all
very Swifty. All the types are MutableCollectionType, Hashable, and
Equatable. Almost everything is generic with deep prototypes. Even most of
the functions were already in Swift with exactly the same name. About the
only disconnect is that GLSL types aren't capitalized.

To prove the math library I wrote a new demo. This one has basic lighting
and camera movement with WASD. It will work on Mac and Linux. Give it a try.

Even if you're not interested in 3D programming, if the above example has
you curious there's more where that came from. SwiftGL has over 36000 lines
of code across 49 files. It was all written by one person after Swift
became open source and no, that's not an extra zero.

https://github.com/AE9RB/SwiftGL

There's still plenty to do. Documentation, tutorials, more unit tests,
libraries for resource loading, graph management, and functions that's
aren't in the spec. I'm optimistic that others will see Swift as a great
tool for creative coding and we'll soon have awesome tools.

-David "Expression too complex" Turnbull

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Gavin Eadie) #3

I did say "quick reaction" !!
More reading of internal README's reveals "Install GLFW
<http://www.glfw.org/> version 3" ..

···

On Mon, Jan 18, 2016 at 2:46 PM, Gavin Eadie <gavin@umich.edu> wrote:

Quick reaction: Amazing!
Second quick reaction: In "glfw3_shim.h" .. 'GLFW/glfw3.h' file not found

This with Xcode 7.2 (therefore Swift 2.1) .. maybe Swift 2.2 is necessary?

On Sat, Jan 16, 2016 at 2:52 PM, David Turnbull via swift-users < > swift-users@swift.org> wrote:

Behold, the power of Swift:

public func +<T:GLmathScalarType>(x1: T, x2: T) -> T {
    return T(x1, x2, +)
}

This is how the addition operator is implemented in SwiftGL. There's no
gyb, no macros, and no shenanigans. In less than 80 characters we created
an addition operator for 36 types.

SwiftGL fundamentals are now complete. Everything in the OpenGL 4.5 spec
is available in the loader. All the types, operators, and functions in the
GLSL 4.5 spec are available in the math library. This is a strong
foundation for 3D programming with the open source Swift. Nobody is going
to pull the rug out from under you since everything is implemented to a
spec that's been developed for over 20 years.

Funny thing is, even though everything is written to a C spec, it's all
very Swifty. All the types are MutableCollectionType, Hashable, and
Equatable. Almost everything is generic with deep prototypes. Even most of
the functions were already in Swift with exactly the same name. About the
only disconnect is that GLSL types aren't capitalized.

To prove the math library I wrote a new demo. This one has basic lighting
and camera movement with WASD. It will work on Mac and Linux. Give it a try.

Even if you're not interested in 3D programming, if the above example has
you curious there's more where that came from. SwiftGL has over 36000 lines
of code across 49 files. It was all written by one person after Swift
became open source and no, that's not an extra zero.

https://github.com/AE9RB/SwiftGL

There's still plenty to do. Documentation, tutorials, more unit tests,
libraries for resource loading, graph management, and functions that's
aren't in the spec. I'm optimistic that others will see Swift as a great
tool for creative coding and we'll soon have awesome tools.

-David "Expression too complex" Turnbull

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(David Turnbull) #4

That green box isn't too exciting. I upgraded the demo so there are
hundreds of colored boxes spinning and moving around.

-david

···

On Mon, Jan 18, 2016 at 12:05 PM, Gavin Eadie <gavin@umich.edu> wrote:

Voila!

On Mon, Jan 18, 2016 at 2:56 PM, Gavin Eadie <gavin@umich.edu> wrote:

I did say "quick reaction" !!
More reading of internal README's reveals "Install GLFW
<http://www.glfw.org/> version 3" ..

On Mon, Jan 18, 2016 at 2:46 PM, Gavin Eadie <gavin@umich.edu> wrote:

Quick reaction: Amazing!
Second quick reaction: In "glfw3_shim.h" .. 'GLFW/glfw3.h' file not
found

This with Xcode 7.2 (therefore Swift 2.1) .. maybe Swift 2.2 is
necessary?