irr_scene_addCameraSceneNode(smgr, NULL, &position, &lookat, -1, true);
// loop
- irr_video_SColor bgcolor = {255, 100, 101, 140};
+ irr_video_SColor bgcolor = MAKE_COLOR(255, 100, 101, 140);
while (irr_run(device))
{
irr_video_beginScene(driver, true, true, &bgcolor, NULL, NULL);
// loop
int lastFPS = -1;
- irr_video_SColor bgcolor = {255, 200, 200, 200};
+ irr_video_SColor bgcolor = MAKE_COLOR(255, 200, 200, 200);
while (irr_run(device))
{
if (irr_isWindowActive(device))
irr_video_S3DVertex vertices[] =
{
// pos, normal, color, tcoords
- { {0, 0, 10}, {1, 1, 0}, {255, 0, 255, 255}, {0, 1} },
- { {10, 0, -10}, {1, 0, 0}, {255, 255, 0, 255}, {1, 1} },
- { {0, 20, 0}, {0, 1, 1}, {255, 255, 255, 0}, {1, 0} },
- { {-10, 0, -10}, {0, 0, 1}, {255, 0, 255, 0}, {0, 0} }
+ { {0, 0, 10}, {1, 1, 0}, MAKE_COLOR(255, 0, 255, 255), {0, 1} },
+ { {10, 0, -10}, {1, 0, 0}, MAKE_COLOR(255, 255, 0, 255), {1, 1} },
+ { {0, 20, 0}, {0, 1, 1}, MAKE_COLOR(255, 255, 255, 0), {1, 0} },
+ { {-10, 0, -10}, {0, 0, 1}, MAKE_COLOR(255, 0, 255, 0), {0, 0} }
};
irr_video_SMaterial material = S_MATERIAL_DEFAULT;
material.wireframe = false;
// loop
int frames = 0;
- irr_video_SColor bgcolor = {0, 100, 100, 100};
+ irr_video_SColor bgcolor = MAKE_COLOR(0, 100, 100, 100);
while (irr_run(device))
{
irr_video_beginScene(driver, true, true, &bgcolor, NULL, NULL);
typedef struct
{
- uint8_t a;
- uint8_t r;
- uint8_t g;
uint8_t b;
+ uint8_t g;
+ uint8_t r;
+ uint8_t a;
} irr_video_SColor;
+#define MAKE_COLOR(a, r, g, b) {b, g, r, a}
+
#endif
wchar_t *wtext = (wchar_t*)malloc((strlen(text) + 1) * sizeof(wchar_t));
mbstowcs(wtext, text, strlen(text) + 1);
- // Make rectangle
- irr::core::rect<irr::s32> rect =
- irr::core::rect<irr::s32>(rectangle->x,
- rectangle->y,
- rectangle->x2,
- rectangle->y2);
-
// Add static text
irr::gui::IGUIStaticText *staticText =
((irr::gui::IGUIEnvironment*)guienv)
->addStaticText(wtext,
- rect,
+ *(irr::core::rect<irr::s32>*)rectangle,
border,
wordWrap,
(irr::gui::IGUIElement*)parent,
irr_core_vector3df* scale,
bool alsoAddIfMeshPointerZero)
{
- const irr::core::vector3df iPosition =
- position ?
- irr::core::vector3df(position->x, position->y, position->z) :
- irr::core::vector3df(0, 0, 0);
-
- const irr::core::vector3df iRotation =
- rotation ?
- irr::core::vector3df(rotation->x, rotation->y, rotation->z) :
- irr::core::vector3df(0, 0, 0);
-
- const irr::core::vector3df& iScale =
- scale ?
- irr::core::vector3df(scale->x, scale->y, scale->z) :
- irr::core::vector3df(1, 1, 1);
-
return (irr_scene_IAnimatedMeshSceneNode*)
((irr::scene::ISceneManager*)smgr)
->addAnimatedMeshSceneNode((irr::scene::IAnimatedMesh*)mesh,
(irr::scene::ISceneNode*)parent,
id,
- iPosition,
- iRotation,
- iScale,
+ position ? *(irr::core::vector3df*)position : irr::core::vector3df(0, 0, 0),
+ rotation ? *(irr::core::vector3df*)rotation : irr::core::vector3df(0, 0, 0),
+ scale ? *(irr::core::vector3df*)scale : irr::core::vector3df(1, 1, 1),
alsoAddIfMeshPointerZero);
}
int32_t id,
bool makeActive)
{
- const irr::core::vector3df& iPosition =
- position ?
- irr::core::vector3df(position->x, position->y, position->z) :
- irr::core::vector3df(0, 0, 0);
-
- const irr::core::vector3df& iLookat =
- lookat ?
- irr::core::vector3df(lookat->x, lookat->y, lookat->z) :
- irr::core::vector3df(0, 0, 100);
-
return (irr_scene_ICameraSceneNode*)
((irr::scene::ISceneManager*)smgr)
->addCameraSceneNode((irr::scene::ISceneNode*)parent,
- iPosition,
- iLookat,
+ position ? *(irr::core::vector3df*)position : irr::core::vector3df(0, 0, 0),
+ lookat ? *(irr::core::vector3df*)lookat : irr::core::vector3df(0, 0, 100),
id,
makeActive);
}
parent = irr_scene_getRootSceneNode(smgr);
}
- const irr::core::vector3df iPosition =
- position ?
- irr::core::vector3df(position->x, position->y, position->z) :
- irr::core::vector3df(0, 0, 0);
-
- const irr::core::vector3df iRotation =
- rotation ?
- irr::core::vector3df(rotation->x, rotation->y, rotation->z) :
- irr::core::vector3df(0, 0, 0);
-
- const irr::core::vector3df& iScale =
- scale ?
- irr::core::vector3df(scale->x, scale->y, scale->z) :
- irr::core::vector3df(1, 1, 1);
-
CustomSceneNode *node =
new CustomSceneNode((irr::scene::ISceneNode*)parent,
(irr::scene::ISceneManager*)smgr,
id,
- iPosition,
- iRotation,
- iScale,
+ position ? *(irr::core::vector3df*)position : irr::core::vector3df(0, 0, 0),
+ rotation ? *(irr::core::vector3df*)rotation : irr::core::vector3df(0, 0, 0),
+ scale ? *(irr::core::vector3df*)scale : irr::core::vector3df(1, 1, 1),
render,
getBoundingBox,
getMaterialCount,
irr_scene_createRotationAnimator(irr_scene_ISceneManager* smgr,
irr_core_vector3df* rotationSpeed)
{
- const irr::core::vector3df& irrRotationSpeed =
- irr::core::vector3df(rotationSpeed->x, rotationSpeed->y, rotationSpeed->z);
-
return ((irr::scene::ISceneManager*)smgr)
- ->createRotationAnimator(irrRotationSpeed);
+ ->createRotationAnimator(*(irr::core::vector3df*)rotationSpeed);
}
void
irr_scene_setPosition(irr_scene_ISceneNode* node,
irr_core_vector3df* newpos)
{
- const irr::core::vector3df newPosition =
- irr::core::vector3df(newpos->x, newpos->y, newpos->z);
-
((irr::scene::ISceneNode*)node)
- ->setPosition(newPosition);
+ ->setPosition(*(irr::core::vector3df*)newpos);
}
}
irr_video_SExposedVideoData* videoData,
const irr_core_rect_s32* sourceRect)
{
- // Color
- irr::video::SColor col = irr::video::SColor(color->a, color->r,
- color->g, color->b);
-
// Video data
// TODO
irr::video::SExposedVideoData vdata = irr::video::SExposedVideoData();
- // Source rect
- irr::core::rect<irr::s32> rect;
- if (sourceRect != NULL)
- {
- rect = irr::core::rect<irr::s32>(sourceRect->x,
- sourceRect->y,
- sourceRect->x2,
- sourceRect->y2);
- }
-
// Begin scene
return ((irr::video::IVideoDriver*)driver)
->beginScene(backBuffer,
zBuffer,
- col,
+ *(irr::video::SColor*)color,
vdata,
- sourceRect != NULL ? &rect : 0);
+ (irr::core::rect<irr::s32>*)sourceRect);
}
void
irr_scene_E_PRIMITIVE_TYPE pType,
irr_video_E_INDEX_TYPE iType)
{
- // Convert vertices
- irr::video::S3DVertex irrVertices[vertexCount];
- for (int i=0; i<vertexCount; i++)
- {
- irr_video_S3DVertex *vertex = (irr_video_S3DVertex*)vertices + i;
- irrVertices[i] =
- irr::video::S3DVertex(vertex->pos.x, vertex->pos.y, vertex->pos.z,
- vertex->normal.x, vertex->normal.y, vertex->normal.z,
- irr::video::SColor(vertex->color.a,
- vertex->color.r,
- vertex->color.g,
- vertex->color.b),
- vertex->tCoords.x, vertex->tCoords.y);
- }
-
- // Convert indices
- size_t indexListSize =
- ((iType == irr_video_EIT_16BIT) ? sizeof(irr::u16) : sizeof(irr::u32)) *
- primCount * 3;
- void* irrIndexList = malloc(indexListSize);
-
- for (int i=0; i<primCount*3; i++)
- {
- if (iType == irr_video_EIT_16BIT)
- {
- uint16_t *index = (uint16_t*)indexList + i;
- ((irr::u16*)irrIndexList)[i] = *index;
- }
- else
- {
- uint32_t *index = (uint32_t*)indexList + i;
- ((irr::u32*)irrIndexList)[i] = *index;
- }
- }
-
((irr::video::IVideoDriver*)driver)
- ->drawVertexPrimitiveList(&irrVertices[0], vertexCount,
- irrIndexList, primCount,
+ ->drawVertexPrimitiveList(vertices, vertexCount,
+ indexList, primCount,
(irr::video::E_VERTEX_TYPE)vType,
(irr::scene::E_PRIMITIVE_TYPE)pType,
(irr::video::E_INDEX_TYPE)iType);
-
- free(irrIndexList);
}
int