Wednesday, June 1, 2011

iPhone OpenGL ES

So I already know how to program on the iPhone for the most part since I took on a small project for work for a few months.

Today I decided to explore the functionality of the device a bit more by checking out OpenGL ES.

About 2 years ago I did a course on OpenGL, but I quickly realized that I wouldn't be able to just copy paste my old code and expect it to work. Things are a bit different in the iPhone setup (and the fact that my old code is written in C, the iPhone uses C++[oops I meant Objective-C])

After a bit (read: a lot) of googling, I was able to get a basic setup done. Its a shame that the default one apple provides starts the application off with using shaders, which even for someone who took a class on this 2 years ago was a bit tough. In the end though I was able to get a triangle drawn and rotate it. Pictures? I do think so!

Some of the code, there is more but these two functions are the heart of it all

The multicolored triangle

It's rotating*
*Note that  though in the last screenshot the triangle should have been rotating it rather looks like its just moving up. I'm not 100% sure why this is, but I think it might have something to do with my view projections. I'll be working on this again tomorrow and trying to get some better results.


Also 100 + followers. Yay!

8 comments:

  1. Wait, doesn't the iPhone use C# not C++

    ReplyDelete
  2. My girlfriend wants to get on this, I'll send her the link!

    ReplyDelete
  3. @Marquall no it uses Objective C

    ReplyDelete
  4. I made an error in the post, where I had C++ I meant to have Objective C

    ReplyDelete
  5. i don't one iphone yet but i will soon

    ReplyDelete
  6. Woah, looks very technical. Impressive post! Keep up the good work!

    ReplyDelete
  7. Gotta lotta
    extraordinary
    exponential
    exactly.
    Wannum?

    ReplyDelete