Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tutorials

Reply
 
LinkBack Thread Tools Display Modes
Old 05-12-2009, 04:49 PM   #26 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 96
Default

Quote:
Originally Posted by smasher View Post
If you enabled textures, they'll stay enabled until you turn them off again. If you want to draw your triangle with no texture, call glDisable(GL_TEXTURE_2D) before you draw it.
Thanks for that! Works Great
Austin is offline   Reply With Quote
Old 05-17-2009, 03:29 PM   #27 (permalink)
New Member
 
Join Date: May 2009
Posts: 2
Default books

are there books for openGL es for the iphone if so which are the best ones to read?
spideyleader is offline   Reply With Quote
Old 05-17-2009, 03:46 PM   #28 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 8
Default

I am wondering the same
KMcNamara is offline   Reply With Quote
Old 05-17-2009, 06:17 PM   #29 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

I've looked but there's nothing iPhone specific but you don't really need it to be iPhone specific. The only parts which are iPhone unique with OpenGL ES is the screen size, user interaction, and setting up of your rendering. Everything else is standard across all platforms.

So any OpenGL ES book should apply to the iPhone. Apple's template takes care of most of the iPhone specific stuff which the book won't cover.

The other things such as touches, accel etc are covered on this site and others.
mauriceatron is offline   Reply With Quote
Old 05-17-2009, 06:19 PM   #30 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Guys,

No new tutorial this past week, I've been out of action with the flu and right now trying to catch up on everything with work etc.

I'll try and find some time this week to get back to putting one up in time for the weekend.

Cheers
Simon
mauriceatron is offline   Reply With Quote
Old 05-17-2009, 07:20 PM   #31 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Quote:
Originally Posted by smasher View Post
If you enabled textures, they'll stay enabled until you turn them off again. If you want to draw your triangle with no texture, call glDisable(GL_TEXTURE_2D) before you draw it.
Yeah, I really should go back to that tutorial and fix a few things in that. I get so much email from people who are taking that tutorial in particular way, way, way, way beyond what that tutorial was designed for

Never mind, at least it's being used.
mauriceatron is offline   Reply With Quote
Old 05-24-2009, 02:18 AM   #32 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Just a quick note to all of the new tutorial out. Sorry for the delay (damn swine flu ), and of course the associated

bumpity, bumpity, bumpity, bump, bump, bump, bump....
mauriceatron is offline   Reply With Quote
Old 05-27-2009, 09:35 PM   #33 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 8
Default

Hey simon,

Thanks for posting the touch tutorial...I'm having some problems at the beginning though where I'm trying to set the app to open in landscape mode. When I click the + sign to add a new key to my Info.plist, the option "Initial Interface Orientation" is not there. Any idea why?

Thanks!
KMcNamara is offline   Reply With Quote
Old 05-27-2009, 10:33 PM   #34 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Quote:
Originally Posted by KMcNamara View Post
Hey simon,

Thanks for posting the touch tutorial...I'm having some problems at the beginning though where I'm trying to set the app to open in landscape mode. When I click the + sign to add a new key to my Info.plist, the option "Initial Interface Orientation" is not there. Any idea why?

Thanks!
I think it's because I'm using the latest and greatest version of Xcode (v3.1.3 at the moment which is marked as "Pre-release") and have OS 3 installed as well. I thought I a general upgrade had made editing plists easier but I guess not.

Anyway, the way to fix this is to edit the same plist file and add the following:


Code:
  < key >UIInterfaceOrientation <  /key >
   < string >UIInterfaceOrientationLandscapeRight < /string >
That will get you going. Note skip the spaces around the "<"'s above. Even using the CODE tag, for some reasong the key and value tags were not being displayed.

hooroo
Simon

Last edited by mauriceatron; 05-27-2009 at 10:36 PM.
mauriceatron is offline   Reply With Quote
Old 05-27-2009, 10:38 PM   #35 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 8
Default

Awesome, and what should we put to disable the status bar?

