| 1 | /* |
| 2 | Copyright 2013-2024 Jan Adamec, Michalis Kamburelis. |
| 3 | |
| 4 | This file is part of "Castle Game Engine". |
| 5 | |
| 6 | "Castle Game Engine" is free software; see the file COPYING.txt, |
| 7 | included in this distribution, for details about the copyright. |
| 8 | |
| 9 | "Castle Game Engine" is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | |
| 13 | ---------------------------------------------------------------------------- |
| 14 | |
| 15 | This file is here as a wrapper, only to load the castleengine.dll for you and |
| 16 | to resolve all exported functions. |
| 17 | |
| 18 | It works for multiplatform projects made in Qt (need to define QT_BUILD macro), |
| 19 | or for projects made in WinAPI. |
| 20 | |
| 21 | Usage: |
| 22 | 1. Add castle_c_loader.cpp and castlelib.h into your project workspace. You may |
| 23 | want to copy them instead in case you don't want to use the latest versions. |
| 24 | |
| 25 | 2. Copy compiled dynamic library (castleengine.dll/.dylib) to your project |
| 26 | folder (or to Debug and Release folders) |
| 27 | |
| 28 | 3. Include castlelib.h in your source files, call CGE_LoadLibrary at |
| 29 | the start of your program, and then call CGE_xxx functions as usual. |
| 30 | */ |
| 31 | |
| 32 | #ifdef QT_BUILD |
| 33 | #include <QLibrary> |
| 34 | #include <QApplication> |
| 35 | #include <QMessageBox> |
| 36 | #else // suppose Windows build |
| 37 | #include <windows.h> |
| 38 | #endif |
| 39 | |
| 40 | #ifdef MSVC |
| 41 | #pragma optimize("", off) // strangely MSVC calls pfrd_CGE_MouseDown always with left button in release ?! |
| 42 | #endif |
| 43 | |
| 44 | #include "castleengine.h" |
| 45 | |
| 46 | //----------------------------------------------------------------------------- |
| 47 | typedef void (CDECL *PFNRD_CGE_Initialize)(const char *applicationConfigDirectory); |
| 48 | typedef void (CDECL *PFNRD_CGE_Finalize)(); |
| 49 | typedef void (CDECL *PFNRD_CGE_Open)(unsigned uiFlags, unsigned initialWidth, unsigned initialHeight, unsigned uiDpi); |
| 50 | typedef void (CDECL *PFNRD_CGE_Close)(bool quitWhenLastWindowClosed); |
| 51 | typedef void (CDECL *PFNRD_CGE_GetOpenGLInformation)(char *szBuffer, int nBufSize); |
| 52 | |
| 53 | typedef void (CDECL *PFNRD_CGE_Resize)(unsigned uiViewWidth, unsigned uiViewHeight); |
| 54 | typedef void (CDECL *PFNRD_CGE_Render)(); |
| 55 | typedef void (CDECL *PFNRD_CGE_SaveScreenshotToFile)(const char *szFile); |
| 56 | typedef void (CDECL *PFNRD_CGE_SetLibraryCallbackProc)(TCgeLibraryCallback pProc); |
| 57 | typedef void (CDECL *PFNRD_CGE_Update)(); |
| 58 | |
| 59 | typedef void (CDECL *PFNRD_CGE_MouseDown)(int x, int y, bool bLeftBtn, int nFingerIdx); |
| 60 | typedef void (CDECL *PFNRD_CGE_Motion)(int x, int y, int nFingerIdx); |
| 61 | typedef void (CDECL *PFNRD_CGE_MouseUp)(int x, int y, bool bLeftBtn, int nFingerIdx, bool trackReleased); |
| 62 | typedef void (CDECL *PFNRD_CGE_MouseWheel)(float zDelta, bool bVertical); |
| 63 | |
| 64 | typedef void (CDECL *PFNRD_CGE_KeyDown)(int eKey); |
| 65 | typedef void (CDECL *PFNRD_CGE_KeyUp)(int eKey); |
| 66 | |
| 67 | typedef void (CDECL *PFNRD_CGE_LoadSceneFromFile)(const char *szFile); |
| 68 | typedef void (CDECL *PFNRD_CGE_SaveSceneToFile)(const char *szFile); |
| 69 | |
| 70 | typedef int (CDECL *PFNRD_CGE_GetViewpointsCount)(); |
| 71 | typedef void (CDECL *PFNRD_CGE_GetViewpointName)(int iViewpointIdx, char *szName, int nBufSize); |
| 72 | typedef void (CDECL *PFNRD_CGE_MoveToViewpoint)(int iViewpointIdx, bool bAnimated); |
| 73 | typedef void (CDECL *PFNRD_CGE_AddViewpointFromCurrentView)(const char *szName); |
| 74 | typedef void (CDECL *PFNRD_CGE_GetBoundingBox)(float *pfXMin, float *pfXMax, float *pfYMin, float *pfYMax, float *pfZMin, float *pfZMax); |
| 75 | typedef void (CDECL *PFNRD_CGE_GetViewCoords)(float *pfPosX, float *pfPosY, float *pfPosZ, float *pfDirX, float *pfDirY, float *pfDirZ, |
| 76 | float *pfUpX, float *pfUpY, float *pfUpZ, float *pfGravX, float *pfGravY, float *pfGravZ); |
| 77 | typedef void (CDECL *PFNRD_CGE_MoveViewToCoords)(float fPosX, float fPosY, float fPosZ, float fDirX, float fDirY, float fDirZ, |
| 78 | float fUpX, float fUpY, float fUpZ, float fGravX, float fGravY, float fGravZ, bool bAnimated); |
| 79 | |
| 80 | typedef void (CDECL *PFNRD_CGE_SetNavigationInputShortcut)(int eInput, int eKey1, int eKey2, int eMouseButton, int eMouseWheel); |
| 81 | |
| 82 | typedef int (CDECL *PFNRD_CGE_GetNavigationType)(); |
| 83 | typedef void (CDECL *PFNRD_CGE_SetNavigationType)(int eNewType); |
| 84 | typedef void (CDECL *PFNRD_CGE_SetTouchInterface)(int eMode); |
| 85 | typedef void (CDECL *PFNRD_CGE_SetUserInterface)(bool bAutomaticTouchInterface); |
| 86 | |
| 87 | typedef void (CDECL *PFNRD_CGE_SetVariableInt)(int eVar, int nValue); |
| 88 | typedef int (CDECL *PFNRD_CGE_GetVariableInt)(int eVar); |
| 89 | typedef void (CDECL *PFNRD_CGE_SetNodeFieldValue)(const char *szNodeName, const char *szFieldName, |
| 90 | float fVal1, float fVal2, float fVal3, float fVal4); |
| 91 | |
| 92 | typedef void (CDECL *PFNRD_CGE_IncreaseSceneTime)(float fTimeS); |
| 93 | |
| 94 | PFNRD_CGE_Initialize pfrd_CGE_Initialize = NULL; |
| 95 | PFNRD_CGE_Finalize pfrd_CGE_Finalize = NULL; |
| 96 | PFNRD_CGE_Open pfrd_CGE_Open = NULL; |
| 97 | PFNRD_CGE_Close pfrd_CGE_Close = NULL; |
| 98 | PFNRD_CGE_GetOpenGLInformation pfrd_CGE_GetOpenGLInformation = NULL; |
| 99 | PFNRD_CGE_Resize pfrd_CGE_Resize = NULL; |
| 100 | PFNRD_CGE_Render pfrd_CGE_Render = NULL; |
| 101 | PFNRD_CGE_SaveScreenshotToFile pfrd_CGE_SaveScreenshotToFile = NULL; |
| 102 | PFNRD_CGE_SetLibraryCallbackProc pfrd_CGE_SetLibraryCallbackProc = NULL; |
| 103 | PFNRD_CGE_Update pfrd_CGE_Update = NULL; |
| 104 | PFNRD_CGE_MouseDown pfrd_CGE_MouseDown = NULL; |
| 105 | PFNRD_CGE_Motion pfrd_CGE_Motion = NULL; |
| 106 | PFNRD_CGE_MouseUp pfrd_CGE_MouseUp = NULL; |
| 107 | PFNRD_CGE_MouseWheel pfrd_CGE_MouseWheel = NULL; |
| 108 | PFNRD_CGE_KeyDown pfrd_CGE_KeyDown = NULL; |
| 109 | PFNRD_CGE_KeyUp pfrd_CGE_KeyUp = NULL; |
| 110 | PFNRD_CGE_LoadSceneFromFile pfrd_CGE_LoadSceneFromFile = NULL; |
| 111 | PFNRD_CGE_SaveSceneToFile pfrd_CGE_SaveSceneToFile = NULL; |
| 112 | PFNRD_CGE_GetViewpointsCount pfrd_CGE_GetViewpointsCount = NULL; |
| 113 | PFNRD_CGE_GetViewpointName pfrd_CGE_GetViewpointName = NULL; |
| 114 | PFNRD_CGE_MoveToViewpoint pfrd_CGE_MoveToViewpoint = NULL; |
| 115 | PFNRD_CGE_AddViewpointFromCurrentView pfrd_CGE_AddViewpointFromCurrentView = NULL; |
| 116 | PFNRD_CGE_GetBoundingBox pfrd_CGE_GetBoundingBox = NULL; |
| 117 | PFNRD_CGE_GetViewCoords pfrd_CGE_GetViewCoords = NULL; |
| 118 | PFNRD_CGE_MoveViewToCoords pfrd_CGE_MoveViewToCoords = NULL; |
| 119 | PFNRD_CGE_SetNavigationInputShortcut pfrd_CGE_SetNavigationInputShortcut = NULL; |
| 120 | PFNRD_CGE_GetNavigationType pfrd_CGE_GetNavigationType = NULL; |
| 121 | PFNRD_CGE_SetNavigationType pfrd_CGE_SetNavigationType = NULL; |
| 122 | PFNRD_CGE_SetTouchInterface pfrd_CGE_SetTouchInterface = NULL; |
| 123 | PFNRD_CGE_SetUserInterface pfrd_CGE_SetUserInterface = NULL; |
| 124 | PFNRD_CGE_SetVariableInt pfrd_CGE_SetVariableInt = NULL; |
| 125 | PFNRD_CGE_GetVariableInt pfrd_CGE_GetVariableInt = NULL; |
| 126 | PFNRD_CGE_SetNodeFieldValue pfrd_CGE_SetNodeFieldValue = NULL; |
| 127 | PFNRD_CGE_IncreaseSceneTime pfrd_CGE_IncreaseSceneTime = NULL; |
| 128 | |
| 129 | #ifdef QT_BUILD |
| 130 | //----------------------------------------------------------------------------- |
| 131 | QFunctionPointer cge_GetProc(QLibrary &rCgeLib, const char *symbol) |
| 132 | { |
| 133 | QFunctionPointer f = rCgeLib.resolve(symbol); |
| 134 | if (f == nullptr) |
| 135 | QMessageBox::critical(NULL, "CGE Load Error", QString("Cannot load Castle Game Engine function: ") + symbol + "\nPlease try reinstalling the software."); |
| 136 | return f; |
| 137 | } |
| 138 | #else |
| 139 | FARPROC WINAPI cge_GetProc(HMODULE hCgeLib, const char *symbol) |
| 140 | { |
| 141 | return GetProcAddress(hCgeLib, symbol); |
| 142 | } |
| 143 | #endif |
| 144 | |
| 145 | //----------------------------------------------------------------------------- |
| 146 | void CGE_LoadLibrary() |
| 147 | { |
| 148 | if (pfrd_CGE_Open != NULL) |
| 149 | return; |
| 150 | |
| 151 | #ifdef QT_BUILD |
| 152 | QLibrary hCgeDll("castleengine"); |
| 153 | hCgeDll.load(); |
| 154 | if (!hCgeDll.isLoaded()) |
| 155 | { |
| 156 | QString sErr = hCgeDll.errorString(); |
| 157 | QMessageBox::critical(NULL, "error", sErr); |
| 158 | return; |
| 159 | } |
| 160 | #else |
| 161 | HMODULE hCgeDll = LoadLibrary("castleengine.dll"); |
| 162 | if (hCgeDll==NULL) |
| 163 | return; |
| 164 | #endif |
| 165 | |
| 166 | pfrd_CGE_Initialize = (PFNRD_CGE_Initialize)cge_GetProc(hCgeDll, "CGE_Initialize"); |
| 167 | pfrd_CGE_Finalize = (PFNRD_CGE_Finalize)cge_GetProc(hCgeDll, "CGE_Finalize"); |
| 168 | pfrd_CGE_Open = (PFNRD_CGE_Open)cge_GetProc(hCgeDll, "CGE_Open"); |
| 169 | pfrd_CGE_Close = (PFNRD_CGE_Close)cge_GetProc(hCgeDll, "CGE_Close"); |
| 170 | pfrd_CGE_GetOpenGLInformation = (PFNRD_CGE_GetOpenGLInformation)cge_GetProc(hCgeDll, "CGE_GetOpenGLInformation"); |
| 171 | pfrd_CGE_Resize = (PFNRD_CGE_Resize)cge_GetProc(hCgeDll, "CGE_Resize"); |
| 172 | pfrd_CGE_Render = (PFNRD_CGE_Render)cge_GetProc(hCgeDll, "CGE_Render"); |
| 173 | pfrd_CGE_SaveScreenshotToFile = (PFNRD_CGE_SaveScreenshotToFile)cge_GetProc(hCgeDll, "CGE_SaveScreenshotToFile"); |
| 174 | pfrd_CGE_SetLibraryCallbackProc = (PFNRD_CGE_SetLibraryCallbackProc)cge_GetProc(hCgeDll, "CGE_SetLibraryCallbackProc"); |
| 175 | pfrd_CGE_Update = (PFNRD_CGE_Update)cge_GetProc(hCgeDll, "CGE_Update"); |
| 176 | pfrd_CGE_MouseDown = (PFNRD_CGE_MouseDown)cge_GetProc(hCgeDll, "CGE_MouseDown"); |
| 177 | pfrd_CGE_Motion = (PFNRD_CGE_Motion)cge_GetProc(hCgeDll, "CGE_Motion"); |
| 178 | pfrd_CGE_MouseUp = (PFNRD_CGE_MouseUp)cge_GetProc(hCgeDll, "CGE_MouseUp"); |
| 179 | pfrd_CGE_MouseWheel = (PFNRD_CGE_MouseWheel)cge_GetProc(hCgeDll, "CGE_MouseWheel"); |
| 180 | pfrd_CGE_KeyDown = (PFNRD_CGE_KeyDown)cge_GetProc(hCgeDll, "CGE_KeyDown"); |
| 181 | pfrd_CGE_KeyUp = (PFNRD_CGE_KeyUp)cge_GetProc(hCgeDll, "CGE_KeyUp"); |
| 182 | pfrd_CGE_LoadSceneFromFile = (PFNRD_CGE_LoadSceneFromFile)cge_GetProc(hCgeDll, "CGE_LoadSceneFromFile"); |
| 183 | pfrd_CGE_SaveSceneToFile = (PFNRD_CGE_SaveSceneToFile)cge_GetProc(hCgeDll, "CGE_SaveSceneToFile"); |
| 184 | pfrd_CGE_GetViewpointsCount = (PFNRD_CGE_GetViewpointsCount)cge_GetProc(hCgeDll, "CGE_GetViewpointsCount"); |
| 185 | pfrd_CGE_GetViewpointName = (PFNRD_CGE_GetViewpointName)cge_GetProc(hCgeDll, "CGE_GetViewpointName"); |
| 186 | pfrd_CGE_MoveToViewpoint = (PFNRD_CGE_MoveToViewpoint)cge_GetProc(hCgeDll, "CGE_MoveToViewpoint"); |
| 187 | pfrd_CGE_AddViewpointFromCurrentView = (PFNRD_CGE_AddViewpointFromCurrentView)cge_GetProc(hCgeDll, "CGE_AddViewpointFromCurrentView"); |
| 188 | pfrd_CGE_GetBoundingBox = (PFNRD_CGE_GetBoundingBox)cge_GetProc(hCgeDll, "CGE_GetBoundingBox"); |
| 189 | pfrd_CGE_GetViewCoords = (PFNRD_CGE_GetViewCoords)cge_GetProc(hCgeDll, "CGE_GetViewCoords"); |
| 190 | pfrd_CGE_MoveViewToCoords = (PFNRD_CGE_MoveViewToCoords)cge_GetProc(hCgeDll, "CGE_MoveViewToCoords"); |
| 191 | pfrd_CGE_SetNavigationInputShortcut = (PFNRD_CGE_SetNavigationInputShortcut)cge_GetProc(hCgeDll, "CGE_SetNavigationInputShortcut"); |
| 192 | pfrd_CGE_GetNavigationType = (PFNRD_CGE_GetNavigationType)cge_GetProc(hCgeDll, "CGE_GetNavigationType"); |
| 193 | pfrd_CGE_SetNavigationType = (PFNRD_CGE_SetNavigationType)cge_GetProc(hCgeDll, "CGE_SetNavigationType"); |
| 194 | pfrd_CGE_SetTouchInterface = (PFNRD_CGE_SetTouchInterface)cge_GetProc(hCgeDll, "CGE_SetTouchInterface"); |
| 195 | pfrd_CGE_SetUserInterface = (PFNRD_CGE_SetUserInterface)cge_GetProc(hCgeDll, "CGE_SetUserInterface"); |
| 196 | pfrd_CGE_SetVariableInt = (PFNRD_CGE_SetVariableInt)cge_GetProc(hCgeDll, "CGE_SetVariableInt"); |
| 197 | pfrd_CGE_GetVariableInt = (PFNRD_CGE_GetVariableInt)cge_GetProc(hCgeDll, "CGE_GetVariableInt"); |
| 198 | pfrd_CGE_SetNodeFieldValue = (PFNRD_CGE_SetNodeFieldValue)cge_GetProc(hCgeDll, "CGE_SetNodeFieldValue"); |
| 199 | pfrd_CGE_IncreaseSceneTime = (PFNRD_CGE_IncreaseSceneTime)cge_GetProc(hCgeDll, "CGE_IncreaseSceneTime"); |
| 200 | } |
| 201 | |
| 202 | //----------------------------------------------------------------------------- |
| 203 | void CGE_Initialize(const char *applicationConfigDirectory) |
| 204 | { |
| 205 | if (pfrd_CGE_Initialize!=NULL) |
| 206 | (*pfrd_CGE_Initialize)(applicationConfigDirectory); |
| 207 | } |
| 208 | |
| 209 | //----------------------------------------------------------------------------- |
| 210 | void CGE_Finalize() |
| 211 | { |
| 212 | if (pfrd_CGE_Finalize!=NULL) |
| 213 | (*pfrd_CGE_Finalize)(); |
| 214 | } |
| 215 | |
| 216 | //----------------------------------------------------------------------------- |
| 217 | void CGE_Open(unsigned uiFlags, unsigned initialWidth, unsigned initialHeight, unsigned uiDpi) |
| 218 | { |
| 219 | if (pfrd_CGE_Open!=NULL) |
| 220 | (*pfrd_CGE_Open)(uiFlags, initialWidth, initialHeight, uiDpi); |
| 221 | } |
| 222 | |
| 223 | //----------------------------------------------------------------------------- |
| 224 | void CGE_Close(bool quitWhenLastWindowClosed) |
| 225 | { |
| 226 | if (pfrd_CGE_Close!=NULL) |
| 227 | (*pfrd_CGE_Close)(quitWhenLastWindowClosed); |
| 228 | } |
| 229 | |
| 230 | //----------------------------------------------------------------------------- |
| 231 | void CGE_GetOpenGLInformation(char *szBuffer, int nBufSize) |
| 232 | { |
| 233 | if (pfrd_CGE_GetOpenGLInformation!=NULL) |
| 234 | (*pfrd_CGE_GetOpenGLInformation)(szBuffer, nBufSize); |
| 235 | } |
| 236 | |
| 237 | //----------------------------------------------------------------------------- |
| 238 | void CGE_Resize(unsigned uiViewWidth, unsigned uiViewHeight) |
| 239 | { |
| 240 | if (pfrd_CGE_Resize!=NULL) |
| 241 | (*pfrd_CGE_Resize)(uiViewWidth, uiViewHeight); |
| 242 | } |
| 243 | |
| 244 | //----------------------------------------------------------------------------- |
| 245 | void CGE_Render() |
| 246 | { |
| 247 | if (pfrd_CGE_Render!=NULL) |
| 248 | (*pfrd_CGE_Render)(); |
| 249 | } |
| 250 | |
| 251 | //----------------------------------------------------------------------------- |
| 252 | void CGE_SaveScreenshotToFile(const char *szFile) |
| 253 | { |
| 254 | if (pfrd_CGE_SaveScreenshotToFile!=NULL) |
| 255 | (*pfrd_CGE_SaveScreenshotToFile)(szFile); |
| 256 | } |
| 257 | |
| 258 | //----------------------------------------------------------------------------- |
| 259 | void CGE_SetLibraryCallbackProc(TCgeLibraryCallback pProc) |
| 260 | { |
| 261 | if (pfrd_CGE_SetLibraryCallbackProc!=NULL) |
| 262 | (*pfrd_CGE_SetLibraryCallbackProc)(pProc); |
| 263 | } |
| 264 | |
| 265 | //----------------------------------------------------------------------------- |
| 266 | void CGE_Update() |
| 267 | { |
| 268 | if (pfrd_CGE_Update!=NULL) |
| 269 | (*pfrd_CGE_Update)(); |
| 270 | } |
| 271 | |
| 272 | //----------------------------------------------------------------------------- |
| 273 | void CGE_MouseDown(int x, int y, bool bLeftBtn, int nFingerIdx) |
| 274 | { |
| 275 | if (pfrd_CGE_MouseDown!=NULL) |
| 276 | (*pfrd_CGE_MouseDown)(x, y, bLeftBtn, nFingerIdx); |
| 277 | } |
| 278 | |
| 279 | //----------------------------------------------------------------------------- |
| 280 | void CGE_Motion(int x, int y, int nFingerIdx) |
| 281 | { |
| 282 | if (pfrd_CGE_Motion!=NULL) |
| 283 | (*pfrd_CGE_Motion)(x, y, nFingerIdx); |
| 284 | } |
| 285 | |
| 286 | //----------------------------------------------------------------------------- |
| 287 | void CGE_MouseUp(int x, int y, bool bLeftBtn, int nFingerIdx, bool trackReleased) |
| 288 | { |
| 289 | if (pfrd_CGE_MouseUp!=NULL) |
| 290 | (*pfrd_CGE_MouseUp)(x, y, bLeftBtn, nFingerIdx, trackReleased); |
| 291 | } |
| 292 | |
| 293 | //----------------------------------------------------------------------------- |
| 294 | void CGE_MouseWheel(float zDelta, bool bVertical) |
| 295 | { |
| 296 | if (pfrd_CGE_MouseWheel!=NULL) |
| 297 | (*pfrd_CGE_MouseWheel)(zDelta, bVertical); |
| 298 | } |
| 299 | |
| 300 | //----------------------------------------------------------------------------- |
| 301 | void CGE_KeyDown(int /*ECgeKey*/ eKey) |
| 302 | { |
| 303 | if (pfrd_CGE_KeyDown!=NULL) |
| 304 | (*pfrd_CGE_KeyDown)(eKey); |
| 305 | } |
| 306 | |
| 307 | //----------------------------------------------------------------------------- |
| 308 | void CGE_KeyUp(int /*ECgeKey*/ eKey) |
| 309 | { |
| 310 | if (pfrd_CGE_KeyUp!=NULL) |
| 311 | (*pfrd_CGE_KeyUp)(eKey); |
| 312 | } |
| 313 | |
| 314 | //----------------------------------------------------------------------------- |
| 315 | void CGE_LoadSceneFromFile(const char *szFile) |
| 316 | { |
| 317 | if (pfrd_CGE_LoadSceneFromFile!=NULL) |
| 318 | (*pfrd_CGE_LoadSceneFromFile)(szFile); |
| 319 | } |
| 320 | |
| 321 | //----------------------------------------------------------------------------- |
| 322 | void CGE_SaveSceneToFile(const char *szFile) |
| 323 | { |
| 324 | if (pfrd_CGE_SaveSceneToFile!=NULL) |
| 325 | (*pfrd_CGE_SaveSceneToFile)(szFile); |
| 326 | } |
| 327 | |
| 328 | //----------------------------------------------------------------------------- |
| 329 | int CGE_GetViewpointsCount() |
| 330 | { |
| 331 | if (pfrd_CGE_MoveToViewpoint!=NULL) |
| 332 | return (*pfrd_CGE_GetViewpointsCount)(); |
| 333 | else |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | //----------------------------------------------------------------------------- |
| 338 | void CGE_GetViewpointName(int iViewpointIdx, char *szName, int nBufSize) |
| 339 | { |
| 340 | if (pfrd_CGE_GetViewpointName!=NULL) |
| 341 | (*pfrd_CGE_GetViewpointName)(iViewpointIdx, szName, nBufSize); |
| 342 | } |
| 343 | |
| 344 | //----------------------------------------------------------------------------- |
| 345 | void CGE_MoveToViewpoint(int iViewpointIdx, bool bAnimated) |
| 346 | { |
| 347 | if (pfrd_CGE_MoveToViewpoint!=NULL) |
| 348 | (*pfrd_CGE_MoveToViewpoint)(iViewpointIdx, bAnimated); |
| 349 | } |
| 350 | |
| 351 | //----------------------------------------------------------------------------- |
| 352 | void CGE_AddViewpointFromCurrentView(const char *szName) |
| 353 | { |
| 354 | if (pfrd_CGE_AddViewpointFromCurrentView!=NULL) |
| 355 | (*pfrd_CGE_AddViewpointFromCurrentView)(szName); |
| 356 | } |
| 357 | |
| 358 | //----------------------------------------------------------------------------- |
| 359 | void CGE_GetBoundingBox(float *pfXMin, float *pfXMax, float *pfYMin, float *pfYMax, float *pfZMin, float *pfZMax) |
| 360 | { |
| 361 | if (pfrd_CGE_GetBoundingBox!=NULL) |
| 362 | (*pfrd_CGE_GetBoundingBox)(pfXMin, pfXMax, pfYMin, pfYMax, pfZMin, pfZMax); |
| 363 | } |
| 364 | |
| 365 | //----------------------------------------------------------------------------- |
| 366 | void CGE_GetViewCoords(float *pfPosX, float *pfPosY, float *pfPosZ, float *pfDirX, float *pfDirY, float *pfDirZ, |
| 367 | float *pfUpX, float *pfUpY, float *pfUpZ, float *pfGravX, float *pfGravY, float *pfGravZ) |
| 368 | { |
| 369 | if (pfrd_CGE_GetViewCoords!=NULL) |
| 370 | (*pfrd_CGE_GetViewCoords)(pfPosX, pfPosY, pfPosZ, pfDirX, pfDirY, pfDirZ, pfUpX, pfUpY, pfUpZ, pfGravX, pfGravY, pfGravZ); |
| 371 | } |
| 372 | |
| 373 | //----------------------------------------------------------------------------- |
| 374 | void CGE_MoveViewToCoords(float fPosX, float fPosY, float fPosZ, float fDirX, float fDirY, float fDirZ, |
| 375 | float fUpX, float fUpY, float fUpZ, float fGravX, float fGravY, float fGravZ, bool bAnimated) |
| 376 | { |
| 377 | if (pfrd_CGE_MoveViewToCoords!=NULL) |
| 378 | (*pfrd_CGE_MoveViewToCoords)(fPosX, fPosY, fPosZ, fDirX, fDirY, fDirZ, fUpX, fUpY, fUpZ, fGravX, fGravY, fGravZ, bAnimated); |
| 379 | } |
| 380 | |
| 381 | //----------------------------------------------------------------------------- |
| 382 | void CGE_SetNavigationInputShortcut(int eInput, int eKey1, int eKey2, int eMouseButton, int eMouseWheel) |
| 383 | { |
| 384 | if (pfrd_CGE_SetNavigationInputShortcut!=NULL) |
| 385 | (*pfrd_CGE_SetNavigationInputShortcut)(eInput, eKey1, eKey2, eMouseButton, eMouseWheel); |
| 386 | } |
| 387 | |
| 388 | //----------------------------------------------------------------------------- |
| 389 | int CGE_GetNavigationType() |
| 390 | { |
| 391 | if (pfrd_CGE_GetNavigationType!=NULL) |
| 392 | return (*pfrd_CGE_GetNavigationType)(); |
| 393 | else |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | //----------------------------------------------------------------------------- |
| 398 | void CGE_SetNavigationType(int /*ECgeNavigationType*/ eNewType) |
| 399 | { |
| 400 | if (pfrd_CGE_SetNavigationType!=NULL) |
| 401 | (*pfrd_CGE_SetNavigationType)(eNewType); |
| 402 | } |
| 403 | |
| 404 | //----------------------------------------------------------------------------- |
| 405 | void CGE_SetTouchInterface(int /*ECgeTouchCtlInterface*/ eMode) |
| 406 | { |
| 407 | if (pfrd_CGE_SetTouchInterface!=NULL) |
| 408 | (*pfrd_CGE_SetTouchInterface)(eMode); |
| 409 | } |
| 410 | |
| 411 | //----------------------------------------------------------------------------- |
| 412 | void CGE_SetUserInterface(bool bAutomaticTouchInterface) |
| 413 | { |
| 414 | if (pfrd_CGE_SetUserInterface!=NULL) |
| 415 | (*pfrd_CGE_SetUserInterface)(bAutomaticTouchInterface); |
| 416 | } |
| 417 | |
| 418 | //----------------------------------------------------------------------------- |
| 419 | void CGE_SetVariableInt(int /*ECgeVariable*/ eVar, int nValue) |
| 420 | { |
| 421 | if (pfrd_CGE_SetVariableInt!=NULL) |
| 422 | (*pfrd_CGE_SetVariableInt)(eVar, nValue); |
| 423 | } |
| 424 | |
| 425 | //----------------------------------------------------------------------------- |
| 426 | int CGE_GetVariableInt(int /*ECgeVariable*/ eVar) |
| 427 | { |
| 428 | if (pfrd_CGE_GetVariableInt!=NULL) |
| 429 | return (*pfrd_CGE_GetVariableInt)(eVar); |
| 430 | else |
| 431 | return -1; |
| 432 | } |
| 433 | |
| 434 | //----------------------------------------------------------------------------- |
| 435 | void CGE_SetNodeFieldValue(const char *szNodeName, const char *szFieldName, |
| 436 | float fVal1, float fVal2, float fVal3, float fVal4) |
| 437 | { |
| 438 | if (pfrd_CGE_SetNodeFieldValue!=NULL) |
| 439 | (*pfrd_CGE_SetNodeFieldValue)(szNodeName, szFieldName, fVal1, fVal2, fVal3, fVal4); |
| 440 | } |
| 441 | |
| 442 | //----------------------------------------------------------------------------- |
| 443 | void CGE_IncreaseSceneTime(float fTimeS) |
| 444 | { |
| 445 | if (pfrd_CGE_IncreaseSceneTime!=NULL) |
| 446 | (*pfrd_CGE_IncreaseSceneTime)(fTimeS); |
| 447 | } |