| 1 |
{ |
| 2 |
Copyright 2008-2023 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 is another test project for our library. Instead of including library |
| 16 |
units directly, it uses the compiled dynamic library. |
| 17 |
|
| 18 |
This file is here as a wrapper, only to load the castleengine shared library |
| 19 |
(castleengine.dll, libcastleengine.so, libcastleengine.dylib depending on OS) |
| 20 |
for you. |
| 21 |
|
| 22 |
Usage: |
| 23 |
1. Copy castlelib_dynloader.pas into your project folder. |
| 24 |
|
| 25 |
2. Make the shared library accessible to your project. |
| 26 |
|
| 27 |
Windows: Copy castleengine.dll to your project folder, |
| 28 |
where executable file is generated. Or to any directory listed on $PATH. |
| 29 |
|
| 30 |
Linux: Make sure libcastleengine.so is available in a directory |
| 31 |
listed on $LD_LIBRARY_PATH (or in one of the predefined directories, |
| 32 |
like /usr/lib; see "man dlopen" for details). For local testing, |
| 33 |
it's usually most comfortable to set LD_LIBRARY_PATH to just contain |
| 34 |
.../castle_game_engine/src/deprecated_library/ directory. |
| 35 |
|
| 36 |
3. Include castlelib_dynloader in your source files. Library is automatically |
| 37 |
initialized. Just call CGE_xxx functions as usual. |
| 38 |
} |
| 39 |
|
| 40 |
unit castlelib_dynloader; |
| 41 |
|
| 42 |
{$I castleconf.inc} |
| 43 |
|
| 44 |
interface |
| 45 |
uses |
| 46 |
ctypes; |
| 47 |
|
| 48 |
const |
| 49 |
// open flags |
| 50 |
ecgeofSaveMemory = 1; |
| 51 |
ecgeofLog = 2; |
| 52 |
|
| 53 |
// used for quering engine parameters in CGE_Set/GetVariable |
| 54 |
ecgevarWalkHeadBobbing = 0; // walking effect (int, 1 = on, 0 = off) |
| 55 |
ecgevarEffectSSAO = 1; // screen space ambient occlusion (int, 1 or 0) |
| 56 |
ecgevarMouseLook = 2; // activate mouse look viewing mode, desktop interface only (int, 1 or 0) |
| 57 |
ecgevarCrossHair = 3; // show crosshair in the center of the screen (int, 1 or 0) |
| 58 |
ecgevarAnimationRunning = 4; // (read-only) engine would like to progress with the animation (int, 1 or 0) |
| 59 |
ecgevarWalkTouchCtl = 5; // walking touch control (int, one of ECgeTouchCtlInterface values) |
| 60 |
ecgevarScenePaused = 6; // pause Viewport (int, 1 = on, 0 = off) |
| 61 |
ecgevarAutoRedisplay = 7; // automatically redraws the window all the time (int, 1 = on, 0 = off) |
| 62 |
ecgevarHeadlight = 8; // avatar's headlight (int, 1 = on, 0 = off) |
| 63 |
ecgevarOcclusionCulling = 9; // occlusion culling (int, 1 = on, 0 = off) |
| 64 |
ecgevarPhongShading = 10; // phong shading (int, 1 = on, 0 = off) |
| 65 |
|
| 66 |
// navigation types (ECgeNavigationType enum) |
| 67 |
ecgenavWalk = 0; |
| 68 |
ecgenavFly = 1; |
| 69 |
ecgenavExamine = 2; |
| 70 |
ecgenavTurntable = 3; |
| 71 |
ecgenavNone = 4; |
| 72 |
|
| 73 |
// touch interface modes |
| 74 |
tiNone = 0; |
| 75 |
tiCtlWalkCtlRotate = 1; |
| 76 |
tiCtlWalkDragRotate = 2; |
| 77 |
tiCtlFlyCtlWalkDragRotate = 3; |
| 78 |
tiCtlPanXYDragRotate = 4; |
| 79 |
|
| 80 |
// library callback codes |
| 81 |
ecgelibNeedsDisplay = 0; |
| 82 |
ecgelibSetMouseCursor = 1; // sends mouse cursor code in iParam1 |
| 83 |
ecgelibNavigationTypeChanged = 2; // sends ECgeNavigationType in iParam1 (see castleengine.h) |
| 84 |
ecgelibSetMousePosition = 3; // sends x in iParam1 and y in iParam2 |
| 85 |
ecgelibWarning = 4; // sends message in szParam |
| 86 |
|
| 87 |
// mouse cursor codes |
| 88 |
ecgecursorDefault = 0; |
| 89 |
ecgecursorWait = 1; |
| 90 |
ecgecursorHand = 2; |
| 91 |
ecgecursorText = 3; |
| 92 |
ecgecursorNone = 4; |
| 93 |
|
| 94 |
// key codes (ECgeKey) |
| 95 |
kcge_None = 0; |
| 96 |
kcge_PrintScreen = 1; |
| 97 |
kcge_CapsLock = 2; |
| 98 |
kcge_ScrollLock = 3; |
| 99 |
kcge_NumLock = 4; |
| 100 |
kcge_Pause = 5; |
| 101 |
kcge_Apostrophe = 6; |
| 102 |
kcge_Semicolon = 7; |
| 103 |
kcge_BackSpace = 8; |
| 104 |
kcge_Tab = 9; |
| 105 |
kcge_Slash = 10; |
| 106 |
kcge_BackQuote = 11; |
| 107 |
kcge_Minus = 12; |
| 108 |
kcge_Enter = 13; |
| 109 |
kcge_Equal = 14; |
| 110 |
kcge_BackSlash = 15; |
| 111 |
kcge_Shift = 16; |
| 112 |
kcge_Ctrl = 17; |
| 113 |
kcge_Alt = 18; |
| 114 |
kcge_Plus = 19; |
| 115 |
kcge_Escape = 27; |
| 116 |
kcge_Space = 32; |
| 117 |
kcge_PageUp = 33; |
| 118 |
kcge_PageDown = 34; |
| 119 |
kcge_End = 35; |
| 120 |
kcge_Home = 36; |
| 121 |
kcge_Left = 37; |
| 122 |
kcge_Up = 38; |
| 123 |
kcge_Right = 39; |
| 124 |
kcge_Down = 40; |
| 125 |
kcge_Insert = 45; |
| 126 |
kcge_Delete = 46; |
| 127 |
kcge_0 = 48; |
| 128 |
kcge_1 = 49; |
| 129 |
kcge_2 = 50; |
| 130 |
kcge_3 = 51; |
| 131 |
kcge_4 = 52; |
| 132 |
kcge_5 = 53; |
| 133 |
kcge_6 = 54; |
| 134 |
kcge_7 = 55; |
| 135 |
kcge_8 = 56; |
| 136 |
kcge_9 = 57; |
| 137 |
kcge_A = 65; |
| 138 |
kcge_B = 66; |
| 139 |
kcge_C = 67; |
| 140 |
kcge_D = 68; |
| 141 |
kcge_E = 69; |
| 142 |
kcge_F = 70; |
| 143 |
kcge_G = 71; |
| 144 |
kcge_H = 72; |
| 145 |
kcge_I = 73; |
| 146 |
kcge_J = 74; |
| 147 |
kcge_K = 75; |
| 148 |
kcge_L = 76; |
| 149 |
kcge_M = 77; |
| 150 |
kcge_N = 78; |
| 151 |
kcge_O = 79; |
| 152 |
kcge_P = 80; |
| 153 |
kcge_Q = 81; |
| 154 |
kcge_R = 82; |
| 155 |
kcge_S = 83; |
| 156 |
kcge_T = 84; |
| 157 |
kcge_U = 85; |
| 158 |
kcge_V = 86; |
| 159 |
kcge_W = 87; |
| 160 |
kcge_X = 88; |
| 161 |
kcge_Y = 89; |
| 162 |
kcge_Z = 90; |
| 163 |
kcge_LeftBracket = 91; |
| 164 |
kcge_RightBracket = 92; |
| 165 |
kcge_Numpad_Plus = 107; |
| 166 |
kcge_Numpad_Minus = 109; |
| 167 |
kcge_F1 = 112; |
| 168 |
kcge_F2 = 113; |
| 169 |
kcge_F3 = 114; |
| 170 |
kcge_F4 = 115; |
| 171 |
kcge_F5 = 116; |
| 172 |
kcge_F6 = 117; |
| 173 |
kcge_F7 = 118; |
| 174 |
kcge_F8 = 119; |
| 175 |
kcge_F9 = 120; |
| 176 |
kcge_F10 = 121; |
| 177 |
kcge_F11 = 122; |
| 178 |
kcge_F12 = 123; |
| 179 |
kcge_Numpad_0 = 140; |
| 180 |
kcge_Numpad_1 = 141; |
| 181 |
kcge_Numpad_2 = 142; |
| 182 |
kcge_Numpad_3 = 143; |
| 183 |
kcge_Numpad_4 = 144; |
| 184 |
kcge_Numpad_5 = 145; |
| 185 |
kcge_Numpad_6 = 146; |
| 186 |
kcge_Numpad_7 = 147; |
| 187 |
kcge_Numpad_8 = 148; |
| 188 |
kcge_Numpad_9 = 149; |
| 189 |
kcge_Numpad_End = 150; |
| 190 |
kcge_Numpad_Down = 151; |
| 191 |
kcge_Numpad_PageDown = 152; |
| 192 |
kcge_Numpad_Left = 153; |
| 193 |
kcge_Numpad_Begin = 154; |
| 194 |
kcge_Numpad_Right = 155; |
| 195 |
kcge_Numpad_Home = 156; |
| 196 |
kcge_Numpad_Up = 157; |
| 197 |
kcge_Numpad_PageUp = 158; |
| 198 |
kcge_Numpad_Insert = 159; |
| 199 |
kcge_Numpad_Delete = 160; |
| 200 |
kcge_Numpad_Enter = 161; |
| 201 |
kcge_Numpad_Multiply = 162; |
| 202 |
kcge_Numpad_Divide = 163; |
| 203 |
kcge_Pad_A = 164; |
| 204 |
kcge_Pad_B = 165; |
| 205 |
kcge_Pad_X = 166; |
| 206 |
kcge_Pad_Y = 167; |
| 207 |
kcge_Pad_L = 168; |
| 208 |
kcge_Pad_R = 169; |
| 209 |
kcge_Pad_ZL = 170; |
| 210 |
kcge_Pad_ZR = 171; |
| 211 |
kcge_Pad_Plus = 172; |
| 212 |
kcge_Pad_Minus = 173; |
| 213 |
kcge_Pad_Left = 174; |
| 214 |
kcge_Pad_Up = 175; |
| 215 |
kcge_Pad_Right = 176; |
| 216 |
kcge_Pad_Down = 177; |
| 217 |
kcge_Comma = 188; |
| 218 |
kcge_Period = 190; |
| 219 |
|
| 220 |
// mouse button (ECgeMouseButton) |
| 221 |
ecgemouseButtonNone = 0; |
| 222 |
ecgemouseButtonLeft = 1; |
| 223 |
ecgemouseButtonMiddle = 2; |
| 224 |
ecgemouseButtonRight = 3; |
| 225 |
ecgemouseButtonExtra1 = 4; |
| 226 |
ecgemouseButtonExtra2 = 5; |
| 227 |
|
| 228 |
// mouse wheel direction (ECgeMouseWheelDirection) |
| 229 |
ecgemouseWheelNone = 0; |
| 230 |
ecgemouseWheelUp = 1; |
| 231 |
ecgemouseWheelDown = 2; |
| 232 |
ecgemouseWheelLeft = 3; |
| 233 |
ecgemouseWheelRight = 4; |
| 234 |
|
| 235 |
// camera input (ECgeNavigationInput) |
| 236 |
ecgeinputZoomIn = 1; |
| 237 |
ecgeinputZoomOut = 2; |
| 238 |
ecgeinputForward = 11; |
| 239 |
ecgeinputBackward = 12; |
| 240 |
ecgeinputLeftRotate = 13; |
| 241 |
ecgeinputRightRotate = 14; |
| 242 |
ecgeinputLeftStrafe = 15; |
| 243 |
ecgeinputRightStrafe = 16; |
| 244 |
ecgeinputUpRotate = 17; |
| 245 |
ecgeinputDownRotate = 18; |
| 246 |
ecgeinputIncreasePreferredHeight = 19; |
| 247 |
ecgeinputDecreasePreferredHeight = 20; |
| 248 |
ecgeinputGravityUp = 21; |
| 249 |
ecgeinputRun = 22; |
| 250 |
ecgeinputMoveSpeedInc = 23; |
| 251 |
ecgeinputMoveSpeedDec = 24; |
| 252 |
ecgeinputJump = 25; |
| 253 |
ecgeinputCrouch = 26; |
| 254 |
ecgeinputExRotate = 31; |
| 255 |
ecgeinputExMove = 32; |
| 256 |
ecgeinputExZoom = 33; |
| 257 |
|
| 258 |
type |
| 259 |
TLibraryCallbackProc = function (eCode, iParam1, iParam2: cInt32; szParam: pcchar):cInt32; cdecl; |
| 260 |
|
| 261 |
procedure CGE_Initialize(ApplicationConfigDirectory: PCChar); cdecl; external 'castleengine'; |
| 262 |
procedure CGE_Finalize(); cdecl; external 'castleengine'; |
| 263 |
procedure CGE_Open(flags: cUInt32; InitialWidth, InitialHeight, Dpi: cUInt32); cdecl; external 'castleengine'; |
| 264 |
procedure CGE_Close(); cdecl; external 'castleengine'; |
| 265 |
procedure CGE_GetOpenGLInformation(szBuffer: pchar; nBufSize: cInt32); cdecl; external 'castleengine'; |
| 266 |
procedure CGE_Resize(uiViewWidth, uiViewHeight: cUInt32); cdecl; external 'castleengine'; |
| 267 |
procedure CGE_Render(); cdecl; external 'castleengine'; |
| 268 |
procedure CGE_SaveScreenshotToFile(szFile: pcchar); cdecl; external 'castleengine'; |
| 269 |
procedure CGE_SetLibraryCallbackProc(aProc: TLibraryCallbackProc); cdecl; external 'castleengine'; |
| 270 |
procedure CGE_Update(); cdecl; external 'castleengine'; |
| 271 |
procedure CGE_MouseDown(X, Y: cInt32; bLeftBtn: cBool; FingerIndex: CInt32); cdecl; external 'castleengine'; |
| 272 |
procedure CGE_Motion(X, Y: cInt32; FingerIndex: CInt32); cdecl; external 'castleengine'; |
| 273 |
procedure CGE_MouseUp(X, Y: cInt32; bLeftBtn: cBool; FingerIndex: CInt32; trackReleased: cBool); cdecl; external 'castleengine'; |
| 274 |
procedure CGE_MouseWheel(zDelta: cFloat; bVertical: cBool); cdecl; external 'castleengine'; |
| 275 |
procedure CGE_KeyDown(eKey: CInt32); cdecl; external 'castleengine'; |
| 276 |
procedure CGE_KeyUp(eKey: CInt32); cdecl; external 'castleengine'; |
| 277 |
procedure CGE_LoadSceneFromFile(szFile: pcchar); cdecl; external 'castleengine'; |
| 278 |
procedure CGE_SaveSceneToFile(szFile: pcchar); cdecl; external 'castleengine'; |
| 279 |
function CGE_GetViewpointsCount(): cInt32; cdecl; external 'castleengine'; |
| 280 |
procedure CGE_GetViewpointName(iViewpointIdx: cInt32; szName: pchar; nBufSize: cInt32); cdecl; external 'castleengine'; |
| 281 |
procedure CGE_MoveToViewpoint(iViewpointIdx: cInt32; bAnimated: cBool); cdecl; external 'castleengine'; |
| 282 |
procedure CGE_AddViewpointFromCurrentView(szName: pcchar); cdecl; external 'castleengine'; |
| 283 |
procedure CGE_GetBoundingBox(pfXMin, pfXMax, pfYMin, pfYMax, pfZMin, pfZMax: pcfloat); cdecl; external 'castleengine'; |
| 284 |
procedure CGE_GetViewCoords(pfPosX, pfPosY, pfPosZ, pfDirX, pfDirY, pfDirZ, |
| 285 |
pfUpX, pfUpY, pfUpZ, pfGravX, pfGravY, pfGravZ: pcfloat); cdecl; external 'castleengine'; |
| 286 |
procedure CGE_MoveViewToCoords(fPosX, fPosY, fPosZ, fDirX, fDirY, fDirZ, |
| 287 |
fUpX, fUpY, fUpZ, fGravX, fGravY, fGravZ: cFloat; |
| 288 |
bAnimated: cBool); cdecl; external 'castleengine'; |
| 289 |
procedure CGE_SetNavigationInputShortcut(eInput, eKey1, eKey2, eMouseButton, eMouseWheel: cInt32); cdecl; external 'castleengine'; |
| 290 |
function CGE_GetNavigationType(): cInt32; cdecl; external 'castleengine'; |
| 291 |
procedure CGE_SetNavigationType(NewType: cInt32); cdecl; external 'castleengine'; |
| 292 |
procedure CGE_SetTouchInterface(eMode: cInt32); cdecl; external 'castleengine'; |
| 293 |
procedure CGE_SetUserInterface(AutomaticTouchInterface: cBool); cdecl; external 'castleengine'; |
| 294 |
|
| 295 |
procedure CGE_SetVariableInt(eVar: cInt32; nValue: cInt32); cdecl; external 'castleengine'; |
| 296 |
function CGE_GetVariableInt(eVar: cInt32): cInt32; cdecl; external 'castleengine'; |
| 297 |
|
| 298 |
procedure CGE_SetNodeFieldValue(szNodeName, szFieldName: pcchar; |
| 299 |
fVal1, fVal2, fVal3, fVal4: cFloat); cdecl; external 'castleengine'; |
| 300 |
|
| 301 |
procedure CGE_IncreaseSceneTime(fTimeS: cFloat); cdecl; external 'castleengine'; |
| 302 |
|
| 303 |
implementation |
| 304 |
|
| 305 |
{$ifdef DARWIN} |
| 306 |
{$linklib castleengine} |
| 307 |
{$endif} |
| 308 |
|
| 309 |
begin |
| 310 |
end. |