PDA

View Full Version : Finished first porting on proton, a very simple game



eye776
08-10-2011, 03:43 AM
Finally, it is done.

Many thanks to Seth for the Proton SDK, and although I must confess that the QT-like design did
"wonders" for my nerves :D, it can be wrestled out of (not that it was free, mind you, the price for
that was losing auto-scaling.)

Apart from that, frankly, it's a great way to get started with irrlicht on android.

So, here are a couple of fixes made over the course of this porting (also posted them on the irrlicht forum):

1) FILLED circles in irrlicht:

You'll need to update CNullDriver.h, CNullDriver.cpp, IVideoDriver.h, IVideoDriver.cpp and your own code.
Also works with OpenGL ES (for interested parties).

EDIT: No ideea what's with the '*' characters.



void CNullDriver::draw2DPolygon(core::position2d<s32> center,
* * * * f32 radius, bool filled, bool outline, video::SColor color, s32 count)
{
* * * * if (count < 2)
* * * * * * * * return;
*
* * * * if(outline)
* * * * {
* * * * * * * * core::position2d<s32> first;
* * * * * * * * core::position2d<s32> a,b;
*
* * * * * * * * for (s32 j=0; j<count; ++j)
* * * * * * * * {
* * * * * * * * * * * * b = a;
*
* * * * * * * * * * * * f32 p = j / (f32)count * (core::PI*2);
* * * * * * * * * * * * a = center + core::position2d<s32>((s32)(sin(p)*radius), (s32)(cos(p)*radius));
*
* * * * * * * * * * * * if (j==0)
* * * * * * * * * * * * * * * * first = a;
* * * * * * * * * * * * else
* * * * * * * * * * * * * * * * draw2DLine(a, b, color);
* * * * * * * * }
*
* * * * * * * * draw2DLine(a, first, color);
* * * * }
* * * *
* * * *
* * * *// DRAW A FILLED CIRCLE IF ASKED FOR ONE
* * * *if(filled)
* * * * {
* * * * * * * * S3DVertex* vertices = new S3DVertex[count];
* * * * * * * * u16* indices = new u16[count];
*
* * * * * * * * vertices[0] = video::S3DVertex((f32)center.X, (f32)center.Y, 0.f, 0, 0, 1,color, 0, 0);
* * * * * * * * indices[0] = 0;
* * * * * * * *
* * * * * * * * for (s32 i = 1; i < count; i++)
* * * * * * * * {
* * * * * * * * * * * * f32 p = i / (f32)(count - 2) * (core::PI*2);
* * * * * * * * * * * * vertices[i] = video::S3DVertex(
* * * * * * * * * * * * * * * * (f32)center.X + (radius * cos(p)),
* * * * * * * * * * * * * * * * (f32)center.Y + (radius * sin(p)),
* * * * * * * * * * * * * * * * 0.f, 0, 0, 1, color, 0, 0);
* * * * * * * * * * * * indices[i] = i;
* * * * * * * * }
*
* * * * * * * * indices[count - 1] = 1;
*
* * * * * * * * video::SMaterial mtl;
* * * * * * * * mtl.Lighting = false;
* * * * * * * * mtl.Wireframe = false;
* * * * * * * * mtl.BackfaceCulling = false;
* * * * * * * * setMaterial(mtl);
*
* * * * * * * * draw2DVertexPrimitiveList(vertices, count, indices, count - 2, video::EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
* * * * }
}


For OpenGL ES, you also need to add this too (update COGLES1Driver.h and COGLES1Driver.cpp):



void COGLES1Driver::draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
* * * * * * * * const void* indexList, u32 primitiveCount,
* * * * * * * * E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType)
{
* * * * setTexture(0, Material.getTexture(0));
* * * * if (Material.MaterialType == EMT_ONETEXTURE_BLEND)
* * * * {
* * * * * * * * E_BLEND_FACTOR srcFact;
* * * * * * * * E_BLEND_FACTOR dstFact;
* * * * * * * * E_MODULATE_FUNC modulo;
* * * * * * * * u32 alphaSource;
* * * * * * * * unpack_texureBlendFunc ( srcFact, dstFact, modulo, alphaSource, Material.MaterialTypeParam);
* * * * * * * * setRenderStates2DMode( alphaSource&video::EAS_VERTEX_COLOR, (Material.getTexture(0) != 0), (alphaSource&video::EAS_TEXTURE) != 0 );
* * * * }
* * * * else
* * * * {
* * * * * * * * setRenderStates2DMode(Material.MaterialType == EMT_TRANSPARENT_VERTEX_ALPHA, (Material.getTexture(0) != 0), Material.MaterialType == EMT_TRANSPARENT_ALPHA_CHANNEL);
* * * * }
*
* * * * drawVertexPrimitiveList2d3d(vertices, vertexCount, (const u16*)indexList, primitiveCount, vType, pType, iType);
}