Selasa, 30 Juni 2009

OpenGL ES 2.0 Programming Guide has 3Gs Sample Code

The authors of the OpenGL ES 2.0 Programming Guide have created Xcode projects for all the code provided in the book. This makes the book a lot more interesting from the perspective of an iPhone developer. Anyone read this book and have an opinion on it?

If you download the sample code for the iPhone 3Gs, make sure you grab the build instructions, as it's a little more complex than just opening Xcode and pressing ⌘B.

Beginning iPhone 3 Development

Well, I guess it's okay to talk about this since it's on Amazon, Dave and I have completely updated and revised Beginning iPhone Development for the 3.0 SDK.



Now, the question some people likely have is, "should I buy the new version." Let me be honest with you: For many of you the answer is definitely "no". While Dave and I certainly would appreciate you buying the new edition, there's not a lot of truly new material, and we don't want anyone buying the book under false pretenses. We've incorporated the errata and clarified some of the conceptual material based on feedback from readers and on having had another year of working with the iPhone SDK. We have also tweaked the code to match Apple's current coding style (moving the IBOutlet keyword to the property, for example), and in several cases modified the code to use SDK 3 features, such as using the faster single-step autorotation instead of the old 2-step autorotation.

But, as far as completely new material, we don't include much. There's really only some discussion of table view cell styles and, in the persistence chapter, a new introduction to Core Data. Table view styles are cool, but they're easy enough to understand and certainly don't justify a new purchase for readers who have mastered table views already.

Core Data is probably something a lot of you are interested in, but the coverage in Beginning iPhone 3 Development is pretty introductory-level. We took that same persistence application that we wrote using archiving, property lists, and SQLite, and re-wrote it one more time using Core Data. The application is simple enough that we really don't cover most of the more difficult aspects of Core Data, (but hold that thought).

I don't want to discourage you from buying the revised book, but Dave and I both feel strongly that we don't want readers to feel duped into buying it and unfortunately, the description of the book on Amazon right now is incorrect. The way publishing works is that publishers often put new book descriptions into the computer system that Amazon pulls from long before the book is actually available, sort of as a placeholder. In fact, sometimes publishers put the description into the system before the book is even written. The description now on Amazon for Beginning iPhone 3 Development is still a holdover from that placeholder and talks about some material that is not actually being covered in the updated book, like in-app purchase, push notifications, and mapkit. Unfortunately, we have to wait for the corrected description to ripple through the various computer systems until it shows up on Amazon.

But...

Dave and I do have another project in the works that does cover Core Data in much more detail - several chapters in fact. It also covers many of the new SDK 3.0 features like GameKit, MapKit, Push Notifications, and In-App Purchase in great detail. Plus, we cover some more intermediate and advanced topics such as networking and concurrency. The new book has not officially been announced, but the title of the book will be More iPhone 3 Development. We don't have an availability date yet, but we are furiously working on the book as we speak and will get it done as quickly as we can without cutting any corners.

The reason we have decided not to cover many of the new 3.0 APIs in the updated version of Beginning iPhone Development is precisely because we didn't want people to feel like they had to buy a book they already owned in order to get the new material. We felt that the persistence chapter needed to mention Core Data, but otherwise, we wanted to put all the new material in a second book to avoid forcing people to buy the first book again. At the same time, we felt that the release of the new SDK warranted an update to the first book so that new readers wouldn't be confused by the differences. It also gave us a chance to incorporate errata and clean up a few things.

I hope that's all clear, and I apologize for any confusion the Amazon description may have caused.

Sabtu, 27 Juni 2009

Terminator Salvation

iTunes Link

Terminator Salvation is a shooter game by Gameloft. $4.99

I have never been a fan of the Terminator movies, finding them boring and in the same trash can as Star Trek. I will grant the movie the fact that it has a storyline perfect for a shooting type game, and Gameloft has taken on the challenge of bringing this movie franchise to the big touch screen!

Terminator Salvation plays very similarly to another successful Gameloft game: Brothers In Arms, with the same style of gameplay but improved graphics and controls. The game stays somewhat true to the movie storyline with features in both versions that you can relate to, for example the motocycle level. The aim of Terminator Salvation is to defeat Skynet by fighting with both John Connor and Marcus Wright, two characters from the movie and from what I understood in the cinemas, previous movies as well.

Gameloft’s classic difficulty level settings are the same with easy and medium being unlocked and the ability to play in the hard difficulty after completing one of the two. Generally the hard difficulty doesn’t take my fancy as its the same game, except a bit harder. Terminator Salvation lets you play as the Terminator on hard mode, something that you will only understand after watching the movie, but certainly something different.

3D Games are rare and generally hard to come across on the App Store. Terminator Salvation is probably close to the top of the 3D games with graphics so good that it feels more like a top class PSP game than a simple $4.99 game on the iPhone. The great graphics doesn’t just end with a pretty background, but instead a huge amount of detail and dedication has gone into every aspect of the game, right down to the sparks coming out one of the Skynet’s enemies after a long range headshot.

Fans of the series will enjoy being able to distinguish different Skynet models while playing the game. Each area from the movie has a different color theme, depending on whether it is the dark Los Angeles or dangerous San Francisco. Terminator Salvation was made by a team of Terminator enthusiasts and has therefore been made to make any fan proud, but those disliking the movie series like myself will still get immersed in the environment.

The sound is surprisingly good for a developer who I find it generally lacking in this department. The in-game sound effects are very detailed and actually make it sound like a full on battle zone. There are intro clips before all levels which are from the game’s graphics and look spectacular for a device like this. This is definitely a shooting game to play with the sound on.

The controls in Terminator Salvation have been a huge step-up from what I thought were clunky and often annoying controls in Brothers In Arms. Moving your character involves dragging the virtual joystick in the desired direction. To move the camera to a position that actually allows to see, especially after turning a corner while walking, you just drag your finger on the screen like the process used in The Sims 3. To shoot you use the attack button on the right of the screen and to change your weapon of choice just touch the weapon icon at the top of the screen. Some other options appear from time to time and a button appears just above the attack button.

The game is a lot smoother than Brothers In Arms, and compared to BIA would be like playing the exact same game on the iPhone 3GS compared to the iPhone 3G. Everything just works a lot easier and just feels like a more enjoyable game to play. Skills like hiding behind barriers and walls is easily implemented and gets rid of the need for a lot more controls. The best shooting game I have found on the App Store in the controls, smoothness department by far.

