Hi Irrlicht Lime Developers!
I'm developer of AltSoftLab Team
http://www.AltSoftLab.com
We presented Irrlicht HW Render Backend (via Irrlicht Lime) of our AltSketch Vector Graphics Library here on forum thread
http://irrlicht.sourceforge.net/forum/v ... =6&t=49917
After the work on Irrlicht integration we have some feature requests & maybe useful recomendations for you.
Feature Requests:
1. It's more efficient to realize S3DVertex in C# or managed C++ and just put the pointer to DrawVertexPrimitiveList than operate with often created/destroied classes with Vertex3D & memory copies.
We implemented S3DVertex like this:
Code: Select all
[StructLayout(LayoutKind.Sequential)]
public struct S3DVertex
{
public Vector3f Pos;
public Vector3f Normal;
public int Color;
public Vector2f TCoords;
}
Vector3f, Vector2f - it's AltSketch structures and can be replaced with just floats like x, y, z, etc.
Please add following method to VideoDriver (or with IntPtr-s if you like more):
Code: Select all
void DrawVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primCount,
VertexType vType,
Scene::PrimitiveType pType,
IndexType iType)
{
m_VideoDriver->drawVertexPrimitiveList(vertices, vertexCount,
indexList, primCount,
(E_VERTEX_TYPE) vType,
(scene::E_PRIMITIVE_TYPE) pType,
(E_INDEX_TYPE) iType);
}
We use it like this:
Code: Select all
unsafe
{
fixed (void* vertices = &m_S3DVertexArray[0])
{
fixed (void* indexList = &indicesUInt16[0])
{
videoDriver.DrawVertexPrimitiveList(vertices, (uint)Positions.Length,
indexList, (uint)PrimitiveCount,
VertexType.Standard, PrimitiveType, IndexType._16Bit);
}
}
}
Also DrawVertexPrimitiveList is only way now to put S3DVertex2TCoords to render with custom PrimitiveType
2. It's need Cursor support!
We realized it like this (please add same support to CursorControl):
Code: Select all
public enum class Cursor_Icon
{
// Following cursors might be system specific, or might use an Irrlicht icon-set. No guarantees so far.
Normal = irr::gui::ECI_NORMAL, // arrow
Cross = irr::gui::ECI_CROSS, // Crosshair
Hand = irr::gui::ECI_HAND, // Hand
Help = irr::gui::ECI_HELP, // Arrow and question mark
IBeam = irr::gui::ECI_IBEAM, // typical text-selection cursor
No = irr::gui::ECI_NO, // should not click icon
Wait = irr::gui::ECI_WAIT, // hourclass
SizeAll = irr::gui::ECI_SIZEALL, // arrow in all directions
SizeNESW = irr::gui::ECI_SIZENESW, // resizes in direction north-east or south-west
SizeNWSE = irr::gui::ECI_SIZENWSE, // resizes in direction north-west or south-east
SizeNS = irr::gui::ECI_SIZENS, // resizes in direction north or south
SizeWE = irr::gui::ECI_SIZEWE, // resizes in direction west or east
Up = irr::gui::ECI_UP, // up-arrow
// Implementer note: Should we add system specific cursors, which use guaranteed the system icons,
// then I would recommend using a naming scheme like ECI_W32_CROSS, ECI_X11_CROSSHAIR and adding those
// additionally.
Count = irr::gui::ECI_COUNT // maximal of defined cursors. Note that higher values can be created at runtime
};
public ref class CursorControl : ReferenceCounted
{
public:
...
void SetActiveIcon(Cursor_Icon iconId)
{
m_CursorControl->setActiveIcon((ECURSOR_ICON)iconId);
}
...
};
Also I just try to give you some recomendations. Maybe it will be useful for you:
1. Some theory (sorry): Yes, for maximum similarity with C++ code it's more efficient to use C++ wrapper classes. But in many cases it's too much extensive because of massive additional operations where only simple operation must use. For example: the only way now to set/get color of Vertex3D or color pixel in TexturePainter is to create a Color object. But is more simple and fastest way is to set Int value, or Color struct that contains Int. In many cases when we process massive data (vector arrays, etc.) just operations with structures is more efficient then with class instancies. Yes C# (or .NET at all) is different from native C++ and we must not to create absolutely comparable interfaces. More good way to use platform features and differences form native interfaces to create efficient programs.
2. Just a few optimisation recomendations:
In Draw2DVertexPrimitiveList (and same funcs) you create index and vertex arrays, copy there src data, call native draw2DVertexPrimitiveList, and then delete temporary arrays. It's not good because of addition memory allocations and copy operations. And of course slower then use src data simpliciter.
a) For Int (Int16) arrays (or other arrays of simple data) is more good and faster to use pin_ptr like this (you not need temporary arrays at all):
Code: Select all
pin_ptr<int> p = &arr[0]; // pin pointer to first element in arr
int* np = p; // pointer to the first element in arr
b) Just to not create and destroy vertex temporary arrays you can use common temporary array of large size. For example just create pointer variable to temporary array in VideoDriver and int variable for size. When you need temporary array you just compare existing tempArray size with needed. If it's lesser, then delete old and create new of larger size. If larger or equals, just copy data to there and in draw2DVertexPrimitiveList put the needed data size. If putted array is larger then needed - it's not bad, because you put needed size. But you don't need to create/destroy memory of large data size.
Best regards!
Evgeny,
AltSoftLab Team