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.
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.
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
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 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:
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.
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.
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
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.
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"
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).
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.
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.
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)
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.
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.
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.
Hey,
I have a question regarding your code for loading textures.
- (void)loadTextureNSString *)name intoLocationGLuint)location {....}
this is the method im refering to
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?