This is one of the best games in terms of action and being a great game that engages you in the gameplay. You don’t get a single moment of rest because around every corner is the chance that one of the smaller, yet deadly fast Skynet robots will come and attack you. Quick reflexes and good aiming skills are the key to defeating the game. The aim of Terminator Salvation is to survive through all the levels by destroying all members of Skynet as well as making it to the end of the level. Each level generally ends with some type of larger boss to destroy and sometimes involves using a simple mini game to defeat them.

The game is, as I said above, filled with action requiring you to shoot and destroy as much as possible. With other members of the Resistance running around to help you fight your battles it really feels like you are on the battlefield, with the same type of feeling that you got from playing Brothers In Arms. There is more than just the classic shooter side of the game, with different levels in the game that let you control a vechile, either a motocycle or a tank. These are great fun to play and a nice way to tie in some of the film aspects with the full on fighting.

Alot of the aspects of Brothers In Arms that I felt let the game down have been improved to give a great gaming experience in Terminator Salvation. The driving levels of BIA were clunky and hard to control, as was some of the movements of your character, such as hiding behind barriers.

While Terminator Salvation gives you a playing time of about 2 hours, this is doubled to 4 hours after playing through the game as the Terminator. I believe the movie went for about 115 minutes (Hooray for Wikipedia) and especially with Popcorn and a Drink on top of the ticket price, is a more expensive exercise than buying this game. While I have just compared this game to Brothers In Arms, it is the best 3D shooter on the App Store by far, easily outclassing others like Resident Evil: Degeneration and Prey Invasion.

Terminator Salvation has class smeared all over what is left of Skynet. Once again Gameloft has prevailed with a outstanding game, showing why they are in what I consider to be the best five game developers/publishers on the App Store (Congratulations to Electronic Arts, Ng:Moco, Chillingo and Freeverse). A great game with graphics to amaze you after every corner. This is seriously one of the better games that you can pick up on the App Store if you enjoy shooting games.

Gameplay- 9/10
Graphics- 9.5/10
Sound- 8.5/10
Overall- 9/10

I would recommend this game if you enjoyed- Brothers In Arms

Tell me what you think about this review at Twitter- http://www.twitter.com/iPhone_Reviews next up is New York Nights

Thanks- iPhone_Reviews

Jumat, 26 Juni 2009

YouTube: 400% Daily Increase in Mobile Uploads since 3Gs

The YouTube Blog is reporting that there has been a 400% increase per day in mobile uploads to their service since the iPhone 3Gs became available. If you read my earlier post, you know that video upload was the first new feature to really grab my interest (and unexpectedly so), so I feel a little vindicated and less weird.

via via Daring Fireball

Rabu, 24 Juni 2009

Blender Export Script

I've revised the Blender Objective-C Export Script. It was a relatively minor change - I was calculating the vertex normals based on the face normals, which was unnecessary work since Blender keeps track of vertex normals as well. On larger models, this version should perform better than the original version since it doesn't have to calculate vertex normals by looping through all vertices on all faces looking for matches.

Empty OpenGL ES Application Project Template Updated for 3.0

I have updated my OpenGL ES Xcode project to work with SDK 3.0. You can find the new version right here.

This new version is actually a rewrite from the ground up, and it fixes several issues that the old one had, including the problem where the controller wasn't receiving touch events and, of course, the fact that it didn't work on 3.0. It also includes more OpenGL-related convenience functions, and a class that makes it easier to do texture mapping.

Using 3D Models from Blender in OpenGL ES

One question I get asked a lot is "how do I load 3D models into OpenGL ES?".

Of course, the answer to that isn't a simple one. If you followed my my earlier posts on importing Wavefront OBJ files, you're probably aware of that already. There are many file formats, and none of them are ideal for loading into a resource-constrained device like the iPhone.

Apple recommends that 3D objects be stored in header files as static arrays. This obviates the need to do any loading or transforming or conversion at all. But… there's not really any easy way to create those header files from within 3D software packages.

Well, there is one way now. The open source 3D program called Blender has a very extensible architecture, making it relatively easy to write custom export modules. Blender's scripting architecture is based on Python, a language that I'm not particularly familiar with, but I hacked out something that works. So, let's say that you've got an object in Blender:

Click to see larger version


And you want to load it into a program you're writing for your iPhone:

Click to see larger version
Note, I know that the screenshots don't actually match - I cropped the texture after exporting from Blender to make it more iPhone sized - I didn't want to resize it for fear that the texture would get too small to see.


All you have to do is take this script and install it into the scripts folder in Blender.

There's a catch, however. The Mac OS X version of Blender doesn't follow the sames rules as it does for other platforms. If you look up how to install a script in Blender, it will tell you to add the script to ~/.blender/scripts/. That directory doesn't get created on the Mac, and if you manually create it, you will lose all the delivered scripts.

Instead, you have to actually install the script into the Blender.app bundle. To make things even more gnarley, the scripts are stored in an invisible folder inside of the Blender bundle. The easiest way to copy the script is to use Terminal.app and the unix cp command. The scripts folder is located at:
/path/to/Blender.app/Contents/MacOS/.blender/scripts
So, if Blender is installed in your Applications folder inside of a folder called Blender, you could use the following command to copy the unzipped script into Blender:
cp objc.py /Applications/Blender/Blender.app/Contents/MacOS/.blender/scripts/

Every time you upgrade your Blender install, you'll have to reinstall this script. The next time you start Blender after copying the script, you will find an entry in the Export menu called Objective-C Header (.h). This is intended to be used with texture-mapped objects, and only exports the active object, not all selected objects or all objects. I am going to create a separate version for non-texture mapped objects. This script will create an inefficient version of non-texture-mapped objects because of the way OpenGL ES uses texture coordinates.

I've also created a sample project that shows how to use the exported header file. It's actually quite easy. You just pass the arrays from the header into the various OpenGL calls, like this:

    glVertexPointer(3, GL_FLOAT, 0, CubeVertices);
glNormalPointer(GL_FLOAT, 0, CubeNormals);
glTexCoordPointer(2, GL_FLOAT, 0, CubeTexCoords);

You can then either use glDrawArrays() or glDrawElements() as you see fit. There are indices provided for glDrawElements(), but since the object is exported as triangles, glDrawArrays() works just fine too.

Before running the script, make sure you put the object into edit mode and select Mesh->Faces->Convert Quads to Triangles. This script will not convert to triangles for you, and OpenGL ES requires triangles. You also need to load and bind the texture you used in Blender, or one that you created based on Blender's exported UV template.

As I said before, I am not a very experienced Python programmer, so if you want to suggest improvements, I'm happy to hear those suggestions. You will not hurt my feelings one little bit. This is what I call a "brute force" script - it gets the job done, but perhaps not with the elegance it should have.

