3

I've been looking at a lot of tutorials trying to find a way to make an OpenGL app written in Swift, but I can't seem to find a good template to use.

Most tutorials suggest using a blank one, but then I have to write a ton of files (such as AppDelegate) all from scratch, which I have no clue how to do.

I tried all the links on this, but the first one doesn't even work and the second one is in Objective-C.

Anyone have anything that might help me?

MysteryPancake
  • 1,365
  • 1
  • 18
  • 47
  • 1
    I strongly discourage you to use Swift for OpenGL app. It is extremely messy. – Matic Oblak Nov 14 '16 at 09:29
  • So I should be using Objective-C? Any example code for that? – MysteryPancake Nov 14 '16 at 09:32
  • 1
    There should be tons of examples, templates and you already mentioned you found one. Anyway even if you are using Swift generally I suggest you to bridge the openGL part from Objective-C. The openGL is very C-like so using Objective-C will help you a lot. Also pure C compiles in Objective-C and you can even compile Objective-C++ so if you get any code in any of the 2 languages you may easily include it into your project... So basically you only need an UIView that overrides the layerClass method and get the render buffer using renderbufferStorage:fromDrawable:. After that use anything. – Matic Oblak Nov 14 '16 at 09:39
  • Okay, I guess I'll use Objective-C. It's just I don't have a clue how to program in that. As long as it works I'll be happy – MysteryPancake Nov 14 '16 at 09:44
  • 1
    Program what in that? The openGL is an API, the calls are pretty much the same in all of the languages. The pain in Swift is that you need to typecast everything in it and that working with data buffers is impossible. Again you can use both in your project very easily so all the logic can still be in Swift. – Matic Oblak Nov 14 '16 at 10:10
  • 1
    tidy bounty here – Fattie Jul 14 '17 at 21:35

1 Answers1

2

I ended up figuring it out myself by using GLKit and smashing together old tutorials. Since OpenGL is just a bunch of functions, all you really need to do is find the right parameters for your programming language.

For anyone else trying to do this, there's some fairly useful resources here and here, and it's also useful to shove in some ported code from Ray Wenderlich if you get stuck. Good luck!

MysteryPancake
  • 1,365
  • 1
  • 18
  • 47