Thanks!
KMcNamara is offline   Reply With Quote
Old 05-27-2009, 10:52 PM   #36 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

From memory, it's

Code:
< key >UIStatusBarHidden< /key > < true />
Otherwise in applicationDidFinishLaunching it's:

Code:
[app setStatusBarHidden:YES animated:NO];
That one I can remember for sure.

Hope that fixes it.

Simon
mauriceatron is offline   Reply With Quote
Old 05-27-2009, 10:58 PM   #37 (permalink)
New Member
 
Join Date: Apr 2009
Posts: 8
Default

You're the man
KMcNamara is offline   Reply With Quote
Old 06-02-2009, 05:20 PM   #38 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 3
Default

Thanks for writing these tutorials! They've been my first ever introduction to Open GL ES.

In the last tutorial, how are these equations used for drawing a circle? I understand that sin = O/A and cos = A/H.

newX = eyeX + radius * cos(TURN_SPEED)*deltaX -
sin(TURN_SPEED)*deltaZ

newZ = eyeZ + radius * sin(TURN_SPEED)* deltaX +
cos(TURN_SPEED)*deltaZ
Steffan is offline   Reply With Quote
Old 06-02-2009, 07:59 PM   #39 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Quote:
Originally Posted by Steffan View Post
Thanks for writing these tutorials! They've been my first ever introduction to Open GL ES.

In the last tutorial, how are these equations used for drawing a circle? I understand that sin = O/A and cos = A/H.

newX = eyeX + radius * cos(TURN_SPEED)*deltaX -
sin(TURN_SPEED)*deltaZ

newZ = eyeZ + radius * sin(TURN_SPEED)* deltaX +
cos(TURN_SPEED)*deltaZ
Hi Steffan,

Yes, I tried to sneak that one past everyone...

Im writing a follow up to that at the moment and will have that posted later on today to explain everything in more detail, as well as covering some other things.

Hooroo
Simon
mauriceatron is offline   Reply With Quote
Old 06-08-2009, 03:29 AM   #40 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 35
Default How to Detect Collision

Hi
Thanx for writing these useful tutorials on openGl Es .
Actually i want to know how to detect collision between two moving objects.
Iam new to openGl. Plz provide help regading this
antilantil is offline   Reply With Quote
Old 06-19-2009, 04:51 PM   #41 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 21
Default

Maurice, - Thanks a lot for the excellent tutorials! If I ever make it big with an app, I'll be sure to donate for your dedication!

For tutorial 8 (labeled 7), I noticed what I think is an error. You say the normal vector is perpendicular to the plane which the vertices make up:



Shouldn't the normal vector point in the opposite direction here? The vertices are going in a clockwise direction, 0 -> 1 -> 2 and by the right-hand rule, the normal should be opposite.
gravity is offline   Reply With Quote
Old 06-19-2009, 09:25 PM   #42 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Quote:
Originally Posted by gravity View Post
Maurice, - Thanks a lot for the excellent tutorials! If I ever make it big with an app, I'll be sure to donate for your dedication!

For tutorial 8 (labeled 7), I noticed what I think is an error. You say the normal vector is perpendicular to the plane which the vertices make up:

Shouldn't the normal vector point in the opposite direction here? The vertices are going in a clockwise direction, 0 -> 1 -> 2 and by the right-hand rule, the normal should be opposite.
Hi gravity,

Perhaps, don't really remember what I was trying to achieve there as that diagram is a bit pointless except that it shows that the normal is perpendicular to a primitive's face. Also, that's a surface normal.

Nah, that section isn't my best work (not that I have any particularly good work). I'll re-write that bit.

Oh, and to answer your question, the normal is the cross product of two of the polygon's edges. That's what gives you the direction, not the right hand rule.

Simon

Last edited by mauriceatron; 06-20-2009 at 09:01 AM. Reason: Fixed stoopid mistake introduced with last "edit"
mauriceatron is offline   Reply With Quote
Old 06-20-2009, 01:44 AM   #43 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 21
Default

