From 3b8ff07b2c13c111e2b9eebaeaf64c7b17b29019 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 13 Oct 2019 09:34:44 +0200 Subject: [PATCH] Replace void* with appropiate types --- Makefile.am | 3 +++ include/IGUIElement.h | 27 +++++++++++++++++++++++++++ include/IGUIEnvironment.h | 26 ++++++++++++++++---------- include/IGUIStaticText.h | 27 +++++++++++++++++++++++++++ include/IVideoDriver.h | 19 ++++++++++++------- include/IrrlichtDevice.h | 30 ++++++++++++++++++++++++------ include/SExposedVideoData.h | 27 +++++++++++++++++++++++++++ include/cirrlicht.h | 16 ++++++++++------ src/CIrrlicht.cpp | 15 ++++++++------- src/IGUIEnvironment.cpp | 20 +++++++++++--------- src/IVideoDriver.cpp | 17 ++++++++++------- src/IrrlichtDevice.cpp | 19 +++++++++++++------ 12 files changed, 188 insertions(+), 58 deletions(-) create mode 100644 include/IGUIElement.h create mode 100644 include/IGUIStaticText.h create mode 100644 include/SExposedVideoData.h diff --git a/Makefile.am b/Makefile.am index 94fd41d..45b7bdb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,9 @@ include_HEADERS = \ include/EMaterialFlags.h \ include/IAnimatedMeshMD2.h \ include/IAnimatedMeshSceneNode.h \ + include/IGUIElement.h \ include/IGUIEnvironment.h \ + include/IGUIStaticText.h \ include/IrrlichtDevice.h \ include/ISceneManager.h \ include/ISceneNode.h \ @@ -25,4 +27,5 @@ include_HEADERS = \ include/IVideoDriver.h \ include/rect.h \ include/SColor.h \ + include/SExposedVideoData.h \ include/vector3d.h diff --git a/include/IGUIElement.h b/include/IGUIElement.h new file mode 100644 index 0000000..97e94cf --- /dev/null +++ b/include/IGUIElement.h @@ -0,0 +1,27 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#ifndef __C_I_GUI_ELEMENT_H_INCLUDED__ +#define __C_I_GUI_ELEMENT_H_INCLUDED__ + +typedef void irr_gui_IGUIElement; + +#endif diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 73ffe37..721d029 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -22,22 +22,28 @@ #ifndef __C_GUI_ENVIRONMENT_H_INCLUDED__ #define __C_GUI_ENVIRONMENT_H_INCLUDED__ +#include "IGUIElement.h" +#include "IGUIStaticText.h" #include "rect.h" +typedef void irr_gui_IGUIEnvironment; + #ifdef __cplusplus extern "C" { #endif - void* irr_gui_IGUIEnvironment_addStaticText(void* guienv, - const char* text, - const irr_core_rect_s32* rectangle, - bool border, - bool wordWrap, - void* parent, - int32_t id, - bool fillBackground); - - void irr_gui_IGUIEnvironment_drawAll(void* guienv); + irr_gui_IGUIStaticText* + irr_gui_IGUIEnvironment_addStaticText(irr_gui_IGUIEnvironment* guienv, + const char* text, + const irr_core_rect_s32* rectangle, + bool border, + bool wordWrap, + irr_gui_IGUIElement* parent, + int32_t id, + bool fillBackground); + + void + irr_gui_IGUIEnvironment_drawAll(irr_gui_IGUIEnvironment* guienv); #ifdef __cplusplus } diff --git a/include/IGUIStaticText.h b/include/IGUIStaticText.h new file mode 100644 index 0000000..f4e91b0 --- /dev/null +++ b/include/IGUIStaticText.h @@ -0,0 +1,27 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#ifndef __C_I_GUI_STATIC_TEXT_H_INCLUDED__ +#define __C_I_GUI_STATIC_TEXT_H_INCLUDED__ + +typedef void irr_gui_IGUIStaticText; + +#endif diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index 260d012..042ee6b 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -23,20 +23,25 @@ #define __C_IRR_I_VIDEO_DRIVER_H_INCLUDED__ #include "SColor.h" +#include "SExposedVideoData.h" #include "rect.h" +typedef void irr_video_IVideoDriver; + #ifdef __cplusplus extern "C" { #endif - bool irr_video_IVideoDriver_beginScene(void* driver, - bool backBuffer, - bool zBuffer, - const irr_video_SColor* color, - void* videoData, // not used for now - const irr_core_rect_s32* sourceRect); + 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); - bool irr_video_IVideoDriver_endScene(void* driver); + bool + irr_video_IVideoDriver_endScene(irr_video_IVideoDriver* driver); #ifdef __cplusplus } diff --git a/include/IrrlichtDevice.h b/include/IrrlichtDevice.h index b6a459e..9ca9589 100644 --- a/include/IrrlichtDevice.h +++ b/include/IrrlichtDevice.h @@ -22,16 +22,34 @@ #ifndef __C_IRRLICHT_DEVICE_H_INCLUDED__ #define __C_IRRLICHT_DEVICE_H_INCLUDED__ +#include "IGUIEnvironment.h" +#include "ISceneManager.h" +#include "IVideoDriver.h" + +typedef void irr_IrrlichtDevice; + #ifdef __cplusplus extern "C" { #endif - void* irr_IrrlichtDevice_getGUIEnvironment(void* device); - void* irr_IrrlichtDevice_getSceneManager(void* device); - void* irr_IrrlichtDevice_getVideoDriver(void* device); - void irr_IrrlichtDevice_setWindowCaption(void* device, const char* text); - int irr_IrrlichtDevice_run(void* device); - int irr_IrrlichtDevice_drop(void* device); + irr_gui_IGUIEnvironment* + irr_IrrlichtDevice_getGUIEnvironment(irr_IrrlichtDevice* device); + + irr_scene_ISceneManager* + irr_IrrlichtDevice_getSceneManager(irr_IrrlichtDevice* device); + + irr_video_IVideoDriver* + irr_IrrlichtDevice_getVideoDriver(irr_IrrlichtDevice* device); + + void + irr_IrrlichtDevice_setWindowCaption(irr_IrrlichtDevice* device, + const char* text); + + int + irr_IrrlichtDevice_run(irr_IrrlichtDevice* device); + + int + irr_IrrlichtDevice_drop(irr_IrrlichtDevice* device); #ifdef __cplusplus } diff --git a/include/SExposedVideoData.h b/include/SExposedVideoData.h new file mode 100644 index 0000000..94ab2db --- /dev/null +++ b/include/SExposedVideoData.h @@ -0,0 +1,27 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#ifndef __C_S_EXPOSED_VIDEO_DATA_H_INCLUDED__ +#define __C_S_EXPOSED_VIDEO_DATA_H_INCLUDED__ + +typedef void irr_video_SExposedVideoData; + +#endif diff --git a/include/cirrlicht.h b/include/cirrlicht.h index 6401841..a091b5f 100644 --- a/include/cirrlicht.h +++ b/include/cirrlicht.h @@ -28,6 +28,8 @@ #include "IAnimatedMeshMD2.h" #include "IAnimatedMeshSceneNode.h" #include "IGUIEnvironment.h" +#include "IGUIElement.h" +#include "IGUIStaticText.h" #include "IrrlichtDevice.h" #include "ISceneManager.h" #include "ISceneNode.h" @@ -35,18 +37,20 @@ #include "IVideoDriver.h" #include "rect.h" #include "SColor.h" +#include "SExposedVideoData.h" #include "vector3d.h" #ifdef __cplusplus extern "C" { #endif - void* irr_createDevice(irr_video_E_DRIVER_TYPE deviceType, - const irr_core_dimension2d_u32* windowSize, - u_int32_t bits, - bool fullscreen, - bool stencilbuffer, - bool vsync); + irr_IrrlichtDevice* + irr_createDevice(irr_video_E_DRIVER_TYPE deviceType, + const irr_core_dimension2d_u32* windowSize, + u_int32_t bits, + bool fullscreen, + bool stencilbuffer, + bool vsync); #ifdef __cplusplus } diff --git a/src/CIrrlicht.cpp b/src/CIrrlicht.cpp index e87663d..dc0c20d 100644 --- a/src/CIrrlicht.cpp +++ b/src/CIrrlicht.cpp @@ -23,12 +23,13 @@ #include "cirrlicht.h" extern "C" { - void* irr_createDevice(irr_video_E_DRIVER_TYPE deviceType, - const irr_core_dimension2d_u32* windowSize, - u_int32_t bits, - bool fullscreen, - bool stencilbuffer, - bool vsync) + irr_IrrlichtDevice* + irr_createDevice(irr_video_E_DRIVER_TYPE deviceType, + const irr_core_dimension2d_u32* windowSize, + u_int32_t bits, + bool fullscreen, + bool stencilbuffer, + bool vsync) { irr::core::dimension2d wsize = \ irr::core::dimension2d(windowSize->width, @@ -37,6 +38,6 @@ extern "C" { irr::createDevice((irr::video::E_DRIVER_TYPE)deviceType, wsize, bits, fullscreen, stencilbuffer, vsync); - return device; + return (irr_IrrlichtDevice*)device; } } diff --git a/src/IGUIEnvironment.cpp b/src/IGUIEnvironment.cpp index a77c678..7f92386 100644 --- a/src/IGUIEnvironment.cpp +++ b/src/IGUIEnvironment.cpp @@ -24,14 +24,15 @@ #include "IGUIEnvironment.h" extern "C" { - void* irr_gui_IGUIEnvironment_addStaticText(void* guienv, - const char* text, - const irr_core_rect_s32* rectangle, - bool border, - bool wordWrap, - void* parent, - int32_t id, - bool fillBackground) + irr_gui_IGUIStaticText* + irr_gui_IGUIEnvironment_addStaticText(irr_gui_IGUIEnvironment* guienv, + const char* text, + const irr_core_rect_s32* rectangle, + bool border, + bool wordWrap, + irr_gui_IGUIElement* parent, + int32_t id, + bool fillBackground) { // Convert to wide char text wchar_t *wtext = (wchar_t*)malloc((strlen(text) + 1) * sizeof(wchar_t)); @@ -56,7 +57,8 @@ extern "C" { return staticText; } - void irr_gui_IGUIEnvironment_drawAll(void* guienv) + void + irr_gui_IGUIEnvironment_drawAll(irr_gui_IGUIEnvironment* guienv) { ((irr::gui::IGUIEnvironment*)guienv)->drawAll(); } diff --git a/src/IVideoDriver.cpp b/src/IVideoDriver.cpp index 86d7347..8f3edbc 100644 --- a/src/IVideoDriver.cpp +++ b/src/IVideoDriver.cpp @@ -23,18 +23,20 @@ #include "IVideoDriver.h" extern "C" { - bool irr_video_IVideoDriver_beginScene(void* driver, - bool backBuffer, - bool zBuffer, - const irr_video_SColor* color, - void* videoData, // not used for now - const irr_core_rect_s32* sourceRect) + 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) { // 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 @@ -55,7 +57,8 @@ extern "C" { sourceRect != NULL ? &rect : 0); } - bool irr_video_IVideoDriver_endScene(void* driver) + bool + irr_video_IVideoDriver_endScene(irr_video_IVideoDriver* driver) { return ((irr::video::IVideoDriver*)driver)->endScene(); } diff --git a/src/IrrlichtDevice.cpp b/src/IrrlichtDevice.cpp index 57fefdf..190800e 100644 --- a/src/IrrlichtDevice.cpp +++ b/src/IrrlichtDevice.cpp @@ -24,34 +24,41 @@ #include "IrrlichtDevice.h" extern "C" { - void* irr_IrrlichtDevice_getGUIEnvironment(void* device) + irr_gui_IGUIEnvironment* + irr_IrrlichtDevice_getGUIEnvironment(irr_IrrlichtDevice* device) { return ((irr::IrrlichtDevice*)device)->getGUIEnvironment(); } - void* irr_IrrlichtDevice_getSceneManager(void* device) + irr_scene_ISceneManager* + irr_IrrlichtDevice_getSceneManager(irr_IrrlichtDevice* device) { return ((irr::IrrlichtDevice*)device)->getSceneManager(); } - void* irr_IrrlichtDevice_getVideoDriver(void* device) + irr_video_IVideoDriver* + irr_IrrlichtDevice_getVideoDriver(irr_IrrlichtDevice* device) { return ((irr::IrrlichtDevice*)device)->getVideoDriver(); } - void irr_IrrlichtDevice_setWindowCaption(void* device, const char* text) + void + irr_IrrlichtDevice_setWindowCaption(irr_IrrlichtDevice* device, + const char* text) { wchar_t *wtext = (wchar_t*)malloc((strlen(text) + 1) * sizeof(wchar_t)); mbsrtowcs(wtext, &text, strlen(text) + 1, NULL); ((irr::IrrlichtDevice*)device)->setWindowCaption(wtext); } - int irr_IrrlichtDevice_run(void* device) + int + irr_IrrlichtDevice_run(irr_IrrlichtDevice* device) { return ((irr::IrrlichtDevice*)device)->run() ? 1 : 0; } - int irr_IrrlichtDevice_drop(void* device) + int + irr_IrrlichtDevice_drop(irr_IrrlichtDevice* device) { return ((irr::IrrlichtDevice*)device)->drop() ? 1 : 0; } -- 2.39.5