Debian Codegraph @

src/deprecated_library/castleengine.h

raw symbols SCIP
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 include file should be used in C/C++ projects. It contains all
16 functions exported from the library.
17
18 Dynamic library: add castlelib_c_loader.cpp file to your project and call
19 CGE_LoadLibrary first to enable to Castle Game Engine funtions.
20
21 iOS: castlelib will be statically linked to your app, so just include
22 this file and you are ready to go.
23 */
24
25
26 #ifndef CGE_LIBRARY_INCLUDED
27 #define CGE_LIBRARY_INCLUDED
28
29 #ifdef __GNUC__
30 # ifdef __i386
31 # define CDECL __attribute__ ((__cdecl__))
32 # else
33 // On other platforms (like x86_64), cdecl is ignored
34 // https://mail.python.org/pipermail/expat-bugs/2004-January/001792.html
35 // https://groups.google.com/forum/#!topic/comp.os.linux.development.apps/7Dd7ge9OgKI
36 # define CDECL
37 # endif
38 #else
39 # ifndef CDECL
40 # define CDECL __cdecl
41 # endif
42 #endif
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 enum ECgeOpenFlag
49 {
50 ecgeofSaveMemory = 1, // memory vs rendering quality (# of triangles)
51 ecgeofLog = 2, // enable logging to stderr
52 };
53
54 enum ECgeVariable // used for querying engine parameters in CGE_Set/GetVariable
55 {
56 ecgevarWalkHeadBobbing = 0, // walking effect (int, 1 = on, 0 = off)
57 ecgevarEffectSSAO = 1, // screen space ambient occlusion (int, 1 or 0)
58 ecgevarMouseLook = 2, // activate mouse look viewing mode, desktop interface only (int, 1 or 0)
59 ecgevarCrossHair = 3, // show crosshair in the center of the screen (int, 1 or 0)
60 ecgevarAnimationRunning = 4, // (read-only) engine would like to progress with the animation (int, 1 or 0)
61 ecgevarWalkTouchCtl = 5, // walking touch control (int, one of ECgeTouchCtlInterface values)
62 ecgevarScenePaused = 6, // pause Viewport (int, 1 = on, 0 = off)
63 ecgevarAutoRedisplay = 7, // automatically redraws the window all the time (int, 1 = on, 0 = off)
64 ecgevarHeadlight = 8, // avatar's headlight (int, 1 = on, 0 = off)
65 ecgevarOcclusionCulling = 9, // occlusion culling (int, 1 = on, 0 = off)
66 ecgevarPhongShading = 10, // phong shading (int, 1 = on, 0 = off)
67 };
68
69 enum ECgeNavigationType
70 {
71 ecgenavWalk = 0,
72 ecgenavFly = 1,
73 ecgenavExamine = 2,
74 ecgenavTurntable = 3,
75 ecgenavNone = 4,
76 };
77
78 enum ECgeTouchCtlInterface
79 {
80 ecgetciNone = 0,
81 ecgetciCtlWalkCtlRotate = 1,
82 ecgetciCtlWalkDragRotate = 2,
83 etciCtlFlyCtlWalkDragRotate = 3,
84 etciCtlPanXYDragRotate = 4,
85 };
86
87 enum ECgeMouseCursor
88 {
89 ecgecursorDefault = 0,
90 ecgecursorWait = 1,
91 ecgecursorHand = 2,
92 ecgecursorText = 3,
93 ecgecursorNone = 4,
94 };
95
96 enum ECgeLibCallbackCode
97 {
98 ecgelibNeedsDisplay = 0, // app should repaint the view (content changed)
99 ecgelibSetMouseCursor = 1, // sends ECgeMouseCursor in iParam1
100 ecgelibNavigationTypeChanged = 2, // sends ECgeNavigationType in iParam1
101 ecgelibSetMousePosition = 3, // sends x in iParam1 and y in iParam2
102 ecgelibWarning = 4, // sends message in szParam
103 };
104
105 enum ECgeKey // values for these constants have to be same as in unit CastleKeysMouse (TKey)
106 {
107 kcge_None = 0,
108 kcge_PrintScreen = 1,
109 kcge_CapsLock = 2,
110 kcge_ScrollLock = 3,
111 kcge_NumLock = 4,
112 kcge_Pause = 5,
113 kcge_Apostrophe = 6,
114 kcge_Semicolon = 7,
115 kcge_BackSpace = 8,
116 kcge_Tab = 9,
117 kcge_Slash = 10,
118 kcge_BackQuote = 11,
119 kcge_Minus = 12,
120 kcge_Enter = 13,
121 kcge_Equal = 14,
122 kcge_BackSlash = 15,
123 kcge_Shift = 16,
124 kcge_Ctrl = 17,
125 kcge_Alt = 18,
126 kcge_Plus = 19,
127 kcge_Escape = 27,
128 kcge_Space = 32,
129 kcge_PageUp = 33,
130 kcge_PageDown = 34,
131 kcge_End = 35,
132 kcge_Home = 36,
133 kcge_Left = 37,
134 kcge_Up = 38,
135 kcge_Right = 39,
136 kcge_Down = 40,
137 kcge_Insert = 45,
138 kcge_Delete = 46,
139 kcge_0 = 48,
140 kcge_1 = 49,
141 kcge_2 = 50,
142 kcge_3 = 51,
143 kcge_4 = 52,
144 kcge_5 = 53,
145 kcge_6 = 54,
146 kcge_7 = 55,
147 kcge_8 = 56,
148 kcge_9 = 57,
149 kcge_A = 65,
150 kcge_B = 66,
151 kcge_C = 67,
152 kcge_D = 68,
153 kcge_E = 69,
154 kcge_F = 70,
155 kcge_G = 71,
156 kcge_H = 72,
157 kcge_I = 73,
158 kcge_J = 74,
159 kcge_K = 75,
160 kcge_L = 76,
161 kcge_M = 77,
162 kcge_N = 78,
163 kcge_O = 79,
164 kcge_P = 80,
165 kcge_Q = 81,
166 kcge_R = 82,
167 kcge_S = 83,
168 kcge_T = 84,
169 kcge_U = 85,
170 kcge_V = 86,
171 kcge_W = 87,
172 kcge_X = 88,
173 kcge_Y = 89,
174 kcge_Z = 90,
175 kcge_LeftBracket = 91,
176 kcge_RightBracket = 92,
177 kcge_Numpad_Plus = 107,
178 kcge_Numpad_Minus = 109,
179 kcge_F1 = 112,
180 kcge_F2 = 113,
181 kcge_F3 = 114,
182 kcge_F4 = 115,
183 kcge_F5 = 116,
184 kcge_F6 = 117,
185 kcge_F7 = 118,
186 kcge_F8 = 119,
187 kcge_F9 = 120,
188 kcge_F10 = 121,
189 kcge_F11 = 122,
190 kcge_F12 = 123,
191 kcge_Numpad_0 = 140,
192 kcge_Numpad_1 = 141,
193 kcge_Numpad_2 = 142,
194 kcge_Numpad_3 = 143,
195 kcge_Numpad_4 = 144,
196 kcge_Numpad_5 = 145,
197 kcge_Numpad_6 = 146,
198 kcge_Numpad_7 = 147,
199 kcge_Numpad_8 = 148,
200 kcge_Numpad_9 = 149,
201 kcge_Numpad_End = 150,
202 kcge_Numpad_Down = 151,
203 kcge_Numpad_PageDown = 152,
204 kcge_Numpad_Left = 153,
205 kcge_Numpad_Begin = 154,
206 kcge_Numpad_Right = 155,
207 kcge_Numpad_Home = 156,
208 kcge_Numpad_Up = 157,
209 kcge_Numpad_PageUp = 158,
210 kcge_Numpad_Insert = 159,
211 kcge_Numpad_Delete = 160,
212 kcge_Numpad_Enter = 161,
213 kcge_Numpad_Multiply = 162,
214 kcge_Numpad_Divide = 163,
215 kcge_Pad_A = 164,
216 kcge_Pad_B = 165,
217 kcge_Pad_X = 166,
218 kcge_Pad_Y = 167,
219 kcge_Pad_L = 168,
220 kcge_Pad_R = 169,
221 kcge_Pad_ZL = 170,
222 kcge_Pad_ZR = 171,
223 kcge_Pad_Plus = 172,
224 kcge_Pad_Minus = 173,
225 kcge_Pad_Left = 174,
226 kcge_Pad_Up = 175,
227 kcge_Pad_Right = 176,
228 kcge_Pad_Down = 177,
229 kcge_Comma = 188,
230 kcge_Period = 190,
231 };
232
233 enum ECgeMouseButton
234 {
235 ecgemouseButtonNone = 0,
236 ecgemouseButtonLeft = 1,
237 ecgemouseButtonMiddle = 2,
238 ecgemouseButtonRight = 3,
239 ecgemouseButtonExtra1 = 4,
240 ecgemouseButtonExtra2 = 5,
241 };
242
243 enum ECgeMouseWheelDirection
244 {
245 ecgemouseWheelNone = 0,
246 ecgemouseWheelUp = 1,
247 ecgemouseWheelDown = 2,
248 ecgemouseWheelLeft = 3,
249 ecgemouseWheelRight = 4,
250 };
251
252 enum ECgeNavigationInput
253 {
254 // common for all navigation types
255 ecgeinputZoomIn = 1,
256 ecgeinputZoomOut = 2,
257 // for walk navigation
258 ecgeinputForward = 11,
259 ecgeinputBackward = 12,
260 ecgeinputLeftRotate = 13,
261 ecgeinputRightRotate = 14,
262 ecgeinputLeftStrafe = 15,
263 ecgeinputRightStrafe = 16,
264 ecgeinputUpRotate = 17,
265 ecgeinputDownRotate = 18,
266 ecgeinputIncreasePreferredHeight = 19,
267 ecgeinputDecreasePreferredHeight = 20,
268 ecgeinputGravityUp = 21,
269 ecgeinputRun = 22,
270 ecgeinputMoveSpeedInc = 23,
271 ecgeinputMoveSpeedDec = 24,
272 ecgeinputJump = 25,
273 ecgeinputCrouch = 26,
274 // for examine navigation
275 ecgeinputExRotate = 31,
276 ecgeinputExMove = 32,
277 ecgeinputExZoom = 33,
278 };
279
280 typedef int (CDECL *TCgeLibraryCallback)(int /*ECgeLibCallbackCode*/eCode, int iParam1, int iParam2, const char *szParam);
281
282
283 //-----------------------------------------------------------------------------
284 extern void CGE_LoadLibrary(void); // function defined in the loader CPP file
285
286 //-----------------------------------------------------------------------------
287
288 // Initialize the library, this function must be called first (required).
289 // Then CGEApp_Open and CGEApp_Close may be called multiple times.
290 extern void CGE_Initialize(const char *applicationConfigDirectory);
291 extern void CGE_Finalize(void);
292
293 extern void CGE_Open(unsigned uiFlags, unsigned initialWidth, unsigned initialHeight, unsigned uiDpi);
294 extern void CGE_Close(bool quitWhenLastWindowClosed);
295 extern void CGE_GetOpenGLInformation(char *szBuffer, int nBufSize); // szBuffer is filled inside the function with max size of nBufSize
296 extern void CGE_SetUserInterface(bool bAutomaticTouchInterface); // should be called at the start of the program. Touch interface controls will be updated automatically then.
297
298 extern void CGE_Resize(unsigned uiViewWidth, unsigned uiViewHeight); // let the library know about the viewport size changes
299 extern void CGE_Render(void); // paints the 3d scene into the context
300 extern void CGE_SaveScreenshotToFile(const char *szFile);
301 extern void CGE_SetLibraryCallbackProc(TCgeLibraryCallback pProc); // set callback function
302 extern void CGE_Update(void); // let the 3d engine perform the animations, etc
303
304 extern void CGE_MouseDown(int x, int y, bool bLeftBtn, int nFingerIdx); // [0,0] is the bottom-left corner!
305 extern void CGE_Motion(int x, int y, int nFingerIdx);
306 extern void CGE_MouseUp(int x, int y, bool bLeftBtn, int nFingerIdx, bool trackReleased);
307 extern void CGE_MouseWheel(float zDelta, bool bVertical);
308
309 extern void CGE_KeyDown(int /*ECgeKey*/ eKey);
310 extern void CGE_KeyUp(int /*ECgeKey*/ eKey);
311
312 extern void CGE_LoadSceneFromFile(const char *szFile); // name od the file has to be utf-8 encoded
313 extern void CGE_SaveSceneToFile(const char *szFile);
314
315 extern int CGE_GetViewpointsCount(void);
316 extern void CGE_GetViewpointName(int iViewpointIdx, char *szName, int nBufSize); // szName is buffer of size nBufSize, and is filled with utf-8 encoded string
317 extern void CGE_MoveToViewpoint(int iViewpointIdx, bool bAnimated);
318 extern void CGE_AddViewpointFromCurrentView(const char *szName);
319
320 extern void CGE_GetBoundingBox(float *pfXMin, float *pfXMax, float *pfYMin, float *pfYMax, float *pfZMin, float *pfZMax);
321 extern void CGE_GetViewCoords(float *pfPosX, float *pfPosY, float *pfPosZ, float *pfDirX, float *pfDirY, float *pfDirZ,
322 float *pfUpX, float *pfUpY, float *pfUpZ, float *pfGravX, float *pfGravY, float *pfGravZ);
323 extern void CGE_MoveViewToCoords(float fPosX, float fPosY, float fPosZ, float fDirX, float fDirY, float fDirZ,
324 float fUpX, float fUpY, float fUpZ, float fGravX, float fGravY, float fGravZ, bool bAnimated);
325
326 extern void CGE_SetNavigationInputShortcut(int /*ECgeNavigationInput*/ eInput,
327 int /*ECgeKey*/ eKey1, int /*ECgeKey*/ eKey2 /* = kcge_None */,
328 int /*ECgeMouseButton*/ eMouseButton /* = ecgemouseButtonNone */,
329 int /*ECgeMouseWheelDirection*/ eMouseWheel /* = ecgemouseWheelNone */); // set input controls for camera; parameters correspond to TInputShortcut.Assign
330
331 extern int CGE_GetNavigationType(void);
332 extern void CGE_SetNavigationType(int /*ECgeNavigationType*/ eNewType);
333
334 extern void CGE_SetTouchInterface(int /*ECgeTouchCtlInterface*/ eMode);
335
336 extern void CGE_SetVariableInt(int /*ECgeVariable*/ eVar, int nValue);
337 extern int CGE_GetVariableInt(int /*ECgeVariable*/ eVar);
338
339 extern void CGE_SetNodeFieldValue(const char *szNodeName, const char *szFieldName,
340 float fVal1, float fVal2, float fVal3, float fVal4);
341
342 extern void CGE_IncreaseSceneTime(float fTimeS); // set time in the scene, useful when viewport paused
343
344 #ifdef __cplusplus
345 }
346 #endif
347
348 #endif //CGE_LIBRARY_INCLUDED