IMicro3d : Doubt regarding rendering primitives. | developer.brewmp.com IMicro3d : Doubt regarding rendering primitives. | developer.brewmp.com

Developer

IMicro3d : Doubt regarding rendering primitives.

Forums:

I have some problem with rendering a quad polygon primitive. Here is the code:

hi_sint32 coord[] = {-409600, 409600, 0, 409600, 409600, 0, -409600, -409600, 0, -409600, 409600, 0};
hi_sint32 normal[] = {0, 4096, 0, 0, 4096, 0, 0, 4096, 0, 0, 4096, 0};
hi_sint32 color[] = {255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 255, 255};

IntArray coord_array, normal_array, color_array;

attr = M3DP_QUADS | M3DPD_NORMAL_PER_VERTEX | M3D_LIGHTING | ( 1 << 16 );

IMICRO3D_Render_setAttribute( pMe->mpMicro3D, &pMe->render, attr );

coord_array.num = ARRAYSIZE(coord) / 3;
normal_array.num = ARRAYSIZE(normal) / 3;
color_array.num = ARRAYSIZE(color) / 3;

coord_array.array = MALLOC(sizeof(coord));
normal_array.array = MALLOC(sizeof(normal));
color_array.array = MALLOC(sizeof(color));

MEMCPY(coord_array.array, coord, sizeof(coord));
MEMCPY(normal_array.array, normal, sizeof(normal));
MEMCPY(color_array.array, color, sizeof(color));

IMICRO3D_Render_drawPrimitive(pMe->mpMicro3D, &pMe->render, M3DP_QUADS, &coord_array, &normal_array, NULL, &color_array);

The quadrilateral polygon is not getting rendered. I changed the coord value from 496000 to 100, incase that was the problem, but still not working.

Please help me to fix this issue.

Thanks in advance.

attr = M3DP_QUADS | M3DPD_NORMAL_PER_VERTEX | M3D_LIGHTING | ( 1 << 16 );
IMICRO3D_Render_setAttribute( pMe->mpMicro3D, &pMe->render, attr );
Ok, this seems very wrong, M3D_LIGHTING is the only valid attribute flag, the rest should be used in the drawPrimitive call.
This:
IMICRO3D_Render_drawPrimitive(pMe->mpMicro3D, &pMe->render, M3DP_QUADS, &coord_array, &normal_array, NULL, &color_array);
should probably be something like this:
IMICRO3D_Render_drawPrimitive(pMe->mpMicro3D, &pMe->render, M3DP_QUADS | M3DPD_NORMAL_PER_VERTEX | M3D_LIGHTING | ( 1 << 16 ), &coord_array, &normal_array, NULL, &color_array);
(the ( 1 << 16 ) at the end is just telling it you want to render 1 quad)

attr = M3DP_QUADS | M3DPD_NORMAL_PER_VERTEX | M3D_LIGHTING | ( 1 << 16 );
IMICRO3D_Render_setAttribute( pMe->mpMicro3D, &pMe->render, attr );
Ok, this seems very wrong, M3D_LIGHTING is the only valid attribute flag, the rest should be used in the drawPrimitive call.
This:
IMICRO3D_Render_drawPrimitive(pMe->mpMicro3D, &pMe->render, M3DP_QUADS, &coord_array, &normal_array, NULL, &color_array);
should probably be something like this:
IMICRO3D_Render_drawPrimitive(pMe->mpMicro3D, &pMe->render, M3DP_QUADS | M3DPD_NORMAL_PER_VERTEX | M3D_LIGHTING | ( 1 << 16 ), &coord_array, &normal_array, NULL, &color_array);
(the ( 1 << 16 ) at the end is just telling it you want to render 1 quad)