Friday, 3 August 2012

LavaGlo Update with Retina Graphics

Our first App has been updated to use retina graphics. Lava looks far smoother and the UI has also had a revamp to look even shinier! Check it out!


Sunday, 1 July 2012

High Definition Player Tank

Having decided on displaying the Player's vehicle in the Front-end it became apparent that more detail would be required, especially for high-end devices such as the iPad3. I recently upped the poly count slightly but more importantly recreated the combatant textures at 4x the size.



Friday, 29 June 2012

Mixing UIKit with OpenGL ES on iPhone

UIKit is a rich library with classes that have been highly polished by Apple. Lot's of development time can be saved by using it in the right way in your game's UI, however, there are problems that can arise.
Standard buttons and the like tend to sit on an OpenGL view without too many issues but as soon as you start using something slightly more complex such as a UISlider, the problems start.
I have a screen 90% drawn in OpenGL with an animated 3D model of a ship rotating round in it. This is kind of important as I need the ship to update in real time whilst a sliding control underneath shows different items the player may select. I wanted to make use of the UISliders functionality for this task.
I started by having a horizontal UISlider with a content width set based on the number of items and their size. I set it to not clip subviews. This allows me to display parts of items on screen that aren't currently centred by the page snapping of the UISlider.

The first problem I encountered was when I pressed down on the UISlider it would block the OpenGL ES layer animating, so the ship and any other OpenGL animation would pause. This is really ugly to watch.

The first step to fixing this is to change the display link run loop mode from

[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]

[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]

Stackoverflow: OpenGL Animation freezes with UIScrollView

This fixed the OpenGL blocking behaviour but meant that some touch events were being missed on the UISlider. So I investigated further and found a fix to this where someone put the OpenGL draw loop in a grand central dispatch thread. Like so:

if (dispatch_semaphore_wait(frameRenderingSemaphore, DISPATCH_TIME_NOW) != 0) { return; }

dispatch_async(openGLESContextQueue, ^{ [EAGLContext setCurrentContext:context]; // Render here dispatch_semaphore_signal(frameRenderingSemaphore); });

I found this at:

CADisplayLink OpenGL rendering UIScrollView behaviour

courtesy of the 'Molecules' app creator Brad Larson

This fixed the issue entirely... however, for some reason my UIView slider items would sometimes just not appear now! Sometimes they would appear after a large delay (10 seconds or so) and sometimes a variable number of them would appear. I then investigated a work around for this.

It turns out that there are several hacky ways to force the main run loop to update after calling a UIView's setNeedsDisplay function and whilst these seemed to help somewhat they were far from a concrete 100% fix for me.

Stackoverflow: more ways of controlling UIView rendering and some hacks

In the end I decided to stop using custom UIViews for rendering and just kept the UISlider for it's polished physics whilst rendering my own OpenGL buttons in the same positions as the slider's items. This gives me no further rendering issues but let's me keep using the best part of the UISlider - it's physics and touch functionality, whilst leaving the graphics control entirely with me using OpenGL.

Sunday, 3 June 2012

Tutorial

I've decided that I will feature a tutorial level, which the user will be forced to play through (for now). Lots of different views on how the tutorial should be done and the current one I've knocked up is subject to change at the moment. Forcing the player to do it means that they will definitely learn the mechanics, however, it also means you can annoy some users who really just want to play quicker.

One way to alleviate this is to keep the tutorial level very easy and lightning quick for someone who knows what to do already whilst also integrating it into the setting/story as much as possible to keep it interesting - sort of like the Half-life hazard course.


Thursday, 17 May 2012

Lava Planet

It's been a while since my last update but I have been busy as ever working away on the game. I'm fairly pleased with the way the Egyptian campaign plays and looks these days. Progress on the lava world has been great, the art and test level has gone through a couple of iterations and reached a fairly decent dark/hot atmosphere! Lava worlds are common in computer games but I still find them awesome to look at. Trying to think a bit more about how I can perhaps put my own spin on the environment.


Sunday, 22 April 2012

Force Landscape framebuffer in OpenGL ES 1.1

I've fixed an orientation bug I had related to the first frame buffer created having incorrect dimensions - as if the app were launched in portrait mode.

Before in my plist:

UISupportedInterfaceOrientations

UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight


Changed to:

UISupportedInterfaceOrientations

UIInterfaceOrientationLandscapeRight
UIInterfaceOrientationLandscapeLeft


In both situations the correct landscape orientation comes through the root view controller but only with the latter array order does it make the initial framebuffer with the correct dimensions!

Please note, the frame buffer is created twice on launch still. The very first time is always portrait dimensions but the second is now landscape (960x640 on iPhone 4). This was not happening until I changed the order of the supported orientation array above.

This bug was in OpenGL ES 1.1 using the now deprecated EAGLView.

Monday, 26 December 2011

Articles on Programming Optimisation

I've linked below some great articles on optimisation. Some of the later ones are quite low level and more just points of interest rather than proving especially useful these days, at least for my purposes.

Some key rules to follow
http://assemblyrequired.crashworks.org/2008/12/22/ea-stl-prevents-memory-leaks/#more-92

Lots of general tips and great blog
http://assemblyrequired.crashworks.org/category/programming/

Good one on branching and data layout for game systems/containers again
http://altdevblogaday.com/2011/11/10/optimisation_lessons/

Optimizing for cache coherence – excellent, and a good reminder of why thinking about the data flow in a program is so important.
http://supercomputingblog.com/optimization/taking-advantage-of-cache-coherence-in-your-programs/

From:
http://gamedev.stackexchange.com/questions/853/c-low-level-optimization-tips

A very, very low-level tip, but one that can come in handy:

Most compilers support some form of explicit conditional hinting. GCC has a function called __builtin_expect which lets you inform the compiler what the value of a result probably is. GCC can use that data to optimize conditionals to perform as quickly as possible in the expected case, with slightly slower execution in the unexpected case.

if(__builtin_expect(entity->extremely_unlikely_flag, 0)) {
// code that is rarely run
}
I've seen a 10-20% speedup with proper use of this.

http://gamesfromwithin.com/data-oriented-design

Use const when possible – it can make the compiler optimise things.

http://diaryofagraphicsprogrammer.blogspot.com/2008/11/iphone-arm-vfp-code.html

_restrict keyword for telling the compiler pointers won’t alias (one pointer -> one instance of data ratio)
http://cellperformance.beyond3d.com/articles/2006/05/demystifying-the-restrict-keyword.html

:? Sometimes compiles to be faster than if else
http://assemblyrequired.crashworks.org/2009/01/04/fcmp-conditional-moves-for-branchless-math/

purecall and virtual function overhead
http://thetweaker.wordpress.com/2010/06/03/on-_purecall-and-the-overheads-of-virtual-functions/

Friday, 14 October 2011