]> git.jsancho.org Git - c-irrlicht.git/blobdiff - src/IVideoDriver.cpp
Use structs with casting, without classes replication
[c-irrlicht.git] / src / IVideoDriver.cpp
index cf703b6aba01ffcc64305564b58ba2227217c9cf..61333989136cdecf3f75933c93084e7d41acd2fc 100644 (file)
 */
 
 #include <irrlicht/irrlicht.h>
+#include <wchar.h>
 #include "IVideoDriver.h"
 
 extern "C" {
-  bool
-  irr_video_IVideoDriver_beginScene(irr_video_IVideoDriver* driver,
-                                    bool backBuffer,
-                                    bool zBuffer,
-                                    const irr_video_SColor* color,
-                                    irr_video_SExposedVideoData* videoData,
-                                    const irr_core_rect_s32* sourceRect)
+  int
+  irr_video_beginScene(irr_video_IVideoDriver* driver,
+                       bool backBuffer,
+                       bool zBuffer,
+                       const irr_video_SColor* color,
+                       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,
-                                                           vdata,
-                                                           sourceRect != NULL ? &rect : 0);
+    return ((irr::video::IVideoDriver*)driver)
+      ->beginScene(backBuffer,
+                   zBuffer,
+                   *(irr::video::SColor*)color,
+                   vdata,
+                   (irr::core::rect<irr::s32>*)sourceRect);
+  }
+
+  void
+  irr_video_drawVertexPrimitiveList(irr_video_IVideoDriver* driver,
+                                    const void* vertices,
+                                    uint32_t vertexCount,
+                                    const void* indexList,
+                                    uint32_t primCount,
+                                    irr_video_E_VERTEX_TYPE vType,
+                                    irr_scene_E_PRIMITIVE_TYPE pType,
+                                    irr_video_E_INDEX_TYPE iType)
+  {
+    ((irr::video::IVideoDriver*)driver)
+      ->drawVertexPrimitiveList(vertices, vertexCount,
+                                indexList, primCount,
+                                (irr::video::E_VERTEX_TYPE)vType,
+                                (irr::scene::E_PRIMITIVE_TYPE)pType,
+                                (irr::video::E_INDEX_TYPE)iType);
   }
 
-  bool
-  irr_video_IVideoDriver_endScene(irr_video_IVideoDriver* driver)
+  int
+  irr_video_endScene(irr_video_IVideoDriver* driver)
   {
     return ((irr::video::IVideoDriver*)driver)->endScene();
   }
 
+  int
+  irr_video_getFPS(irr_video_IVideoDriver* driver)
+  {
+    return ((irr::video::IVideoDriver*)driver)->getFPS();
+  }
+
+  const char*
+  irr_video_getName(irr_video_IVideoDriver* driver)
+  {
+    const wchar_t *wname = ((irr::video::IVideoDriver*)driver)->getName();
+    size_t nbytes = wcslen(wname) + 1;
+    char *name = (char*)malloc(nbytes);
+    wcstombs(name, wname, nbytes);
+    return name;
+  }
+
   irr_video_ITexture*
-  irr_video_IVideoDriver_getTexture(irr_video_IVideoDriver* driver,
-                                    const char* filename)
+  irr_video_getTexture(irr_video_IVideoDriver* driver,
+                       const char* filename)
   {
     return (irr_video_ITexture*)
       ((irr::video::IVideoDriver*)driver)->getTexture(filename);
   }
 
+  void
+  irr_video_setMaterial(irr_video_IVideoDriver* driver,
+                        irr_video_SMaterial* material)
+  {
+    ((irr::video::IVideoDriver*)driver)->setMaterial(*(irr::video::SMaterial*)material);
+  }
+
+  void
+  irr_video_setTransform(irr_video_IVideoDriver* driver,
+                         irr_video_E_TRANSFORMATION_STATE state,
+                         irr_core_matrix4* mat)
+  {
+    ((irr::video::IVideoDriver*)driver)
+      ->setTransform((irr::video::E_TRANSFORMATION_STATE)state,
+                     *(irr::core::matrix4*)mat);
+  }
 }