Quote:
Originally Posted by mauriceatron View Post
Hi gravity,

Perhaps, don't really remember what I was trying to achieve there as that diagram is a bit pointless except that it shows that the normal is perpendicular to a primitive's face. Also, that's a surface normal.

Nah, that section isn't my best work (not that I have any particularly good work). I'll re-write that bit.

Oh, and to answer your question, the normal is the dot product of two of the polygon's edges. That's what gives you the direction, not the right hand rule.

Simon
Well, I thought it was done quite well- all of your tutorials are succinct, but clear, which makes it easy to tackle one subject at a time. Especially when you bring in screenshots for when you pass differ GL_* parameters in as arguments.

The dot product actually does not return a vector, rather a scalar (which is just a number without a direction). Rather the cross product would return a direction, and using the cross product on any two sides of the polygon in order (going in a loop) will follow the right hand rule.

If somebody is reading this and doesn't know what the right hand rule is, here is a quick definition. If you were to curl your four fingers in the direction that the vertices are loaded, the normal would be in the direction of your upright thumb. It's easier to show visually, here is a quick youtube video showing this, it's the magnetic field induced by an electric current, but don't let that confuse you, just imagine the red circles as the shapes being drawn and the arrows represent the vertices, and they are pointing in the direction that they are created in your array. The blue arrow coming out orthogonal (perpendicular in 3d) from your surface is the normal.

You load the vertices in anti-clockwise direction if you were looking down upon the surface of the polygon, which defines the normal as going outwards. The right-hand rule gives you the normal, which is also the axis that glRotate() calls will rotate around (in the same anti-clockwise direction). As well, when you drop a texture onto it, it faces normal side up (or so I've been led to believe).

Last edited by gravity; 06-20-2009 at 01:59 AM.
gravity is offline   Reply With Quote
Old 06-20-2009, 05:39 AM   #44 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Yes, correct: it is a cross product, not the dot product to calculate the normal.

I rushed that last post so I should really explain that I do not use the right hand grip rule to work out the surface normal. Before OpenGL became "the standard", it was common to use clockwise vertex order to achieve normal calculation for backface removal. X-Sharp, the first 3D library I ever worked with, followed clockwise sequence which the right hand grip rule doesn't apply.

For that reason, I've never relied on the right hand rule. I used the calculated normal. That's not because I'm more hardcore than you, I'm just old and was around when we used the clockwise vertex sequence, so I learned a different way. That's all.

Like I said, I need to go back and fix that section. It's pretty scrappy and I clearly wasn't thinking when I did that drawing because I just "labelled" the 3 points rather than think about what I was trying to say.

Cheers
Simon
mauriceatron is offline   Reply With Quote
Old 06-20-2009, 11:00 PM   #45 (permalink)
jim
New Member
 
Join Date: Jun 2009
Posts: 2
Default

Simon,

Thank you so much for the tutorials! They are very well done and extremely useful. I have only been working with OpenGL ES for a week now and they have helped me a great deal. I look forward to many more!

To anyone who may be interested,

I have spent quite a bit of time over this last week trying to get an object to rotate around it's origin with touch input from the user. Countless Google searches turned up page after page of "lecture notes" on angle/axis, quaternions, and rotation matrices, but nothing to tie it all together -- at least for me. It had been quite a few years since I had to deal with those concepts, and it was pretty rough trying to cram all of that back into my head. But, as I read more, and derived quite a bit on my own, I began to understand most of it. I was almost done implementing my own algorithms (though they had a few issues) when I revisited an example I had seen previously. The difference this time was that I actually understood what it was doing.

So, using Simon's OpenGL ES 10 Tutorial as a starting point, and the code I found at opengl.org, I was able to get the cube to rotate around it's origin the way I wanted. You can download the source files I used from my web site (BizarreSoftware.com) and use them with the tutorial #10 from Simon's site.

Please let me know if there is a better way to do the rotations. It looks like it's working, but I know things are not always as they seem.

Jim
jim is offline   Reply With Quote
Old 06-24-2009, 09:39 AM   #46 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: currently AZ
Posts: 112
Send a message via MSN to kingbombs
Default

Hey,

The tutorials are awesome!
I don't know if you are able to explain a few things or help me with my coding problems to do with 2D textures
I have 2 threads ( both quite similar, although top one is more understandable i think)

http://www.iphonedevsdk.com/forum/ip...-question.html

http://www.iphonedevsdk.com/forum/ip...opengl-es.html

If you can help me at all with anything i mention on either of those two threads, that would be greatly appreciated!
kingbombs is offline   Reply With Quote
Old 06-24-2009, 10:00 AM   #47 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Quote:
Originally Posted by kingbombs View Post
Hey,

The tutorials are awesome!
I don't know if you are able to explain a few things or help me with my coding problems to do with 2D textures
I have 2 threads ( both quite similar, although top one is more understandable i think)
Yes, top one understandable, the bottom one, not so. Just replied to your top thread.

Simon
mauriceatron is offline   Reply With Quote
Old 06-24-2009, 10:12 AM   #48 (permalink)
Tutorial Author
 
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 29
Default

Quote:
Originally Posted by jim View Post
Please let me know if there is a better way to do the rotations. It looks like it's working, but I know things are not always as they seem.

Jim
Hi Jim,

Sounds like you had an long search. I thought there would have been something out there on that. I'll have a quick look over your code later this week and see if there's an easier way.

Let you know.

Simon
mauriceatron is offline   Reply With Quote
Old 06-29-2009, 02:41 PM   #49 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: currently AZ
Posts: 112
Send a message via MSN to kingbombs
Default

Hey,

so i have been searching quite a while for my problem, and if you are stuck on thinking of new tutorials, unless someone messages me a tutorial that is useful it might be a good tutorial to do:
http://www.iphonedevsdk.com/forum/ip...html#post98040

Bassicly creating text in OpenGL ES that doesn't worry about code to change the font selected and just uses the standard font used.
kingbombs is offline   Reply With Quote
Old 07-06-2009, 01:22 PM   #50 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: currently AZ
Posts: 112
Send a message via MSN to kingbombs
Default

Hey,
I have a question regarding your code for loading textures.
- (void)loadTextureNSString *)name intoLocationGLuint)location {....}
this is the method im refering to

