QoD XO devlog 2

I’ve been tweaking a lot of the gameplay to be suitable to use with a game controller and I’m starting to like the way it’s headed, it’s much more streamlined, faster and easy to use than the first attempt I made, some beta testing with a group of people helped with that. Last week I started porting the engine to DirectX, yeah it’s that fun moment where nothing works, crashes everywhere....

January 11, 2015 · 1 min · 145 words · David Amador

Native game on Android & Porting Quest of Dungeons

Quest of Dungeons was made in C++ and OpenGL, it runs on Windows, Mac and Linux in native code. iOS is not a problem either since I just have a thin layer of Objective-C to access some functionality like touch, accelerometer, etc and the rest of the code just runs. I never made anything for Android, in fact I never even used one before this, so when I decided to port QoD to it, I had no idea of what to expect....

August 30, 2014 · 6 min · 1205 words · David Amador

OpenGL Camera 2d with zoom and rotation

I’ve been working on OpenGL for some time now and one of the things that some people have asked me is how to do that 2d camera with zoom and rotation in a similar way to a post regarding a XNA 2D Camera I wrote some time ago. Some of them where just subtracting the camera position to all objects drawn, but that’s just ‘ugly’ in my opinion. And the advantage of using a more complicated (at first glance) system as a matrix is that you can easily apply more complicated operations like scaling and rotation....

July 11, 2013 · 3 min · 587 words · David Amador

OpenGL 2D Independent Resolution Rendering

Around two years ago I made a tutorial for XNA in which you could render 2D games scaled to the current window resolution with proper letter-boxes or pillar-boxes. As many know since then I moved to C++ and OpenGL, and ocasionally people ask me “Can you still do that independent resolution thing?”, and yes it’s perfectly possible. I’ve used this on all latest Windows, Mac and iOS, in case you are wondering....

April 22, 2013 · 3 min · 539 words · David Amador

How to take screenshots in opengl

So here’s some quick code to save a screenshot of your OpenGL game in a TGA file. bool save_screenshot(string filename, int w, int h) { //This prevents the images getting padded // when the width multiplied by 3 is not a multiple of 4 glPixelStorei(GL_PACK_ALIGNMENT, 1); int nSize = w*h*3; // First let's create our buffer, 3 channels per Pixel char* dataBuffer = (char*)malloc(nSize*sizeof(char)); if (!dataBuffer) return false; // Let's fetch them from the backbuffer // We request the pixels in GL_BGR format, thanks to Berzeger for the tip glReadPixels((GLint)0, (GLint)0, (GLint)w, (GLint)h, GL_BGR, GL_UNSIGNED_BYTE, dataBuffer); //Now the file creation FILE *filePtr = fopen(filename....

September 8, 2012 · 1 min · 199 words · David Amador

Engine, video player and tools, tools tools!

So these past 2 weeks I’ve been adding some “bits and bytes” to the engine. Taking a rest between some more complex game mechanisms I decided to start doing a video player. After a bit research I decided to choose theora, but a bit skeptic, I’ve used it before on a game company I worked at and I remember being a tiny nightmare, specially because of YUV->RGB(A) conversion and because of video/audio sync....

January 29, 2012 · 3 min · 532 words · David Amador

OpenGL Render to Texture

Render to texture is a very handy functionality. Imagine your game allows for some character customization. You have the body, some different hats, different clothes and other small stuff. Now the easiest way to render this is to just draw it piece by piece every frame. With the proper Z coordinates everything falls in place. But you now have like 4-5 draw calls for one single object. Worse, you might have different textures and swamping textures is expensive....

April 29, 2011 · 2 min · 238 words · David Amador

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

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

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