Starting OpenGL ES

Apprentice
Posts: 19
Joined: 2006.11
Post: #1
Does anyone know of any good tutorials or resources for OpenGL ES (particularly 1.1)? I'd like to learn it, and all I can find are tutorials for platforms like Windows Mobile and Symbian, and with lots of platform-specific code.
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #2
try http://developer.apple.com/iphone tons of examples on OpenGL ES there.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #3
I found their examples to lack useful explanation (maybe it's just me), but a friend suggested this (http://www.amazon.com/Mobile-3D-Graphics...0123737273) book. I went out and bought it, and it seems to do a pretty good job explaining things. If you have prior experience with graphics programming, you can skip a great deal of the beginning right up to the ES stuff, but it's all good material.

Kind of answered my own question, but figured I'd at least try to be helpful and throw you guys the link to the book.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #4
I'm trying to figure out how to detect collision in a game. The way I understand it, I need to write code myself to detect if objects are touching/intersecting, and OpenGL doesn't have support for this built in.

I've been throwing around ideas, and at this point I'm just looking for some confirmation that what I'm saying make sense (or for somebody to tell me a better way to do this).

My idea is to create a class to represent drawn objects. The class will contain information such as its position and bounds in a coordinate system (derived from screen size), and every time I draw a frame, I update the coords and whatnot of my class using knowledge of the animation timer and the magnitude of translations that have been made. After I've got this kind of tracking working, I can just check the bounds of these objects in the draw loop to see if they're intersecting and act accordingly.

I don't really expect anyone to give me a detailed lesson in collision programming or anything, but I'd like to know if I'm doing this right, so any feedback is appreciated.

Thanks Grin
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #5
That method can get very processor intensive if you have many many objects and are working in a 3d world.

In a 2d environment with only a couple dozen objects it may be very doable. Just keep in mind that your processor will need to preform a lot of additional math each frame to make sure nothing has collided.

Take a look at http://www.codeproject.com/KB/GDI-plus/P...ision.aspx has some very simple (for collision detection at least) examples and pseudo code.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #6
Looks good, thanks a ton.
Quote this message in a reply
Member
Posts: 338
Joined: 2004.07
Post: #7
I'd say just use normal OpenGL tutorials (NeHe, etc) while keeping in mind the things you won't be able to use in ES, namely Immediate Mode. If you use NeHe make a point of skipping ahead to the Vertex Array tutorial, and implement that while you work through the first 10-20. After that, you can pretty much pick and choose your topics from NeHe based on what you need.

DylanE Wrote:My idea is to create a class to represent drawn objects. The class will contain information such as its position and bounds in a coordinate system (derived from screen size), and every time I draw a frame, I update the coords and whatnot of my class using knowledge of the animation timer and the magnitude of translations that have been made. After I've got this kind of tracking working, I can just check the bounds of these objects in the draw loop to see if they're intersecting and act accordingly.

The way I approached this is to separate an object's visual representation from its physical representation, but have both representations tied to just one point (or point + vector, for rotations.) That way I can mix + match representations, so if I have a bunch of objects on screen I can switch them all to using bounding circles/spheres, or use more accurate bounds if there's only a few objects.

Justin Ficarrotta
http://www.justinfic.com
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #8
I had been ignoring NeHe with the assumption that it was useless without immediate mode, so I've been teaching myself based on the spec and the book above. Looking at the tutorials, it looks like they could be pretty useful. Thanks for the tip.

Referring to your collision technique: do you mean you would use the data from the visual representation for accuracy and the physical representation using bounding circles/spheres?
Quote this message in a reply
Member
Posts: 338
Joined: 2004.07
Post: #9
Yeah, just replace the NeHe immediate mode stuff with vertex arrays, and proceed as normal. There's some good stuff in there.

On collision, the stuff used for visual representation (3d models, sprites) is separate from the stuff used for physics and collision (bounding volumes.) So a sprite can use a bounding sphere, circle, or 3D axis-aligned bounding box, or I can switch the sprite out for a 3d model and keep the same physical representation. Essentially, it's one thing to the renderer, and something totally different to the physics system.

Justin Ficarrotta
http://www.justinfic.com
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #10
I noticed the Oolong Engine a while back on the Bullet Physics homepage. It's for the iPhone, and has builtin physics.

http://oolongengine.com/

Thought it might be useful!
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #11
Even more useful stuff...

I'll take a look at Oolong, as it looks like it could save me a lot of trouble. Thanks for the tip.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
I had no idea OpenGL ES doesn't support immediate mode! I suppose this is a natural evolution of GL, but what a surprise.

( That being said, the only place I still use immediate mode is in drawing my GUI, and a couple debug visualizations, like drawing AABBs, frustums, etc. All my real rendering is with VBOs ).

I'm buying an iPod touch one of these days, I'm looking forward to learning GL development on it.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #13
I'm relatively new to OpenGL and I'm having a really weird (maybe) problem drawing a pyramid. I can't figure out what I'm doing wrong after a couple hours googling around. Basically, I draw a pyramid and rotate it, but it looks as though I can see through it at times as it rotates. The relevant code is below. Any feedback would be appreciated, as I am totally lost on this one.

Code:
    const GLfloat pyramid[] = {
        -1.0f,-1.0f,1.0f,
        0.0f,1.0f,0.0f,
        1.0f,-1.0f,1.0f,
        
        1.0f,-1.0f,1.0f,
        0.0f,1.0f,0.0f,
        1.0f,-1.0f,-1.0f,
        
        1.0f,-1.0f,-1.0f,
        0.0f,1.0f,0.0f,
        -1.0f,-1.0f,-1.0f,
        
        -1.0f,-1.0f,-1.0f,
        0.0f,1.0f,0.0f,
        -1.0f,-1.0f,1.0f,
    };
    
    const GLubyte pyramidColors[] = {
        255, 0, 0, 255,
        0, 255, 0, 0,
        0, 0, 255, 0,
        
        255, 0, 0, 255,
        0, 0, 255, 0,
        0, 255, 0, 0,
        
        255, 0, 0, 255,
        0, 255, 0, 0,
        0, 0, 255, 0,
        
        255, 0, 0, 255,
        0, 0, 255, 0,
        0, 255, 0, 0,
    };

    [EAGLContext setCurrentContext:context];
    
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
    glViewport(0, 0, backingWidth, backingHeight);
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrthof(-5.0f, 5.0f, -7.5f, 7.5f, -10.0f, 10.0f);
    glMatrixMode(GL_MODELVIEW);    
    glLoadIdentity();
    
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    
    glRotatef(rtri, 0.0f, 1.0f, 0.0f);
    
    glVertexPointer(3, GL_FLOAT, 0, pyramid);
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, pyramidColors);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 9);
    
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
    
    rtri+=1.0f;
Quote this message in a reply
Moderator
Posts: 613
Joined: 2004.09
Post: #14
Dylan do you happen to have a screen shot of what you mean by "can see through it" it can be any number of issues and a picture says a 1000 words =).
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #15
Yes, this is rotated 45 degrees around the X-axis to make the problem more visible. Images of the triangle in various positions as it rotates.

[Image: 2.png]
[Image: 1.png]
[Image: 3.png]

EDIT: Note, there is not supposed to be a bottom on the triangle
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Starting with OpenGL, need some help wsc981 5 5,493 Jul 17, 2010 06:28 AM
Last Post: wsc981
  Starting with OpenGL ES techy 2 2,799 Dec 21, 2009 12:10 PM
Last Post: techy
  starting to work with openGL, need some help smartalco 1 2,640 Mar 26, 2007 08:21 PM
Last Post: arekkusu
  openGL questions before starting 3d engine code chopplebrains 16 7,705 Jan 15, 2003 01:42 PM
Last Post: henryj