Loading images into OpenGL in iPhone

So you can’t make a game without images, right? Well, actually you can but that’s another story. But how can you load a jpg or a png and use then on OpenGLES? First let’s make a simple class Texture2D class Texture2D { public: Texture2D(int id, int width, int height) { _textureId = id; _width = width; _height = height; } virtual ~Texture2D(void) { // Delete Texture from HGL Memory glDeleteTextures(1, ((GLuint*)&_textureId)); } int getTextureId() {return _textureId; } protected: int _textureId; // The reference ID of the texture in OpenGL memory int _width; int _height; }; Now for the code to actually load the image ...

March 18, 2011 · 2 min · 319 words · David Amador

Vizati for iPhone is now available at App Store

People who follow me on twitter are probably aware, or maybe not: After 3 months tacking an iPhone port it was finally approved by Apple to the App store and it’s on sale today!!! Hypnotizing start… Buy buy buy…. On the count of 3 you will feel refreshed and happy for buying this awesome game… 1 2 3 Oh right, here’s the trailer: I’ve searched some forums and found some talking about it and that they liked, general feedback looks positive. It’s great that people have fun with out little game. If everything goes as planned a version 1.1 with retina support a few other improvements. ...

October 6, 2010 · 1 min · 163 words · David Amador

Setting OpenGL view for iPhone 4 retina hi resolution

This had me scratching my head for awhile. At first I thought that glGetRenderbufferParameterivOES would properly detect Retina screen at 960×640 but it keeps returning 480×320. A little explanation on Retina screen first. Older devices have 320×480 screen resolution. With new iPhone 4 and iPod Touch 4G the screen has 640×960 but on the same physical area. This means that each pixel is 4 times as small. To properly simulate older games resolutions iOS will replace each of your 320×480 game pixel by 4, this way your game will look identical. ...

September 10, 2010 · 2 min · 256 words · David Amador

Targetting iOS devices hardware

I decided to compile all iOS devices specs here so we can get a better glimpse on their hardware and what we can expect from them. This covers iPhones, iPod Touches and iPad. iPhone/iPhone 3G – 412 MHz / 128MB / 320×480 iPhone 3GS – 600 MHz / 256MB / 320×480 iPhone 4 -~800MHz / 512MB / 640×960 iPod Touch 1G – 412 MHz / 128MB / 320×480 iPod Touch 2G – 532 MHz / 128MB / 320×480 iPod Touch 3G – 600 MHz / 256MB / 320×480 iPod Touch 4G – 800 MHz / 256MB / 640×960 ...

September 8, 2010 · 1 min · 156 words · David Amador

iPhone OpenGL screen orientation using the accelerometer

Even tough it’s not mandatory to support all screen orientations it’s always nice to support at least 2 of them. Let’s imagine your game is landscaped, by some reason the user may want to use either with the home button on the left or on the right. Most games support this, if you flip the device, the game will too. I’ve been using OpenGL to support the device orientation, most people on forums want an automatic solution, but belive me, it’s best that you have control on this. ...

August 27, 2010 · 3 min · 500 words · David Amador

Developers log stardate 26082010

It’s been awhile since I last updated this, I’ve have my hands full with Vizati iPhone. Ever since I got an IPod Touch 2G it was easier for Rita to get a sense of the screen size (although we knew to be 320×480) it’s different when you are testing on the real thing, text looks smaller, other stuff looks way too big. Here’s a picture she took after a few adjustments. ...

August 26, 2010 · 4 min · 760 words · David Amador