If you want to play around with the simple Blender project I used in the test Xcode project, you can find that right here (right-click and save to disk).

I hope to create a future version that interleaves the data as suggested by Apple, but for now, I was just thrilled to get something working.

Senin, 22 Juni 2009

Mobile Orchard Two Day iPhone Training Class

Dan Grigsby, the founder of Mobile Orchard, just wrote to let me know that he has started offering two-day iPhone programming workshops targeted at developers coming from other platforms like Java and .Net. The workshops are intensive and very hands-on. Over the course of the workshop, Dan walks you through developing seven complete applications and covers many of the core iPhone technologies, including several that are new with the 3.0 SDK such as Core Data.

There are upcoming workshops in the San Francisco Bay Area and in the Seattle area, with more to come in the future.

Dan has been nice enough to offer a $200 discount on the workshop to my readers. You can get this discount by entering the discount code "jeff". Dan has also authored a great series of tutorials that you might want to check out.

A Weekend with the 3Gs

Okay, I've now had my iPhone 3Gs for a few days. My wife's out of town, so I'm on single-parent duty right now, which means I haven't gotten a chance to play with the phone as a developer yet, but I did get quite a bit of time with the phone as a user. I'm still feeling really positive about my purchase. On the surface, the revision from the 3G to the 3Gs doesn't seem that dramatic - same form factor, same operating system. But, in terms of user experience, the difference is huge.

The feature that has impressed me the most is not one that I thought it would be. The ability to take videos is huge, and I didn't really realize how huge until I had a 3Gs in my pocket. The quality of the video is pretty darn decent, and the tap-to-focus works really well. It also adjusts the light-metering based on where you tap, so if you tap to focus on something closer to the camera, for example, it will adjust the light so that the object you focus on can be seen better.

Man, I wish I had this twelve years ago. As a parent, the ability to take short video clips is really great. Pictures are great, but being able to remember what your kids sounded like and seeing their mannerisms is great. You forget things, even things you wouldn't think you'd forget. Having short reminders in the form of videos is great.

We bought a camcorder when my oldest, now twelve, was born, and were diligent about taking video when she was young. As she got older, and the other kids were born, and life got busier, we got less and less good about taking video because it was a hassle. After a few years, we stopped taking video almost altogether, except on vacation sometimes. The camera was big and bulky and importing the video into the computer was a painful, multi-step process. Now, my phone doubles as a video camera, so it's always with me, and importing the video is as easy as plugging it into my computer and pressing a single button.

This weekend, I took several movies and pictures of my boys as we were out and about, and was able to immediately send them to my wife and daughters who are out of town, as well as to my parents who live in Florida. It's pretty amazing how quickly the iPhone 3Gs compresses and sends movies to YouTube over the 3G connection. The quality of the video does suffer a bit, however, when you send it to YouTube. There is a noticeable degradation when you compare the YouTube video to the original pulled from the phone through iPhoto. I couldn't seem to find any way to tell it to use less compression, which I'm guessing is done on purpose to preserve bandwidth. It would be nice to have the option to use less compression, at least when sending over wi-fi.

The ability to zoom and a little higher resolution for still images would be great, but I'm being pretty demanding there. Cell phones have had video for a while, but none have had video like this. I think the video camera will be my most-used feature of this phone, since it will let me share, almost immediately, what's going on with relatives who live far away.

