Fabien Sanglard, a canadian coder (I must say I like his website, simple and neat!), has released the source code of an OpenGL ES rendering engine he wrote back in 2009. This engine called dEngine (again a simple choice!) can be seen as a good introduction of OpenGL ES programming for iPhone. The engine is written in pure C.
Most of the OpenGL ES and shader management code is localized in the renderer_prog.c file. dEngine uses an uber-shader to reduce branching in the fragment shader. The uber-shader contains the code for different kind of materials delimited by some #idef. Final shaders for rendering are generated during the execution and are cached.
Here is a code snippet of the uber-shader used in
#ifdef BUMP_MAPPING bump = texture2D(s_bumpMap, v_texcoord).rgb * 2.0 - 1.0; lamberFactor = max(0.0,dot(lightVec, bump) ); specularFactor = max(0.0,pow(dot(halfVec,bump),materialShininess)) ; #else lamberFactor = max(0.0,dot(lightVec, v_normal) ); specularFactor = max(0.0,pow(dot(halfVec,v_normal),materialShininess)) ; #endif #ifdef SPEC_MAPPING vec3 matTextColor = texture2D(s_specularMap, v_texcoord).rgb; #else vec3 matTextColor = matColorSpecular; #endif
More details and source code download of this iPhone / OpenGL ES engine HERE. You can find other details HERE.
And don’t forget id Software version of Wolf3D for iPhone. You can download Wolf3D for iPhone HERE.
downloaded doom and quake1,2,3 ports for my cheap 7″ tablet runnin android 2.1 and supporting OpenGL ES1.0…without any specialised graphics hardware..
it manages to get about 5fps!.. i need to upgrade now ive been bitten by the Android!