Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,704
6,296
For my next iOS app, I think I'd like to take a stab at making a 3D game.

I've followed Ray Wenderlich's tutorial on drawing models using GLKit/OpenGL ES 2.0, but I'm not really sure I know how to go from that to having a game.

I think the next thing I need to learn how to do is this:
how do I create multiple instances of a single model effectively?

Ideally it seems like I would have one file containing a level which explains which models should be placed where and then several other files defining what each model look like.

And while I'm aware that things like Unity are out there to simplify this process, I feel like I might lose out on some valuable learning experiences if I just use that.

I have the book OpenGL ES 2.0 Programming Guide, published by Addison Wesley, but I haven't even looked at it in nearly two years (when I discovered it was way over my head... am I to the level where reading it would be worth my time now?)
 
Are you writing a game to learn OpenGL, or are you writing a game to write a game?

If the former, I guess you'll have to dig deep into OpenGL (and I can't help ya). If the latter, I suppose you should consider using unity or some other engine that takes care of a lot of the gritty stuff for you.
 
Hmmm, well best of luck! OpenGL makes my head hurt. :p

Haha, mine too.

I've cracked the book open and started going through it... some of the types are confusing me a little though.

List of types I've seen that I'm not quite sure what are...

vec3
vec4
varying
GLKMatrix4

These are all things that I've seen come before variable declarations, like, where you'd have int or float, but instead they have something like varying vec4, as in

Code:
varying vec4 v_color;

What? What is a vec4 and what does varying do to it?

Edit: Unless... is it akin to saying
Code:
NSMutableArray *v_color = [NSMutableArray arrayWithCapacity:4];
or something like that? Varying means I'm allowed to set it multiple times (like being a mutable object,) and vec4 means it's an array that can hold 4 values?
 
Haha, mine too.

I've cracked the book open and started going through it... some of the types are confusing me a little though.

List of types I've seen that I'm not quite sure what are...

vec3
vec4
varying
GLKMatrix4

These are all things that I've seen come before variable declarations, like, where you'd have int or float, but instead they have something like varying vec4, as in

Code:
varying vec4 v_color;

What? What is a vec4 and what does varying do to it?

Edit: Unless... is it akin to saying
Code:
NSMutableArray *v_color = [NSMutableArray arrayWithCapacity:4];
or something like that? Varying means I'm allowed to set it multiple times (like being a mutable object,) and vec4 means it's an array that can hold 4 values?

Take what I say with a grain of salt because every time I get back into OpenGL some other project rips me right back out.

As for learning, I would highly suggest not making a game with it from the bat. There is lots to worry about in a game (not sure if you ever wrote one or not so if you did disregard) and it'll just get in the way of learning OpenGL.

Also for learning it, there is the old way with a fixed function pipeline and the newer way using shaders. The new way (OpenGL 3 and higher) is what you'll want to probably work on learning, although many people suggest learning the old way first to grab the concepts, then switch to the new way.

As for your vec3 and vec4 those *should* be vector types which is more of a struct than an array. Take for instance a point in 3D space:

vec3 myCoords = (25, 25, 0);

For a vec4, something like a color would fit in there (a color with an alpha channel)

vec4 myColor = (0.25f, 0.25f, 1.0f, 1.0f);

The first three arguments in the red, green, and blue channel respectively, and the fourth argument is the alpha so if its less than one, and your blend modes are enabled the color will blend with what is behind it.

I'm not sure what varying is, I've never run in to that but the

"GLKMatrix4" is most likely a 4 x 4 matrix used for something like custom transformations. I'm not sure if OpenGL supports built in transformations or not anymore, if not this would be one use for these.

I hope this made more sense than confusion. Its been awhile since I got to play in OpenGL and I'm not quite sure how to translate it to Objective-C since I've always used it in C++.

EDIT: Also remember, take the above with a grain of salt! Its been awhile since I used OpenGL, and when I did use it it was an older version so some of my info may be incorrect.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.