include/dimension2d.h \
include/EDriverTypes.h \
include/EMaterialFlags.h \
+ include/EPrimitiveTypes.h \
include/IAnimatedMesh.h \
include/IAnimatedMeshMD2.h \
include/IAnimatedMeshSceneNode.h \
include/SExposedVideoData.h \
include/SKeyMap.h \
include/SMaterial.h \
+ include/SVertexIndex.h \
include/vector2d.h \
include/vector3d.h
--- /dev/null
+/* c-irrlicht --- C bindings for Irrlicht Engine
+
+ Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+
+ This file is part of c-irrlicht.
+
+ c-irrlicht is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+
+ c-irrlicht is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with guile-irrlicht. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __C_IRR_E_PRIMITIVE_TYPES_H_INCLUDED__
+#define __C_IRR_E_PRIMITIVE_TYPES_H_INCLUDED__
+
+//! Enumeration for all primitive types there are.
+typedef enum
+ {
+ //! All vertices are non-connected points.
+ irr_scene_EPT_POINTS=0,
+
+ //! All vertices form a single connected line.
+ irr_scene_EPT_LINE_STRIP,
+
+ //! Just as LINE_STRIP, but the last and the first vertex is also connected.
+ irr_scene_EPT_LINE_LOOP,
+
+ //! Every two vertices are connected creating n/2 lines.
+ irr_scene_EPT_LINES,
+
+ //! After the first two vertices each vertex defines a new triangle.
+ //! Always the two last and the new one form a new triangle.
+ irr_scene_EPT_TRIANGLE_STRIP,
+
+ //! After the first two vertices each vertex defines a new triangle.
+ //! All around the common first vertex.
+ irr_scene_EPT_TRIANGLE_FAN,
+
+ //! Explicitly set all vertices for each triangle.
+ irr_scene_EPT_TRIANGLES,
+
+ //! After the first two vertices each further tw vetices create a quad with the preceding two.
+ irr_scene_EPT_QUAD_STRIP,
+
+ //! Every four vertices create a quad.
+ irr_scene_EPT_QUADS,
+
+ //! Just as LINE_LOOP, but filled.
+ irr_scene_EPT_POLYGON,
+
+ //! The single vertices are expanded to quad billboards on the GPU.
+ irr_scene_EPT_POINT_SPRITES
+ } irr_scene_E_PRIMITIVE_TYPE;
+
+#endif
#ifndef __C_I_VIDEO_DRIVER_H_INCLUDED__
#define __C_I_VIDEO_DRIVER_H_INCLUDED__
+#include "EPrimitiveTypes.h"
#include "ITexture.h"
#include "matrix4.h"
+#include "rect.h"
+#include "S3DVertex.h"
#include "SColor.h"
#include "SExposedVideoData.h"
#include "SMaterial.h"
-#include "rect.h"
+#include "SVertexIndex.h"
//! enumeration for geometry transformation states
typedef enum
irr_video_SExposedVideoData* videoData,
const irr_core_rect_s32* sourceRect);
+ void
+ irr_video_drawVertexPrimitiveList(irr_video_IVideoDriver* driver,
+ const void* vertices,
+ unsigned int vertexCount,
+ const void* indexList,
+ unsigned int primCount,
+ irr_video_E_VERTEX_TYPE vType,
+ irr_scene_E_PRIMITIVE_TYPE pType,
+ irr_video_E_INDEX_TYPE iType);
+
int
irr_video_endScene(irr_video_IVideoDriver* driver);
#include "vector2d.h"
#include "vector3d.h"
+//! Enumeration for all vertex types there are.
+typedef enum
+ {
+ //! Standard vertex type used by the Irrlicht engine, video::S3DVertex.
+ irr_video_EVT_STANDARD = 0,
+
+ //! Vertex with two texture coordinates, video::S3DVertex2TCoords.
+ /** Usually used for geometry with lightmaps or other special materials. */
+ irr_video_EVT_2TCOORDS,
+
+ //! Vertex with a tangent and binormal vector, video::S3DVertexTangents.
+ /** Usually used for tangent space normal mapping. */
+ irr_video_EVT_TANGENTS
+ } irr_video_E_VERTEX_TYPE;
+
typedef struct
{
irr_core_vector3df pos;
--- /dev/null
+/* c-irrlicht --- C bindings for Irrlicht Engine
+
+ Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+
+ This file is part of c-irrlicht.
+
+ c-irrlicht is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+
+ c-irrlicht is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with guile-irrlicht. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __C_IRR_S_VERTEX_INDEX_H_INCLUDED__
+#define __C_IRR_S_VERTEX_INDEX_H_INCLUDED__
+
+typedef enum
+ {
+ irr_video_EIT_16BIT = 0,
+ irr_video_EIT_32BIT
+ } irr_video_E_INDEX_TYPE;
+
+#endif
#include "dimension2d.h"
#include "EDriverTypes.h"
#include "EMaterialFlags.h"
+#include "EPrimitiveTypes.h"
#include "IAnimatedMeshMD2.h"
#include "IAnimatedMeshSceneNode.h"
#include "ICameraSceneNode.h"
#include "SExposedVideoData.h"
#include "SKeyMap.h"
#include "SMaterial.h"
+#include "SVertexIndex.h"
#include "vector2d.h"
#include "vector3d.h"
sourceRect != NULL ? &rect : 0);
}
+ void
+ irr_video_drawVertexPrimitiveList(irr_video_IVideoDriver* driver,
+ const void* vertices,
+ unsigned int vertexCount,
+ const void* indexList,
+ unsigned int primCount,
+ irr_video_E_VERTEX_TYPE vType,
+ 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++)
+ {
+ unsigned int *index = (unsigned int*)indexList + i;
+ if (iType == irr_video_EIT_16BIT)
+ {
+ ((irr::u16*)irrIndexList)[i] = *index;
+ }
+ else
+ {
+ ((irr::u32*)irrIndexList)[i] = *index;
+ }
+ }
+
+ ((irr::video::IVideoDriver*)driver)
+ ->drawVertexPrimitiveList(&irrVertices[0], vertexCount,
+ irrIndexList, primCount,
+ (irr::video::E_VERTEX_TYPE)vType,
+ (irr::scene::E_PRIMITIVE_TYPE)pType,
+ (irr::video::E_INDEX_TYPE)iType);
+
+ free(irrIndexList);
+ }
+
int
irr_video_endScene(irr_video_IVideoDriver* driver)
{