Code:
    CGContextRef textureContext = CGBitmapContextCreate(textureData,	texWidth, texHeight, 8, texWidth * 4, CGImageGetColorSpace(textureImage),
kCGImageAlphaPremultipliedLast);

	// This is code added
	CGContextClearRect(textureContext, CGRectMake(0, 0, (float)texWidth, (float)texHeight));

	CGContextDrawImage(textureContext, CGRectMake(0.0, 0.0, (float)texWidth, (float)texHeight), textureImage);
	CGContextRelease(textureContext);
I had noticed that if i applied a block image to the texture, then apply an image thats not square, then around the outside of the last image the block texture would appear.
I used that line to stop the last texture being drawn behind the current one. (this works and fixes it)

But i noticed behind the image thats not a square it appears black. (for example a leg image takes up apart of the square and the rest is black around it (as a texture))
I was wondering how i could get the outside part of the texture transparent, so only the leg image would be applied and around it would be transparent. (so if i had a texture having two legs that doesnt move you could see between its legs)

(sorry if i made no sense),
Is there also a reason why you haven't used that line of code? Or am i being an idiot for using that and should be using something else?

Last edited by kingbombs; 07-06-2009 at 01:28 PM.
kingbombs is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 261
24 members and 237 guests
@sandris, ADY, Dani77, diyora, FAED, fredidf, F_Bryant, GHuebner, HDshot, iDifferent, JamesCahall, JasonR, mer10, Oral B, prchn4christ, Rudy, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Touchmint, twerner, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,753
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0