The speed increase is noticeable for me. I upgraded from a first-generation Edge-based iPhone to a 3G phone, which is quite a nice improvement in connection speed. Coverage is quite good around here (it wasn't a year ago), and I'm very happy with the speeds I'm seeing. Even watching YouTube videos is quite tolerable over 3G and Mobile Safari seems lightning fast other than the short latency delay at the start. I'm sure I'll be jaded and wanting more speed in a few months, but for now, I'm really happy with the internet speed I get on this phone.

I haven't pulled down any games that really utilize the capabilities of the new graphics chip and additional memory, nor have I done any OpenGL ES 2.0 work on my own yet, so my impressions of that will have to wait for another day, but I'm sure it's going to floor me. Everything on this phone is snappy, and the demos we saw at WWDC of what can be done with OpenGL ES 2.0 are pretty phenomenal.

Voice control seems to work well. It's not a feature I really care about much, but I've tried about a half dozen commands and they were all interpreted correctly the first time. The last phone I had with voice control was much dodgier in that respect, so if voice control is something that matters to you, I think you'll like the 3Gs.

The Oleoresistant screen, which is supposed to resist fingerprints and smudges, works pretty well also. it's not perfect - it is possible to smudge the screen, especially if your fingers are really dirty. I found out first hand that having wet clay on your fingers, for example, will smudge the screen. But under ordinary use, you should see very few fingerprints, and the screen cleans easily on your shirt or other soft cloth.

Walking directions with the magnetometer are great, and that's quite a boon in a strange city. I can't tell you how many times I've been somewhere traveling and had to walk a block (or two) in order to get my orientation. Knowing which way you're heading is a really great feature and it's implemented almost flawlessly.

I would love to tell you all about MMS and tethering, but um... y'know... AT&T. sigh.

In fact, AT&T is almost my only complaint about this phone. My other complaint is one that I know is simply a limitation of current technology, but the battery life on this thing isn't as good as my first generation iPhone. I know that the 3G radio sucks additional power and all that, but it's still frustrating. Especially when I'm traveling, I use my phone a lot. I use it to check e-mail, and tweet, make calls, and to pass the time on long flights playing games, watching movies, and listening to music. Standby time and music-listening time seem to be at least as good as my old phone, but if I'm actively using the phone with the screen on and with 3G service, the battery goes frustratingly fast. An external battery pack is probably a good investment if you go long periods away from your computer or power outlet.

I saw this morning on TUAW that Apple sold a million iPhone 3Gs's over the weekend. I'm not surprised, as there were still long lines yesterday (Father's day), on the phone's third day of sale. I don't think the sales are going to stop, either. I think it's going to continue to sell very strongly based on strong word-of-mouth. Everyone I've talked to who got one is thrilled with the phone. Granted, many of my friends are, like me, borderline fan-boys, but even taking that into account, it's still an impressive phone.

If you're on the fence, I say go for it if you can afford it. It's a great update that addresses most of my complaints with the original. If you're a developer, especially if you're a game developer or developing anything with a lot of visual impact, I'd say the 3Gs is not only compelling, but necessary. If you want to create cool looking programs, you want to be able to leverage the power of OpenGL ES 2.0 and the new graphics chip and extra memory that the 3Gs provides.

Sabtu, 20 Juni 2009

Castle Conflict



iTunes Link


Castle Conflict is a castle defense game by Broken Kings. $0.99

Games like Defend Your Castle are really successful on the PC for their simple use of throwing away stick people coming to attack your castle. Both this game and a spin-off called StickWars have reaped the benefits of the App Store, with StickWars being the No.1 game for a long time before being dethroned by the useless Moron Test.

Castle Conflict adds in another castle and adds a bit of action in between. The game is a lot of fun, but once you have mastered how to win, it doesn't really give you any reason to continue returning to play. The unique style of play is great, but only for really short periods of time. Instead of just defending your castle against attacks, you also have to defeat the opponents castle without yours being overtaken. But is this game a successful conversion from the classic game format? In some parts it is, in some parts it isn't.

The graphics are pretty good f0r a simple game. They look almost cartoon like, but are a bit pixelatted when you take a deep look at the game. While playing the actual game however you don't tend to notice it at all. The animations are very smooth, with no glitches or freezes what so ever in my entire playing time. The different soldiers move at different speeds but the only let down is how the fighting happens. It seems that you run into them, somebody or both die instantly in a poof of smoke. I would have like to seen a bit of animation or even a quick fight scene between the two. The opposing soldiers and bombs are easy to distinguish due to their different colors in the game.

The game is pretty basic when it comes to sound, with hardly any game related sound effects and really just random ones when you select soldiers to go onto the field of battle. There is SOME background music but its not all that great so it is suggested that you stick listening to whatever you have on your iPhone or iPod Touch at the moment.

This game has probably the easiest controls out of any game I have played for a very long time. All that is required in this game is for you to touch the icon up the top of the screen on the soldier or option that you wish to select, if you have the money of course. This is a very easy way to play and requires no reading of the rules before picking up the game. It however isn't very engaging and often leads me bored and wanting more action than something I would expect from an iMob game. This is really better suited for a flash game on the PC. Defend Your Castle does well on the iPhone because it requires the 'flick' method to engage you in the game, instead of the touch and watch what happens process.

The aim of Castle Conflict is to protect your castle at all costs while managing to destroy your opponents castle. This is done by sending out men to collect wood from the forest in the middle of the field, which becomes the games currency almost. For a dearer price you can send out a ninja to steal wood from the opponents supplies. If a soldier comes along, either walking or on a horse then they will kill any opponents in their path. If they meet a soldier equal to their ability or better then they will be killed. If they make it alive to the opposing castle then they can attack it and inflict damage. The battle is also taken to the air when cannons able to fire cannonballs and air balloons exploding into the opponents castle. Finally for a hefty price you can speed up the amount of wood that is grown in the forest area. The winner is the last one with their castle standing.

This all sounds very easy, but after you progress to medium or hard it requires a well thought out strategy to win. Not only do you have to harvest enough wood to keep your supplies up but you also have to defend them from attacks, attack yourself with soldiers and worry about air attacks. The game is split into three difficulty levels with three times as such for gameplay. You can choose quick, medium or long time limit which basically decides how much damage is inflicted per attack. I didn't see much difference in times when defeating the game between quick and long as it all depends on how well your strategy works.

This is a great game for a while but as soon as you have a strategy down, this game gets downright boring and is begging to get deleted off your iPhone. The game has promised additional levels, game modes and even a multiplayer mode which I assume will be Wi-Fi so it should add to the replayability of Castle Conflict.

While this is a great game to start off with, it doesn't have that engaging factor to bring me back to this game after playing it a few times. There is nothing to be gained from playing the game and is definitely only for those who really enjoy the more casual game. The concept behind the game is good but feels like more of a beta version compared to other games that are doing well at $0.99. We have started to expect more out of the games of this price, especially if they are in the Top 100 games. So, if Broken Wings wants to continue bringing in more buyers they should add content quick smart.

The graphics, animation and gameplay is great but as I just said wears off after a few turns. In this state I would buy this game if you are really into casual games or are hoping to play it alot more with the new content as it is sure to rise to a price upwards of $1.99 with a big update. I'm not screaming at you to get this game, so I will leave the decision up to you whether it is the right game for your iPhone.

Gameplay- 5.5/10
Graphics- 8/10
Sound- 7/10
Overall- 6.5/10

I would recommend this game if you enjoyed- StickWars

Tell me what you think about this review at Twitter- http://www.twitter.com/iPhone_Reviews next up is International Athletics

Thanks- iPhone_Reviews

Willpower Fail

After posting yesterday that I was going to be responsible and wait a few weeks before getting a iPhone 3Gs, I ended up running out and getting one this morning when I found out the nearest Apple store had some still in stock. I got a 32 gig black model. I haven't used it much, but first impressions are pretty fabulous. Video looks good, touch-to-focus works really well, camera does much better in low-light, and sound quality seems to be better. But the biggest difference you notice is how snappy everything is. Apps launch faster, the keyboard responds quicker and never hiccups.

I'll post my full impressions after I've had a day or two to play with it, but I'm really excited to see what people do with this new hardware. I think we're going to see some awesome games and other programs before long.

Jumat, 19 Juni 2009

OpenGL ES 2 Shaders

Looking for a good starting place for creating shaders for the new OpenGL ES 2.0 available on the iPhone 3Gs?

The orange book has an online home that's well worth looking at. The Orange Book (the current version of which actually has more purple than orange) is the official book on the shading language. If you're thinking of writing shaders, this is the first resource you should get. The official site has example shaders and links plus errata, so you might want to bookmark it.

You should also check out this page, which has lots of shader resources, including a zip full of shaders that you can use.

Lastly, in the Developer folder on your hard drive, in /Applications/Graphics Tools, there's a program called OpenGL Shader Builder that you might want to check out.

Upgrading etc.

Sorry for the quiet week. Been suffering from the post-WWDC blues, a combination of being massively behind on my workload and massively tired.

I have updated several of my iPhone projects that don't work after upgrading to 3.0 so that they do, including a completely new version of the OpenGL ES Xcode template. The only problem is, I did all the udpating on a pre-release version of Xcode under Snow Leopard. I need to find some time to install the release version of SDK3 and "downgrade" the Xcode projects before I can post them without violating the NDA.

The next two installments of the OpenGL ES from the Ground Up series are, tentatively, drawing text and hit testing, although I may push those off and insert a OpenGL ES 2.0-specific posting in there first, because I know a lot of people are interested in the ES 2. stuff. Perhaps I'll write an introduction to shaders as my next one. In any case, I'm unlikely to get another OpenGL ES posting done until I've got a few more chapters under my belt, so probably two weeks or so.

In completely unrelated news, the inimitable Wil Shipley tweeted about an interesting blog post by somebody from the Microsoft camp today.

I can only assume this is the latest in their recent ham-fisted campaign to win back marketshare for their products. Other parts of it include a page of outright silly assertions labeled as "facts" and a $10,000 bribe to use IE8.

In this blog post, Guy Claperton insinuates that the twitterverse burst into flames over problems with the iPhone OS 3.0 upgrade. Now, it may be a little immodest to say this, but I think I probably have my finger a little closer to the pulse of the iPhone community than a "freelance journalist" who specializes in small business who is on Microsoft's payroll, and I didn't witness anything close to a meltdown from the 3.0 rollout. There were a few complaints here and there, sure, but that's to be expected with a major OS upgrade, and make no mistake, this was a major upgrade, and it's been only one year since 2.0, so that's pretty impressive. How long did Vista take, again?

Guy then goes on to insinuate that Microsoft users are smarter because they don't upgrade immediately.

How's that again? Really? I don't think I've seen a more blatant form of apologism out of anybody ever, including Microsoft. Right, people didn't upgrade to Vista because they were responsible and cautious.

Bullshit.

People didn't upgrade to Vista because it was a huge flaming pile of dog shit, and instead of fixing it, Microsoft spent millions justifying and defending it, essentially telling their customers they were wrong in the process. Advertising can do a lot, but it can't force people to buy dog shit that is currently on fire. Corporations didn't upgrade to Vista because it was expensive, required hardware upgrades, in many cases also required software upgrades, and offered no compelling new features.

Guy writes off "twitter going crazy for a few hours" to the "fan mentality".

Wow. Yeah, Microsoft doesn't want fans. Seriously, do Microsoft bloggers believe the stuff they write, or are they given an agenda from Marketing and then have to craft something that fits it, like some eighth-grade homework assignment, only in hell?

The fact is, fans are an indication that a company is doing something right. Every company has their fan-boys (and girls) - people who love that company regardless of what they do. But a critical mass of true fans - people who love a company's products so much they wait in line for them - is what companies strive for. It's an indication of success, and there's just no way to spin that to make it look bad.

The 3.0 SDK offered some very neat and very desired new functionality. People wanted the upgrade. Plus, the upgrade was free except for iPod Touch users, for whom it cost a small amount (about $10, if I remember correctly). A few upgrade glitches does not a Vista make, and it's hard to imagine that iPhone OS 3.0 could be labelled anything other than a success.

In related news, I am NOT standing in line for a 3Gs today, as much as I'd like to be. I'm being responsible and waiting for my next royalty check before upgrading my phone. This has been a crazy month for finances, between WWDC, a problem with my wife's car that set us back well over $1k. Also, our clothes dryer blew, our dishwasher blew, and a huge silver maple in our backyard fell down. Because of the latter, we had to hire first an arborist to asses the situation, then a tree removal company to come remove the fallen tree from our neighbor's yard, and then to remove a few other standing trees that posed similar threat of falling. Plus, my wife is taking my daughters on a weeklong trip to Florida to celebrate their birthdays.

So, as you're playing with your new iPhone 3Gs with all its wonderful features, extra memory, and extra speed, please think of me sitting at my desk working with my first generation iPhone.

The VOID


iTunes Link

The VOID is a space shooter game by Alexander Wayne. $2.99

[This is a modified post by TheAppEra]

When I first saw this game I was thinking it was going to be a total disappointment. Looking at the game I thought it would turn out to be a bad Galaxy on Fire look-a-like. I ended up eating my words as this is a great top down shooter with an incredible amount of content.

This is safe to say one of the best hidden gems on the App Store. Before James came to me with this I haven't even heard a single tweet or mention of The Void, and upon looking at the screenshots I was thinking it was going to be a failure. I was thinking a a space shooter with about 10 levels and a survival mode, but instead is a fully fledged game with over 80 levels to explore. When playing this game it seems to me like a top down version of Galaxy on Fire with hundreds of items including weapons, equipment and spaceships available to buy and upgrade. The graphics in this game are pretty basic, but the number of different enemies are a welcome addition from the same ships over and over again. But for a game you probably haven't heard of before, is it worth it?

The Void doesn't have any whiz bang graphics to go with the gameplay which is one of the reasons why people don't buy this game. I am a victim of this as the game doesn't look that great. The game is a pretty basic space environment with the background as stars absolutely everywhere and all the objects floating around. These are pretty basic but what makes these graphics understandable is the amount of objects and enemies floating around in all the enemies.

Not only are there many enemies trying to hunt you down, but many objects pop up in quite a few of the levels. As you progress, you will find more of these hanging around in the levels. Some examples of items that you can find are asteroids, mines, packages and planets. These can be used to your advantage in different ways throughout the game. I will talk more about them later on.

Both the enemy and your own ships start out basic and small, with basic yet original designs. As you progress not only do the ship designs look better but they get bigger with a wider range of choices. Enemies ships also change frequently determining on how far you are into the game. There are hundreds of weapons available to use each with their unique attack and animation.

The controls have been designed perfectly for the space game. To control your space ship you have an up and down arrow to accelerate and reverse with a button to brake. To turn you have to tilt your iPhone in any direction depending on how sharp and quickly you want to turn. Mastering using the accelerator and brake to turn corners can take a while to do it quickly but these controls work well.

To attack there are three buttons, an A B and C button. You can assign certain weapons to certain mounts on your ship which can then be assigned to one, two or all three buttons. In the start it seems like a waste to have different weapons on different buttons but each attack uses energy, so having long distance weapons and short distance weapons on different buttons to save energy could be reasonable later on.

The ships have been designed to move around the levels just like they were in space. Alot of thought has gone into their movement and the ships move just like they were in an area with no gravity. Unlike other shooter games, when going in one direction and turning around you will continue to move forward, almost drifting around slowly instead of a quick turn. This seems more realistic and while taking more time to do, certainly enhances the playing experience.

The basic storyline in The VOID is that you are an insignificant space pirate that raids and plunders various uninhabited lands, before climbing the ranks and eradicating the four neighboring alien races. The VOID plays as a role playing game with over 80 stages to complete in the game with varying difficulties.

The game is split into five sectors basically with the aim of defeating all stages in each sector. The sectors are color co-ordinated and represent the four alien races and one unhabiated section. The enemies and items in each sector vary depending on the difficulty and color of the sector. Darker shades of the colors mean that the level is easier in difficulty than the brighter shades which are ultra difficult. There is a large bright dot for each of the four alien sectors which act as a type of 'boss' level.

The aim of each level is to destroy all of the 'red' items in the level. By red items I mean ones that have a red marker where they are positioned on the map which is on the left of the screen. These include enemies, packages and mines as well as others. These items as well as the yellow items, which are asteroids, drop off the currency in the game to buy ships etc. as well as new ships, weapons and equipment. The game is very challenging and the statement on the description sums up the fighting perfectly, "Winning battles will take skill and not just a big gun". Going up to an enemy and blasting away will often get you killed as your defence will disappear and you will die. The way to kill an enemy successfully is to attack it without getting hit. Often getting its attention then running away or circling it with well timed hits can often kill an enemy.

I personally think the controls dashboard needs a some work. It offsets the quality of the games graphics with super big buttons and what not. It can maybe get transparent a little or make them smaller.

The VOID gladly surprised me, and ending up being an exciting adventure to play. You will find many hours wrapped up in this very challenging game. The VOID plays like more of a role playing game than a space shooter with the original style of play. This has something for everyone, with the ability to try and collect all the ships or beat every sector in the solar system.

While this hasn't had the success of similar games like Galaxy on Fire, don't let that deter you from buying The VOID. For those not sure if they will like this game, as there is a bit of a learning curve to master, there is a lite version with a few levels from the beginning of the game. This is an addicting game, that will keep you hooked for hours on end, definitely one to check out.

Gameplay- 8.5/10
Graphics- 6.5/10
Sound- 7/10
Overall- 7.5/10

I would recommend this game if you enjoyed- Galaxy on Fire

Tell me what you think about this review at Twitter- http://www.twitter.com/iPhone_Reviews next up is Castle Conflict

Thanks- iPhone_Reviews

I would recommend this game if you enjoyed- SimCity

Tell me what you think about this review at Twitter- http://www.twitter.com/iPhone_Reviews next up is The VOID!

Rabu, 17 Juni 2009

iPhone 3.0 OS upgrade video

Here's the link.

Get copy and paste, stereo bluetooth, landscape keyboard, peer to peer gaming and more. SV





Video presentation


Apple

iPod Touch 3.0 OS upgrade video

Here's the link.

Get copy and paste, stereo bluetooth, landscape keyboard, peer to peer gaming and more. SV


Video presentation


Apple

The Sims 3


iTunes Link

The Sims 3 is a simulation game by Electronic Arts. $9.99

[A Modified post from TheAppEra]

The Sims 3 has been well awaited on the App Store with amazing hype. The game has had the best release ever on the App Store, skyrocketing to the No.1 top paid app in less than 24 hours priced at the premium price of $9.99. Is the game worth the price? After a few seconds in the game I could safely say Yes!

I bought the original Sims on the PC with all of the expansion packs and would play it for hours on end. As my computer was only capable of handling one Sims game, I wasn't able to buy and play Sims 2. My first impressions of The Sims 3 were amazing, with graphics that are equal or even better than the original Sims. Obviously for $9.99 and 64MB content in The Sims 3 will not withheld most of the content of its PC counterpart, but it is certainly worthy of its price. Hey! Give us a game that knocks off Moron Test from the top slot, and we're a happy camper. The Sims 3 is cherry on top.

As stated before the graphics are super impressive for an iPhone game. Not only has Electronic Arts made a detailed home for you but every building in the neighbourhood is originally crafted and different from every other house in the game. Everything down to the dustbin outside your house looks beautiful and easily better than many DS, PSP and PC games.

The characters are very detailed with a range of clothes and hairstyles that can be created when you first start the game. The choices are between only a few hairstyles and clothing items with pre-set colour changes. These look great, but I didn't see a shop in the town that changes hair styles or lets you buy and sell clothes. The neighborhood is an amazing place to look around as all the different places look absolutely brilliant. As with Need for Speed the attention to detail is top notch, and this is easily one of the best looking games on the App Store.

The controls in The Sims 3 are exactly the same as the other games in the franchise. For this game however, there are some mini games which have been implemented to use the iPhone's controls which the PC doesn't have. To move around and interact with different objects and people in the neighborhood and your house, all you do is tap on the required spot and select one of the many options. The process is effective and very easy to use as it always has been.

The hardest part of the touch controls is moving the camera angle and zoom around to suit what you are doing at the time. To zoom in you slide a button up and down the right hand side of the screen. To move the camera without changing the angle of it you just slide your finger in any direction on the screen. The hardest part of this is changing the angle of the camera, which is done by having two fingers on the screen and moving them around. I find it hard to change the angle easily and often gets difficult.

The mini games that are on this version use different touch screen controls. Two examples of the four mini games are repairing and fishing. To fish you have to tilt you rod left and right and flick it up when you catch a fish. To repair electronic items from your house you have to throw out the old circuits and replace them with new ones.

The sound in this game is also what I have come to expect from The Sims games. This game provides an experience just like you are in a neighborhood with trees blowing in the wind, cars driving by and various other sounds.

When talking to people they again do not actually talk, instead make the cute yet so hilarious sounds when they do their actions. I love it when you give someone a tender embrace, and it sounds like you are halfway between dribbling and laughing at the same time. These sounds are great and better than having music in the game. The game doesn't sound as good as Need for Speed Undercover or Tiger Woods PGA Tour, but certainly close.

The emphasis in this version of The Sims is more on relationship making and and less on becoming successful with a huge house. One big part of the Sims that is missing from this game is the build mode that many people love doing. I can understand why it is missing with difficulty making a house with a finger, but instead they have the ability to do house upgrades. This gives you a bigger house for $1000, but it seems like you can only upgrade it once.

I was hoping for more upgrades with maybe a second storey, but hopefully they will come in DLC (Downloadable Content). There are many items that can be bought and for your house, with specific items for each room as well as the ability to grow your own food outside. From what I could tell there aren't many extravangant items that are available to put in and out of your house, but I am hoping for expansion packs when the OS 3.0 is released sometime soon.

The house up-keep and person up-keep seem to be alot easier than in The Sims as it gives you more chances to build your relationships with people. Your character can have his own personality that you choose at the beginning of the game. I chose a nice guy who wants to be friends with everyone. He is easily impressed and has a good sense of humour. Not all characters are like this, as you can choose a maniac who talks to trees or even someone who wants to be hated by the entire neighborhood.

As always your career makes you money which lets you get a better house and items. There are multiple jobs which you can do and your profession will go down a certain path. As always though what happens in the game is entirely up to you, whether you decide to have your own bachelor pad and be single or get married and work all the time. This game can be hilarious at times especially when you try and tune up the hot girl on the street, get a budding romance then visit her at her house only to find out she has a boyfriend. Still unphased by the boyfriend and you walk in to get her a hot smooch, he starts to get annoyed and creeped out by you before kicking you out of their house.

The Sims 3 will keep you entertained for hours on end. I have only been playing this game for about 2 hours and I feel like I have only skimmed the top of the iceberg with what there is to come in this game. For $10 this is an incredible game, especially when the full version on the PC is upwards of $80 in some places. Brilliant graphics, sound and gameplay that the world has fallen in with for many years has been successfully brought onto the iPhone.

I can see why this can rose to No.1 in such a short amount of time. The Sims 3 will give you all kinds of experience and easily surpasses the gaming experience of New York Nights, which I found really short. While that game is great for the casual gamer, The Sims 3 provides an experience for all types of gamers which is why it has turned into such a huge game. This is the best game on the App Store by far. If you do not buy this game right now you are definitely missing out on something special.

Gameplay- 10/10
Graphics- 10/10

Sound- 1010/10
Overall- 10/10
~ PERFECT GAME!
I would recommend this game if you enjoyed- SimCity

Tell me what you think about this review at Twitter- http://www.twitter.com/iPhone_Reviews next up is The VOID!

Sabtu, 13 Juni 2009

An Amazing WWDC

Well, WWDC ended yesterday. I'm a little sad about that, though I am looking forward to getting home to my wife and kids. I miss them quite a lot. I find it hard to believe that I used to travel as much as I did. I'm not sure how I handled doing that as long as I did.

Right now, I'm waiting at my hotel in San Francisco until it's time to go to the airport. My brain's not yet quite awake enough to write code, so I thought I'd finally get around to doing a short post about the week. I had the best intentions of doing some status updates during the week, but time was a scarce commodity this week, and many of the nights I got less than four hours sleep (something that used to be much easier for me).

I have very few complaints about this year's show. There were a few sessions that were, in my mind, mislabeled a bit as to their target audience (high level sessions being marked as "Expert", for example). The name badges were also printed in 14-point font so that they couldn't be easily read, But those were tiny blips in an absolutely great week. I doubt that many Apple folks read my blog, but for any of you who might stumble across it, thank you all so much for this past week. I know you all kill yourselves for the months leading up to WWDC. I certainly appreciate the effort you put in, and so does most everybody I talked to this week.

Even if the content hadn't been so great, this week would still have been one amazing week. Thanks to the extraordinary power of the intertubes, most especially the power of Twitter, I was able to meet an awful lot of my wife calls my "imaginary friends" - people that I have interacted with only on the internet. I also met an awful lot of new people.

This week was very special for me personally because it represents the completion of a very long-held goal of becoming a part of the Mac (and now iPhone) developer community. For years, Cocoa was my hobby, done as my work and personal obligations allowed. While I had written for MacTech and participated on and off in the Cocoa-Dev mailing list for years, I was alway on the sidelines and never felt like I was truly a part of the community. I think I can safely say that I have achieved my goal, and it feels good.

It has struck me for years that in the Mac development community there is a very low asshole ratio. Almost everybody is nice. I mean, direct competitors not only get along, they often even consider each other friends. People are relatively unselfish and are happy to help others, regardless of skill level. The iPhone dev community seems to have picked up on this trend, something that I'm very glad about.

And as weird as it sounds, though the people here this week came from many different places and different backgrounds, there was a sense of camaraderie and friendship that's hard to explain or imagine.

Though most of what I learned this last week is under NDA, I can tell you that some (not all, but some) of the information will fall out of NDA on June 17th which is only a few days away. At very least, I plan to update my OpenGL ES template for 3.0 (already done, it just can't be posted until 3.0 GM is released to the public) as well as updated versions of the projects that accompany the OpenGL ES articles. I've also got two more OpenGL ES articles in the pipeline, though it may be quite some time before I can get them done. I'm very behind on some writing projects thanks to this week and have to give that work priority.

Let's see... this is a little bit of a rambly posting, and I apologize. It takes a few days for my brain to recover after WWDC. I didn't take many pictures this week, but I'll finish off by sharing just a couple of things I did shoot.

The first truly odd thing of the week was the fact that a porn producer targeting the iPhone platform paid a bunch of girls to circle Moscone West wearing bikinis while advertising a website and a soi-disant "launch party". For the benefit of those who weren't there, or who got in line early, here is some video (don't play if watching bikini girls yelling "iPorn" is not appropriate where you are):



I'm hardly a prude and do not typically object to seeing attractive young women in very little clothing, but I do have to say this whole thing struck me as odd and somewhat out of place. I can understand the thought process behind this - there were going to be 6,000 geeks in one place, the vast majority of which were young men. But... it just seemed like a bad fit. And though this is probably an indication that I'm getting old, my first thought was to honestly feel bad for the young women. It was so not bikini weather that morning. They were however, as one commenter on YouTube put it, "troopers" about the whole situation. I can't imagine it's easy to be excited about freezing your ass off for money.

Here's another odd, yet wonderful thing from the week for me: I got to meet one of Apple's co-founders: Woz.



For those of you who haven't met us, I'm on the left, Dave Mark is on the right. And though I look drunk in that shot, it was taken just as we arrived and I hadn't actually started drinking yet. Oh, well.

Woz (in the middle of course) was just as nice as I've always heard. Having learned to program on a machine that he designed and for which he wrote much of the operating system, it was really something to get to meet him.

Well, time to pack so I can make the long journey back to my home. Save travels to everyone on their way home.

Selasa, 09 Juni 2009

New iPhone 3 GS: guided tour

The new iPhone is out: runs applications faster (about twice as fast), connects to broadband faster (HSDPA), 3.2 MP camera and does video.
Tell us which applications you use and would like to see. SV


iPhone 3 GS guided tour


Apple WWDC 2009 Keynote address

Minggu, 07 Juni 2009

OpenGL ES from the Ground Up Part 8: Interleaving Vertex Data

Technote 2230 makes many suggestions for improving the performance of your iPhone apps that use OpenGL ES. You're now far enough along in your understanding of OpenGL ES that you should read it. No, really. Go read it, I'll wait.

Okay, done? Under the section titled Optimizing Vertex Data, there's a somewhat cryptic recommendation to "submit strip-ordered indexed triangles with per vertex data interleaved". When Apple makes a recommendation, they usually have a good reason for it, so let's look at how we comply with this one.

First of all, let's look at what it means. Let's break it down:

Strip Ordered: In other words, if your model has adjacent triangles, submit them as triangle strips rather than submitting each triangle individually. We've talked about using triangle-strips in earlier installments, so you already know a little about doing that. It's not always possible to use triangle strips, but for a good many objects you will be able to, and whenever you can, you should because using triangle strips greatly decreases the amount of vertex data you have to push into OpenGL ES every frame.

indexed: This is also nothing new. We've been using vertex indices for a while now. Our spinning icosahedron uses them to create twenty faces with only twelve vertices. glDrawElements() draws based an indices rather than vertices.

Heck, we're doing great so far, aren't we? So far, we seem to be doing all the right things! Let's look at the last part of the recommendation, however:

with per vertex data interleaved: Okay, hmm.. What the hell does that mean?

Okay, time to test out your memory. Do you remember in several of the past installments when we time we talked about functions like glVertexPointer(), glNormalPointer(), glColorPointer(), or glTexCoordPointer ? In earlier installments, I told you not to worry about the parameter called stride and to just set it to 0.

Well, now you can start worrying about stride, because that's the key to interleaving your per vertex data.

Per Vertex Data

So, you might be wondering what "per vertex data" is and how you would interleave it.

You remember, of course, that in OpenGL ES we always pass geometry in using a vertex array, which is an array containing sets of three GLfloats that define the points that make up our objects. Along with that, we also sometimes specify other data. For example, if we use lighting and need vertex normals, we have to specify one normal per vertex in our normal array. if we use texture coordinates, we have to make sure that our texture coordinate array has one set of texture coordinates per vertex. And if we use a color array, we have to specify one color per vertex. Do you notice how I keep saying "per vertex"? Well, these types of data are what Apple is referring to when they say "per vertex data" in that Technote. It's anything that you pass as an array into OpenGL ES that supplies any kind of data that applies to the vertices in the vertex array.

Interleaving

Up until now in this series, we've created one array to hold the vertex data, and additional separate arrays to hold the normal data, color data, and/or texture coordinate data, like so:

separatearrays.png


What we're going learn how to do today is to smush all this data together into a single contiguous chunk of memory:

interleaved.png


Don't worry if you can't read the code in that illustration. When it becomes important, I'll give you the code listing again, that's just to illustrate the point that we're going to have all of our vertex data in a single glob of memory. What that's going to do is put all the data describing a single vertex together in one place in memory. That will allow OpenGL faster access to the information about each vertex. In today's installment, we're going to interleave vertices, normals, and color data, though the same exact technique would work for texture coordinates, or for just interleaving vertices and normals. In fact, in the accompanying Xcode Project, there are data structures defined to handle all three of those interleaving scenarios.

Defining a Vertex Node

In order for this to work, we need a new data structure. In order to interleave vertices, normals, and color data, we need a structure that looks like this:

typedef struct {
Vertex3D vertex;
Vector3D normal;
Color3D color;
}
ColoredVertexData3D;


Pretty straightforward, huh? You just create a struct with each piece of per-vertex data that we're using.

Next, of course, we need to populate our vertex data, so we need to combine those three static const arrays into a single one. Here's what the same icosahedron data looks like specified using a static array of our new datatype:

static const ColoredVertexData3D vertexData[] = {
{
{0, -0.525731, 0.850651}, // Vertex |
{0.000000, -0.417775, 0.675974}, // Normal | Vertex 0
{1.0, 0.0, 0.0, 1.0} // Color |
}
,
{
{0.850651, 0, 0.525731}, // Vertex |
{0.675973, 0.000000, 0.417775}, // Normal | Vertex 1
{1.0, 0.5, 0.0, 1.0} // Color |
}
,
{
{0.850651, 0, -0.525731}, // Vertex |
{0.675973, -0.000000, -0.417775}, // Normal | Vertex 2
{1.0, 1.0, 0.0, 1.0} // Color |
}
,
{
{-0.850651, 0, -0.525731}, // Vertex |
{-0.675973, 0.000000, -0.417775}, // Normal | Vertex 3
{0.5, 1.0, 0.0, 1.0} // Color |
}
,
{
{-0.850651, 0, 0.525731}, // Vertex |
{-0.675973, -0.000000, 0.417775}, // Normal | Vertex 4
{0.0, 1.0, 0.0, 1.0} // Color |
}
,
{
{-0.525731, 0.850651, 0}, // Vertex |
{-0.417775, 0.675974, 0.000000}, // Normal | Vertex 5
{0.0, 1.0, 0.5, 1.0} // Color |
}
,
{
{0.525731, 0.850651, 0}, // Vertex |
{0.417775, 0.675973, -0.000000}, // Normal | Vertex 6
{0.0, 1.0, 1.0, 1.0} // Color |
}
,
{
{0.525731, -0.850651, 0}, // Vertex |
{0.417775, -0.675974, 0.000000}, // Normal | Vertex 7
{0.0, 0.5, 1.0, 1.0} // Color |
}
,
{
{-0.525731, -0.850651, 0}, // Vertex |
{-0.417775, -0.675974, 0.000000}, // Normal | Vertex 8
{0.0, 0.0, 1.0, 1.0}, // Color |
}
,
{
{0, -0.525731, -0.850651}, // Vertex |
{0.000000, -0.417775, -0.675973}, // Normal | Vertex 9
{0.5, 0.0, 1.0, 1.0} // Color |
}
,
{
{0, 0.525731, -0.850651}, // Vertex |
{0.000000, 0.417775, -0.675974}, // Normal | Vertex 10
{1.0, 0.0, 1.0, 1.0} // Color |
}
,
{
{0, 0.525731, 0.850651}, // Vertex |
{0.000000, 0.417775, 0.675973}, // Normal | Vertex 11
{1.0, 0.0, 0.5, 1.0} // Color |
}

}
;


Here is how we pass the information into OpenGL. Instead of passing in the pointer to the appropriate array, we pass the address of the appropriate member of the first vertex in the array, and provide the size of that struct as the stride argument.

    glVertexPointer(3, GL_FLOAT, sizeof(ColoredVertexData3D), &vertexData[0].vertex);
glColorPointer(4, GL_FLOAT, sizeof(ColoredVertexData3D), &vertexData[0].color);
glNormalPointer(GL_FLOAT, sizeof(ColoredVertexData3D), &vertexData[0].normal);


The the last parameter in each of those calls a points to the data corresponding to the first vertex. So, for example, &vertexData[0].color points to the color information for the first vertex. The stride parameter identifies how many bytes of data need to be skipped before the same type of data for the next vertex can be found. That might make a little more sense if you look at this diagram (sorry, it's wide, you may have to expand your browser to see all of this one:

stridediagram.png


What could be easier, right? If you don't feel like typing it all in, you can download the interleaved version of the spinning icosahedron. I've also updated my OpenGL ES Xcode Template with these new data structures<.

We're still not using triangle strips, but merging triangles into triangle strips is going to have to be a subject for a future installment, because it's time to go meet some people at WWDC.

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Lady Gaga, Salman Khan