diff --git a/.gitattributes b/.gitattributes
index 64fe8bac..703035e0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,5 @@
src/OpenCL/** linguist-vendored
+src/X11/** linguist-vendored
src/lodepng.* linguist-vendored
src/kernel.cpp linguist-language=OpenCL
src/setup.cpp linguist-documentation
\ No newline at end of file
diff --git a/README.md b/README.md
index ebecde28..5d5eceb4 100644
--- a/README.md
+++ b/README.md
@@ -94,7 +94,7 @@ Q = Σαβ Παβαβ ΠαβP key to start/pause the simulation.
+3. When done with the setup, hit compile+run on Windows in Visual Studio Community or execute `./make.sh` on Linux; this will automatically select the fastest installed GPU. Alternatively, you can add the device ID as the first command-line argument, for example `./make.sh 2` to compile+run on device 2, or `bin/FluidX3D.exe 2` to run the executable on device 2. Compile time for the entire code is about 10 seconds. If you use `INTERACTIVE_GRAPHICS` on Linux, change to the "compile on Linux with X11" command in `make.sh`.
+4. With `INTERACTIVE_GRAPHICS`/`INTERACTIVE_GRAPHICS_ASCII` enabled, press the P key to start/pause the simulation.
Toggle rendering modes with the keyboard:
- 1: flags (and force vectors on solid boundary nodes if the extension is used)
@@ -173,6 +173,7 @@ In consequence, the arithmetic intensity of this implementation is 2.13 (FP32/FP
| :---------------------------- | -----------------: | ----------: | -----------: | ---------------------: | ----------------------: | ----------------------: |
| AMD Instinct MI250 (1 GCD) | 45.26 | 64 | 1638 | 5638 (53%) | 9030 (42%) | 8506 (40%) |
| AMD Radeon VII | 13.83 | 16 | 1024 | 4898 (73%) | 7778 (58%) | 5256 (40%) |
+| Nvidia H100 PCIe 80GB | 51.01 | 80 | 2000 | 11128 (85%) | 20624 (79%) | 13862 (53%) |
| Nvidia A100 SXM4 80GB | 19.49 | 80 | 2039 | 10228 (77%) | 18448 (70%) | 11197 (42%) |
| Nvidia A100 SXM4 40GB | 19.49 | 40 | 1555 | 8522 (84%) | 16013 (79%) | 11251 (56%) |
| Nvidia A100 PCIe 40GB | 19.49 | 40 | 1555 | 8526 (84%) | 16035 (79%) | 11088 (55%) |
@@ -188,15 +189,20 @@ In consequence, the arithmetic intensity of this implementation is 2.13 (FP32/FP
| AMD Radeon RX Vega 64 | 13.35 | 8 | 484 | 1875 (59%) | 2878 (46%) | 3227 (51%) |
| AMD Radeon RX 580 4GB | 6.50 | 4 | 256 | 946 (57%) | 1848 (56%) | 1577 (47%) |
| AMD Radeon HD 7850 | 1.84 | 2 | 154 | 112 (11%) | 120 ( 6%) | 635 (32%) |
+| Intel Arc A770 LE | 19.66 | 16 | 560 | 2741 (75%) | 4591 (63%) | 4626 (64%) |
+| Intel Arc A750 LE | 17.20 | 8 | 512 | 2625 (78%) | 4184 (63%) | 4238 (64%) |
+| Nvidia GeForce RTX 4090 | 82.58 | 24 | 1008 | 5624 (85%) | 11091 (85%) | 11496 (88%) |
| Nvidia GeForce RTX 3090 Ti | 40.00 | 24 | 1008 | 5717 (87%) | 10956 (84%) | 10400 (79%) |
| Nvidia GeForce RTX 3090 | 39.05 | 24 | 936 | 5418 (89%) | 10732 (88%) | 10215 (84%) |
| Nvidia GeForce RTX 3080 Ti | 37.17 | 12 | 912 | 5202 (87%) | 9832 (87%) | 9347 (79%) |
| Nvidia GeForce RTX 3080 | 29.77 | 10 | 760 | 4230 (85%) | 8118 (82%) | 7714 (78%) |
| Nvidia GeForce RTX 3070 | 20.31 | 8 | 448 | 2578 (88%) | 5096 (88%) | 5060 (87%) |
| Nvidia GeForce RTX 3060 Ti | 16.49 | 8 | 448 | 2644 (90%) | 5129 (88%) | 4718 (81%) |
+| Nvidia RTX A5000M | 16.59 | 16 | 448 | 2228 (76%) | 4461 (77%) | 3662 (63%) |
| Nvidia GeForce RTX 3060 | 13.17 | 12 | 360 | 2108 (90%) | 4070 (87%) | 3566 (76%) |
| Nvidia GeForce RTX 3060M | 10.94 | 6 | 336 | 2019 (92%) | 4012 (92%) | 3572 (82%) |
| Nvidia GeForce RTX 3050M | 7.13 | 4 | 192 | 1180 (94%) | 2339 (94%) | 2016 (81%) |
+| Nvidia Quadro RTX 6000 | 16.31 | 24 | 672 | 3307 (75%) | 6836 (78%) | 6879 (79%) |
| Nvidia Quadro RTX 8000 Pass. | 14.93 | 48 | 624 | 2591 (64%) | 5408 (67%) | 5607 (69%) |
| Nvidia GeForce RTX 2080 Ti | 13.45 | 11 | 616 | 3194 (79%) | 6700 (84%) | 6853 (86%) |
| Nvidia GeForce RTX 2080 Sup. | 11.34 | 8 | 496 | 2434 (75%) | 5284 (82%) | 5087 (79%) |
@@ -229,6 +235,7 @@ In consequence, the arithmetic intensity of this implementation is 2.13 (FP32/FP
| Intel HD Graphics 5500 | 0.35 | 3 | 26 | 75 (45%) | 192 (58%) | 108 (32%) |
| Intel HD Graphics 4600 | 0.38 | 2 | 26 | 105 (63%) | 115 (35%) | 34 (10%) |
| Samsung ARM Mali-G72 MP18 | 0.24 | 4 | 29 | 14 ( 7%) | 17 ( 5%) | 12 ( 3%) |
+| 2x AMD EPYC 9654 | 29.49 | 1536 | 922 | 1381 (23%) | 1814 (15%) | 1801 (15%) |
| Intel Xeon Phi 7210 | 5.32 | 192 | 102 | 415 (62%) | 193 (15%) | 223 (17%) |
| 4x Intel Xeon E5-4620 v4 | 2.69 | 512 | 273 | 460 (26%) | 275 ( 8%) | 239 ( 7%) |
| 2x Intel Xeon E5-2630 v4 | 1.41 | 64 | 137 | 264 (30%) | 146 ( 8%) | 129 ( 7%) |
@@ -330,6 +337,8 @@ In consequence, the arithmetic intensity of this implementation is 2.13 (FP32/FP
## External Code/Libraries/Images used in FluidX3D
- [OpenCL-Headers](https://github.com/KhronosGroup/OpenCL-Headers) for GPU parallelization ([Khronos Group](https://www.khronos.org/opencl/))
+- [Win32 API](https://learn.microsoft.com/en-us/windows/win32/api/winbase/) for interactive graphics in Windows ([Microsoft](https://www.microsoft.com/))
+- [X11/Xlib](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) for interactive graphics in Linux ([The Open Group](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html))
- [marching-cubes tables](http://paulbourke.net/geometry/polygonise/) for isosurface generation on GPU ([Paul Bourke](http://paulbourke.net/geometry/))
- [`src/lodepng.cpp`](https://github.com/lvandeve/lodepng/blob/master/lodepng.cpp) and [`src/lodepng.hpp`](https://github.com/lvandeve/lodepng/blob/master/lodepng.h) for `.png` encoding and decoding ([Lode Vandevenne](https://lodev.org/))
- [SimplexNoise](https://weber.itn.liu.se/~stegu/simplexnoise/SimplexNoise.java) class in [`src/utilities.hpp`](https://github.com/ProjectPhysX/FluidX3D/blob/master/src/utilities.hpp) for generating continuous noise in 2D/3D/4D space ([Stefan Gustavson](https://github.com/stegu))
diff --git a/make.sh b/make.sh
index 6b264b50..b5d93558 100644
--- a/make.sh
+++ b/make.sh
@@ -1,7 +1,12 @@
# command line argument $1: device ID; if empty, FluidX3D will automatically choose the fastest available device
+
mkdir -p bin # create directory for executable
rm -f ./bin/FluidX3D.exe # prevent execution of old version if compiling fails
-g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL # compile on Linux
-#g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -framework OpenCL # compile on macOS
-#g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -L/system/vendor/lib64 -lOpenCL # compile on Android
+
+#g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL -I./src/X11/include -L./src/X11/lib -lX11 # compile on Linux with X11
+
+g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -L./src/OpenCL/lib -lOpenCL # compile on Linux (without X11)
+#g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -framework OpenCL # compile on macOS (without X11)
+#g++ ./src/*.cpp -o ./bin/FluidX3D.exe -std=c++17 -pthread -I./src/OpenCL/include -L/system/vendor/lib64 -lOpenCL # compile on Android (without X11)
+
./bin/FluidX3D.exe $1 # run FluidX3D
diff --git a/src/X11/include/X11/X.h b/src/X11/include/X11/X.h
new file mode 100644
index 00000000..4df7d22e
--- /dev/null
+++ b/src/X11/include/X11/X.h
@@ -0,0 +1,717 @@
+/* Definitions for the X window system likely to be used by applications */
+
+#ifndef X_H
+#define X_H
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+#define X_PROTOCOL 11 /* current protocol version */
+#define X_PROTOCOL_REVISION 0 /* current minor version */
+
+/* Resources */
+
+/*
+ * _XSERVER64 must ONLY be defined when compiling X server sources on
+ * systems where unsigned long is not 32 bits, must NOT be used in
+ * client or library code.
+ */
+#ifndef _XSERVER64
+# ifndef _XTYPEDEF_XID
+# define _XTYPEDEF_XID
+typedef unsigned long XID;
+# endif
+# ifndef _XTYPEDEF_MASK
+# define _XTYPEDEF_MASK
+typedef unsigned long Mask;
+# endif
+# ifndef _XTYPEDEF_ATOM
+# define _XTYPEDEF_ATOM
+typedef unsigned long Atom; /* Also in Xdefs.h */
+# endif
+typedef unsigned long VisualID;
+typedef unsigned long Time;
+#else
+# include
+# ifndef _XTYPEDEF_XID
+# define _XTYPEDEF_XID
+typedef CARD32 XID;
+# endif
+# ifndef _XTYPEDEF_MASK
+# define _XTYPEDEF_MASK
+typedef CARD32 Mask;
+# endif
+# ifndef _XTYPEDEF_ATOM
+# define _XTYPEDEF_ATOM
+typedef CARD32 Atom;
+# endif
+typedef CARD32 VisualID;
+typedef CARD32 Time;
+#endif
+
+typedef XID Window;
+typedef XID Drawable;
+#ifndef _XTYPEDEF_FONT
+# define _XTYPEDEF_FONT
+typedef XID Font;
+#endif
+typedef XID Pixmap;
+typedef XID Cursor;
+typedef XID Colormap;
+typedef XID GContext;
+typedef XID KeySym;
+
+typedef unsigned char KeyCode;
+
+/*****************************************************************
+ * RESERVED RESOURCE AND CONSTANT DEFINITIONS
+ *****************************************************************/
+
+#ifndef None
+#define None 0L /* universal null resource or null atom */
+#endif
+
+#define ParentRelative 1L /* background pixmap in CreateWindow
+ and ChangeWindowAttributes */
+
+#define CopyFromParent 0L /* border pixmap in CreateWindow
+ and ChangeWindowAttributes
+ special VisualID and special window
+ class passed to CreateWindow */
+
+#define PointerWindow 0L /* destination window in SendEvent */
+#define InputFocus 1L /* destination window in SendEvent */
+
+#define PointerRoot 1L /* focus window in SetInputFocus */
+
+#define AnyPropertyType 0L /* special Atom, passed to GetProperty */
+
+#define AnyKey 0L /* special Key Code, passed to GrabKey */
+
+#define AnyButton 0L /* special Button Code, passed to GrabButton */
+
+#define AllTemporary 0L /* special Resource ID passed to KillClient */
+
+#define CurrentTime 0L /* special Time */
+
+#define NoSymbol 0L /* special KeySym */
+
+/*****************************************************************
+ * EVENT DEFINITIONS
+ *****************************************************************/
+
+/* Input Event Masks. Used as event-mask window attribute and as arguments
+ to Grab requests. Not to be confused with event names. */
+
+#define NoEventMask 0L
+#define KeyPressMask (1L<<0)
+#define KeyReleaseMask (1L<<1)
+#define ButtonPressMask (1L<<2)
+#define ButtonReleaseMask (1L<<3)
+#define EnterWindowMask (1L<<4)
+#define LeaveWindowMask (1L<<5)
+#define PointerMotionMask (1L<<6)
+#define PointerMotionHintMask (1L<<7)
+#define Button1MotionMask (1L<<8)
+#define Button2MotionMask (1L<<9)
+#define Button3MotionMask (1L<<10)
+#define Button4MotionMask (1L<<11)
+#define Button5MotionMask (1L<<12)
+#define ButtonMotionMask (1L<<13)
+#define KeymapStateMask (1L<<14)
+#define ExposureMask (1L<<15)
+#define VisibilityChangeMask (1L<<16)
+#define StructureNotifyMask (1L<<17)
+#define ResizeRedirectMask (1L<<18)
+#define SubstructureNotifyMask (1L<<19)
+#define SubstructureRedirectMask (1L<<20)
+#define FocusChangeMask (1L<<21)
+#define PropertyChangeMask (1L<<22)
+#define ColormapChangeMask (1L<<23)
+#define OwnerGrabButtonMask (1L<<24)
+
+/* Event names. Used in "type" field in XEvent structures. Not to be
+confused with event masks above. They start from 2 because 0 and 1
+are reserved in the protocol for errors and replies. */
+
+#define KeyPress 2
+#define KeyRelease 3
+#define ButtonPress 4
+#define ButtonRelease 5
+#define MotionNotify 6
+#define EnterNotify 7
+#define LeaveNotify 8
+#define FocusIn 9
+#define FocusOut 10
+#define KeymapNotify 11
+#define Expose 12
+#define GraphicsExpose 13
+#define NoExpose 14
+#define VisibilityNotify 15
+#define CreateNotify 16
+#define DestroyNotify 17
+#define UnmapNotify 18
+#define MapNotify 19
+#define MapRequest 20
+#define ReparentNotify 21
+#define ConfigureNotify 22
+#define ConfigureRequest 23
+#define GravityNotify 24
+#define ResizeRequest 25
+#define CirculateNotify 26
+#define CirculateRequest 27
+#define PropertyNotify 28
+#define SelectionClear 29
+#define SelectionRequest 30
+#define SelectionNotify 31
+#define ColormapNotify 32
+#define ClientMessage 33
+#define MappingNotify 34
+#define GenericEvent 35
+#define LASTEvent 36 /* must be bigger than any event # */
+
+
+/* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
+ state in various key-, mouse-, and button-related events. */
+
+#define ShiftMask (1<<0)
+#define LockMask (1<<1)
+#define ControlMask (1<<2)
+#define Mod1Mask (1<<3)
+#define Mod2Mask (1<<4)
+#define Mod3Mask (1<<5)
+#define Mod4Mask (1<<6)
+#define Mod5Mask (1<<7)
+
+/* modifier names. Used to build a SetModifierMapping request or
+ to read a GetModifierMapping request. These correspond to the
+ masks defined above. */
+#define ShiftMapIndex 0
+#define LockMapIndex 1
+#define ControlMapIndex 2
+#define Mod1MapIndex 3
+#define Mod2MapIndex 4
+#define Mod3MapIndex 5
+#define Mod4MapIndex 6
+#define Mod5MapIndex 7
+
+
+/* button masks. Used in same manner as Key masks above. Not to be confused
+ with button names below. */
+
+#define Button1Mask (1<<8)
+#define Button2Mask (1<<9)
+#define Button3Mask (1<<10)
+#define Button4Mask (1<<11)
+#define Button5Mask (1<<12)
+
+#define AnyModifier (1<<15) /* used in GrabButton, GrabKey */
+
+
+/* button names. Used as arguments to GrabButton and as detail in ButtonPress
+ and ButtonRelease events. Not to be confused with button masks above.
+ Note that 0 is already defined above as "AnyButton". */
+
+#define Button1 1
+#define Button2 2
+#define Button3 3
+#define Button4 4
+#define Button5 5
+
+/* Notify modes */
+
+#define NotifyNormal 0
+#define NotifyGrab 1
+#define NotifyUngrab 2
+#define NotifyWhileGrabbed 3
+
+#define NotifyHint 1 /* for MotionNotify events */
+
+/* Notify detail */
+
+#define NotifyAncestor 0
+#define NotifyVirtual 1
+#define NotifyInferior 2
+#define NotifyNonlinear 3
+#define NotifyNonlinearVirtual 4
+#define NotifyPointer 5
+#define NotifyPointerRoot 6
+#define NotifyDetailNone 7
+
+/* Visibility notify */
+
+#define VisibilityUnobscured 0
+#define VisibilityPartiallyObscured 1
+#define VisibilityFullyObscured 2
+
+/* Circulation request */
+
+#define PlaceOnTop 0
+#define PlaceOnBottom 1
+
+/* protocol families */
+
+#define FamilyInternet 0 /* IPv4 */
+#define FamilyDECnet 1
+#define FamilyChaos 2
+#define FamilyInternet6 6 /* IPv6 */
+
+/* authentication families not tied to a specific protocol */
+#define FamilyServerInterpreted 5
+
+/* Property notification */
+
+#define PropertyNewValue 0
+#define PropertyDelete 1
+
+/* Color Map notification */
+
+#define ColormapUninstalled 0
+#define ColormapInstalled 1
+
+/* GrabPointer, GrabButton, GrabKeyboard, GrabKey Modes */
+
+#define GrabModeSync 0
+#define GrabModeAsync 1
+
+/* GrabPointer, GrabKeyboard reply status */
+
+#define GrabSuccess 0
+#define AlreadyGrabbed 1
+#define GrabInvalidTime 2
+#define GrabNotViewable 3
+#define GrabFrozen 4
+
+/* AllowEvents modes */
+
+#define AsyncPointer 0
+#define SyncPointer 1
+#define ReplayPointer 2
+#define AsyncKeyboard 3
+#define SyncKeyboard 4
+#define ReplayKeyboard 5
+#define AsyncBoth 6
+#define SyncBoth 7
+
+/* Used in SetInputFocus, GetInputFocus */
+
+#define RevertToNone (int)None
+#define RevertToPointerRoot (int)PointerRoot
+#define RevertToParent 2
+
+/*****************************************************************
+ * ERROR CODES
+ *****************************************************************/
+
+#define Success 0 /* everything's okay */
+#define BadRequest 1 /* bad request code */
+#define BadValue 2 /* int parameter out of range */
+#define BadWindow 3 /* parameter not a Window */
+#define BadPixmap 4 /* parameter not a Pixmap */
+#define BadAtom 5 /* parameter not an Atom */
+#define BadCursor 6 /* parameter not a Cursor */
+#define BadFont 7 /* parameter not a Font */
+#define BadMatch 8 /* parameter mismatch */
+#define BadDrawable 9 /* parameter not a Pixmap or Window */
+#define BadAccess 10 /* depending on context:
+ - key/button already grabbed
+ - attempt to free an illegal
+ cmap entry
+ - attempt to store into a read-only
+ color map entry.
+ - attempt to modify the access control
+ list from other than the local host.
+ */
+#define BadAlloc 11 /* insufficient resources */
+#define BadColor 12 /* no such colormap */
+#define BadGC 13 /* parameter not a GC */
+#define BadIDChoice 14 /* choice not in range or already used */
+#define BadName 15 /* font or color name doesn't exist */
+#define BadLength 16 /* Request length incorrect */
+#define BadImplementation 17 /* server is defective */
+
+#define FirstExtensionError 128
+#define LastExtensionError 255
+
+/*****************************************************************
+ * WINDOW DEFINITIONS
+ *****************************************************************/
+
+/* Window classes used by CreateWindow */
+/* Note that CopyFromParent is already defined as 0 above */
+
+#define InputOutput 1
+#define InputOnly 2
+
+/* Window attributes for CreateWindow and ChangeWindowAttributes */
+
+#define CWBackPixmap (1L<<0)
+#define CWBackPixel (1L<<1)
+#define CWBorderPixmap (1L<<2)
+#define CWBorderPixel (1L<<3)
+#define CWBitGravity (1L<<4)
+#define CWWinGravity (1L<<5)
+#define CWBackingStore (1L<<6)
+#define CWBackingPlanes (1L<<7)
+#define CWBackingPixel (1L<<8)
+#define CWOverrideRedirect (1L<<9)
+#define CWSaveUnder (1L<<10)
+#define CWEventMask (1L<<11)
+#define CWDontPropagate (1L<<12)
+#define CWColormap (1L<<13)
+#define CWCursor (1L<<14)
+
+/* ConfigureWindow structure */
+
+#define CWX (1<<0)
+#define CWY (1<<1)
+#define CWWidth (1<<2)
+#define CWHeight (1<<3)
+#define CWBorderWidth (1<<4)
+#define CWSibling (1<<5)
+#define CWStackMode (1<<6)
+
+
+/* Bit Gravity */
+
+#define ForgetGravity 0
+#define NorthWestGravity 1
+#define NorthGravity 2
+#define NorthEastGravity 3
+#define WestGravity 4
+#define CenterGravity 5
+#define EastGravity 6
+#define SouthWestGravity 7
+#define SouthGravity 8
+#define SouthEastGravity 9
+#define StaticGravity 10
+
+/* Window gravity + bit gravity above */
+
+#define UnmapGravity 0
+
+/* Used in CreateWindow for backing-store hint */
+
+#define NotUseful 0
+#define WhenMapped 1
+#define Always 2
+
+/* Used in GetWindowAttributes reply */
+
+#define IsUnmapped 0
+#define IsUnviewable 1
+#define IsViewable 2
+
+/* Used in ChangeSaveSet */
+
+#define SetModeInsert 0
+#define SetModeDelete 1
+
+/* Used in ChangeCloseDownMode */
+
+#define DestroyAll 0
+#define RetainPermanent 1
+#define RetainTemporary 2
+
+/* Window stacking method (in configureWindow) */
+
+#define Above 0
+#define Below 1
+#define TopIf 2
+#define BottomIf 3
+#define Opposite 4
+
+/* Circulation direction */
+
+#define RaiseLowest 0
+#define LowerHighest 1
+
+/* Property modes */
+
+#define PropModeReplace 0
+#define PropModePrepend 1
+#define PropModeAppend 2
+
+/*****************************************************************
+ * GRAPHICS DEFINITIONS
+ *****************************************************************/
+
+/* graphics functions, as in GC.alu */
+
+#define GXclear 0x0 /* 0 */
+#define GXand 0x1 /* src AND dst */
+#define GXandReverse 0x2 /* src AND NOT dst */
+#define GXcopy 0x3 /* src */
+#define GXandInverted 0x4 /* NOT src AND dst */
+#define GXnoop 0x5 /* dst */
+#define GXxor 0x6 /* src XOR dst */
+#define GXor 0x7 /* src OR dst */
+#define GXnor 0x8 /* NOT src AND NOT dst */
+#define GXequiv 0x9 /* NOT src XOR dst */
+#define GXinvert 0xa /* NOT dst */
+#define GXorReverse 0xb /* src OR NOT dst */
+#define GXcopyInverted 0xc /* NOT src */
+#define GXorInverted 0xd /* NOT src OR dst */
+#define GXnand 0xe /* NOT src OR NOT dst */
+#define GXset 0xf /* 1 */
+
+/* LineStyle */
+
+#define LineSolid 0
+#define LineOnOffDash 1
+#define LineDoubleDash 2
+
+/* capStyle */
+
+#define CapNotLast 0
+#define CapButt 1
+#define CapRound 2
+#define CapProjecting 3
+
+/* joinStyle */
+
+#define JoinMiter 0
+#define JoinRound 1
+#define JoinBevel 2
+
+/* fillStyle */
+
+#define FillSolid 0
+#define FillTiled 1
+#define FillStippled 2
+#define FillOpaqueStippled 3
+
+/* fillRule */
+
+#define EvenOddRule 0
+#define WindingRule 1
+
+/* subwindow mode */
+
+#define ClipByChildren 0
+#define IncludeInferiors 1
+
+/* SetClipRectangles ordering */
+
+#define Unsorted 0
+#define YSorted 1
+#define YXSorted 2
+#define YXBanded 3
+
+/* CoordinateMode for drawing routines */
+
+#define CoordModeOrigin 0 /* relative to the origin */
+#define CoordModePrevious 1 /* relative to previous point */
+
+/* Polygon shapes */
+
+#define Complex 0 /* paths may intersect */
+#define Nonconvex 1 /* no paths intersect, but not convex */
+#define Convex 2 /* wholly convex */
+
+/* Arc modes for PolyFillArc */
+
+#define ArcChord 0 /* join endpoints of arc */
+#define ArcPieSlice 1 /* join endpoints to center of arc */
+
+/* GC components: masks used in CreateGC, CopyGC, ChangeGC, OR'ed into
+ GC.stateChanges */
+
+#define GCFunction (1L<<0)
+#define GCPlaneMask (1L<<1)
+#define GCForeground (1L<<2)
+#define GCBackground (1L<<3)
+#define GCLineWidth (1L<<4)
+#define GCLineStyle (1L<<5)
+#define GCCapStyle (1L<<6)
+#define GCJoinStyle (1L<<7)
+#define GCFillStyle (1L<<8)
+#define GCFillRule (1L<<9)
+#define GCTile (1L<<10)
+#define GCStipple (1L<<11)
+#define GCTileStipXOrigin (1L<<12)
+#define GCTileStipYOrigin (1L<<13)
+#define GCFont (1L<<14)
+#define GCSubwindowMode (1L<<15)
+#define GCGraphicsExposures (1L<<16)
+#define GCClipXOrigin (1L<<17)
+#define GCClipYOrigin (1L<<18)
+#define GCClipMask (1L<<19)
+#define GCDashOffset (1L<<20)
+#define GCDashList (1L<<21)
+#define GCArcMode (1L<<22)
+
+#define GCLastBit 22
+/*****************************************************************
+ * FONTS
+ *****************************************************************/
+
+/* used in QueryFont -- draw direction */
+
+#define FontLeftToRight 0
+#define FontRightToLeft 1
+
+#define FontChange 255
+
+/*****************************************************************
+ * IMAGING
+ *****************************************************************/
+
+/* ImageFormat -- PutImage, GetImage */
+
+#define XYBitmap 0 /* depth 1, XYFormat */
+#define XYPixmap 1 /* depth == drawable depth */
+#define ZPixmap 2 /* depth == drawable depth */
+
+/*****************************************************************
+ * COLOR MAP STUFF
+ *****************************************************************/
+
+/* For CreateColormap */
+
+#define AllocNone 0 /* create map with no entries */
+#define AllocAll 1 /* allocate entire map writeable */
+
+
+/* Flags used in StoreNamedColor, StoreColors */
+
+#define DoRed (1<<0)
+#define DoGreen (1<<1)
+#define DoBlue (1<<2)
+
+/*****************************************************************
+ * CURSOR STUFF
+ *****************************************************************/
+
+/* QueryBestSize Class */
+
+#define CursorShape 0 /* largest size that can be displayed */
+#define TileShape 1 /* size tiled fastest */
+#define StippleShape 2 /* size stippled fastest */
+
+/*****************************************************************
+ * KEYBOARD/POINTER STUFF
+ *****************************************************************/
+
+#define AutoRepeatModeOff 0
+#define AutoRepeatModeOn 1
+#define AutoRepeatModeDefault 2
+
+#define LedModeOff 0
+#define LedModeOn 1
+
+/* masks for ChangeKeyboardControl */
+
+#define KBKeyClickPercent (1L<<0)
+#define KBBellPercent (1L<<1)
+#define KBBellPitch (1L<<2)
+#define KBBellDuration (1L<<3)
+#define KBLed (1L<<4)
+#define KBLedMode (1L<<5)
+#define KBKey (1L<<6)
+#define KBAutoRepeatMode (1L<<7)
+
+#define MappingSuccess 0
+#define MappingBusy 1
+#define MappingFailed 2
+
+#define MappingModifier 0
+#define MappingKeyboard 1
+#define MappingPointer 2
+
+/*****************************************************************
+ * SCREEN SAVER STUFF
+ *****************************************************************/
+
+#define DontPreferBlanking 0
+#define PreferBlanking 1
+#define DefaultBlanking 2
+
+#define DisableScreenSaver 0
+#define DisableScreenInterval 0
+
+#define DontAllowExposures 0
+#define AllowExposures 1
+#define DefaultExposures 2
+
+/* for ForceScreenSaver */
+
+#define ScreenSaverReset 0
+#define ScreenSaverActive 1
+
+/*****************************************************************
+ * HOSTS AND CONNECTIONS
+ *****************************************************************/
+
+/* for ChangeHosts */
+
+#define HostInsert 0
+#define HostDelete 1
+
+/* for ChangeAccessControl */
+
+#define EnableAccess 1
+#define DisableAccess 0
+
+/* Display classes used in opening the connection
+ * Note that the statically allocated ones are even numbered and the
+ * dynamically changeable ones are odd numbered */
+
+#define StaticGray 0
+#define GrayScale 1
+#define StaticColor 2
+#define PseudoColor 3
+#define TrueColor 4
+#define DirectColor 5
+
+
+/* Byte order used in imageByteOrder and bitmapBitOrder */
+
+#define LSBFirst 0
+#define MSBFirst 1
+
+#endif /* X_H */
diff --git a/src/X11/include/X11/Xfuncproto.h b/src/X11/include/X11/Xfuncproto.h
new file mode 100644
index 00000000..89bc96fd
--- /dev/null
+++ b/src/X11/include/X11/Xfuncproto.h
@@ -0,0 +1,221 @@
+/*
+ *
+Copyright 1989, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ *
+ */
+
+/* Definitions to make function prototypes manageable */
+
+#ifndef _XFUNCPROTO_H_
+#define _XFUNCPROTO_H_
+
+#ifndef NeedFunctionPrototypes
+#define NeedFunctionPrototypes 1
+#endif /* NeedFunctionPrototypes */
+
+#ifndef NeedVarargsPrototypes
+#define NeedVarargsPrototypes 1
+#endif /* NeedVarargsPrototypes */
+
+#if NeedFunctionPrototypes
+
+#ifndef NeedNestedPrototypes
+#define NeedNestedPrototypes 1
+#endif /* NeedNestedPrototypes */
+
+#ifndef _Xconst
+#define _Xconst const
+#endif /* _Xconst */
+
+/* Function prototype configuration (see configure for more info) */
+#if !defined(NARROWPROTO) && \
+ (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
+#define NARROWPROTO
+#endif
+#ifndef FUNCPROTO
+#define FUNCPROTO 15
+#endif
+
+#ifndef NeedWidePrototypes
+#ifdef NARROWPROTO
+#define NeedWidePrototypes 0
+#else
+#define NeedWidePrototypes 1 /* default to make interropt. easier */
+#endif
+#endif /* NeedWidePrototypes */
+
+#endif /* NeedFunctionPrototypes */
+
+#ifndef _XFUNCPROTOBEGIN
+#if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */
+#define _XFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
+#define _XFUNCPROTOEND }
+#else
+#define _XFUNCPROTOBEGIN
+#define _XFUNCPROTOEND
+#endif
+#endif /* _XFUNCPROTOBEGIN */
+
+/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */
+#ifndef __has_attribute
+# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+#ifndef __has_feature
+# define __has_feature(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+#ifndef __has_extension
+# define __has_extension(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))
+# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))
+#else
+# define _X_SENTINEL(x)
+#endif /* GNUC >= 4 */
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \
+ && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define _X_EXPORT __attribute__((visibility("default")))
+# define _X_HIDDEN __attribute__((visibility("hidden")))
+# define _X_INTERNAL __attribute__((visibility("internal")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define _X_EXPORT __global
+# define _X_HIDDEN __hidden
+# define _X_INTERNAL __hidden
+#else /* not gcc >= 4 and not Sun Studio >= 8 */
+# define _X_EXPORT
+# define _X_HIDDEN
+# define _X_INTERNAL
+#endif /* GNUC >= 4 */
+
+/* Branch prediction hints for individual conditionals */
+/* requires xproto >= 7.0.9 */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+# define _X_LIKELY(x) __builtin_expect(!!(x), 1)
+# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)
+#else /* not gcc >= 3.3 */
+# define _X_LIKELY(x) (x)
+# define _X_UNLIKELY(x) (x)
+#endif
+
+/* Bulk branch prediction hints via marking error path functions as "cold" */
+/* requires xproto >= 7.0.25 */
+#if __has_attribute(__cold__) || \
+ (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */
+# define _X_COLD __attribute__((__cold__))
+#else
+# define _X_COLD /* nothing */
+#endif
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if __has_attribute(deprecated) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130))
+# define _X_DEPRECATED __attribute__((deprecated))
+#else /* not gcc >= 3.1 */
+# define _X_DEPRECATED
+#endif
+
+/* requires xproto >= 7.0.30 */
+#if __has_extension(attribute_deprecated_with_message) || \
+ (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
+# define _X_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg)))
+#else
+# define _X_DEPRECATED_MSG(_msg) _X_DEPRECATED
+#endif
+
+/* requires xproto >= 7.0.17 */
+#if __has_attribute(noreturn) \
+ || (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+# define _X_NORETURN __attribute((noreturn))
+#else
+# define _X_NORETURN
+#endif /* GNUC */
+
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if __has_attribute(__format__) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
+#else /* not gcc >= 2.3 */
+# define _X_ATTRIBUTE_PRINTF(x,y)
+#endif
+
+/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable
+ argument macros, must be only used inside #ifdef _X_NONNULL guards, as
+ many legacy X clients are compiled in C89 mode still. */
+#if __has_attribute(nonnull) \
+ && defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
+#define _X_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
+#elif __has_attribute(nonnull) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
+#define _X_NONNULL(args...) __attribute__((nonnull(args)))
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */
+#define _X_NONNULL(...) /* */
+#endif
+
+/* requires xproto >= 7.0.22 */
+#if __has_attribute(__unused__) \
+ || defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)
+#define _X_UNUSED __attribute__((__unused__))
+#else
+#define _X_UNUSED /* */
+#endif
+
+/* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */
+/* requires xproto >= 7.0.9
+ (introduced in 7.0.8 but didn't support all compilers until 7.0.9) */
+#if defined(inline) /* assume autoconf set it correctly */ || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \
+ (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))
+# define _X_INLINE inline
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+# define _X_INLINE __inline__
+#else
+# define _X_INLINE
+#endif
+
+/* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */
+/* requires xproto >= 7.0.21 */
+#ifndef _X_RESTRICT_KYWD
+# if defined(restrict) /* assume autoconf set it correctly */ || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \
+ && !defined(__cplusplus)) /* Workaround g++ issue on Solaris */
+# define _X_RESTRICT_KYWD restrict
+# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+# define _X_RESTRICT_KYWD __restrict__
+# else
+# define _X_RESTRICT_KYWD
+# endif
+#endif
+
+/* requires xproto >= 7.0.30 */
+#if __has_attribute(no_sanitize_thread)
+# define _X_NOTSAN __attribute__((no_sanitize_thread))
+#else
+# define _X_NOTSAN
+#endif
+
+#endif /* _XFUNCPROTO_H_ */
diff --git a/src/X11/include/X11/Xlib.h b/src/X11/include/X11/Xlib.h
new file mode 100644
index 00000000..84403f79
--- /dev/null
+++ b/src/X11/include/X11/Xlib.h
@@ -0,0 +1,4015 @@
+/*
+
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+
+/*
+ * Xlib.h - Header definition and support file for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol (V11).
+ * Structures and symbols starting with "_" are private to the library.
+ */
+#ifndef _X11_XLIB_H_
+#define _X11_XLIB_H_
+
+#define XlibSpecificationRelease 6
+
+#include
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include
+#endif
+
+#include
+
+/* applications should not depend on these two headers being included! */
+#include
+#include
+
+#ifndef X_WCHAR
+#include
+#else
+#ifdef __UNIXOS2__
+#include
+#else
+/* replace this with #include or typedef appropriate for your system */
+typedef unsigned long wchar_t;
+#endif
+#endif
+
+
+extern int
+_Xmblen(
+ char *str,
+ int len
+ );
+
+/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
+ November 2000. Its presence is indicated through the following macro. */
+#define X_HAVE_UTF8_STRING 1
+
+/* The Xlib structs are full of implicit padding to properly align members.
+ We can't clean that up without breaking ABI, so tell clang not to bother
+ complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+typedef char *XPointer;
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+#define QueuedAlready 0
+#define QueuedAfterReading 1
+#define QueuedAfterFlush 2
+
+#define ConnectionNumber(dpy) (((_XPrivDisplay)(dpy))->fd)
+#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
+#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
+#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
+#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
+#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
+#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
+#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
+#define AllPlanes ((unsigned long)~0L)
+#define QLength(dpy) (((_XPrivDisplay)(dpy))->qlen)
+#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
+#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
+#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
+#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
+#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
+#define ScreenCount(dpy) (((_XPrivDisplay)(dpy))->nscreens)
+#define ServerVendor(dpy) (((_XPrivDisplay)(dpy))->vendor)
+#define ProtocolVersion(dpy) (((_XPrivDisplay)(dpy))->proto_major_version)
+#define ProtocolRevision(dpy) (((_XPrivDisplay)(dpy))->proto_minor_version)
+#define VendorRelease(dpy) (((_XPrivDisplay)(dpy))->release)
+#define DisplayString(dpy) (((_XPrivDisplay)(dpy))->display_name)
+#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
+#define BitmapUnit(dpy) (((_XPrivDisplay)(dpy))->bitmap_unit)
+#define BitmapBitOrder(dpy) (((_XPrivDisplay)(dpy))->bitmap_bit_order)
+#define BitmapPad(dpy) (((_XPrivDisplay)(dpy))->bitmap_pad)
+#define ImageByteOrder(dpy) (((_XPrivDisplay)(dpy))->byte_order)
+#define NextRequest(dpy) (((_XPrivDisplay)(dpy))->request + 1)
+#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)(dpy))->last_request_read)
+
+/* macros for screen oriented applications (toolkit) */
+#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)(dpy))->screens[scr])
+#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
+#define DisplayOfScreen(s) ((s)->display)
+#define RootWindowOfScreen(s) ((s)->root)
+#define BlackPixelOfScreen(s) ((s)->black_pixel)
+#define WhitePixelOfScreen(s) ((s)->white_pixel)
+#define DefaultColormapOfScreen(s)((s)->cmap)
+#define DefaultDepthOfScreen(s) ((s)->root_depth)
+#define DefaultGCOfScreen(s) ((s)->default_gc)
+#define DefaultVisualOfScreen(s)((s)->root_visual)
+#define WidthOfScreen(s) ((s)->width)
+#define HeightOfScreen(s) ((s)->height)
+#define WidthMMOfScreen(s) ((s)->mwidth)
+#define HeightMMOfScreen(s) ((s)->mheight)
+#define PlanesOfScreen(s) ((s)->root_depth)
+#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
+#define MinCmapsOfScreen(s) ((s)->min_maps)
+#define MaxCmapsOfScreen(s) ((s)->max_maps)
+#define DoesSaveUnders(s) ((s)->save_unders)
+#define DoesBackingStore(s) ((s)->backing_store)
+#define EventMaskOfScreen(s) ((s)->root_input_mask)
+
+/*
+ * Extensions need a way to hang private data on some structures.
+ */
+typedef struct _XExtData {
+ int number; /* number returned by XRegisterExtension */
+ struct _XExtData *next; /* next item on list of data for structure */
+ int (*free_private)( /* called to free private storage */
+ struct _XExtData *extension
+ );
+ XPointer private_data; /* data private to this extension. */
+} XExtData;
+
+/*
+ * This file contains structures used by the extension mechanism.
+ */
+typedef struct { /* public to extension, cannot be changed */
+ int extension; /* extension number */
+ int major_opcode; /* major op-code assigned by server */
+ int first_event; /* first event number for the extension */
+ int first_error; /* first error number for the extension */
+} XExtCodes;
+
+/*
+ * Data structure for retrieving info about pixmap formats.
+ */
+
+typedef struct {
+ int depth;
+ int bits_per_pixel;
+ int scanline_pad;
+} XPixmapFormatValues;
+
+
+/*
+ * Data structure for setting graphics context.
+ */
+typedef struct {
+ int function; /* logical operation */
+ unsigned long plane_mask;/* plane mask */
+ unsigned long foreground;/* foreground pixel */
+ unsigned long background;/* background pixel */
+ int line_width; /* line width */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt,
+ CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ int fill_style; /* FillSolid, FillTiled,
+ FillStippled, FillOpaeueStippled */
+ int fill_rule; /* EvenOddRule, WindingRule */
+ int arc_mode; /* ArcChord, ArcPieSlice */
+ Pixmap tile; /* tile pixmap for tiling operations */
+ Pixmap stipple; /* stipple 1 plane pixmap for stipping */
+ int ts_x_origin; /* offset for tile or stipple operations */
+ int ts_y_origin;
+ Font font; /* default text font for text operations */
+ int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ Bool graphics_exposures;/* boolean, should exposures be generated */
+ int clip_x_origin; /* origin for clipping */
+ int clip_y_origin;
+ Pixmap clip_mask; /* bitmap clipping; other calls for rects */
+ int dash_offset; /* patterned/dashed line information */
+ char dashes;
+} XGCValues;
+
+/*
+ * Graphics context. The contents of this structure are implementation
+ * dependent. A GC should be treated as opaque by application code.
+ */
+
+typedef struct _XGC
+#ifdef XLIB_ILLEGAL_ACCESS
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#endif
+*GC;
+
+/*
+ * Visual structure; contains information about colormapping possible.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ VisualID visualid; /* visual id of this visual */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ class of screen (monochrome, etc.) */
+#else
+ int class; /* class of screen (monochrome, etc.) */
+#endif
+ unsigned long red_mask, green_mask, blue_mask; /* mask values */
+ int bits_per_rgb; /* log base 2 of distinct color values */
+ int map_entries; /* color map entries */
+} Visual;
+
+/*
+ * Depth structure; contains information for each possible depth.
+ */
+typedef struct {
+ int depth; /* this depth (Z) of the depth */
+ int nvisuals; /* number of Visual types at this depth */
+ Visual *visuals; /* list of visuals possible at this depth */
+} Depth;
+
+/*
+ * Information about the screen. The contents of this structure are
+ * implementation dependent. A Screen should be treated as opaque
+ * by application code.
+ */
+
+struct _XDisplay; /* Forward declare before use for C++ */
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XDisplay *display;/* back pointer to display structure */
+ Window root; /* Root window id. */
+ int width, height; /* width and height of screen */
+ int mwidth, mheight; /* width and height of in millimeters */
+ int ndepths; /* number of depths possible */
+ Depth *depths; /* list of allowable depths on the screen */
+ int root_depth; /* bits per pixel */
+ Visual *root_visual; /* root visual */
+ GC default_gc; /* GC for the root root visual */
+ Colormap cmap; /* default color map */
+ unsigned long white_pixel;
+ unsigned long black_pixel; /* White and Black pixel values */
+ int max_maps, min_maps; /* max and min color maps */
+ int backing_store; /* Never, WhenMapped, Always */
+ Bool save_unders;
+ long root_input_mask; /* initial root input mask */
+} Screen;
+
+/*
+ * Format structure; describes ZFormat data the screen will understand.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ int depth; /* depth of this image format */
+ int bits_per_pixel; /* bits/pixel at this depth */
+ int scanline_pad; /* scanline must padded to this multiple */
+} ScreenFormat;
+
+/*
+ * Data structure for setting window attributes.
+ */
+typedef struct {
+ Pixmap background_pixmap; /* background or None or ParentRelative */
+ unsigned long background_pixel; /* background pixel */
+ Pixmap border_pixmap; /* border of the window */
+ unsigned long border_pixel; /* border pixel value */
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preseved if possible */
+ unsigned long backing_pixel;/* value to use in restoring planes */
+ Bool save_under; /* should bits under be saved? (popups) */
+ long event_mask; /* set of events that should be saved */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Colormap colormap; /* color map to be associated with window */
+ Cursor cursor; /* cursor to be displayed (or None) */
+} XSetWindowAttributes;
+
+typedef struct {
+ int x, y; /* location of window */
+ int width, height; /* width and height of window */
+ int border_width; /* border width of window */
+ int depth; /* depth of window */
+ Visual *visual; /* the associated visual structure */
+ Window root; /* root of screen containing window */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ InputOutput, InputOnly*/
+#else
+ int class; /* InputOutput, InputOnly*/
+#endif
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preserved if possible */
+ unsigned long backing_pixel;/* value to be used when restoring planes */
+ Bool save_under; /* boolean, should bits under be saved? */
+ Colormap colormap; /* color map to be associated with window */
+ Bool map_installed; /* boolean, is color map currently installed*/
+ int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ long all_event_masks; /* set of events all people have interest in*/
+ long your_event_mask; /* my event mask */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Screen *screen; /* back pointer to correct screen */
+} XWindowAttributes;
+
+/*
+ * Data structure for host setting; getting routines.
+ *
+ */
+
+typedef struct {
+ int family; /* for example FamilyInternet */
+ int length; /* length of address, in bytes */
+ char *address; /* pointer to where to find the bytes */
+} XHostAddress;
+
+/*
+ * Data structure for ServerFamilyInterpreted addresses in host routines
+ */
+typedef struct {
+ int typelength; /* length of type string, in bytes */
+ int valuelength; /* length of value string, in bytes */
+ char *type; /* pointer to where to find the type string */
+ char *value; /* pointer to where to find the address */
+} XServerInterpretedAddress;
+
+/*
+ * Data structure for "image" data, used by image manipulation routines.
+ */
+typedef struct _XImage {
+ int width, height; /* size of image */
+ int xoffset; /* number of pixels offset in X direction */
+ int format; /* XYBitmap, XYPixmap, ZPixmap */
+ char *data; /* pointer to image data */
+ int byte_order; /* data byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* quant. of scanline 8, 16, 32 */
+ int bitmap_bit_order; /* LSBFirst, MSBFirst */
+ int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
+ int depth; /* depth of image */
+ int bytes_per_line; /* accelarator to next line */
+ int bits_per_pixel; /* bits per pixel (ZPixmap) */
+ unsigned long red_mask; /* bits in z arrangment */
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ XPointer obdata; /* hook for the object routines to hang on */
+ struct funcs { /* image manipulation routines */
+ struct _XImage *(*create_image)(
+ struct _XDisplay* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */);
+ int (*destroy_image) (struct _XImage *);
+ unsigned long (*get_pixel) (struct _XImage *, int, int);
+ int (*put_pixel) (struct _XImage *, int, int, unsigned long);
+ struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
+ int (*add_pixel) (struct _XImage *, long);
+ } f;
+} XImage;
+
+/*
+ * Data structure for XReconfigureWindow
+ */
+typedef struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+} XWindowChanges;
+
+/*
+ * Data structure used by color operations
+ */
+typedef struct {
+ unsigned long pixel;
+ unsigned short red, green, blue;
+ char flags; /* do_red, do_green, do_blue */
+ char pad;
+} XColor;
+
+/*
+ * Data structures for graphics operations. On most machines, these are
+ * congruent with the wire protocol structures, so reformatting the data
+ * can be avoided on these architectures.
+ */
+typedef struct {
+ short x1, y1, x2, y2;
+} XSegment;
+
+typedef struct {
+ short x, y;
+} XPoint;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ short angle1, angle2;
+} XArc;
+
+
+/* Data structure for XChangeKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ int bell_pitch;
+ int bell_duration;
+ int led;
+ int led_mode;
+ int key;
+ int auto_repeat_mode; /* On, Off, Default */
+} XKeyboardControl;
+
+/* Data structure for XGetKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ unsigned int bell_pitch, bell_duration;
+ unsigned long led_mask;
+ int global_auto_repeat;
+ char auto_repeats[32];
+} XKeyboardState;
+
+/* Data structure for XGetMotionEvents. */
+
+typedef struct {
+ Time time;
+ short x, y;
+} XTimeCoord;
+
+/* Data structure for X{Set,Get}ModifierMapping */
+
+typedef struct {
+ int max_keypermod; /* The server's max # of keys per modifier */
+ KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
+} XModifierKeymap;
+
+
+/*
+ * Display datatype maintaining display specific data.
+ * The contents of this structure are implementation dependent.
+ * A Display should be treated as opaque by application code.
+ */
+#ifndef XLIB_ILLEGAL_ACCESS
+typedef struct _XDisplay Display;
+#endif
+
+struct _XPrivate; /* Forward declare before use for C++ */
+struct _XrmHashBucketRec;
+
+typedef struct
+#ifdef XLIB_ILLEGAL_ACCESS
+_XDisplay
+#endif
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XPrivate *private1;
+ int fd; /* Network socket. */
+ int private2;
+ int proto_major_version;/* major version of server's X protocol */
+ int proto_minor_version;/* minor version of servers X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID private3;
+ XID private4;
+ XID private5;
+ int private6;
+ XID (*resource_alloc)( /* allocator function */
+ struct _XDisplay*
+ );
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int private8;
+ int release; /* release of the server */
+ struct _XPrivate *private9, *private10;
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ XPointer private11;
+ XPointer private12;
+ XPointer private13;
+ XPointer private14;
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*private15)(
+ struct _XDisplay*
+ );
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long private16;
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ XPointer private17;
+ XPointer private18;
+ int private19;
+ char *xdefaults; /* contents of defaults from server */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#ifdef XLIB_ILLEGAL_ACCESS
+Display,
+#endif
+*_XPrivDisplay;
+
+#undef _XEVENT_
+#ifndef _XEVENT_
+/*
+ * Definitions of specific events.
+ */
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int keycode; /* detail */
+ Bool same_screen; /* same screen flag */
+} XKeyEvent;
+typedef XKeyEvent XKeyPressedEvent;
+typedef XKeyEvent XKeyReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int button; /* detail */
+ Bool same_screen; /* same screen flag */
+} XButtonEvent;
+typedef XButtonEvent XButtonPressedEvent;
+typedef XButtonEvent XButtonReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ char is_hint; /* detail */
+ Bool same_screen; /* same screen flag */
+} XMotionEvent;
+typedef XMotionEvent XPointerMovedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual
+ */
+ Bool same_screen; /* same screen flag */
+ Bool focus; /* boolean focus */
+ unsigned int state; /* key or button mask */
+} XCrossingEvent;
+typedef XCrossingEvent XEnterWindowEvent;
+typedef XCrossingEvent XLeaveWindowEvent;
+
+typedef struct {
+ int type; /* FocusIn or FocusOut */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ int mode; /* NotifyNormal, NotifyWhileGrabbed,
+ NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+} XFocusChangeEvent;
+typedef XFocusChangeEvent XFocusInEvent;
+typedef XFocusChangeEvent XFocusOutEvent;
+
+/* generated on EnterWindow and FocusIn when KeyMapState selected */
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ char key_vector[32];
+} XKeymapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+} XExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XGraphicsExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XNoExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int state; /* Visibility state */
+} XVisibilityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent; /* parent of the window */
+ Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+} XDestroyWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool from_configure;
+} XUnmapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+} XMapRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Window parent;
+ int x, y;
+ Bool override_redirect;
+} XReparentEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ Bool override_redirect;
+} XConfigureEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+} XGravityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int width, height;
+} XResizeRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ int detail; /* Above, Below, TopIf, BottomIf, Opposite */
+ unsigned long value_mask;
+} XConfigureRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom atom;
+ Time time;
+ int state; /* NewValue, Deleted */
+} XPropertyEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom selection;
+ Time time;
+} XSelectionClearEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window owner;
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property;
+ Time time;
+} XSelectionRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property; /* ATOM or None */
+ Time time;
+} XSelectionEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Colormap colormap; /* COLORMAP or None */
+#if defined(__cplusplus) || defined(c_plusplus)
+ Bool c_new; /* C++ */
+#else
+ Bool new;
+#endif
+ int state; /* ColormapInstalled, ColormapUninstalled */
+} XColormapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* unused */
+ int request; /* one of MappingModifier, MappingKeyboard,
+ MappingPointer */
+ int first_keycode; /* first keycode */
+ int count; /* defines range of change w. first_keycode*/
+} XMappingEvent;
+
+typedef struct {
+ int type;
+ Display *display; /* Display the event was read from */
+ XID resourceid; /* resource id */
+ unsigned long serial; /* serial number of failed request */
+ unsigned char error_code; /* error code of failed request */
+ unsigned char request_code; /* Major op-code of failed request */
+ unsigned char minor_code; /* Minor op-code of failed request */
+} XErrorEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display;/* Display the event was read from */
+ Window window; /* window on which event was requested in event mask */
+} XAnyEvent;
+
+
+/***************************************************************
+ *
+ * GenericEvent. This event is the standard event for all newer extensions.
+ */
+
+typedef struct
+ {
+ int type; /* of event. Always GenericEvent */
+ unsigned long serial; /* # of last request processed */
+ Bool send_event; /* true if from SendEvent request */
+ Display *display; /* Display the event was read from */
+ int extension; /* major opcode of extension that caused the event */
+ int evtype; /* actual event type. */
+ } XGenericEvent;
+
+typedef struct {
+ int type; /* of event. Always GenericEvent */
+ unsigned long serial; /* # of last request processed */
+ Bool send_event; /* true if from SendEvent request */
+ Display *display; /* Display the event was read from */
+ int extension; /* major opcode of extension that caused the event */
+ int evtype; /* actual event type. */
+ unsigned int cookie;
+ void *data;
+} XGenericEventCookie;
+
+/*
+ * this union is defined so Xlib can always use the same sized
+ * event structure internally, to avoid memory fragmentation.
+ */
+typedef union _XEvent {
+ int type; /* must not be changed; first element */
+ XAnyEvent xany;
+ XKeyEvent xkey;
+ XButtonEvent xbutton;
+ XMotionEvent xmotion;
+ XCrossingEvent xcrossing;
+ XFocusChangeEvent xfocus;
+ XExposeEvent xexpose;
+ XGraphicsExposeEvent xgraphicsexpose;
+ XNoExposeEvent xnoexpose;
+ XVisibilityEvent xvisibility;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ XReparentEvent xreparent;
+ XConfigureEvent xconfigure;
+ XGravityEvent xgravity;
+ XResizeRequestEvent xresizerequest;
+ XConfigureRequestEvent xconfigurerequest;
+ XCirculateEvent xcirculate;
+ XCirculateRequestEvent xcirculaterequest;
+ XPropertyEvent xproperty;
+ XSelectionClearEvent xselectionclear;
+ XSelectionRequestEvent xselectionrequest;
+ XSelectionEvent xselection;
+ XColormapEvent xcolormap;
+ XClientMessageEvent xclient;
+ XMappingEvent xmapping;
+ XErrorEvent xerror;
+ XKeymapEvent xkeymap;
+ XGenericEvent xgeneric;
+ XGenericEventCookie xcookie;
+ long pad[24];
+} XEvent;
+#endif
+
+#define XAllocID(dpy) ((*((_XPrivDisplay)(dpy))->resource_alloc)((dpy)))
+
+/*
+ * per character font metric information.
+ */
+typedef struct {
+ short lbearing; /* origin to left edge of raster */
+ short rbearing; /* origin to right edge of raster */
+ short width; /* advance to next char's origin */
+ short ascent; /* baseline to top edge of raster */
+ short descent; /* baseline to bottom edge of raster */
+ unsigned short attributes; /* per char flags (not predefined) */
+} XCharStruct;
+
+/*
+ * To allow arbitrary information with fonts, there are additional properties
+ * returned.
+ */
+typedef struct {
+ Atom name;
+ unsigned long card32;
+} XFontProp;
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ Font fid; /* Font id for this font */
+ unsigned direction; /* hint about direction the font is painted */
+ unsigned min_char_or_byte2;/* first character */
+ unsigned max_char_or_byte2;/* last character */
+ unsigned min_byte1; /* first row that exists */
+ unsigned max_byte1; /* last row that exists */
+ Bool all_chars_exist;/* flag if all characters have non-zero size*/
+ unsigned default_char; /* char to print for undefined character */
+ int n_properties; /* how many properties there are */
+ XFontProp *properties; /* pointer to array of additional properties*/
+ XCharStruct min_bounds; /* minimum bounds over all existing char*/
+ XCharStruct max_bounds; /* maximum bounds over all existing char*/
+ XCharStruct *per_char; /* first_char to last_char information */
+ int ascent; /* log. extent above baseline for spacing */
+ int descent; /* log. descent below baseline for spacing */
+} XFontStruct;
+
+/*
+ * PolyText routines take these as arguments.
+ */
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem;
+
+typedef struct { /* normal 16 bit characters are two bytes */
+ unsigned char byte1;
+ unsigned char byte2;
+} XChar2b;
+
+typedef struct {
+ XChar2b *chars; /* two byte characters */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem16;
+
+
+typedef union { Display *display;
+ GC gc;
+ Visual *visual;
+ Screen *screen;
+ ScreenFormat *pixmap_format;
+ XFontStruct *font; } XEDataObject;
+
+typedef struct {
+ XRectangle max_ink_extent;
+ XRectangle max_logical_extent;
+} XFontSetExtents;
+
+/* unused:
+typedef void (*XOMProc)();
+ */
+
+typedef struct _XOM *XOM;
+typedef struct _XOC *XOC, *XFontSet;
+
+typedef struct {
+ char *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XmbTextItem;
+
+typedef struct {
+ wchar_t *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XwcTextItem;
+
+#define XNRequiredCharSet "requiredCharSet"
+#define XNQueryOrientation "queryOrientation"
+#define XNBaseFontName "baseFontName"
+#define XNOMAutomatic "omAutomatic"
+#define XNMissingCharSet "missingCharSet"
+#define XNDefaultString "defaultString"
+#define XNOrientation "orientation"
+#define XNDirectionalDependentDrawing "directionalDependentDrawing"
+#define XNContextualDrawing "contextualDrawing"
+#define XNFontInfo "fontInfo"
+
+typedef struct {
+ int charset_count;
+ char **charset_list;
+} XOMCharSetList;
+
+typedef enum {
+ XOMOrientation_LTR_TTB,
+ XOMOrientation_RTL_TTB,
+ XOMOrientation_TTB_LTR,
+ XOMOrientation_TTB_RTL,
+ XOMOrientation_Context
+} XOrientation;
+
+typedef struct {
+ int num_orientation;
+ XOrientation *orientation; /* Input Text description */
+} XOMOrientation;
+
+typedef struct {
+ int num_font;
+ XFontStruct **font_struct_list;
+ char **font_name_list;
+} XOMFontInfo;
+
+typedef struct _XIM *XIM;
+typedef struct _XIC *XIC;
+
+typedef void (*XIMProc)(
+ XIM,
+ XPointer,
+ XPointer
+);
+
+typedef Bool (*XICProc)(
+ XIC,
+ XPointer,
+ XPointer
+);
+
+typedef void (*XIDProc)(
+ Display*,
+ XPointer,
+ XPointer
+);
+
+typedef unsigned long XIMStyle;
+
+typedef struct {
+ unsigned short count_styles;
+ XIMStyle *supported_styles;
+} XIMStyles;
+
+#define XIMPreeditArea 0x0001L
+#define XIMPreeditCallbacks 0x0002L
+#define XIMPreeditPosition 0x0004L
+#define XIMPreeditNothing 0x0008L
+#define XIMPreeditNone 0x0010L
+#define XIMStatusArea 0x0100L
+#define XIMStatusCallbacks 0x0200L
+#define XIMStatusNothing 0x0400L
+#define XIMStatusNone 0x0800L
+
+#define XNVaNestedList "XNVaNestedList"
+#define XNQueryInputStyle "queryInputStyle"
+#define XNClientWindow "clientWindow"
+#define XNInputStyle "inputStyle"
+#define XNFocusWindow "focusWindow"
+#define XNResourceName "resourceName"
+#define XNResourceClass "resourceClass"
+#define XNGeometryCallback "geometryCallback"
+#define XNDestroyCallback "destroyCallback"
+#define XNFilterEvents "filterEvents"
+#define XNPreeditStartCallback "preeditStartCallback"
+#define XNPreeditDoneCallback "preeditDoneCallback"
+#define XNPreeditDrawCallback "preeditDrawCallback"
+#define XNPreeditCaretCallback "preeditCaretCallback"
+#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
+#define XNPreeditAttributes "preeditAttributes"
+#define XNStatusStartCallback "statusStartCallback"
+#define XNStatusDoneCallback "statusDoneCallback"
+#define XNStatusDrawCallback "statusDrawCallback"
+#define XNStatusAttributes "statusAttributes"
+#define XNArea "area"
+#define XNAreaNeeded "areaNeeded"
+#define XNSpotLocation "spotLocation"
+#define XNColormap "colorMap"
+#define XNStdColormap "stdColorMap"
+#define XNForeground "foreground"
+#define XNBackground "background"
+#define XNBackgroundPixmap "backgroundPixmap"
+#define XNFontSet "fontSet"
+#define XNLineSpace "lineSpace"
+#define XNCursor "cursor"
+
+#define XNQueryIMValuesList "queryIMValuesList"
+#define XNQueryICValuesList "queryICValuesList"
+#define XNVisiblePosition "visiblePosition"
+#define XNR6PreeditCallback "r6PreeditCallback"
+#define XNStringConversionCallback "stringConversionCallback"
+#define XNStringConversion "stringConversion"
+#define XNResetState "resetState"
+#define XNHotKey "hotKey"
+#define XNHotKeyState "hotKeyState"
+#define XNPreeditState "preeditState"
+#define XNSeparatorofNestedList "separatorofNestedList"
+
+#define XBufferOverflow -1
+#define XLookupNone 1
+#define XLookupChars 2
+#define XLookupKeySym 3
+#define XLookupBoth 4
+
+typedef void *XVaNestedList;
+
+typedef struct {
+ XPointer client_data;
+ XIMProc callback;
+} XIMCallback;
+
+typedef struct {
+ XPointer client_data;
+ XICProc callback;
+} XICCallback;
+
+typedef unsigned long XIMFeedback;
+
+#define XIMReverse 1L
+#define XIMUnderline (1L<<1)
+#define XIMHighlight (1L<<2)
+#define XIMPrimary (1L<<5)
+#define XIMSecondary (1L<<6)
+#define XIMTertiary (1L<<7)
+#define XIMVisibleToForward (1L<<8)
+#define XIMVisibleToBackword (1L<<9)
+#define XIMVisibleToCenter (1L<<10)
+
+typedef struct _XIMText {
+ unsigned short length;
+ XIMFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *multi_byte;
+ wchar_t *wide_char;
+ } string;
+} XIMText;
+
+typedef unsigned long XIMPreeditState;
+
+#define XIMPreeditUnKnown 0L
+#define XIMPreeditEnable 1L
+#define XIMPreeditDisable (1L<<1)
+
+typedef struct _XIMPreeditStateNotifyCallbackStruct {
+ XIMPreeditState state;
+} XIMPreeditStateNotifyCallbackStruct;
+
+typedef unsigned long XIMResetState;
+
+#define XIMInitialState 1L
+#define XIMPreserveState (1L<<1)
+
+typedef unsigned long XIMStringConversionFeedback;
+
+#define XIMStringConversionLeftEdge (0x00000001)
+#define XIMStringConversionRightEdge (0x00000002)
+#define XIMStringConversionTopEdge (0x00000004)
+#define XIMStringConversionBottomEdge (0x00000008)
+#define XIMStringConversionConcealed (0x00000010)
+#define XIMStringConversionWrapped (0x00000020)
+
+typedef struct _XIMStringConversionText {
+ unsigned short length;
+ XIMStringConversionFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *mbs;
+ wchar_t *wcs;
+ } string;
+} XIMStringConversionText;
+
+typedef unsigned short XIMStringConversionPosition;
+
+typedef unsigned short XIMStringConversionType;
+
+#define XIMStringConversionBuffer (0x0001)
+#define XIMStringConversionLine (0x0002)
+#define XIMStringConversionWord (0x0003)
+#define XIMStringConversionChar (0x0004)
+
+typedef unsigned short XIMStringConversionOperation;
+
+#define XIMStringConversionSubstitution (0x0001)
+#define XIMStringConversionRetrieval (0x0002)
+
+typedef enum {
+ XIMForwardChar, XIMBackwardChar,
+ XIMForwardWord, XIMBackwardWord,
+ XIMCaretUp, XIMCaretDown,
+ XIMNextLine, XIMPreviousLine,
+ XIMLineStart, XIMLineEnd,
+ XIMAbsolutePosition,
+ XIMDontChange
+} XIMCaretDirection;
+
+typedef struct _XIMStringConversionCallbackStruct {
+ XIMStringConversionPosition position;
+ XIMCaretDirection direction;
+ XIMStringConversionOperation operation;
+ unsigned short factor;
+ XIMStringConversionText *text;
+} XIMStringConversionCallbackStruct;
+
+typedef struct _XIMPreeditDrawCallbackStruct {
+ int caret; /* Cursor offset within pre-edit string */
+ int chg_first; /* Starting change position */
+ int chg_length; /* Length of the change in character count */
+ XIMText *text;
+} XIMPreeditDrawCallbackStruct;
+
+typedef enum {
+ XIMIsInvisible, /* Disable caret feedback */
+ XIMIsPrimary, /* UI defined caret feedback */
+ XIMIsSecondary /* UI defined caret feedback */
+} XIMCaretStyle;
+
+typedef struct _XIMPreeditCaretCallbackStruct {
+ int position; /* Caret offset within pre-edit string */
+ XIMCaretDirection direction; /* Caret moves direction */
+ XIMCaretStyle style; /* Feedback of the caret */
+} XIMPreeditCaretCallbackStruct;
+
+typedef enum {
+ XIMTextType,
+ XIMBitmapType
+} XIMStatusDataType;
+
+typedef struct _XIMStatusDrawCallbackStruct {
+ XIMStatusDataType type;
+ union {
+ XIMText *text;
+ Pixmap bitmap;
+ } data;
+} XIMStatusDrawCallbackStruct;
+
+typedef struct _XIMHotKeyTrigger {
+ KeySym keysym;
+ int modifier;
+ int modifier_mask;
+} XIMHotKeyTrigger;
+
+typedef struct _XIMHotKeyTriggers {
+ int num_hot_key;
+ XIMHotKeyTrigger *key;
+} XIMHotKeyTriggers;
+
+typedef unsigned long XIMHotKeyState;
+
+#define XIMHotKeyStateON (0x0001L)
+#define XIMHotKeyStateOFF (0x0002L)
+
+typedef struct {
+ unsigned short count_values;
+ char **supported_values;
+} XIMValuesList;
+
+_XFUNCPROTOBEGIN
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _Xdebug (*_Xdebug_p)
+#endif
+
+extern int _Xdebug;
+
+extern XFontStruct *XLoadQueryFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XFontStruct *XQueryFont(
+ Display* /* display */,
+ XID /* font_ID */
+);
+
+
+extern XTimeCoord *XGetMotionEvents(
+ Display* /* display */,
+ Window /* w */,
+ Time /* start */,
+ Time /* stop */,
+ int* /* nevents_return */
+);
+
+extern XModifierKeymap *XDeleteModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XGetModifierMapping(
+ Display* /* display */
+);
+
+extern XModifierKeymap *XInsertModifiermapEntry(
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+);
+
+extern XModifierKeymap *XNewModifiermap(
+ int /* max_keys_per_mod */
+);
+
+extern XImage *XCreateImage(
+ Display* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */
+);
+extern Status XInitImage(
+ XImage* /* image */
+);
+extern XImage *XGetImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */
+);
+extern XImage *XGetSubImage(
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */,
+ XImage* /* dest_image */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+/*
+ * X function declarations.
+ */
+extern Display *XOpenDisplay(
+ _Xconst char* /* display_name */
+);
+
+extern void XrmInitialize(
+ void
+);
+
+extern char *XFetchBytes(
+ Display* /* display */,
+ int* /* nbytes_return */
+);
+extern char *XFetchBuffer(
+ Display* /* display */,
+ int* /* nbytes_return */,
+ int /* buffer */
+);
+extern char *XGetAtomName(
+ Display* /* display */,
+ Atom /* atom */
+);
+extern Status XGetAtomNames(
+ Display* /* dpy */,
+ Atom* /* atoms */,
+ int /* count */,
+ char** /* names_return */
+);
+extern char *XGetDefault(
+ Display* /* display */,
+ _Xconst char* /* program */,
+ _Xconst char* /* option */
+);
+extern char *XDisplayName(
+ _Xconst char* /* string */
+);
+extern char *XKeysymToString(
+ KeySym /* keysym */
+);
+
+extern int (*XSynchronize(
+ Display* /* display */,
+ Bool /* onoff */
+))(
+ Display* /* display */
+);
+extern int (*XSetAfterFunction(
+ Display* /* display */,
+ int (*) (
+ Display* /* display */
+ ) /* procedure */
+))(
+ Display* /* display */
+);
+extern Atom XInternAtom(
+ Display* /* display */,
+ _Xconst char* /* atom_name */,
+ Bool /* only_if_exists */
+);
+extern Status XInternAtoms(
+ Display* /* dpy */,
+ char** /* names */,
+ int /* count */,
+ Bool /* onlyIfExists */,
+ Atom* /* atoms_return */
+);
+extern Colormap XCopyColormapAndFree(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+extern Colormap XCreateColormap(
+ Display* /* display */,
+ Window /* w */,
+ Visual* /* visual */,
+ int /* alloc */
+);
+extern Cursor XCreatePixmapCursor(
+ Display* /* display */,
+ Pixmap /* source */,
+ Pixmap /* mask */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */,
+ unsigned int /* x */,
+ unsigned int /* y */
+);
+extern Cursor XCreateGlyphCursor(
+ Display* /* display */,
+ Font /* source_font */,
+ Font /* mask_font */,
+ unsigned int /* source_char */,
+ unsigned int /* mask_char */,
+ XColor _Xconst * /* foreground_color */,
+ XColor _Xconst * /* background_color */
+);
+extern Cursor XCreateFontCursor(
+ Display* /* display */,
+ unsigned int /* shape */
+);
+extern Font XLoadFont(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+extern GC XCreateGC(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+extern GContext XGContextFromGC(
+ GC /* gc */
+);
+extern void XFlushGC(
+ Display* /* display */,
+ GC /* gc */
+);
+extern Pixmap XCreatePixmap(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */
+);
+extern Pixmap XCreateBitmapFromData(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+extern Pixmap XCreatePixmapFromBitmapData(
+ Display* /* display */,
+ Drawable /* d */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* fg */,
+ unsigned long /* bg */,
+ unsigned int /* depth */
+);
+extern Window XCreateSimpleWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ unsigned long /* border */,
+ unsigned long /* background */
+);
+extern Window XGetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */
+);
+extern Window XCreateWindow(
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ int /* depth */,
+ unsigned int /* class */,
+ Visual* /* visual */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+extern Colormap *XListInstalledColormaps(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_return */
+);
+extern char **XListFonts(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* actual_count_return */
+);
+extern char **XListFontsWithInfo(
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* count_return */,
+ XFontStruct** /* info_return */
+);
+extern char **XGetFontPath(
+ Display* /* display */,
+ int* /* npaths_return */
+);
+extern char **XListExtensions(
+ Display* /* display */,
+ int* /* nextensions_return */
+);
+extern Atom *XListProperties(
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_prop_return */
+);
+extern XHostAddress *XListHosts(
+ Display* /* display */,
+ int* /* nhosts_return */,
+ Bool* /* state_return */
+);
+_X_DEPRECATED
+extern KeySym XKeycodeToKeysym(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+);
+extern KeySym XLookupKeysym(
+ XKeyEvent* /* key_event */,
+ int /* index */
+);
+extern KeySym *XGetKeyboardMapping(
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* first_keycode */,
+#else
+ KeyCode /* first_keycode */,
+#endif
+ int /* keycode_count */,
+ int* /* keysyms_per_keycode_return */
+);
+extern KeySym XStringToKeysym(
+ _Xconst char* /* string */
+);
+extern long XMaxRequestSize(
+ Display* /* display */
+);
+extern long XExtendedMaxRequestSize(
+ Display* /* display */
+);
+extern char *XResourceManagerString(
+ Display* /* display */
+);
+extern char *XScreenResourceString(
+ Screen* /* screen */
+);
+extern unsigned long XDisplayMotionBufferSize(
+ Display* /* display */
+);
+extern VisualID XVisualIDFromVisual(
+ Visual* /* visual */
+);
+
+/* multithread routines */
+
+extern Status XInitThreads(
+ void
+);
+
+extern void XLockDisplay(
+ Display* /* display */
+);
+
+extern void XUnlockDisplay(
+ Display* /* display */
+);
+
+/* routines for dealing with extensions */
+
+extern XExtCodes *XInitExtension(
+ Display* /* display */,
+ _Xconst char* /* name */
+);
+
+extern XExtCodes *XAddExtension(
+ Display* /* display */
+);
+extern XExtData *XFindOnExtensionList(
+ XExtData** /* structure */,
+ int /* number */
+);
+extern XExtData **XEHeadOfExtensionList(
+ XEDataObject /* object */
+);
+
+/* these are routines for which there are also macros */
+extern Window XRootWindow(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Window XDefaultRootWindow(
+ Display* /* display */
+);
+extern Window XRootWindowOfScreen(
+ Screen* /* screen */
+);
+extern Visual *XDefaultVisual(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Visual *XDefaultVisualOfScreen(
+ Screen* /* screen */
+);
+extern GC XDefaultGC(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern GC XDefaultGCOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XBlackPixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XWhitePixel(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern unsigned long XAllPlanes(
+ void
+);
+extern unsigned long XBlackPixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XWhitePixelOfScreen(
+ Screen* /* screen */
+);
+extern unsigned long XNextRequest(
+ Display* /* display */
+);
+extern unsigned long XLastKnownRequestProcessed(
+ Display* /* display */
+);
+extern char *XServerVendor(
+ Display* /* display */
+);
+extern char *XDisplayString(
+ Display* /* display */
+);
+extern Colormap XDefaultColormap(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Colormap XDefaultColormapOfScreen(
+ Screen* /* screen */
+);
+extern Display *XDisplayOfScreen(
+ Screen* /* screen */
+);
+extern Screen *XScreenOfDisplay(
+ Display* /* display */,
+ int /* screen_number */
+);
+extern Screen *XDefaultScreenOfDisplay(
+ Display* /* display */
+);
+extern long XEventMaskOfScreen(
+ Screen* /* screen */
+);
+
+extern int XScreenNumberOfScreen(
+ Screen* /* screen */
+);
+
+typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */,
+ XErrorEvent* /* error_event */
+);
+
+extern XErrorHandler XSetErrorHandler (
+ XErrorHandler /* handler */
+);
+
+
+typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
+ Display* /* display */
+);
+
+extern XIOErrorHandler XSetIOErrorHandler (
+ XIOErrorHandler /* handler */
+);
+
+
+extern XPixmapFormatValues *XListPixmapFormats(
+ Display* /* display */,
+ int* /* count_return */
+);
+extern int *XListDepths(
+ Display* /* display */,
+ int /* screen_number */,
+ int* /* count_return */
+);
+
+/* ICCCM routines for things that don't require special include files; */
+/* other declarations are given in Xutil.h */
+extern Status XReconfigureWMWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */,
+ unsigned int /* mask */,
+ XWindowChanges* /* changes */
+);
+
+extern Status XGetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom** /* protocols_return */,
+ int* /* count_return */
+);
+extern Status XSetWMProtocols(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* protocols */,
+ int /* count */
+);
+extern Status XIconifyWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XWithdrawWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+);
+extern Status XGetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char*** /* argv_return */,
+ int* /* argc_return */
+);
+extern Status XGetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window** /* windows_return */,
+ int* /* count_return */
+);
+extern Status XSetWMColormapWindows(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* colormap_windows */,
+ int /* count */
+);
+extern void XFreeStringList(
+ char** /* list */
+);
+extern int XSetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window /* prop_window */
+);
+
+/* The following are given in alphabetical order */
+
+extern int XActivateScreenSaver(
+ Display* /* display */
+);
+
+extern int XAddHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XAddHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XAddToExtensionList(
+ struct _XExtData** /* structure */,
+ XExtData* /* ext_data */
+);
+
+extern int XAddToSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern Status XAllocColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */
+);
+
+extern Status XAllocColorCells(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* plane_masks_return */,
+ unsigned int /* nplanes */,
+ unsigned long* /* pixels_return */,
+ unsigned int /* npixels */
+);
+
+extern Status XAllocColorPlanes(
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* pixels_return */,
+ int /* ncolors */,
+ int /* nreds */,
+ int /* ngreens */,
+ int /* nblues */,
+ unsigned long* /* rmask_return */,
+ unsigned long* /* gmask_return */,
+ unsigned long* /* bmask_return */
+);
+
+extern Status XAllocNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* screen_def_return */,
+ XColor* /* exact_def_return */
+);
+
+extern int XAllowEvents(
+ Display* /* display */,
+ int /* event_mode */,
+ Time /* time */
+);
+
+extern int XAutoRepeatOff(
+ Display* /* display */
+);
+
+extern int XAutoRepeatOn(
+ Display* /* display */
+);
+
+extern int XBell(
+ Display* /* display */,
+ int /* percent */
+);
+
+extern int XBitmapBitOrder(
+ Display* /* display */
+);
+
+extern int XBitmapPad(
+ Display* /* display */
+);
+
+extern int XBitmapUnit(
+ Display* /* display */
+);
+
+extern int XCellsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XChangeActivePointerGrab(
+ Display* /* display */,
+ unsigned int /* event_mask */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XChangeGC(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+);
+
+extern int XChangeKeyboardControl(
+ Display* /* display */,
+ unsigned long /* value_mask */,
+ XKeyboardControl* /* values */
+);
+
+extern int XChangeKeyboardMapping(
+ Display* /* display */,
+ int /* first_keycode */,
+ int /* keysyms_per_keycode */,
+ KeySym* /* keysyms */,
+ int /* num_codes */
+);
+
+extern int XChangePointerControl(
+ Display* /* display */,
+ Bool /* do_accel */,
+ Bool /* do_threshold */,
+ int /* accel_numerator */,
+ int /* accel_denominator */,
+ int /* threshold */
+);
+
+extern int XChangeProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ Atom /* type */,
+ int /* format */,
+ int /* mode */,
+ _Xconst unsigned char* /* data */,
+ int /* nelements */
+);
+
+extern int XChangeSaveSet(
+ Display* /* display */,
+ Window /* w */,
+ int /* change_mode */
+);
+
+extern int XChangeWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+);
+
+extern Bool XCheckIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern Bool XCheckMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedEvent(
+ Display* /* display */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckTypedWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ int /* event_type */,
+ XEvent* /* event_return */
+);
+
+extern Bool XCheckWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XCirculateSubwindows(
+ Display* /* display */,
+ Window /* w */,
+ int /* direction */
+);
+
+extern int XCirculateSubwindowsDown(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCirculateSubwindowsUp(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XClearArea(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ Bool /* exposures */
+);
+
+extern int XClearWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XCloseDisplay(
+ Display* /* display */
+);
+
+extern int XConfigureWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* value_mask */,
+ XWindowChanges* /* values */
+);
+
+extern int XConnectionNumber(
+ Display* /* display */
+);
+
+extern int XConvertSelection(
+ Display* /* display */,
+ Atom /* selection */,
+ Atom /* target */,
+ Atom /* property */,
+ Window /* requestor */,
+ Time /* time */
+);
+
+extern int XCopyArea(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XCopyGC(
+ Display* /* display */,
+ GC /* src */,
+ unsigned long /* valuemask */,
+ GC /* dest */
+);
+
+extern int XCopyPlane(
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned long /* plane */
+);
+
+extern int XDefaultDepth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDefaultDepthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XDefaultScreen(
+ Display* /* display */
+);
+
+extern int XDefineCursor(
+ Display* /* display */,
+ Window /* w */,
+ Cursor /* cursor */
+);
+
+extern int XDeleteProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */
+);
+
+extern int XDestroyWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDestroySubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XDoesBackingStore(
+ Screen* /* screen */
+);
+
+extern Bool XDoesSaveUnders(
+ Screen* /* screen */
+);
+
+extern int XDisableAccessControl(
+ Display* /* display */
+);
+
+
+extern int XDisplayCells(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeight(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayHeightMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayKeycodes(
+ Display* /* display */,
+ int* /* min_keycodes_return */,
+ int* /* max_keycodes_return */
+);
+
+extern int XDisplayPlanes(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidth(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDisplayWidthMM(
+ Display* /* display */,
+ int /* screen_number */
+);
+
+extern int XDrawArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XDrawArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawImageString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawLine(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x1 */,
+ int /* y1 */,
+ int /* x2 */,
+ int /* y2 */
+);
+
+extern int XDrawLines(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawPoint(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XDrawPoints(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+);
+
+extern int XDrawRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XDrawRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XDrawSegments(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XSegment* /* segments */,
+ int /* nsegments */
+);
+
+extern int XDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+);
+
+extern int XDrawString16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+);
+
+extern int XDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem* /* items */,
+ int /* nitems */
+);
+
+extern int XDrawText16(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem16* /* items */,
+ int /* nitems */
+);
+
+extern int XEnableAccessControl(
+ Display* /* display */
+);
+
+extern int XEventsQueued(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern Status XFetchName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* window_name_return */
+);
+
+extern int XFillArc(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+);
+
+extern int XFillArcs(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+);
+
+extern int XFillPolygon(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* shape */,
+ int /* mode */
+);
+
+extern int XFillRectangle(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XFillRectangles(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+);
+
+extern int XFlush(
+ Display* /* display */
+);
+
+extern int XForceScreenSaver(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XFree(
+ void* /* data */
+);
+
+extern int XFreeColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XFreeColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ unsigned long* /* pixels */,
+ int /* npixels */,
+ unsigned long /* planes */
+);
+
+extern int XFreeCursor(
+ Display* /* display */,
+ Cursor /* cursor */
+);
+
+extern int XFreeExtensionList(
+ char** /* list */
+);
+
+extern int XFreeFont(
+ Display* /* display */,
+ XFontStruct* /* font_struct */
+);
+
+extern int XFreeFontInfo(
+ char** /* names */,
+ XFontStruct* /* free_info */,
+ int /* actual_count */
+);
+
+extern int XFreeFontNames(
+ char** /* list */
+);
+
+extern int XFreeFontPath(
+ char** /* list */
+);
+
+extern int XFreeGC(
+ Display* /* display */,
+ GC /* gc */
+);
+
+extern int XFreeModifiermap(
+ XModifierKeymap* /* modmap */
+);
+
+extern int XFreePixmap(
+ Display* /* display */,
+ Pixmap /* pixmap */
+);
+
+extern int XGeometry(
+ Display* /* display */,
+ int /* screen */,
+ _Xconst char* /* position */,
+ _Xconst char* /* default_position */,
+ unsigned int /* bwidth */,
+ unsigned int /* fwidth */,
+ unsigned int /* fheight */,
+ int /* xadder */,
+ int /* yadder */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */
+);
+
+extern int XGetErrorDatabaseText(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ _Xconst char* /* message */,
+ _Xconst char* /* default_string */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern int XGetErrorText(
+ Display* /* display */,
+ int /* code */,
+ char* /* buffer_return */,
+ int /* length */
+);
+
+extern Bool XGetFontProperty(
+ XFontStruct* /* font_struct */,
+ Atom /* atom */,
+ unsigned long* /* value_return */
+);
+
+extern Status XGetGCValues(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values_return */
+);
+
+extern Status XGetGeometry(
+ Display* /* display */,
+ Drawable /* d */,
+ Window* /* root_return */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned int* /* border_width_return */,
+ unsigned int* /* depth_return */
+);
+
+extern Status XGetIconName(
+ Display* /* display */,
+ Window /* w */,
+ char** /* icon_name_return */
+);
+
+extern int XGetInputFocus(
+ Display* /* display */,
+ Window* /* focus_return */,
+ int* /* revert_to_return */
+);
+
+extern int XGetKeyboardControl(
+ Display* /* display */,
+ XKeyboardState* /* values_return */
+);
+
+extern int XGetPointerControl(
+ Display* /* display */,
+ int* /* accel_numerator_return */,
+ int* /* accel_denominator_return */,
+ int* /* threshold_return */
+);
+
+extern int XGetPointerMapping(
+ Display* /* display */,
+ unsigned char* /* map_return */,
+ int /* nmap */
+);
+
+extern int XGetScreenSaver(
+ Display* /* display */,
+ int* /* timeout_return */,
+ int* /* interval_return */,
+ int* /* prefer_blanking_return */,
+ int* /* allow_exposures_return */
+);
+
+extern Status XGetTransientForHint(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* prop_window_return */
+);
+
+extern int XGetWindowProperty(
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ long /* long_offset */,
+ long /* long_length */,
+ Bool /* delete */,
+ Atom /* req_type */,
+ Atom* /* actual_type_return */,
+ int* /* actual_format_return */,
+ unsigned long* /* nitems_return */,
+ unsigned long* /* bytes_after_return */,
+ unsigned char** /* prop_return */
+);
+
+extern Status XGetWindowAttributes(
+ Display* /* display */,
+ Window /* w */,
+ XWindowAttributes* /* window_attributes_return */
+);
+
+extern int XGrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+);
+
+extern int XGrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+);
+
+extern int XGrabKeyboard(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+);
+
+extern int XGrabPointer(
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+);
+
+extern int XGrabServer(
+ Display* /* display */
+);
+
+extern int XHeightMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XHeightOfScreen(
+ Screen* /* screen */
+);
+
+extern int XIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XImageByteOrder(
+ Display* /* display */
+);
+
+extern int XInstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern KeyCode XKeysymToKeycode(
+ Display* /* display */,
+ KeySym /* keysym */
+);
+
+extern int XKillClient(
+ Display* /* display */,
+ XID /* resource */
+);
+
+extern Status XLookupColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* exact_def_return */,
+ XColor* /* screen_def_return */
+);
+
+extern int XLowerWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapRaised(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XMaskEvent(
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XMaxCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMinCmapsOfScreen(
+ Screen* /* screen */
+);
+
+extern int XMoveResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XMoveWindow(
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XNextEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XNoOp(
+ Display* /* display */
+);
+
+extern Status XParseColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* spec */,
+ XColor* /* exact_def_return */
+);
+
+extern int XParseGeometry(
+ _Xconst char* /* parsestring */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XPeekEvent(
+ Display* /* display */,
+ XEvent* /* event_return */
+);
+
+extern int XPeekIfEvent(
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+ ) /* predicate */,
+ XPointer /* arg */
+);
+
+extern int XPending(
+ Display* /* display */
+);
+
+extern int XPlanesOfScreen(
+ Screen* /* screen */
+);
+
+extern int XProtocolRevision(
+ Display* /* display */
+);
+
+extern int XProtocolVersion(
+ Display* /* display */
+);
+
+
+extern int XPutBackEvent(
+ Display* /* display */,
+ XEvent* /* event */
+);
+
+extern int XPutImage(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XImage* /* image */,
+ int /* src_x */,
+ int /* src_y */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XQLength(
+ Display* /* display */
+);
+
+extern Status XQueryBestCursor(
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestSize(
+ Display* /* display */,
+ int /* class */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestStipple(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern Status XQueryBestTile(
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+);
+
+extern int XQueryColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* def_in_out */
+);
+
+extern int XQueryColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* defs_in_out */,
+ int /* ncolors */
+);
+
+extern Bool XQueryExtension(
+ Display* /* display */,
+ _Xconst char* /* name */,
+ int* /* major_opcode_return */,
+ int* /* first_event_return */,
+ int* /* first_error_return */
+);
+
+extern int XQueryKeymap(
+ Display* /* display */,
+ char [32] /* keys_return */
+);
+
+extern Bool XQueryPointer(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* child_return */,
+ int* /* root_x_return */,
+ int* /* root_y_return */,
+ int* /* win_x_return */,
+ int* /* win_y_return */,
+ unsigned int* /* mask_return */
+);
+
+extern int XQueryTextExtents(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XQueryTextExtents16(
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern Status XQueryTree(
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* parent_return */,
+ Window** /* children_return */,
+ unsigned int* /* nchildren_return */
+);
+
+extern int XRaiseWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XReadBitmapFile(
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ Pixmap* /* bitmap_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XReadBitmapFileData(
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* data_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+);
+
+extern int XRebindKeysym(
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* list */,
+ int /* mod_count */,
+ _Xconst unsigned char* /* string */,
+ int /* bytes_string */
+);
+
+extern int XRecolorCursor(
+ Display* /* display */,
+ Cursor /* cursor */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+);
+
+extern int XRefreshKeyboardMapping(
+ XMappingEvent* /* event_map */
+);
+
+extern int XRemoveFromSaveSet(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XRemoveHost(
+ Display* /* display */,
+ XHostAddress* /* host */
+);
+
+extern int XRemoveHosts(
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+);
+
+extern int XReparentWindow(
+ Display* /* display */,
+ Window /* w */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */
+);
+
+extern int XResetScreenSaver(
+ Display* /* display */
+);
+
+extern int XResizeWindow(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */,
+ unsigned int /* height */
+);
+
+extern int XRestackWindows(
+ Display* /* display */,
+ Window* /* windows */,
+ int /* nwindows */
+);
+
+extern int XRotateBuffers(
+ Display* /* display */,
+ int /* rotate */
+);
+
+extern int XRotateWindowProperties(
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* properties */,
+ int /* num_prop */,
+ int /* npositions */
+);
+
+extern int XScreenCount(
+ Display* /* display */
+);
+
+extern int XSelectInput(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */
+);
+
+extern Status XSendEvent(
+ Display* /* display */,
+ Window /* w */,
+ Bool /* propagate */,
+ long /* event_mask */,
+ XEvent* /* event_send */
+);
+
+extern int XSetAccessControl(
+ Display* /* display */,
+ int /* mode */
+);
+
+extern int XSetArcMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* arc_mode */
+);
+
+extern int XSetBackground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* background */
+);
+
+extern int XSetClipMask(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* pixmap */
+);
+
+extern int XSetClipOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */
+);
+
+extern int XSetClipRectangles(
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */,
+ XRectangle* /* rectangles */,
+ int /* n */,
+ int /* ordering */
+);
+
+extern int XSetCloseDownMode(
+ Display* /* display */,
+ int /* close_mode */
+);
+
+extern int XSetCommand(
+ Display* /* display */,
+ Window /* w */,
+ char** /* argv */,
+ int /* argc */
+);
+
+extern int XSetDashes(
+ Display* /* display */,
+ GC /* gc */,
+ int /* dash_offset */,
+ _Xconst char* /* dash_list */,
+ int /* n */
+);
+
+extern int XSetFillRule(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_rule */
+);
+
+extern int XSetFillStyle(
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_style */
+);
+
+extern int XSetFont(
+ Display* /* display */,
+ GC /* gc */,
+ Font /* font */
+);
+
+extern int XSetFontPath(
+ Display* /* display */,
+ char** /* directories */,
+ int /* ndirs */
+);
+
+extern int XSetForeground(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */
+);
+
+extern int XSetFunction(
+ Display* /* display */,
+ GC /* gc */,
+ int /* function */
+);
+
+extern int XSetGraphicsExposures(
+ Display* /* display */,
+ GC /* gc */,
+ Bool /* graphics_exposures */
+);
+
+extern int XSetIconName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* icon_name */
+);
+
+extern int XSetInputFocus(
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+);
+
+extern int XSetLineAttributes(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned int /* line_width */,
+ int /* line_style */,
+ int /* cap_style */,
+ int /* join_style */
+);
+
+extern int XSetModifierMapping(
+ Display* /* display */,
+ XModifierKeymap* /* modmap */
+);
+
+extern int XSetPlaneMask(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetPointerMapping(
+ Display* /* display */,
+ _Xconst unsigned char* /* map */,
+ int /* nmap */
+);
+
+extern int XSetScreenSaver(
+ Display* /* display */,
+ int /* timeout */,
+ int /* interval */,
+ int /* prefer_blanking */,
+ int /* allow_exposures */
+);
+
+extern int XSetSelectionOwner(
+ Display* /* display */,
+ Atom /* selection */,
+ Window /* owner */,
+ Time /* time */
+);
+
+extern int XSetState(
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */,
+ unsigned long /* background */,
+ int /* function */,
+ unsigned long /* plane_mask */
+);
+
+extern int XSetStipple(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* stipple */
+);
+
+extern int XSetSubwindowMode(
+ Display* /* display */,
+ GC /* gc */,
+ int /* subwindow_mode */
+);
+
+extern int XSetTSOrigin(
+ Display* /* display */,
+ GC /* gc */,
+ int /* ts_x_origin */,
+ int /* ts_y_origin */
+);
+
+extern int XSetTile(
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* tile */
+);
+
+extern int XSetWindowBackground(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* background_pixel */
+);
+
+extern int XSetWindowBackgroundPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* background_pixmap */
+);
+
+extern int XSetWindowBorder(
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* border_pixel */
+);
+
+extern int XSetWindowBorderPixmap(
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* border_pixmap */
+);
+
+extern int XSetWindowBorderWidth(
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */
+);
+
+extern int XSetWindowColormap(
+ Display* /* display */,
+ Window /* w */,
+ Colormap /* colormap */
+);
+
+extern int XStoreBuffer(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */,
+ int /* buffer */
+);
+
+extern int XStoreBytes(
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */
+);
+
+extern int XStoreColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */
+);
+
+extern int XStoreColors(
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */,
+ int /* ncolors */
+);
+
+extern int XStoreName(
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */
+);
+
+extern int XStoreNamedColor(
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color */,
+ unsigned long /* pixel */,
+ int /* flags */
+);
+
+extern int XSync(
+ Display* /* display */,
+ Bool /* discard */
+);
+
+extern int XTextExtents(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextExtents16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+);
+
+extern int XTextWidth(
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+);
+
+extern int XTextWidth16(
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+);
+
+extern Bool XTranslateCoordinates(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ int* /* dest_x_return */,
+ int* /* dest_y_return */,
+ Window* /* child_return */
+);
+
+extern int XUndefineCursor(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUngrabButton(
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKey(
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+);
+
+extern int XUngrabKeyboard(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabPointer(
+ Display* /* display */,
+ Time /* time */
+);
+
+extern int XUngrabServer(
+ Display* /* display */
+);
+
+extern int XUninstallColormap(
+ Display* /* display */,
+ Colormap /* colormap */
+);
+
+extern int XUnloadFont(
+ Display* /* display */,
+ Font /* font */
+);
+
+extern int XUnmapSubwindows(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XUnmapWindow(
+ Display* /* display */,
+ Window /* w */
+);
+
+extern int XVendorRelease(
+ Display* /* display */
+);
+
+extern int XWarpPointer(
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* src_width */,
+ unsigned int /* src_height */,
+ int /* dest_x */,
+ int /* dest_y */
+);
+
+extern int XWidthMMOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWidthOfScreen(
+ Screen* /* screen */
+);
+
+extern int XWindowEvent(
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+);
+
+extern int XWriteBitmapFile(
+ Display* /* display */,
+ _Xconst char* /* filename */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* x_hot */,
+ int /* y_hot */
+);
+
+extern Bool XSupportsLocale (void);
+
+extern char *XSetLocaleModifiers(
+ const char* /* modifier_list */
+);
+
+extern XOM XOpenOM(
+ Display* /* display */,
+ struct _XrmHashBucketRec* /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+);
+
+extern Status XCloseOM(
+ XOM /* om */
+);
+
+extern char *XSetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOMValues(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfOM(
+ XOM /* om */
+);
+
+extern char *XLocaleOfOM(
+ XOM /* om */
+);
+
+extern XOC XCreateOC(
+ XOM /* om */,
+ ...
+) _X_SENTINEL(0);
+
+extern void XDestroyOC(
+ XOC /* oc */
+);
+
+extern XOM XOMOfOC(
+ XOC /* oc */
+);
+
+extern char *XSetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern char *XGetOCValues(
+ XOC /* oc */,
+ ...
+) _X_SENTINEL(0);
+
+extern XFontSet XCreateFontSet(
+ Display* /* display */,
+ _Xconst char* /* base_font_name_list */,
+ char*** /* missing_charset_list */,
+ int* /* missing_charset_count */,
+ char** /* def_string */
+);
+
+extern void XFreeFontSet(
+ Display* /* display */,
+ XFontSet /* font_set */
+);
+
+extern int XFontsOfFontSet(
+ XFontSet /* font_set */,
+ XFontStruct*** /* font_struct_list */,
+ char*** /* font_name_list */
+);
+
+extern char *XBaseFontNameListOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern char *XLocaleOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XDirectionalDependentDrawing(
+ XFontSet /* font_set */
+);
+
+extern Bool XContextualDrawing(
+ XFontSet /* font_set */
+);
+
+extern XFontSetExtents *XExtentsOfFontSet(
+ XFontSet /* font_set */
+);
+
+extern int XmbTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XwcTextEscapement(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern int Xutf8TextEscapement(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern int XmbTextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int XwcTextExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern int Xutf8TextExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XmbTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status XwcTextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern Status Xutf8TextPerCharExtents(
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+);
+
+extern void XmbDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XwcDrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XwcTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void Xutf8DrawText(
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+);
+
+extern void XmbDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XmbDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern void XwcDrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+);
+
+extern void Xutf8DrawImageString(
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+);
+
+extern XIM XOpenIM(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+);
+
+extern Status XCloseIM(
+ XIM /* im */
+);
+
+extern char *XGetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern char *XSetIMValues(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern Display *XDisplayOfIM(
+ XIM /* im */
+);
+
+extern char *XLocaleOfIM(
+ XIM /* im*/
+);
+
+extern XIC XCreateIC(
+ XIM /* im */, ...
+) _X_SENTINEL(0);
+
+extern void XDestroyIC(
+ XIC /* ic */
+);
+
+extern void XSetICFocus(
+ XIC /* ic */
+);
+
+extern void XUnsetICFocus(
+ XIC /* ic */
+);
+
+extern wchar_t *XwcResetIC(
+ XIC /* ic */
+);
+
+extern char *XmbResetIC(
+ XIC /* ic */
+);
+
+extern char *Xutf8ResetIC(
+ XIC /* ic */
+);
+
+extern char *XSetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern char *XGetICValues(
+ XIC /* ic */, ...
+) _X_SENTINEL(0);
+
+extern XIM XIMOfIC(
+ XIC /* ic */
+);
+
+extern Bool XFilterEvent(
+ XEvent* /* event */,
+ Window /* window */
+);
+
+extern int XmbLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int XwcLookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ wchar_t* /* buffer_return */,
+ int /* wchars_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern int Xutf8LookupString(
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+);
+
+extern XVaNestedList XVaCreateNestedList(
+ int /*unused*/, ...
+) _X_SENTINEL(0);
+
+/* internal connections for IMs */
+
+extern Bool XRegisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern Bool XUnregisterIMInstantiateCallback(
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIDProc /* callback */,
+ XPointer /* client_data */
+);
+
+typedef void (*XConnectionWatchProc)(
+ Display* /* dpy */,
+ XPointer /* client_data */,
+ int /* fd */,
+ Bool /* opening */, /* open or close flag */
+ XPointer* /* watch_data */ /* open sets, close uses */
+);
+
+
+extern Status XInternalConnectionNumbers(
+ Display* /* dpy */,
+ int** /* fd_return */,
+ int* /* count_return */
+);
+
+extern void XProcessInternalConnection(
+ Display* /* dpy */,
+ int /* fd */
+);
+
+extern Status XAddConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XRemoveConnectionWatch(
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+);
+
+extern void XSetAuthorization(
+ char * /* name */,
+ int /* namelen */,
+ char * /* data */,
+ int /* datalen */
+);
+
+extern int _Xmbtowc(
+ wchar_t * /* wstr */,
+ char * /* str */,
+ int /* len */
+);
+
+extern int _Xwctomb(
+ char * /* str */,
+ wchar_t /* wc */
+);
+
+extern Bool XGetEventData(
+ Display* /* dpy */,
+ XGenericEventCookie* /* cookie*/
+);
+
+extern void XFreeEventData(
+ Display* /* dpy */,
+ XGenericEventCookie* /* cookie*/
+);
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _X11_XLIB_H_ */
diff --git a/src/X11/include/X11/Xosdefs.h b/src/X11/include/X11/Xosdefs.h
new file mode 100644
index 00000000..33eaee43
--- /dev/null
+++ b/src/X11/include/X11/Xosdefs.h
@@ -0,0 +1,116 @@
+/*
+ * O/S-dependent (mis)feature macro definitions
+ *
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+#ifndef _XOSDEFS_H_
+# define _XOSDEFS_H_
+
+/*
+ * X_NOT_POSIX means does not have POSIX header files. Lack of this
+ * symbol does NOT mean that the POSIX environment is the default.
+ * You may still have to define _POSIX_SOURCE to get it.
+ */
+
+
+# ifdef _SCO_DS
+# ifndef __SCO__
+# define __SCO__
+# endif
+# endif
+
+# ifdef __i386__
+# ifdef SYSV
+# if !defined(__SCO__) && \
+ !defined(__UNIXWARE__) && !defined(__sun)
+# if !defined(_POSIX_SOURCE)
+# define X_NOT_POSIX
+# endif
+# endif
+# endif
+# endif
+
+# ifdef __sun
+/* Imake configs define SVR4 on Solaris, but cc & gcc only define __SVR4
+ * This check allows non-Imake configured programs to build correctly.
+ */
+# if defined(__SVR4) && !defined(SVR4)
+# define SVR4 1
+# endif
+# ifdef SVR4
+/* define this to whatever it needs to be */
+# define X_POSIX_C_SOURCE 199300L
+# endif
+# endif
+
+# ifdef WIN32
+# ifndef _POSIX_
+# define X_NOT_POSIX
+# endif
+# endif
+
+
+# ifdef __APPLE__
+# define NULL_NOT_ZERO
+
+/* Defining any of these will sanitize the namespace to JUST want is defined by
+ * that particular standard. If that happens, we don't get some expected
+ * prototypes, typedefs, etc (like fd_mask). We can define _DARWIN_C_SOURCE to
+ * loosen our belts a tad.
+ */
+# if defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE)
+# ifndef _DARWIN_C_SOURCE
+# define _DARWIN_C_SOURCE
+# endif
+# endif
+
+# endif
+
+# ifdef __GNU__
+# ifndef PATH_MAX
+# define PATH_MAX 4096
+# endif
+# ifndef MAXPATHLEN
+# define MAXPATHLEN 4096
+# endif
+# endif
+
+# if defined(__SCO__) || defined(__UNIXWARE__)
+# ifndef PATH_MAX
+# define PATH_MAX 1024
+# endif
+# ifndef MAXPATHLEN
+# define MAXPATHLEN 1024
+# endif
+# endif
+
+# if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) \
+ || defined(__APPLE__) || defined(__DragonFly__)
+# ifndef CSRG_BASED
+# define CSRG_BASED
+# endif
+# endif
+
+#endif /* _XOSDEFS_H_ */
+
diff --git a/src/X11/lib/libX11.so b/src/X11/lib/libX11.so
new file mode 100644
index 00000000..f0ef0e85
Binary files /dev/null and b/src/X11/lib/libX11.so differ
diff --git a/src/defines.hpp b/src/defines.hpp
index 91700c63..3a897b2f 100644
--- a/src/defines.hpp
+++ b/src/defines.hpp
@@ -23,8 +23,8 @@
//#define TEMPERATURE // enables temperature extension; set fixed-temperature nodes with TYPE_T (similar to EQUILIBRIUM_BOUNDARIES); allocates an extra 32 (FP32) or 18 (FP16) Bytes/node
//#define SUBGRID // enables Smagorinsky-Lilly subgrid turbulence model to keep simulations with very large Reynolds number stable
-//#define WINDOWS_GRAPHICS // enable interactive graphics in Windows; start/pause the simulation by pressing P
-//#define CONSOLE_GRAPHICS // enable interactive graphics in the console; start/pause the simulation by pressing P
+//#define INTERACTIVE_GRAPHICS // enable interactive graphics; start/pause the simulation by pressing P; either Windows or Linux X11 desktop must be available; on Linux: change to "compile on Linux with X11" command in make.sh
+//#define INTERACTIVE_GRAPHICS_ASCII // enable interactive graphics in ASCII mode the console; start/pause the simulation by pressing P
//#define GRAPHICS // run FluidX3D in the console, but still enable graphics functionality for writing rendered frames to the hard drive
#define GRAPHICS_FRAME_WIDTH 3840 // set frame width if only GRAPHICS is enabled
@@ -64,8 +64,8 @@
#undef SURFACE
#undef TEMPERATURE
#undef SUBGRID
-#undef WINDOWS_GRAPHICS
-#undef CONSOLE_GRAPHICS
+#undef INTERACTIVE_GRAPHICS
+#undef INTERACTIVE_GRAPHICS_ASCII
#undef GRAPHICS
#endif // BENCHMARK
@@ -77,9 +77,6 @@
#define VOLUME_FORCE
#endif // TEMPERATURE
-#ifdef WINDOWS_GRAPHICS
+#if defined(INTERACTIVE_GRAPHICS) || defined(INTERACTIVE_GRAPHICS_ASCII)
#define GRAPHICS
-#endif // WINDOWS_GRAPHICS
-#ifdef CONSOLE_GRAPHICS
-#define GRAPHICS
-#endif // CONSOLE_GRAPHICS
\ No newline at end of file
+#endif // INTERACTIVE_GRAPHICS || INTERACTIVE_GRAPHICS_ASCII
\ No newline at end of file
diff --git a/src/graphics.cpp b/src/graphics.cpp
index a7322602..0b803f12 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -12,195 +12,9 @@ Camera camera;
bool key_E=false, key_G=false, key_H=false, key_O=false, key_P=false, key_Q=false, key_T=false, key_Z=false;
bool key_1=false, key_2=false, key_3=false, key_4=false, key_5=false, key_6=false, key_7=false, key_8=false, key_9=false, key_0=false;
-const uint max_light_sources = 100u; // maximal number of light sources
+const uint light_sources_N = 100u; // maximal number of light sources
+float3 light_sources[light_sources_N]; // coordinates of light sources
uint light_sources_n = 0u; // number of light sources
-float3 light_sources[max_light_sources]; // coordinates of light sources
-bool lockmouse = false; // mouse movement won't change camera view when this is true
-bool autorotation = false; // autorotation
-double mx=0.0, my=0.0, dmx=0.0, dmy=0.0; // mouse position
-float zo=0.0f, dzo=0.0f; // zoom and perspective
-float fl=0.0f, fvel=0.05f; // free camera speed
-
-void update_rotation(const double arx, const double ary) {
-#ifdef WINDOWS_GRAPHICS
- SetCursorPos(camera.width/2, camera.height/2);
-#endif // WINDOWS_GRAPHICS
- camera.rx += arx*pi/180.0;
- camera.ry += ary*pi/180.0;
- camera.rx = fmod(camera.rx, 2.0*pi);
- camera.ry = clamp(camera.ry, 0.5*pi, 1.5*pi);
- camera.update_matrix();
-}
-
-void key_bindings(const int key) {
- camera.key_update = true;
- switch(key) {
- // reserved keys for graphics: W,A,S,D, I,J,K,L, R,U, V,B, C,VK_SPACE, Y,X, N,M
- //case 'A': key_A = !key_A; break;
- //case 'B': key_B = !key_B; break;
- //case 'C': key_C = !key_C; break;
- //case 'D': key_D = !key_D; break;
- case 'E': key_E = !key_E; break;
- //case 'F': key_F = !key_F; break;
- case 'G': key_G = !key_G; break;
- case 'H': key_H = !key_H; break;
- //case 'I': key_I = !key_I; break;
- //case 'J': key_J = !key_J; break;
- //case 'K': key_K = !key_K; break;
- //case 'L': key_L = !key_L; break;
- //case 'M': key_M = !key_M; break;
- //case 'N': key_N = !key_N; break;
- case 'O': key_O = !key_O; break;
- case 'P': key_P = !key_P; break;
- case 'Q': key_Q = !key_Q; break;
- //case 'R': key_R = !key_R; break;
- //case 'S': key_S = !key_S; break;
- case 'T': key_T = !key_T; break;
- //case 'U': key_U = !key_U; break;
- //case 'V': key_V = !key_V; break;
- //case 'W': key_W = !key_W; break;
- //case 'X': key_X = !key_X; break;
- //case 'Y': key_Y = !key_Y; break;
- case 'Z': key_Z = !key_Z; break;
-
- case '1': key_1 = !key_1; break;
- case '2': key_2 = !key_2; break;
- case '3': key_3 = !key_3; break;
- case '4': key_4 = !key_4; break;
- case '5': key_5 = !key_5; break;
- case '6': key_6 = !key_6; break;
- case '7': key_7 = !key_7; break;
- case '8': key_8 = !key_8; break;
- case '9': key_9 = !key_9; break;
- case '0': key_0 = !key_0; break;
-
- case 'R': autorotation = !autorotation; break;
- case 'U': lockmouse = !lockmouse; break;
- case 'I':
- if(lockmouse) {
- double d = (camera.ry*18.0/pi)-(double)((int)(camera.ry*18.0f/pi));
- d = d<1E-6 ? 1.0 : 1.0-d;
- update_rotation(0.0, 10.0*d);
- }
- break;
- case 'J':
- if(lockmouse) {
- double d = (camera.rx*18.0/pi)-(double)((int)(camera.rx*18.0/pi));
- d = d<1E-6 ? 1.0 : 1.0-d;
- update_rotation(10.0*d, 0.0);
- }
- break;
- case 'K':
- if(lockmouse) {
- double d = (camera.ry*18.0/pi)-(double)((int)(camera.ry*18.0/pi));
- d = d<1E-6 ? 1.0f : d;
- update_rotation(0.0, -10.0*d);
- }
- break;
- case 'L':
- if(lockmouse) {
- double d = (camera.rx*18.0/pi)-(double)((int)(camera.rx*18.0/pi));
- d = d<1E-6 ? 1.0 : d;
- update_rotation(-10.0*d, 0.0);
- }
- break;
- case 'V': camera.vr = !camera.vr; break;
- case 'B': camera.tv = !camera.tv; break;
- case ',': case 0xBC: // 0xBC is Windows Virtual-Key Code for ','
- if(!camera.free) { // centered camera zoom
- dzo -= 1.0f;
- } else if(!lockmouse) { // free camera speed
- fl -= 1.0f;
- fvel = 0.05f*exp(fl*0.25f);
- }
- break;
- case '.': case 0xBE: // 0xBE is Windows Virtual-Key Code for '.'
- if(!camera.free) { // centered camera zoom
- dzo += 1.0f;
- } else if(!lockmouse) { // free camera speed
- fl += 1.0f;
- fvel = 0.05f*exp(fl*0.25f);
- }
- break;
- case 'F':
- camera.free = !camera.free;
- if(!camera.free) {
- camera.zoom = exp(zo*0.25f);
- } else {
- camera.zoom = 1E16f;
- }
- break;
- case 27:
- running = false;
- exit(0);
- }
-
-#ifndef WINDOWS_GRAPHICS
- if(camera.free) { // move free camera
- if(key=='W') {
- camera.pos.x += camera.R.xy*camera.R.yz*fvel;
- camera.pos.y -= camera.R.xx*camera.R.yz*fvel;
- camera.pos.z -= camera.R.zz*fvel;
- }
- if(key=='A') {
- camera.pos.x -= camera.R.xx*fvel;
- camera.pos.y -= camera.R.xy*fvel;
- }
- if(key=='S') {
- camera.pos.x -= camera.R.xy*camera.R.yz*fvel;
- camera.pos.y += camera.R.xx*camera.R.yz*fvel;
- camera.pos.z += camera.R.zz*fvel;
- }
- if(key=='D') {
- camera.pos.x += camera.R.xx*fvel;
- camera.pos.y += camera.R.xy*fvel;
- }
- if(key==' ') {
- camera.pos.x -= camera.R.xy*camera.R.zz*fvel;
- camera.pos.y += camera.R.xx*camera.R.zz*fvel;
- camera.pos.z -= camera.R.yz*fvel;
- }
- if(key=='C') {
- camera.pos.x += camera.R.xy*camera.R.zz*fvel;
- camera.pos.y -= camera.R.xx*camera.R.zz*fvel;
- camera.pos.z += camera.R.yz*fvel;
- }
- }
- if(!lockmouse) {
- if(key=='I') dmy += camera.ms; // rotating camera with keys
- if(key=='J') dmx += camera.ms;
- if(key=='K') dmy -= camera.ms;
- if(key=='L') dmx -= camera.ms;
- }
- if(key=='Y') { // adjusting field of view
- camera.fov = fmin(camera.fov<1.0f ? 1.0f : camera.fov+1.0f, 179.0f);
- camera.dis = 0.5f*(float)camera.width/tan(camera.fov*pif/360.0f);
- }
- if(key=='X') {
- camera.fov = fmax(camera.fov-1.0f, 1.0f);
- camera.dis = 0.5f*(float)camera.width/tan(camera.fov*pif/360.0f);
- }
- if(key=='N') { // adjust camera.vr eye distance
- camera.eye_distance -= 0.2f;
- if(camera.eye_distance<0.0f) camera.eye_distance = 0.0f;
- }
- if(key=='M') {
- camera.eye_distance += 0.2f;
- }
-#endif // WINDOWS_GRAPHICS
-}
-
-void set_zoom(const float rad) {
- camera.zoom = 0.5f*(float)min(camera.width, camera.height)/rad;
- zo = 4.0f*log(camera.zoom);
- dzo = zo;
-}
-void set_light(const uint i, const float3& position) {
- if(i 2D
float3 t, r;
@@ -218,6 +32,9 @@ bool convert(int& rx, int& ry, float& rz, const float3& p, const int stereo) { /
rz = r.z;
return true;
}
+bool is_off_screen(const int x, const int y) { // check if point is off screen
+ return x<0||x>=(int)camera.width ||y<0||y>=(int)camera.height; // entire screen
+}
bool is_off_screen(const int x, const int y, const int stereo) { // check if point is off screen
switch(stereo) {
default: return x< 0||x>=(int)camera.width ||y<0||y>=(int)camera.height; // entire screen
@@ -243,7 +60,13 @@ bool intersects_screen(const int x0, const int y0, const int x1, const int y1, c
}
return false;
}
-Color lighting(const Color& c, const float3& p, const float3& normal, const bool translucent=false) {
+void set_light(const uint i, const float3& position) {
+ if(i
-#ifndef UTILITIES_REGEX
-#include // included in in "utilities.hpp"
-#endif // UTILITIES_REGEX
-HWND hWnd;
-HDC frontDC, backDC;
-HBITMAP frame;
-
-void key_hold() {
- if(!camera.free) {
- zo = 0.8f*zo+0.2f*dzo; // continuous camera.zoom
- camera.zoom = exp(zo*0.25f);
- } else { // move free camera
- if(GetAsyncKeyState('W')<0) {
- camera.pos.x += camera.R.xy*camera.R.yz*fvel;
- camera.pos.y -= camera.R.xx*camera.R.yz*fvel;
- camera.pos.z -= camera.R.zz*fvel;
- }
- if(GetAsyncKeyState('A')<0) {
- camera.pos.x -= camera.R.xx*fvel;
- camera.pos.y -= camera.R.xy*fvel;
- }
- if(GetAsyncKeyState('S')<0) {
- camera.pos.x -= camera.R.xy*camera.R.yz*fvel;
- camera.pos.y += camera.R.xx*camera.R.yz*fvel;
- camera.pos.z += camera.R.zz*fvel;
- }
- if(GetAsyncKeyState('D')<0) {
- camera.pos.x += camera.R.xx*fvel;
- camera.pos.y += camera.R.xy*fvel;
- }
- if(GetAsyncKeyState(VK_SPACE)<0) {
- camera.pos.x -= camera.R.xy*camera.R.zz*fvel;
- camera.pos.y += camera.R.xx*camera.R.zz*fvel;
- camera.pos.z -= camera.R.yz*fvel;
- }
- if(GetAsyncKeyState('C')<0) {
- camera.pos.x += camera.R.xy*camera.R.zz*fvel;
- camera.pos.y -= camera.R.xx*camera.R.zz*fvel;
- camera.pos.z += camera.R.yz*fvel;
- }
- }
- if(!lockmouse) {
- if(GetAsyncKeyState('I')<0) dmy += camera.ms; // rotate camera with keys
- if(GetAsyncKeyState('J')<0) dmx += camera.ms;
- if(GetAsyncKeyState('K')<0) dmy -= camera.ms;
- if(GetAsyncKeyState('L')<0) dmx -= camera.ms;
- }
- if(autorotation) update_rotation(-1, 0);
- if(GetAsyncKeyState('Y')<0) { // adjust field of view
- camera.fov = fmin(camera.fov<1.0f ? 1.0f : camera.fov+1.0f, 179.0f);
- camera.dis = 0.5f*(float)camera.width/tan(camera.fov*pif/360.0f);
- }
- if(GetAsyncKeyState('X')<0) {
- camera.fov = fmax(camera.fov-1.0f, 1.0f);
- camera.dis = 0.5f*(float)camera.width/tan(camera.fov*pif/360.0f);
- }
- if(GetAsyncKeyState('N')<0) { // adjust camera.vr eye distance
- camera.eye_distance = fmax(camera.eye_distance-0.2f, 0.0f);
- }
- if(GetAsyncKeyState('M')<0) {
- camera.eye_distance += 0.2f;
- }
- mx = 0.8*mx+0.2*dmx; // continuous mouse movement
- my = 0.8*my+0.2*dmy;
- dmx = 0.0;
- dmy = 0.0;
- if(!lockmouse) update_rotation(mx, my);
-}
-
-void draw_bitmap(const void* buffer) {
- SetBitmapBits(frame, 4*camera.width*camera.height, buffer);
-}
-void draw_label(const Color& c, const string& s, const int x, const int y) {
- SetTextColor(backDC, RGB(c.r, c.g, c.b));
- TextOut(backDC, x, y, s.c_str(), (int)s.length());
- if(camera.vr) {
- if(x-camera.width/2>0) {
- TextOut(backDC, x-camera.width/2, y, s.c_str(), (int)s.length());
- } else if(x+camera.width/2c = c;
- this->z = z;
- this->x = x+1;
- this->y = y+1;
- }
- void draw() const override {
- draw_pixel(c, x, y);
- }
-};
-class Circle: public Shape {
-private:
- int x, y, r;
-public:
- Circle(const Color& c, const float z, const int x, const int y, const int r) {
- this->c = c;
- this->z = z;
- this->x = x;
- this->y = y;
- this->r = r;
- }
- void draw() const override {
- draw_circle(c, x, y, r);
- }
-};
-class Line: public Shape {
-private:
- int x0, y0, x1, y1;
-public:
- Line(const Color& c, float z, const int x0, const int y0, const int x1, const int y1) {
- this->c = c;
- this->z = z;
- this->x0 = x0;
- this->y0 = y0;
- this->x1 = x1;
- this->y1 = y1;
- }
- void draw() const override {
- draw_line(c, x0, y0, x1, y1);
- }
-};
-class Triangle: public Shape {
-private:
- POINT p[3];
-public:
- Triangle(const Color& c, const float z, const int x[3], const int y[3]) {
- this->c = c;
- this->z = z;
- p[0].x = x[0]; p[0].y = y[0];
- p[1].x = x[1]; p[1].y = y[1];
- p[2].x = x[2]; p[2].y = y[2];
- }
- void draw() const override {
- SetDCPenColor(backDC, RGB(c.r, c.g, c.b));
- SetDCBrushColor(backDC, RGB(c.r, c.g, c.b));
- Polygon(backDC, p, 3);
- }
-};
-class Quadrangle: public Shape {
-private:
- POINT p[4];
-public:
- Quadrangle(const Color& c, const float z, const int x[4], const int y[4]) {
- this->c = c;
- this->z = z;
- p[0].x = x[0]; p[0].y = y[0];
- p[1].x = x[1]; p[1].y = y[1];
- p[2].x = x[2]; p[2].y = y[2];
- p[3].x = x[3]; p[3].y = y[3];
- }
- void draw() const override {
- SetDCPenColor(backDC, RGB(c.r, c.g, c.b));
- SetDCBrushColor(backDC, RGB(c.r, c.g, c.b));
- Polygon(backDC, p, 4);
- }
-};
-class Text: public Shape {
-private:
- int x, y;
- string s;
-public:
- Text(const Color& c, const float z, const string& s, const int x, const int y) {
- this->c = c;
- this->z = z;
- this->s = s;
- this->x = x;
- this->y = y;
- }
- void draw() const override {
- draw_text(c, s, x, y);
- }
-};
-
-const uint maxNum = 10000u; // maximum number of 3D shapes (lines, circles, triangles) that can be drawn per frame
-uint nums=0u, numr=0u;
-Shape* shapes[maxNum]; // shapes for main or left screen
-Shape* rights[maxNum]; // shapes for right screen
-
-void convert_pixel(const Color& c, const float3& p, const int stereo) {
+ return ::color((int)(br*(float)red(color)), (int)(br*(float)green(color)), (int)(br*(float)blue(color)));
+}
+int color_mix_3(const int c0, const int c1, const int c2, const float w0, const float w1, const float w2) { // w0+w1+w2 = 1
+ const int r0=red(c0), g0=green(c0), b0=blue(c0);
+ const int r1=red(c1), g1=green(c1), b1=blue(c1);
+ const int r2=red(c2), g2=green(c2), b2=blue(c2);
+ const float3 fc0=float3((float)r0, (float)g0, (float)b0), fc1=float3((float)r1, (float)g1, (float)b1), fc2=float3((float)r2, (float)g2, (float)b2);
+ const float3 fcm = w0*fc0+(w1*fc1+(w2*fc2+float3(0.5f, 0.5f, 0.5f)));
+ return ::color((int)fcm.x, (int)fcm.y, (int)fcm.z);
+}
+ulong get_font_pixels(const int character) {
+ ulong pixels[224] = { // font data (my own 6x11 monospace font)
+ 0x0000000000000000ull, 0x2082082080082000ull, 0x5145000000000000ull, 0x514F94514F945000ull, 0x21CAA870AA9C2000ull, 0x4AA50421052A9000ull, 0x2145085628A27400ull, 0x2082000000000000ull,
+ 0x0842082082040800ull, 0x4081041041084000ull, 0xA9C72A0000000000ull, 0x000208F882000000ull, 0x0000000000041080ull, 0x000000F800000000ull, 0x00000000000C3000ull, 0x0821042104208000ull,
+ 0x7228A28A28A27000ull, 0x0862928820820800ull, 0x722882108420F800ull, 0x7228823028A27000ull, 0x10C51493E1041000ull, 0xFA083C082082F000ull, 0x722820F228A27000ull, 0xF821042084104000ull,
+ 0x7228A27228A27000ull, 0x7228A27820A27000ull, 0x00030C00030C0000ull, 0x00030C00030C1080ull, 0x0021084081020000ull, 0x00003E03E0000000ull, 0x0204081084200000ull, 0x7228842080082000ull,
+ 0x7A1B75D75D6E81E0ull, 0x20851453E8A28800ull, 0xF228A2F228A2F000ull, 0x7228208208227000ull, 0xF228A28A28A2F000ull, 0xFA0820F20820F800ull, 0xFA0820F208208000ull, 0x722820B228A27000ull,
+ 0x8A28A2FA28A28800ull, 0xF88208208208F800ull, 0xF820820820A27000ull, 0x8A4928C289248800ull, 0x820820820820F800ull, 0x8B6DAAAA28A28800ull, 0x8B2CAAAAA9A68800ull, 0xFA28A28A28A2F800ull,
+ 0xF228A2F208208000ull, 0x7228A28A28A46800ull, 0xF228A2F289228800ull, 0x7228207020A27000ull, 0xF882082082082000ull, 0x8A28A28A28A27000ull, 0x8A28A25145082000ull, 0x8A28A28AAA945000ull,
+ 0x8A25142145228800ull, 0x8A25142082082000ull, 0xF82104210420F800ull, 0x3882082082083800ull, 0x8204102041020800ull, 0xE08208208208E000ull, 0x2148800000000000ull, 0x000000000000F800ull,
+ 0x2040000000000000ull, 0x0000007027A27000ull, 0x820820F228A2F000ull, 0x0000007A08207800ull, 0x0820827A28A27800ull, 0x000000722FA07000ull, 0x1882087082082000ull, 0x0000007A28A27827ull,
+ 0x820820F228A28800ull, 0x0002002082082000ull, 0x0002002082082284ull, 0x4104104946144800ull, 0x4104104104103000ull, 0x000000F2AAAAA800ull, 0x000000F228A28800ull, 0x0000007228A27000ull,
+ 0x0000007124927104ull, 0x0000007249247041ull, 0x0000007124104000ull, 0x0000003907827000ull, 0x2082087082081800ull, 0x0000008A28A27800ull, 0x0000008A25142000ull, 0x0000008AA7145000ull,
+ 0x0000008942148800ull, 0x0000008A25142084ull, 0x000000F84210F800ull, 0x0841042041040800ull, 0x2082082082082000ull, 0x8104102104108000ull, 0x000010A840000000ull, 0x0000000000000000ull,
+ 0x7228208208227084ull, 0x0005008A28A27800ull, 0x004200722FA07000ull, 0x0085007027A27000ull, 0x0005007027A27000ull, 0x0102007027A27000ull, 0x2142007027A27000ull, 0x0000007A08207884ull,
+ 0x008500722FA07000ull, 0x000500722FA07000ull, 0x010200722FA07000ull, 0x0005002082082000ull, 0x0085002082082000ull, 0x0102002082082000ull, 0xA8851453E8A28800ull, 0x21421453E8A28800ull,
+ 0x108FA083C820F800ull, 0x000000D89FE85C00ull, 0x5D4B2CFA49249C00ull, 0x0085007228A27000ull, 0x0005007228A27000ull, 0x0102007228A27000ull, 0x0085008A28A27800ull, 0x0102008A28A27800ull,
+ 0x0005008A25142084ull, 0x500FA28A28A2F800ull, 0x5008A28A28A27000ull, 0x002726AB27200000ull, 0x390410F10410F800ull, 0x082726AB27208000ull, 0x0008942148800000ull, 0x188208708208C000ull,
+ 0x0042007027A27000ull, 0x0042002082082000ull, 0x0042007228A27000ull, 0x0042008A28A27800ull, 0x42A1007124924800ull, 0x42A122CAAAA68800ull, 0x604624700F800000ull, 0x7228A2700F800000ull,
+ 0x2080082108A27000ull, 0x01E86DAEDAE17800ull, 0x000000F820000000ull, 0x4B25142164A4B800ull, 0x4B25142125AF8800ull, 0x2080082082082000ull, 0x0002529122400000ull, 0x0009122529000000ull,
+ 0x9004802409004800ull, 0xA95222568095A120ull, 0xA95A95A95A95A950ull, 0x2082082082082082ull, 0x2082082382082082ull, 0x108008514FA28800ull, 0x214008514FA28800ull, 0x408008514FA28800ull,
+ 0x01E867A699E17800ull, 0x514514D04D145145ull, 0x5145145145145145ull, 0x000000F04D145145ull, 0x514514D04F000000ull, 0x08472AA2A7108000ull, 0x8A251421C21C2000ull, 0x0000000382082082ull,
+ 0x20820820F0000000ull, 0x20820823F0000000ull, 0x00000003F2082082ull, 0x20820820F2082082ull, 0x00000003F0000000ull, 0x20820823F2082082ull, 0x42A1007027A27000ull, 0x42A108514FA28800ull,
+ 0x5145145D07C00000ull, 0x0000007D05D45145ull, 0x514514DC0FC00000ull, 0x000000FC0DD45145ull, 0x5145145D05D45145ull, 0x000000FC0FC00000ull, 0x514514DC0DD45145ull, 0x0227228A27220000ull,
+ 0xA10A047228A27000ull, 0x712492E924927000ull, 0x214FA083C820F800ull, 0x500FA083C820F800ull, 0x408FA083C820F800ull, 0x000000608208F800ull, 0x10803E208208F800ull, 0x21403E208208F800ull,
+ 0x01403E208208F800ull, 0x2082082380000000ull, 0x00000000F2082082ull, 0xFFFFFFFFFFFFFFF0ull, 0x00000003FFFFFFF0ull, 0x2082080002082080ull, 0x40803E208208F800ull, 0xFFFFFFFC00000000ull,
+ 0x10803E8A28A2F800ull, 0x3124944925104000ull, 0x21403E8A28A2F800ull, 0x40803E8A28A2F800ull, 0x42A1007228A27000ull, 0x42A13E8A28A2F800ull, 0x0000008A28A2FA08ull, 0x82082CCA28A2F208ull,
+ 0x000820F228A2F208ull, 0x1088A28A28A2F800ull, 0x2140228A28A2F800ull, 0x4088A28A28A2F800ull, 0x0042008A25142084ull, 0x12A8945082082000ull, 0xF800000000000000ull, 0x1080000000000000ull,
+ 0x0000007000000000ull, 0x00823E20803E0000ull, 0x00000000003E03E0ull, 0xC49C8AD0A3974800ull, 0x7BAEBA6820A27000ull, 0x31240C49230248C0ull, 0x000200F802000000ull, 0x0000000000002080ull,
+ 0x7147000000000000ull, 0x0140000000000000ull, 0x0000002000000000ull, 0x2182087000000000ull, 0x6046046000000000ull, 0x6042107000000000ull, 0x000FFFFFFFC00000ull, 0x0000000000000000ull
+ };
+ return pixels[clamp(character+256*(character<0)-32, 0, 223)];
+}
+void draw(const int x, const int y, const float z, const int color, const int stereo) {
+ const int index=x+y*(int)camera.width, iz=(int)(z*(2147483647.0f/10000.0f));
+ if(!is_off_screen(x, y, stereo)&&iz>camera.zbuffer[index]) {
+ camera.zbuffer[index] = iz;
+ camera.bitmap[index] = color; // only draw if point is on screen and first in zbuffer
+ }
+}
+void convert_pixel(const float3& p, const int color, const int stereo) {
int rx, ry; float rz;
- if(nums= 0 && rx-radius<(int)camera.width || ry+radius>=0 || ry-radius<(int)camera.height)) shapes[nums++] = new Circle(c, rz, rx, ry, radius); break; // cancel drawing if circle is off screen
- case -1: if((rx+radius>= 0 && rx-radius<(int)camera.width/2 || ry+radius>=0 || ry-radius<(int)camera.height)) shapes[nums++] = new Circle(c, rz, rx, ry, radius); break;
- case +1: if((rx+radius>=(int)camera.width/2 && rx-radius<(int)camera.width || ry+radius>=0 || ry-radius<(int)camera.height)) rights[numr++] = new Circle(c, rz, rx, ry, radius); break;
+ default: if(rx< -radius||rx>=(int)camera.width +radius || ry<-radius||ry>=(int)camera.height+radius) return; break; // cancel drawing if circle is off screen
+ case -1: if(rx< -radius||rx>=(int)camera.width/2+radius || ry<-radius||ry>=(int)camera.height+radius) return; break;
+ case +1: if(rx<(int)camera.width/2-radius||rx>=(int)camera.width +radius || ry<-radius||ry>=(int)camera.height+radius) return; break;
+ }
+ int d=-radius, x=radius, y=0; // Bresenham algorithm for circle
+ while(x>=y) {
+ draw(rx+x, ry+y, rz, color, stereo);
+ draw(rx-x, ry+y, rz, color, stereo);
+ draw(rx+x, ry-y, rz, color, stereo);
+ draw(rx-x, ry-y, rz, color, stereo);
+ draw(rx+y, ry+x, rz, color, stereo);
+ draw(rx-y, ry+x, rz, color, stereo);
+ draw(rx+y, ry-x, rz, color, stereo);
+ draw(rx-y, ry-x, rz, color, stereo);
+ d += 2*y+1;
+ y++;
+ if(d>0) d-=2*(--x);
}
}
}
-void convert_line(const Color& c, const float3& p0, const float3& p1, const int stereo) {
+void convert_line(const float3& p0, const float3& p1, const int color, const int stereo) {
int r0x, r0y, r1x, r1y; float r0z, r1z;
- if(numsdy) { err+=dy; x+=sx; }
+ if(e2r1y) { std::swap(r0x, r1x); std::swap(r0y, r1y); } // sort vertices ascending by y
+ if(r0y>r2y) { std::swap(r0x, r2x); std::swap(r0y, r2y); }
+ if(r1y>r2y) { std::swap(r1x, r2x); std::swap(r1y, r2y); }
+ const float z = (r0z+r1z+r2z)/3.0f; // approximate triangle z position for each pixel to be equal
+ for(int y=r0y; yr1y) { std::swap(r0x, r1x); std::swap(r0y, r1y); std::swap(c0, c1); } // sort vertices ascending by y
+ if(r0y>r2y) { std::swap(r0x, r2x); std::swap(r0y, r2y); std::swap(c0, c2); }
+ if(r1y>r2y) { std::swap(r1x, r2x); std::swap(r1y, r2y); std::swap(c1, c2); }
+ const float z = (r0z+r1z+r2z)/3.0f; // approximate triangle z position for each pixel to be equal
+ const float d = (float)((r1y-r2y)*(r0x-r2x)+(r2x-r1x)*(r0y-r2y));
+ for(int y=r0y; y= 0 && rx-radius<(int)camera.width || ry+radius>=0 || ry-radius<(int)camera.height)) shapes[nums++] = new Text(c, rz, s, (int)(rx+4.0f+tr), (int)(ry+3.0f+tr)); break; // cancel drawing if circle is off screen
- case -1: if((rx+radius>= 0 && rx-radius<(int)camera.width/2 || ry+radius>=0 || ry-radius<(int)camera.height)) shapes[nums++] = new Text(c, rz, s, (int)(rx+4.0f+tr), (int)(ry+3.0f+tr)); break;
- case +1: if((rx+radius>=(int)camera.width/2 && rx-radius<(int)camera.width || ry+radius>=0 || ry-radius<(int)camera.height)) rights[numr++] = new Text(c, rz, s, (int)(rx+4.0f+tr), (int)(ry+3.0f+tr)); break;
+ rx += 4+(int)tr;
+ ry += 3+(int)tr;
+ for(int i=0u; i<(int)length(s); i++) {
+ const int character = (int)s[i];
+ const ulong pixels = get_font_pixels(character);
+ for(int k=0; k<64; k++) {
+ if((pixels>>(63-k))&1) draw(rx+i*6+k%6+(character==113), ry+k/6, rz, color, stereo);
+ }
}
}
}
-void draw_pixel(const Color& c, const float3& p) {
+void draw_pixel(const int x, const int y, const int color) {
+ if(!is_off_screen(x, y)) camera.bitmap[x+y*(int)camera.width] = color; // only draw if point is on screen
+}
+void draw_circle(const int x, const int y, const int r, const int color) {
+ int d=-r, dx=r, dy=0; // Bresenham algorithm for circle
+ while(dx>=dy) {
+ draw_pixel(x+dx, y+dy, color);
+ draw_pixel(x-dx, y+dy, color);
+ draw_pixel(x+dx, y-dy, color);
+ draw_pixel(x-dx, y-dy, color);
+ draw_pixel(x+dy, y+dx, color);
+ draw_pixel(x-dy, y+dx, color);
+ draw_pixel(x+dy, y-dx, color);
+ draw_pixel(x-dy, y-dx, color);
+ d += 2*dy+1;
+ dy++;
+ if(d>0) d-=2*(--dx);
+ }
+}
+void draw_line(const int x0, const int y0, const int x1, const int y1, const int color) {
+ int x=x0, y=y0; // Bresenham algorithm
+ const int dx= abs(x1-x0), sx=2*(x0dy) { err+=dy; x+=sx; }
+ if(e2r1y) { std::swap(r0x, r1x); std::swap(r0y, r1y); } // sort vertices ascending by y
+ if(r0y>r2y) { std::swap(r0x, r2x); std::swap(r0y, r2y); }
+ if(r1y>r2y) { std::swap(r1x, r2x); std::swap(r1y, r2y); }
+ for(int y=r0y; y>(63-k))&1) draw_pixel(x+i*6+k%6+(character==113), y+k/6, color);
+ }
+ }
+}
+void draw_label(const int x, const int y, const string& s, const int color) {
+ draw_text(x, y, s, color);
+ if(camera.vr) {
+ if(x-camera.width/2>0) {
+ draw_text(x-(int)camera.width/2, y, s, color);
+ } else if(x+(int)camera.width/2<(int)camera.width) {
+ draw_text(x+(int)camera.width/2, y, s, color);
+ }
+ }
+}
+void draw_bitmap(const int* bitmap) {
+ std::copy(bitmap, bitmap+(int)camera.width*(int)camera.height, camera.bitmap);
+}
+
+void draw_pixel(const float3& p, const int color) {
if(!camera.vr) {
- convert_pixel(c, p, 0);
+ convert_pixel(p, color, 0);
} else {
- convert_pixel(c, p, -1);
- convert_pixel(c, p, +1);
+ convert_pixel(p, color, -1);
+ convert_pixel(p, color, +1);
}
}
-void draw_circle(const Color& c, const float3& p, const float r) {
+void draw_circle(const float3& p, const float r, const int color) {
if(!camera.vr) {
- convert_circle(c, p, r, 0);
+ convert_circle(p, r, color, 0);
} else {
- convert_circle(c, p, r, -1);
- convert_circle(c, p, r, +1);
+ convert_circle(p, r, color, -1);
+ convert_circle(p, r, color, +1);
}
}
-void draw_line(const Color& c, const float3& p0, const float3& p1) {
+void draw_line(const float3& p0, const float3& p1, const int color) {
if(!camera.vr) {
- convert_line(c, p0, p1, 0);
+ convert_line(p0, p1, color, 0);
} else {
- convert_line(c, p0, p1, -1);
- convert_line(c, p0, p1, +1);
+ convert_line(p0, p1, color, -1);
+ convert_line(p0, p1, color, +1);
}
}
-void draw_triangle(const Color& c, const float3& p0, const float3& p1, const float3& p2, const bool translucent) { // points clockwise from above
- const Color cl = lighting(c, (p0+p1+p2)/3.0f, cross(p1-p0, p2-p0), translucent);
+void draw_triangle(const float3& p0, const float3& p1, const float3& p2, const int color, const bool translucent) { // points clockwise from above
+ const int cl = lighting(color, (p0+p1+p2)/3.0f, cross(p1-p0, p2-p0), translucent);
if(!camera.vr) {
- convert_triangle(cl, p0, p1, p2, 0);
+ convert_triangle(p0, p1, p2, cl, 0);
} else {
- convert_triangle(cl, p0, p1, p2, -1);
- convert_triangle(cl, p0, p1, p2, +1);
+ convert_triangle(p0, p1, p2, cl, -1);
+ convert_triangle(p0, p1, p2, cl, +1);
}
}
-void draw_quadrangle(const Color& c, const float3& p0, const float3& p1, const float3& p2, const float3& p3, const bool translucent) { // points clockwise from above, only planar points
- const Color cl = lighting(c, (p0+p1+p2+p3)*0.25f, cross(p1-p0, p2-p0), translucent);
+void draw_triangle(const float3& p0, const float3& p1, const float3& p2, const int c0, const int c1, const int c2, const bool translucent) { // points clockwise from above
+ const float3 normal = cross(p1-p0, p2-p0);
+ const int cl0 = lighting(c0, p0, normal, translucent);
+ const int cl1 = lighting(c1, p1, normal, translucent);
+ const int cl2 = lighting(c2, p2, normal, translucent);
if(!camera.vr) {
- convert_quadrangle(cl, p0, p1, p2, p3, 0);
+ convert_triangle_interpolated(p0, p1, p2, cl0, cl1, cl2, 0);
} else {
- convert_quadrangle(cl, p0, p1, p2, p3, -1);
- convert_quadrangle(cl, p0, p1, p2, p3, +1);
+ convert_triangle_interpolated(p0, p1, p2, cl0, cl1, cl2, -1);
+ convert_triangle_interpolated(p0, p1, p2, cl0, cl1, cl2, +1);
}
}
-void draw_text(const Color& c, const float3& p, const string& s, const float r) {
+void draw_text(const float3& p, const float r, const string& s, const int color) {
if(!camera.vr) {
- convert_text(c, p, s, r, 0);
+ convert_text(p, s, r, color, 0);
} else {
- convert_text(c, p, s, r, -1);
- convert_text(c, p, s, r, +1);
+ convert_text(p, s, r, color, -1);
+ convert_text(p, s, r, color, +1);
}
}
-void set_mouse(const int x, const int y) {
- SetCursorPos(x, y);
-}
-void set_clip(const int x, const int y, const int w, const int h) {
- SelectClipRgn(backDC, CreateRectRgn(x, y, x+w, y+h));
-}
-inline bool z_order(const Shape* const lhs, const Shape* const rhs) {
- return lhs->zz;
-}
-void draw_frame() {
-#ifndef SKIP_VISIBILITY_CHECKS
- if(!camera.vr) {
- std::sort(shapes, shapes+nums, z_order); // sort data array (--> visibility <--)
- } else if(numr>0u) {
- std::sort(shapes, shapes+nums, z_order);
- std::sort(rights, rights+numr, z_order);
- }
-#endif // SKIP_VISIBILITY_CHECKS
- if(!camera.vr) {
- for(uint i=0u; idraw(); // draw in right order on frame
- delete shapes[i];
- shapes[i] = nullptr;
- }
- nums = 0u;
- } else {
- set_clip(0, 0, camera.width/2, camera.height); // draw on left image only
- for(uint i=0u; idraw();
- delete shapes[i];
- shapes[i] = nullptr;
- }
- nums = 0u;
- set_clip(camera.width/2, 0, camera.width/2, camera.height); // draw on right image only
- for(uint i=0u; idraw();
- delete rights[i];
- rights[i] = nullptr;
- }
- numr = 0u;
- set_clip(0, 0, camera.width, camera.height); // enable full drawing area again
+void key_bindings(const int key) {
+ camera.key_update = true;
+ switch(key) {
+ // reserved keys for graphics: W,A,S,D, I,J,K,L, R,U, V,B, C,VK_SPACE, Y,X, N,M
+ //case 'A': key_A = !key_A; break;
+ //case 'B': key_B = !key_B; break;
+ //case 'C': key_C = !key_C; break;
+ //case 'D': key_D = !key_D; break;
+ case 'E': key_E = !key_E; break;
+ //case 'F': key_F = !key_F; break;
+ case 'G': key_G = !key_G; break;
+ case 'H': key_H = !key_H; break;
+ //case 'I': key_I = !key_I; break;
+ //case 'J': key_J = !key_J; break;
+ //case 'K': key_K = !key_K; break;
+ //case 'L': key_L = !key_L; break;
+ //case 'M': key_M = !key_M; break;
+ //case 'N': key_N = !key_N; break;
+ case 'O': key_O = !key_O; break;
+ case 'P': key_P = !key_P; break;
+ case 'Q': key_Q = !key_Q; break;
+ //case 'R': key_R = !key_R; break;
+ //case 'S': key_S = !key_S; break;
+ case 'T': key_T = !key_T; break;
+ //case 'U': key_U = !key_U; break;
+ //case 'V': key_V = !key_V; break;
+ //case 'W': key_W = !key_W; break;
+ //case 'X': key_X = !key_X; break;
+ //case 'Y': key_Y = !key_Y; break;
+ case 'Z': key_Z = !key_Z; break;
+ case '1': key_1 = !key_1; break;
+ case '2': key_2 = !key_2; break;
+ case '3': key_3 = !key_3; break;
+ case '4': key_4 = !key_4; break;
+ case '5': key_5 = !key_5; break;
+ case '6': key_6 = !key_6; break;
+ case '7': key_7 = !key_7; break;
+ case '8': key_8 = !key_8; break;
+ case '9': key_9 = !key_9; break;
+ case '0': key_0 = !key_0; break;
+ default: camera.input_key(key);
}
}
+#if defined(INTERACTIVE_GRAPHICS)
+#if defined(_WIN32)
+
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRALEAN
+#include
+HWND window;
+HDC displayDC, memDC;
+HBITMAP frameDC;
+
+int key_windows(const int keycode) {
+ switch(keycode) {
+ case VK_SPACE : return ' '; // space
+ case VK_ESCAPE : return 27; // escape
+ case VK_UP : return -38; // up arrow
+ case VK_DOWN : return 40; // down arrow
+ case VK_LEFT : return -37; // left arrow
+ case VK_RIGHT : return -39; // right arrow
+ case VK_PRIOR : return -33; // page up
+ case VK_NEXT : return -34; // page down
+ case VK_HOME : return -36; // pos1
+ case VK_OEM_COMMA : return ','; // ,
+ case VK_OEM_PERIOD: return '.'; // .
+ default: return keycode;
+ }
+}
void update_frame(const double frametime) {
main_label(frametime);
- BitBlt(frontDC, 0, 0, camera.width, camera.height, backDC, 0, 0, SRCCOPY); // copy back buffer to front buffer
- HPEN oldPen = (HPEN )SelectObject(backDC, GetStockObject(BLACK_PEN ));
- HBRUSH oldBrush = (HBRUSH)SelectObject(backDC, GetStockObject(BLACK_BRUSH));
- Rectangle(backDC, 0, 0, camera.width, camera.height); // clear back buffer
- SelectObject(backDC, oldPen);
- SelectObject(backDC, oldBrush);
-}
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
- switch(message) {
- case WM_DESTROY:
- running = false;
- PostQuitMessage(0);
- exit(0);
- return 0;
- case WM_MOUSEMOVE:
- if(!lockmouse) {
- dmx = camera.ms*(double)((int)camera.width/2 -(int)LOWORD(lParam));
- dmy = camera.ms*(double)((int)camera.height/2-(int)HIWORD(lParam));
- }
- break;
- case WM_MOUSEWHEEL:
- if(!camera.free) { // camera.zoom
- if((short)HIWORD(wParam)<0) dzo += 1.0f;
- else dzo -= 1.0f;
- } else if(!lockmouse) {
- if((short)HIWORD(wParam)<0) fl -= 1.0f;
- else fl += 1.0f;
- fvel = 0.05f*exp(fl*0.25f);
- }
- break;
- case WM_KEYDOWN:
- int key = (int)wParam;
- switch(key) {
- case VK_ESCAPE: key = 27; break; // escape
- case VK_UP : key = -38; break; // up arrow
- case VK_DOWN : key = 40; break; // down arrow
- case VK_LEFT : key = -37; break; // left arrow
- case VK_RIGHT : key = -39; break; // right arrow
- case VK_PRIOR : key = -33; break; // page up
- case VK_NEXT : key = -34; break; // page down
- case VK_HOME : key = -36; break; // pos1
- case VK_END : key = -35; break; // end
- }
- if(key=='U') {
- if(!lockmouse) {
- ShowCursor(true); // show cursor
- } else {
- ShowCursor(false); // hide cursor
- set_mouse(camera.width/2, camera.height/2); // reset mouse
- }
- }
- key_bindings(key);
- break;
+ SetBitmapBits(frameDC, 4*(int)camera.width*(int)camera.height, camera.bitmap);
+ BitBlt(displayDC, 0, 0, (int)camera.width, (int)camera.height, memDC, 0, 0, SRCCOPY); // copy back buffer to front buffer
+ camera.clear_frame(); // clear frame
+}
+LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam) {
+ if(message==WM_DESTROY) {
+ running = false;
+ PostQuitMessage(0);
+ exit(0);
+ } else if(message==WM_MOUSEMOVE) {
+ camera.input_mouse_moved((int)LOWORD(lParam), (int)HIWORD(lParam));
+ } else if(message==WM_MOUSEWHEEL) {
+ if((short)HIWORD(wParam)>0) camera.input_scroll_up(); else camera.input_scroll_down();
+ } else if(message==WM_KEYDOWN) {
+ int key = key_windows((int)wParam);
+ camera.set_key_state(key, true);
+ key_bindings(key);
+ } else if(message==WM_KEYUP) {
+ int key = key_windows((int)wParam);
+ camera.set_key_state(key, false);
}
- return DefWindowProc(hWnd, message, wParam, lParam);
+ return DefWindowProc(window, message, wParam, lParam);
}
#ifdef GRAPHICS_CONSOLE
int main(int argc, char* argv[]) { // call WinMain from dummy main function in order to have an additional console window
main_arguments = get_main_arguments(argc, argv);
- return WinMain(GetModuleHandle(NULL), NULL, GetCommandLineA(), SW_SHOWMINIMIZED);
+ return WinMain(GetModuleHandle(0), 0, GetCommandLineA(), SW_SHOWMINIMIZED);
}
#endif // GRAPHICS_CONSOLE
INT WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ PSTR, _In_ INT) {
- WNDCLASS wndClass;
- wndClass.style = CS_HREDRAW|CS_VREDRAW;
- wndClass.lpfnWndProc = WndProc;
- wndClass.cbClsExtra = 0;
- wndClass.cbWndExtra = 0;
- wndClass.hInstance = hInstance;
- wndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- wndClass.lpszMenuName = NULL;
- wndClass.lpszClassName = TEXT("WindowClass");
+ WNDCLASS wndClass = { 0, WndProc, 0, 0, hInstance, LoadIcon(0, IDI_APPLICATION), LoadCursor(0, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), 0, TEXT("WindowClass") };
RegisterClass(&wndClass);
- HMONITOR hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi = {sizeof(mi)};
- if(!GetMonitorInfo(hMon, &mi)) return 1;
-
- DEVMODE lpDevMode; // get monitor fps
- memset(&lpDevMode, 0, sizeof(DEVMODE));
- camera.fps_limit = (uint)EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode)!=0 ? (uint)lpDevMode.dmDisplayFrequency : 60u; // find out screen refresh rate
- camera.width = (uint)(mi.rcMonitor.right-mi.rcMonitor.left); // get screen size, initialize variables
- camera.height = (uint)(mi.rcMonitor.bottom-mi.rcMonitor.top);
- camera.fov = 100.0f;
- set_zoom(1.0f); // set initial zoom (weird 1.0f/1.296875f value required for backwards compatibility with previous work)
+ MONITORINFO mi = { sizeof(mi) };
+ if(!GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), &mi)) return 1;
+ const uint width = (uint)(mi.rcMonitor.right-mi.rcMonitor.left); // get screen size, initialize variables
+ const uint height = (uint)(mi.rcMonitor.bottom-mi.rcMonitor.top);
ShowCursor(false); // hide cursor
- set_mouse(camera.width/2, camera.height/2);
- camera.update_matrix();
-
- hWnd = CreateWindow("WindowClass", WINDOW_NAME, WS_POPUP|WS_VISIBLE, mi.rcMonitor.left, mi.rcMonitor.top, camera.width, camera.height, NULL, NULL, hInstance, 0); // create fullscreen window
- frontDC = GetDC(hWnd);
- frame = CreateCompatibleBitmap(frontDC, camera.width, camera.height); // initialize back buffer
- backDC = CreateCompatibleDC(frontDC);
- HBITMAP oldBMP = (HBITMAP)SelectObject(backDC, frame);
- DeleteObject(oldBMP);
- SelectObject(backDC, GetStockObject(DC_PEN ));
- SelectObject(backDC, GetStockObject(DC_BRUSH));
- //SelectObject(backDC, GetStockObject(NULL_BRUSH)); for no filling of circles and polygons
- SetDCPenColor(backDC, RGB(255, 255, 255)); // define drawing properties
- SetDCBrushColor(backDC, RGB(0, 0, 0));
- SetTextAlign(backDC, TA_TOP);
- SetBkMode(backDC, TRANSPARENT);
- SetPolyFillMode(backDC, ALTERNATE);
- HFONT hFont = CreateFont(FONT_HEIGHT+5, FONT_WIDTH+1, 0, 0, 500, 0, 0, 0, ANSI_CHARSET, 0, 0, 0, 0, "Courier New"); // (HFONT)GetStockObject(ANSI_FIXED_FONT);
- SelectObject(backDC, hFont);
-
+ SetCursorPos(width/2, height/2);
+ DEVMODE lpDevMode = { 0 }; // get monitor fps
+ const uint fps_limit = (uint)EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &lpDevMode)!=0 ? (uint)lpDevMode.dmDisplayFrequency : 60u; // find out screen refresh rate
+ window = CreateWindow("WindowClass", WINDOW_NAME, WS_POPUP|WS_VISIBLE, mi.rcMonitor.left, mi.rcMonitor.top, width, height, 0, 0, hInstance, 0); // create fullscreen window
+ displayDC = GetDC(window);
+ memDC = CreateCompatibleDC(displayDC);
+ frameDC = CreateCompatibleBitmap(displayDC, width, height); // initialize back buffer
+ SelectObject(memDC, frameDC);
+
+ camera = Camera(width, height, fps_limit);
thread compute_thread(main_physics); // start main_physics() in a new thread
- MSG msg = {0};
Clock clock;
double frametime = 1.0;
+ MSG msg = { 0 };
while(msg.message!=WM_QUIT) {
- while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ while(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
if(msg.message==WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// main loop ################################################################
- key_hold();
+ camera.update_state();
main_graphics();
- draw_frame();
update_frame(frametime);
frametime = clock.stop();
sleep(1.0/(double)camera.fps_limit-frametime);
clock.start();
// ##########################################################################
}
- ReleaseDC(hWnd, frontDC);
+
+ ReleaseDC(window, displayDC);
compute_thread.join();
return 0;
}
-#elif defined(CONSOLE_GRAPHICS)
+#elif defined(__linux__)||defined(__APPLE__)
+
+#include "X11/include/X11/Xlib.h" // source: libx11-dev
+
+Display* x11_display;
+Window x11_window;
+GC x11_gc;
+XImage* x11_image;
+std::atomic_bool updating_frame = true;
+
+int key_linux(const int keycode) {
+ switch(keycode) {
+ case 38: return 'A'; case 42: return 'G'; case 58: return 'M'; case 39: return 'S'; case 52: return 'Y'; case 15: return '6';
+ case 56: return 'B'; case 43: return 'H'; case 57: return 'N'; case 28: return 'T'; case 29: return 'Z'; case 16: return '7';
+ case 54: return 'C'; case 31: return 'I'; case 32: return 'O'; case 30: return 'U'; case 10: return '1'; case 17: return '8';
+ case 40: return 'D'; case 44: return 'J'; case 33: return 'P'; case 55: return 'V'; case 11: return '2'; case 18: return '9';
+ case 26: return 'E'; case 45: return 'K'; case 24: return 'Q'; case 25: return 'W'; case 12: return '3'; case 14: return '5';
+ case 41: return 'F'; case 46: return 'L'; case 27: return 'R'; case 53: return 'X'; case 13: return '4'; case 19: return '0';
+ case 51: return '#'; case 94: return '<'; case 35: return '+'; case 61: return '-'; case 59: return ','; case 60: return '.';
+ case 65: return ' '; // space
+ case 36: return 10; // enter
+ case 22: return 8; // backspace
+ case 9: return 27; // escape
+ case 107: return 127; // delete
+ case 48: return 142; // Ä
+ case 47: return 153; // Ö
+ case 34: return 154; // Ü
+ case 20: return 225; // ß
+ case 49: return 248; // ^
+ case 21: return 239; // ´
+ case 106: return -45; // insert
+ case 77: return -144; // num lock
+ case 66: return -20; // caps lock
+ case 115: return -91; // windows key
+ case 117: return -93; // kontext menu key
+ case 87: return '1'; case 85: return '6'; // numpad
+ case 88: return '2'; case 79: return '7'; // numpad
+ case 89: return '3'; case 80: return '8'; // numpad
+ case 83: return '4'; case 81: return '9'; // numpad
+ case 84: return '5'; case 90: return '0'; // numpad
+ case 63: return '*'; case 112: return '/'; // numpad
+ case 86: return '+'; case 82: return '-'; // numpad
+ case 91: return ','; case 108: return 10; // numpad
+ case 98: return -38; case 104: return -40; // up/down arrow
+ case 100: return -37; case 102: return -39; // left/right arrow
+ case 99: return -33; case 105: return -34; // page up/down
+ case 97: return -36; case 103: return -35; // pos1/end
+ case 67: return -112; case 73: return -118; // F1/F7
+ case 68: return -113; case 74: return -119; // F2/F8
+ case 69: return -114; case 75: return -120; // F3/F9
+ case 70: return -115; case 76: return -121; // F4/F10
+ case 71: return -116; case 95: return -122; // F5/F11
+ case 72: return -117; case 96: return -123; // F6/F12
+ default: return 0;
+ }
+}
+void update_frame(const double frametime) {
+ main_label(frametime);
+ updating_frame = true;
+ XPutImage(x11_display, x11_window, x11_gc, x11_image, 0, 0, 0, 0, camera.width, camera.height);
+ updating_frame = false;
+ camera.clear_frame(); // clear frame
+}
+void input_detection() {
+ int last_x=camera.width/2, last_y=camera.height/2;
+ bool mouse_pressed = false;
+ XEvent x11_event;
+ while(running) {
+ if(!updating_frame) {
+ XNextEvent(x11_display, &x11_event);
+ if(x11_event.type==KeyPress) {
+ const int key = key_linux((int)x11_event.xkey.keycode);
+ camera.set_key_state(key, true);
+ key_bindings(key);
+ } else if(x11_event.type==KeyRelease) {
+ const int key = key_linux((int)x11_event.xkey.keycode);
+ camera.set_key_state(key, false);
+ } else if(x11_event.type==ButtonPress) {
+ const int x11_button = x11_event.xbutton.button;
+ if(x11_button==Button4) { // scroll up
+ camera.input_scroll_up();
+ } else if(x11_button==Button5) { // scroll down
+ camera.input_scroll_down();
+ } else {
+ mouse_pressed = true;
+ last_x = (int)x11_event.xmotion.x;
+ last_y = (int)x11_event.xmotion.y;
+ }
+ } else if(x11_event.type==ButtonRelease) {
+ mouse_pressed = false;
+ } else if(x11_event.type==MotionNotify) {
+ int new_x = (int)x11_event.xmotion.x;
+ int new_y = (int)x11_event.xmotion.y;
+ if(mouse_pressed) {
+ camera.input_mouse_dragged(new_x-last_x, new_y-last_y);
+ last_x = new_x;
+ last_y = new_y;
+ }
+ }
+ } else {
+ sleep(0.01);
+ }
+ }
+}
+int main(int argc, char* argv[]) {
+ main_arguments = get_main_arguments(argc, argv);
+
+ x11_display = XOpenDisplay(0);
+ if(!x11_display) print_error("No X11 display available.");
+
+ const uint height = 720u; // (uint)DisplayHeight(x11_display, 0);
+ const uint width = height*16u/9u; // (uint)DisplayWidth(x11_display, 0);
+ camera = Camera(width, height, 60u);
-Image* frame = nullptr;
+ x11_window = XCreateWindow(x11_display, DefaultRootWindow(x11_display), 0, 0, width, height, 0, CopyFromParent, CopyFromParent, CopyFromParent, 0, 0);
+ XStoreName(x11_display, x11_window, WINDOW_NAME);
+ struct Hints { long flags=2l, functions=0l, decorations=0b0111010l, input_mode=0l, status=0l; } x11_hints; // decorations=maximize|minimize|menu|title|resize|border|all
+ Atom x11_property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", 0);
+ XChangeProperty(x11_display, x11_window, x11_property, x11_property, 32, PropModeReplace, (unsigned char*)&x11_hints, 5);
+ XMapRaised(x11_display, x11_window);
+ x11_gc = XCreateGC(x11_display, x11_window, 0, 0);
+ x11_image = XCreateImage(x11_display, CopyFromParent, DefaultDepth(x11_display, DefaultScreen(x11_display)), ZPixmap, 0, (char*)camera.bitmap, width, height, 32, 0);
+ XSelectInput(x11_display, x11_window, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask);
+
+ thread compute_thread(main_physics); // start main_physics() in a new thread
+ thread input_thread(input_detection);
+
+ Clock clock;
+ double frametime = 1.0;
+ while(running) {
+ // main loop ################################################################
+ camera.update_state();
+ main_graphics();
+ update_frame(frametime);
+ frametime = clock.stop();
+ sleep(1.0/(double)camera.fps_limit-frametime);
+ clock.start();
+ // ##########################################################################
+ }
-void draw_bitmap(const void* buffer) {
- std::copy((int*)buffer, (int*)buffer+camera.width*camera.height, frame->data());
+ XFreeGC(x11_display, x11_gc);
+ XDestroyWindow(x11_display, x11_window);
+ XCloseDisplay(x11_display);
+ compute_thread.join();
+ input_thread.join();
+ return 0;
}
-void draw_label(const Color& c, const string& s, const int x, const int y) {}
+#endif // Linux
+#endif // INTERACTIVE_GRAPHICS
-uint ltw=0u, lth=0u;
+#ifdef INTERACTIVE_GRAPHICS_ASCII
+uint last_textwidth=0u, last_textheight=0u;
uint fontwidth=8u, fontheight=16u;
void update_frame(const double frametime) {
- if(ltw==0u&<h==0u) get_console_font_size(fontwidth, fontheight);
+ if(last_textwidth==0u&&last_textheight==0u) get_console_font_size(fontwidth, fontheight);
uint textwidth=0u, textheight=0u;
get_console_size(textwidth, textheight);
textwidth = max(textwidth, 2u)-1u;
- textwidth = min(textwidth, textheight*frame->width()*fontheight/(frame->height()*fontwidth));
- textheight = min(textheight, textwidth*frame->height()*fontwidth/(frame->width()*fontheight));
+ textwidth = min(textwidth, textheight*camera.width*fontheight/(camera.height*fontwidth));
+ textheight = min(textheight, textwidth*camera.height*fontwidth/(camera.width*fontheight));
textwidth = max(textwidth, 1u);
textheight = max(textheight, 1u);
- if(textwidth!=ltw||textheight!=lth) {
+ if(textwidth!=last_textwidth||textheight!=last_textheight) {
clear_console();
- ltw = textwidth;
- lth = textheight;
+ last_textwidth = textwidth;
+ last_textheight = textheight;
}
show_console_cursor(false);
- print_video_dither(frame, textwidth, textheight);
+ const Image image(camera.width, camera.height, camera.bitmap);
+ print_video_dither(&image, textwidth, textheight);
print(alignr(textwidth, to_string(textwidth)+"x"+to_string(textheight)+" "+alignr(4, to_int(1.0/frametime))+"fps"));
show_console_cursor(true);
+ camera.clear_frame(); // clear frame
}
-
-void key_detection() {
+void input_detection() {
while(running) {
int key = key_press();
key -= (key>96&&key<123)*32; // convert lower case to upper case
key_bindings(key);
}
}
-
-void key_hold() {
- if(autorotation) update_rotation(-1, 0);
- if(!camera.free) {
- zo = 0.8f*zo+0.2f*dzo; // continuous camera.zoom
- camera.zoom = exp(zo*0.25f);
- }
- mx = 0.8*mx+0.2*dmx; // continuous mouse movement
- my = 0.8*my+0.2*dmy; // continuous mouse movement
- dmx = 0.0;
- dmy = 0.0;
- if(!lockmouse) update_rotation(mx, my);
-}
-
int main(int argc, char* argv[]) {
main_arguments = get_main_arguments(argc, argv);
- camera.fps_limit = 60u; // find out screen refresh rate
- camera.width = 384u; // must be divisible by 8
- camera.height = 216u; // must be divisible by 8
- camera.fov = 100.0f;
- set_zoom(1.0f); // set initial zoom
- camera.update_matrix();
-
- frame = new Image(camera.width, camera.height);
-
+ camera = Camera(384u, 216u, 60u); // width and height must be divisible by 8
thread compute_thread(main_physics); // start main_physics() in a new thread
- thread key_thread(key_detection);
-
+ thread input_thread(input_detection);
Clock clock;
double frametime = 1.0;
#ifdef UTILITIES_CONSOLE_DITHER_LOOKUP
@@ -880,7 +729,7 @@ int main(int argc, char* argv[]) {
clear_console();
while(running) {
// main loop ################################################################
- key_hold();
+ camera.update_state();
main_graphics();
update_frame(frametime);
frametime = clock.stop();
@@ -889,26 +738,16 @@ int main(int argc, char* argv[]) {
// ##########################################################################
}
compute_thread.join();
- key_thread.join();
+ input_thread.join();
return 0;
}
+#endif // INTERACTIVE_GRAPHICS_ASCII
-#else // GRAPHICS
-
-void draw_bitmap(const void* buffer) {}
-void draw_label(const Color& c, const string& s, const int x, const int y) {}
-
+#if !defined(INTERACTIVE_GRAPHICS) && !defined(INTERACTIVE_GRAPHICS_ASCII)
int main(int argc, char* argv[]) {
main_arguments = get_main_arguments(argc, argv);
- camera.fps_limit = 60u; // find out screen refresh rate
- camera.width = GRAPHICS_FRAME_WIDTH; // must be divisible by 8
- camera.height = GRAPHICS_FRAME_HEIGHT; // must be divisible by 8
- camera.fov = 100.0f;
- set_zoom(1.0f); // set initial zoom
- camera.update_matrix();
-
+ camera = Camera(GRAPHICS_FRAME_WIDTH, GRAPHICS_FRAME_HEIGHT, 60u); // width and height must be divisible by 8
thread compute_thread(main_physics); // start main_physics() in a new thread
-
while(running) {
// main loop ################################################################
main_label(1.0);
@@ -918,6 +757,5 @@ int main(int argc, char* argv[]) {
compute_thread.join();
return 0;
}
-
-#endif // GRAPHICS
+#endif // no INTERACTIVE_GRAPHICS and no INTERACTIVE_GRAPHICS_ASCII
#endif // GRAPHICS
\ No newline at end of file
diff --git a/src/graphics.hpp b/src/graphics.hpp
index 3e3a7697..23defa2e 100644
--- a/src/graphics.hpp
+++ b/src/graphics.hpp
@@ -17,29 +17,62 @@ void main_label(const double frametime); // implement these three
void main_graphics();
void main_physics();
-struct Camera {
-#ifdef GRAPHICS_WIDTH
- uint width = (uint)(GRAPHICS_WIDTH);
-#else // GRAPHICS_WIDTH
+class Camera {
+public:
+ int* bitmap = nullptr;
+ int* zbuffer = nullptr;
uint width = 1920u; // screen width
-#endif // GRAPHICS_WIDTH
-#ifdef GRAPHICS_HEIGHT
- uint height = (uint)(GRAPHICS_HEIGHT);
-#else // GRAPHICS_HEIGHT
uint height = 1080u; // screen height
-#endif // GRAPHICS_HEIGHT
uint fps_limit = 60u; // default value for screen frames per second limit
- bool key_update = true; // a key variable has been updated
- float fov = 1E-6f; // field of view, default: orthogonal graphics (fov cannot be exactly 0)
- float zoom = 0.5f*(float)min(width, height); // zoom
- float dis = 0.5f*(float)width/tan(fov*pif/360.0f); // distance from camera to rotation center
- float3 pos = float3(0.0f); // free camera position
+ float fov = 100.0f; // field of view, default: 100
+ float zoom=0.5f*(float)min(width, height), dis=0.5f*(float)width/tan(fov*pif/360.0f); // zoom, distance from camera to rotation center
float3x3 R = float3x3(1.0f); // camera rotation matrix
+ double rx=0.5*pi, ry=pi; // rotation angles
+ float3 pos = float3(0.0f); // free camera position
bool free = false; // free camera mode
bool vr=false, tv=false; // virtual reality mode (enables stereoscopic rendering), VR TV mode
- float eye_distance = 8.0f; // distance between cameras
- const double ms = 1.0; // mouse sensitivity
- double rx=0.5*pi, ry=pi; // rotation angles
+ float eye_distance = 8.0f; // distance between cameras in VR mode
+ bool key_update = true; // a key variable has been updated
+
+private:
+ float log_zoom=4.0f*log(zoom), target_log_zoom=log_zoom;
+ double free_camera_velocity = 0.05; // free camera speed
+ double mouse_x=0.0, mouse_y=0.0, target_mouse_x=0.0, target_mouse_y=0.0; // mouse position
+ double mouse_sensitivity = 1.0; // mouse sensitivity
+ bool lockmouse = false; // mouse movement won't change camera view when this is true
+ bool autorotation = false; // autorotation
+ bool key_state[512] = { 0 };
+
+public:
+ Camera(const uint width, const uint height, const uint fps_limit) {
+ this->width = width;
+ this->height = height;
+ this->fps_limit = fps_limit;
+ bitmap = new int[width*height];
+ zbuffer = new int[width*height];
+ set_zoom(1.0f); // set initial zoom
+ update_matrix();
+ }
+ Camera() = default; // default constructor
+ ~Camera() {
+ delete[] bitmap;
+ delete[] zbuffer;
+ }
+ Camera& operator=(Camera&& camera) noexcept { // move assignment
+ this->width = camera.width;
+ this->height = camera.height;
+ this->fps_limit = camera.fps_limit;
+ std::swap(bitmap, camera.bitmap);
+ std::swap(zbuffer, camera.zbuffer);
+ set_zoom(1.0f); // set initial zoom
+ update_matrix();
+ return *this;
+ }
+
+ void set_zoom(const float rad) {
+ zoom = 0.5f*(float)min(width, height)/rad;
+ log_zoom = target_log_zoom = 4.0f*log(zoom);
+ }
void update_matrix() {
dis = 0.5f*(float)width/tan(fov*pif/360.0f);
const float sinrx=sin((float)rx), cosrx=cos((float)rx), sinry=sin((float)ry), cosry=cos((float)ry);
@@ -47,7 +80,84 @@ struct Camera {
R.yx = sinrx*sinry; R.yy = -cosrx*sinry; R.yz = cosry;
R.zx = -sinrx*cosry; R.zy = cosrx*cosry; R.zz = sinry;
}
- float data(const uint i) { // returns all camera data required for rendering
+ void set_key_state(const int key, const bool state) {
+ key_state[clamp(256+key, 0, 511)] = state;
+ }
+ bool get_key_state(const int key) {
+ return key_state[clamp(256+key, 0, 511)];
+ }
+ void input_key(const int key) {
+ switch(key) {
+ case 'R': input_R(); break;
+ case 'U': input_U(); break;
+ case 'I': input_I(); break;
+ case 'J': input_J(); break;
+ case 'K': input_K(); break;
+ case 'L': input_L(); break;
+ case 'V': input_V(); break;
+ case 'B': input_B(); break;
+ case ',': input_scroll_up(); break;
+ case '.': input_scroll_down(); break;
+ case 'F': input_F(); break;
+ case 27: running=false; exit(0);
+ }
+#ifdef INTERACTIVE_GRAPHICS_ASCII
+ if(free) { // move free camera
+ if(key=='W') input_W();
+ if(key=='A') input_A();
+ if(key=='S') input_S();
+ if(key=='D') input_D();
+ if(key==' ') input_Space();
+ if(key=='C') input_C();
+ }
+ if(!lockmouse) {
+ if(key=='I') input_I(); // rotating camera with keys
+ if(key=='J') input_J();
+ if(key=='K') input_K();
+ if(key=='L') input_L();
+ }
+ if(key=='Y') input_Y(); // adjusting field of view
+ if(key=='X') input_X();
+ if(key=='N') input_N(); // adjust camera.vr eye distance
+ if(key=='M') input_M();
+#endif // INTERACTIVE_GRAPHICS_ASCII
+ }
+ void update_state() {
+ if(!free) {
+ log_zoom = 0.8f*log_zoom+0.2f*target_log_zoom; // continuous zoom
+ zoom = exp(log_zoom*0.25f);
+ } else { // move free camera
+ if(get_key_state('W')) input_W();
+ if(get_key_state('A')) input_A();
+ if(get_key_state('S')) input_S();
+ if(get_key_state('D')) input_D();
+ if(get_key_state(' ')) input_Space();
+ if(get_key_state('C')) input_C();
+ }
+ if(!lockmouse) {
+ if(get_key_state('I')) input_I(); // rotate camera with keys
+ if(get_key_state('J')) input_J();
+ if(get_key_state('K')) input_K();
+ if(get_key_state('L')) input_L();
+ }
+ if(autorotation) update_rotation(-1, 0);
+ if(get_key_state('Y')) input_Y(); // adjust field of view
+ if(get_key_state('X')) input_X();
+ if(get_key_state('N')) input_N(); // adjust vr eye distance
+ if(get_key_state('M')) input_M();
+ mouse_x = 0.8*mouse_x+0.2*target_mouse_x; // continuous mouse movement
+ mouse_y = 0.8*mouse_y+0.2*target_mouse_y;
+ target_mouse_x = 0.0;
+ target_mouse_y = 0.0;
+ if(!lockmouse) update_rotation(mouse_x, mouse_y);
+ }
+ void clear_frame() {
+ for(uint i=0u; ir = (uchar)r;
- this->g = (uchar)g;
- this->b = (uchar)b;
- }
- Color() = default;
-};
-
-#define FONT_HEIGHT 10 // default: 10
-#define FONT_WIDTH 5 // default: 6
+#define GRAPHICS_CONSOLE // open console additionally to graphics window
+#define FONT_HEIGHT 11 // default: 11
+#define FONT_WIDTH 6 // default: 6
-void set_zoom(const float rad);
void set_light(const uint i, const float3& p);
-void draw_bitmap(const void* buffer);
-void draw_label(const Color& c, const string& s, const int x, const int y);
-
-#ifdef WINDOWS_GRAPHICS
-
-#define GRAPHICS_CONSOLE
-//#define SKIP_VISIBILITY_CHECKS // makes CPU graphics without polygons 40% faster
+void draw_bitmap(const int* bitmap);
+void draw_label(const int x, const int y, const string& s, const int color);
-void draw_pixel(const Color& c, const int x, const int y); // 2D drawing functions
-void draw_circle(const Color& c, const int x, const int y, const int r);
-void draw_line(const Color& c, const int x0, const int y0, const int x1, const int y1);
-void draw_triangle(const Color& c, const int x0, const int y0, const int x1, const int y1, const int x2, const int y2);
-void draw_rectangle(const Color& c, const int x0, const int y0, const int x1, const int y1);
-void draw_polygon(const Color& c, const int* const x, const int* const y, const int n);
-void draw_text(const Color& c, const string& s, const int x, const int y);
+void draw_pixel(const int x, const int y, const int color); // 2D drawing functions
+void draw_circle(const int x, const int y, const int r, const int color);
+void draw_line(const int x0, const int y0, const int x1, const int y1, const int color);
+void draw_triangle(const int x0, const int y0, const int x1, const int y1, const int x2, const int y2, const int color);
+void draw_rectangle(const int x0, const int y0, const int x1, const int y1, const int color);
+void draw_text(const int x, const int y, const string& s, const int color);
-void draw_pixel(const Color& c, const float3& p); // 3D drawing functions
-void draw_circle(const Color& c, const float3& p, const float r);
-void draw_line(const Color& c, const float3& p0, const float3& p1);
-void draw_triangle(const Color& c, const float3& p0, const float3& p1, const float3& p2, const bool translucent=false);
-void draw_quadrangle(const Color& c, const float3& p0, const float3& p1, const float3& p2, const float3& p3, const bool translucent=false);
-void draw_text(const Color& c, const float3& p, const string& s, const float r);
+void draw_pixel(const float3& p, const int color); // 3D drawing functions
+void draw_circle(const float3& p, const float r, const int color);
+void draw_line(const float3& p0, const float3& p1, const int color);
+void draw_triangle(const float3& p0, const float3& p1, const float3& p2, const int color, const bool translucent=false);
+void draw_triangle(const float3& p0, const float3& p1, const float3& p2, const int c0, const int c1, const int c2, const bool translucent=false);
+void draw_text(const float3& p, const float r, const string& s, const int color);
-#endif // WINDOWS_GRAPHICS
#endif // GRAPHICS
\ No newline at end of file
diff --git a/src/info.cpp b/src/info.cpp
index 855f9e6d..277eea7c 100644
--- a/src/info.cpp
+++ b/src/info.cpp
@@ -103,12 +103,12 @@ void Info::print_initialize() {
println("| Thermal Diff. | "+alignr(57u, to_string(lbm->get_alpha(), 8u))+" |");
println("| Thermal Exp. | "+alignr(57u, to_string(lbm->get_beta(), 8u))+" |");
#endif // TEMPERATURE
-#ifndef CONSOLE_GRAPHICS
+#ifndef INTERACTIVE_GRAPHICS_ASCII
println("|---------.-------'-----.-----------.-------------------.---------------------|");
println("| MLUPs | Bandwidth | Steps/s | Current Step | "+string(steps==max_ulong?"Elapsed Time ":"Time Remaining")+" |");
-#else // CONSOLE_GRAPHICS
+#else // INTERACTIVE_GRAPHICS_ASCII
println("'-----------------'-----------------------------------------------------------'");
-#endif // CONSOLE_GRAPHICS
+#endif // INTERACTIVE_GRAPHICS_ASCII
allow_rendering = true;
}
void Info::print_update() const {
diff --git a/src/kernel.cpp b/src/kernel.cpp
index 33aaeadd..0157ae63 100644
--- a/src/kernel.cpp
+++ b/src/kernel.cpp
@@ -89,11 +89,11 @@ string opencl_c_container() { return R( // ########################## begin of O
// draw_circle(...) : draw 3D circle
// draw_line(...) : draw 3D line
// draw_triangle(...) : draw 3D triangle
-// iron_color(...) : convert float in [0,255] to iron spectrum uint color
+// iron_color(...) : convert float in [0,255] to iron spectrum int color
// graphics_clear() : kernel to reset bitmap and zbuffer
)+"#ifdef GRAPHICS"+R(
-)+R(uint iron_color(float x) { // coloring scheme (float 0-255 -> uint color)
+)+R(int iron_color(float x) { // coloring scheme (float 0-255 -> int color)
x = clamp(360.0f-x*360.0f/255.0f, 0.0f, 360.0f);
float r=255.0f, g=0.0f, b=0.0f;
if(x<60.0f) { // white - yellow
@@ -108,9 +108,9 @@ string opencl_c_container() { return R( // ########################## begin of O
r = 255.0f-255.0f*(x-180.0f)/180.0f;
b = 255.0f-255.0f*(x-270.0f)/90.0f;
}
- return (((uint)r)<<16)|(((uint)g)<<8)|((uint)b);
+ return (((int)r)<<16)|(((int)g)<<8)|((int)b);
}
-)+R(uint rainbow_color(float x) { // coloring scheme (float 0-255 -> uint color)
+)+R(int rainbow_color(float x) { // coloring scheme (float 0-255 -> int color)
x = clamp(360.0f-x*360.0f/255.0f, 0.0f, 360.0f);
float r=0.0f, g=0.0f, b=0.0f; // black
if(x<60.0f) { // red - yellow
@@ -132,27 +132,27 @@ string opencl_c_container() { return R( // ########################## begin of O
r = (255.0f-255.0f*(x-300.0f)/60.0f)/2.0f;
b = 255.0f-255.0f*(x-300.0f)/60.0f;
}
- return (((uint)r)<<16)|(((uint)g)<<8)|((uint)b);
+ return (((int)r)<<16)|(((int)g)<<8)|((int)b);
}
-)+R(uint color_dim(const uint c, const float x) {
- const uint r = clamp((uint)fma((float)((c>>16)&255), x, 0.5f), 0u, 255u);
- const uint g = clamp((uint)fma((float)((c>> 8)&255), x, 0.5f), 0u, 255u);
- const uint b = clamp((uint)fma((float)( c &255), x, 0.5f), 0u, 255u);
+)+R(int color_dim(const int c, const float x) {
+ const int r = clamp((int)fma((float)((c>>16)&255), x, 0.5f), 0, 255);
+ const int g = clamp((int)fma((float)((c>> 8)&255), x, 0.5f), 0, 255);
+ const int b = clamp((int)fma((float)( c &255), x, 0.5f), 0, 255);
return (r&255)<<16|(g&255)<<8|(b&255);
}
-)+R(uint color_mix(const uint c1, const uint c2, const float w) {
+)+R(int color_mix(const int c1, const int c2, const float w) {
const uchar4 cc1=as_uchar4(c1), cc2=as_uchar4(c2);
const float3 fc1=(float3)((float)cc1.x, (float)cc1.y, (float)cc1.z), fc2=(float3)((float)cc2.x, (float)cc2.y, (float)cc2.z);
const float3 fcm = fma(w, fc1, fma(1.0f-w, fc2, (float3)(0.5f, 0.5f, 0.5f)));
- return as_uint((uchar4)((uchar)fcm.x, (uchar)fcm.y, (uchar)fcm.z, (uchar)0u));
+ return as_int((uchar4)((uchar)fcm.x, (uchar)fcm.y, (uchar)fcm.z, (uchar)0u));
}
-)+R(uint color_mix_3(const uint c0, const uint c1, const uint c2, const float w0, const float w1, const float w2) { // w0+w1+w2 = 1
+)+R(int color_mix_3(const int c0, const int c1, const int c2, const float w0, const float w1, const float w2) { // w0+w1+w2 = 1
const uchar4 cc0=as_uchar4(c0), cc1=as_uchar4(c1), cc2=as_uchar4(c2);
const float3 fc0=(float3)((float)cc0.x, (float)cc0.y, (float)cc0.z), fc1=(float3)((float)cc1.x, (float)cc1.y, (float)cc1.z), fc2=(float3)((float)cc2.x, (float)cc2.y, (float)cc2.z);
const float3 fcm = fma(w0, fc0, fma(w1, fc1, fma(w2, fc2, (float3)(0.5f, 0.5f, 0.5f))));
- return as_uint((uchar4)((uchar)fcm.x, (uchar)fcm.y, (uchar)fcm.z, (uchar)0u));
+ return as_int((uchar4)((uchar)fcm.x, (uchar)fcm.y, (uchar)fcm.z, (uchar)0u));
}
-)+R(uint hsv_to_rgb(const float h, const float s, const float v) {
+)+R(int hsv_to_rgb(const float h, const float s, const float v) {
const float c = v*s;
const float x = c*(1.0f-fabs(fmod(h/60.0f, 2.0f)-1.0f));
const float m = v-c;
@@ -163,9 +163,9 @@ string opencl_c_container() { return R( // ########################## begin of O
else if(h<240.0f) { g = x; b = c; }
else if(h<300.0f) { r = x; b = c; }
else if(h<360.0f) { r = c; b = x; }
- return (uint)((r+m)*255.0f)<<16|(uint)((g+m)*255.0f)<<8|(uint)((b+m)*255.0f);
+ return (int)((r+m)*255.0f)<<16|(int)((g+m)*255.0f)<<8|(int)((b+m)*255.0f);
}
-)+R(uint lighting(const uint c, const float3 p, const float3 normal, const float* camera_cache) { // calculate lighting of triangle
+)+R(int lighting(const int c, const float3 p, const float3 normal, const float* camera_cache) { // calculate lighting of triangle
const float dis = camera_cache[ 1]; // fetch camera parameters (rotation matrix, camera position, etc.)
const float posx = camera_cache[ 2];
const float posy = camera_cache[ 3];
@@ -179,8 +179,8 @@ string opencl_c_container() { return R( // ########################## begin of O
const float dy = p.y-fma(Rzy, dis, posy);
const float dz = p.z-fma(Rzz, dis, posz);
const float dl2 = sq(dx)+sq(dy)+sq(dz);
- const float br = max(1.5f*fabs(normal.x*dx+normal.y*dy+normal.z*dz)/native_sqrt(nl2*dl2), 0.3f);
- return min((uint)(br*cr), 255u)<<16|min((uint)(br*cg), 255u)<<8|min((uint)(br*cb), 255u);
+ const float br = max(1.5f*fabs(normal.x*dx+normal.y*dy+normal.z*dz)*rsqrt(nl2*dl2), 0.3f);
+ return min((int)(br*cr), 255)<<16|min((int)(br*cg), 255)<<8|min((int)(br*cb), 255);
}
)+R(bool is_off_screen(const int x, const int y, const int stereo) {
switch(stereo) {
@@ -189,7 +189,7 @@ string opencl_c_container() { return R( // ########################## begin of O
case +1: return x=def_screen_width ||y<0||y>=def_screen_height; // right half
}
}
-)+R(void draw(const int x, const int y, const float z, const uint color, global uint* bitmap, volatile global int* zbuffer, const int stereo) {
+)+R(void draw(const int x, const int y, const float z, const int color, global int* bitmap, volatile global int* zbuffer, const int stereo) {
const int index=x+y*def_screen_width, iz=(int)(z*(2147483647.0f/10000.0f)); // use int z-buffer and atomic_max to minimize noise in image
if(!is_off_screen(x, y, stereo)&&iz>atomic_max(&zbuffer[index], iz)) bitmap[index] = color; // only draw if point is on screen and first in zbuffer
}
@@ -224,7 +224,7 @@ string opencl_c_container() { return R( // ########################## begin of O
*rz = r.z;
return true;
}
-)+R(void convert_circle(float3 p, const float r, const uint color, const float* camera_cache, global uint* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
+)+R(void convert_circle(float3 p, const float r, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
int rx, ry; float rz;
if(convert(&rx, &ry, &rz, p, camera_cache, stereo)) {
const float zoom = camera_cache[0];
@@ -252,7 +252,7 @@ string opencl_c_container() { return R( // ########################## begin of O
}
}
}
-)+R(void convert_line(const float3 p0, const float3 p1, const uint color, const float* camera_cache, global uint* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
+)+R(void convert_line(const float3 p0, const float3 p1, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
int r0x, r0y, r1x, r1y; float r0z, r1z;
if(convert(&r0x, &r0y, &r0z, p0, camera_cache, stereo) && convert(&r1x, &r1y, &r1z, p1, camera_cache, stereo)
&& !(is_off_screen(r0x, r0y, stereo) && is_off_screen(r1x, r1y, stereo))) { // cancel drawing if both points are off screen
@@ -269,7 +269,7 @@ string opencl_c_container() { return R( // ########################## begin of O
}
}
}
-)+R(void convert_triangle(float3 p0, float3 p1, float3 p2, const uint color, const float* camera_cache, global uint* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
+)+R(void convert_triangle(float3 p0, float3 p1, float3 p2, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
int r0x, r0y, r1x, r1y, r2x, r2y; float r0z, r1z, r2z;
if(convert(&r0x, &r0y, &r0z, p0, camera_cache, stereo) && convert(&r1x, &r1y, &r1z, p1, camera_cache, stereo) && convert(&r2x, &r2y, &r2z, p2, camera_cache, stereo)
&& !(is_off_screen(r0x, r0y, stereo) && is_off_screen(r1x, r1y, stereo) && is_off_screen(r2x, r2y, stereo))) { // cancel drawing if all points are off screen
@@ -294,14 +294,14 @@ string opencl_c_container() { return R( // ########################## begin of O
}
}
}
-)+R(void convert_triangle_interpolated(float3 p0, float3 p1, float3 p2, uint c0, uint c1, uint c2, const float* camera_cache, global uint* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
+)+R(void convert_triangle_interpolated(float3 p0, float3 p1, float3 p2, int c0, int c1, int c2, const float* camera_cache, global int* bitmap, global int* zbuffer, const int stereo) { // 3D -> 2D
int r0x, r0y, r1x, r1y, r2x, r2y; float r0z, r1z, r2z;
if(convert(&r0x, &r0y, &r0z, p0, camera_cache, stereo) && convert(&r1x, &r1y, &r1z, p1, camera_cache, stereo) && convert(&r2x, &r2y, &r2z, p2, camera_cache, stereo)
&& !(is_off_screen(r0x, r0y, stereo) && is_off_screen(r1x, r1y, stereo) && is_off_screen(r2x, r2y, stereo))) { // cancel drawing if all points are off screen
if(r0x*(r1y-r2y)+r1x*(r2y-r0y)+r2x*(r0y-r1y)>100000 || (r0y==r1y&&r0y==r2y)) return; // return for large triangle area or degenerate triangles
- if(r0y>r1y) { const int xt = r0x; const int yt = r0y; r0x = r1x; r0y = r1y; r1x = xt; r1y = yt; const uint ct = c0; c0 = c1; c1 = ct; } // sort vertices ascending by y
- if(r0y>r2y) { const int xt = r0x; const int yt = r0y; r0x = r2x; r0y = r2y; r2x = xt; r2y = yt; const uint ct = c0; c0 = c2; c2 = ct; }
- if(r1y>r2y) { const int xt = r1x; const int yt = r1y; r1x = r2x; r1y = r2y; r2x = xt; r2y = yt; const uint ct = c1; c1 = c2; c2 = ct; }
+ if(r0y>r1y) { const int xt = r0x; const int yt = r0y; r0x = r1x; r0y = r1y; r1x = xt; r1y = yt; const int ct = c0; c0 = c1; c1 = ct; } // sort vertices ascending by y
+ if(r0y>r2y) { const int xt = r0x; const int yt = r0y; r0x = r2x; r0y = r2y; r2x = xt; r2y = yt; const int ct = c0; c0 = c2; c2 = ct; }
+ if(r1y>r2y) { const int xt = r1x; const int yt = r1y; r1x = r2x; r1y = r2y; r2x = xt; r2y = yt; const int ct = c1; c1 = c2; c2 = ct; }
const float z = (r0z+r1z+r2z)/3.0f; // approximate triangle z position for each pixel to be equal
const float d = (float)((r1y-r2y)*(r0x-r2x)+(r2x-r1x)*(r0y-r2y));
for(int y=r0y; y 2D
+)+R(void draw_point(const float3 p, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer) { // 3D -> 2D
const bool vr = (as_int(camera_cache[14])>>31)&0x1;
int rx, ry; float rz;
if(!vr) {
@@ -338,7 +338,7 @@ string opencl_c_container() { return R( // ########################## begin of O
if(convert(&rx, &ry, &rz, p, camera_cache, +1)) draw(rx, ry, rz, color, bitmap, zbuffer, +1); // right eye
}
}
-)+R(void draw_circle(const float3 p, const float r, const uint color, const float* camera_cache, global uint* bitmap, global int* zbuffer) { // 3D -> 2D
+)+R(void draw_circle(const float3 p, const float r, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer) { // 3D -> 2D
const bool vr = (as_int(camera_cache[14])>>31)&0x1;
if(!vr) {
convert_circle(p, r, color, camera_cache, bitmap, zbuffer, 0);
@@ -347,7 +347,7 @@ string opencl_c_container() { return R( // ########################## begin of O
convert_circle(p, r, color, camera_cache, bitmap, zbuffer, +1); // right eye
}
}
-)+R(void draw_line(const float3 p0, const float3 p1, const uint color, const float* camera_cache, global uint* bitmap, global int* zbuffer) { // 3D -> 2D
+)+R(void draw_line(const float3 p0, const float3 p1, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer) { // 3D -> 2D
const bool vr = (as_int(camera_cache[14])>>31)&0x1;
if(!vr) {
convert_line(p0, p1, color, camera_cache, bitmap, zbuffer, 0);
@@ -356,7 +356,7 @@ string opencl_c_container() { return R( // ########################## begin of O
convert_line(p0, p1, color, camera_cache, bitmap, zbuffer, +1); // right eye
}
}
-)+R(void draw_triangle(const float3 p0, const float3 p1, const float3 p2, const uint color, const float* camera_cache, global uint* bitmap, global int* zbuffer) { // 3D -> 2D
+)+R(void draw_triangle(const float3 p0, const float3 p1, const float3 p2, const int color, const float* camera_cache, global int* bitmap, global int* zbuffer) { // 3D -> 2D
const bool vr = (as_int(camera_cache[14])>>31)&0x1;
if(!vr) {
convert_triangle(p0, p1, p2, color, camera_cache, bitmap, zbuffer, 0);
@@ -365,7 +365,7 @@ string opencl_c_container() { return R( // ########################## begin of O
convert_triangle(p0, p1, p2, color, camera_cache, bitmap, zbuffer, +1); // right eye
}
}
-)+R(void draw_triangle_interpolated(const float3 p0, const float3 p1, const float3 p2, const uint c0, const uint c1, const uint c2, const float* camera_cache, global uint* bitmap, global int* zbuffer) { // 3D -> 2D
+)+R(void draw_triangle_interpolated(const float3 p0, const float3 p1, const float3 p2, const int c0, const int c1, const int c2, const float* camera_cache, global int* bitmap, global int* zbuffer) { // 3D -> 2D
const bool vr = (as_int(camera_cache[14])>>31)&0x1;
if(!vr) {
convert_triangle_interpolated(p0, p1, p2, c0, c1, c2, camera_cache, bitmap, zbuffer, 0);
@@ -374,9 +374,9 @@ string opencl_c_container() { return R( // ########################## begin of O
convert_triangle_interpolated(p0, p1, p2, c0, c1, c2, camera_cache, bitmap, zbuffer, +1); // right eye
}
}
-)+R(kernel void graphics_clear(global uint* bitmap, global int* zbuffer) {
+)+R(kernel void graphics_clear(global int* bitmap, global int* zbuffer) {
const uint n = get_global_id(0);
- bitmap[n] = def_background_color; // black background = 0x000000u, use 0xFFFFFFu for white background
+ bitmap[n] = def_background_color; // black background = 0x000000, use 0xFFFFFF for white background
zbuffer[n] = -2147483648;
}
)+R(constant ushort edge_table_data[128] = { // source: Paul Bourke, http://paulbourke.net/geometry/polygonise/, mirror symmetry applied, makes marching-cubes 31% faster
@@ -631,7 +631,7 @@ string opencl_c_container() { return R( // ########################## begin of O
int b = (int)(18.0f*y);
return 0xFFFFFF*(a%2==b%2);
}
-)+R(uint skybox_color(const ray r, const global uint* skybox) {
+)+R(uint skybox_color(const ray r, const global int* skybox) {
//const float x = fma(atan2(r.direction.x, r.direction.y), 0.5f/3.1415927f, 0.5f);
//const float y = fma(asin (r.direction.z ), -1.0f/3.1415927f, 0.5f);
//return color_mix(skybox_color_hsv(x, y), skybox_color_grid(x, y), 0.95f-0.33f*(2.0f*(0.5f-fabs(y-0.5))));
@@ -643,7 +643,7 @@ string opencl_c_container() { return R( // ########################## begin of O
const float u1=fu-(float)ua, v1=fv-(float)va, u0=1.0f-u1, v0=1.0f-v1; // interpolation factors
return color_mix(color_mix(s00, s01, v0), color_mix(s10, s11, v0), u0); // perform bilinear interpolation
}
-)+R(uint last_ray_reflectivity(const ray reflection, const ray transmission, const uint last_color, const float reflectivity, const global uint* skybox) {
+)+R(uint last_ray_reflectivity(const ray reflection, const ray transmission, const uint last_color, const float reflectivity, const global int* skybox) {
return color_mix(skybox_color(reflection, skybox), skybox_color(transmission, skybox), reflectivity);
}
)+R(float ray_grid_traverse(const ray r, const global float* phi, const global uchar* flags, float3* normal, const uint Nx, const uint Ny, const uint Nz) {
@@ -731,7 +731,7 @@ string opencl_c_container() { return R( // ########################## begin of O
}
return -1.0f; // no intersection found
}
-)+R(bool raytrace_phi_mirror(const ray ray_in, ray* ray_reflect, const global float* phi, const global uchar* flags, const global uint* skybox, const uint Nx, const uint Ny, const uint Nz) { // only reflection
+)+R(bool raytrace_phi_mirror(const ray ray_in, ray* ray_reflect, const global float* phi, const global uchar* flags, const global int* skybox, const uint Nx, const uint Ny, const uint Nz) { // only reflection
float3 normal;
float d = ray_grid_traverse(ray_in, phi, flags, &normal, Nx, Ny, Nz); // move ray through lattice, at each cell call marching_cubes
if(d==-1.0f) return false; // no intersection found
@@ -739,7 +739,7 @@ string opencl_c_container() { return R( // ########################## begin of O
ray_reflect->direction = reflect(ray_in.direction, normal);
return true;
}
-)+R(bool raytrace_phi(const ray ray_in, ray* ray_reflect, ray* ray_transmit, float* reflectivity, const global float* phi, const global uchar* flags, const global uint* skybox, const uint Nx, const uint Ny, const uint Nz) {
+)+R(bool raytrace_phi(const ray ray_in, ray* ray_reflect, ray* ray_transmit, float* reflectivity, const global float* phi, const global uchar* flags, const global int* skybox, const uint Nx, const uint Ny, const uint Nz) {
float3 normal;
float d = ray_grid_traverse(ray_in, phi, flags, &normal, Nx, Ny, Nz); // move ray through lattice, at each cell call marching_cubes
if(d==-1.0f) return false; // no intersection found
@@ -1915,9 +1915,9 @@ string opencl_c_container() { return R( // ########################## begin of O
)+"#ifdef GRAPHICS"+R(
)+"#ifndef FORCE_FIELD"+R(
-)+R(kernel void graphics_flags(const global uchar* flags, const global float* camera, global uint* bitmap, global int* zbuffer) {
+)+R(kernel void graphics_flags(const global uchar* flags, const global float* camera, global int* bitmap, global int* zbuffer) {
)+"#else"+R( // FORCE_FIELD
-)+R(kernel void graphics_flags(const global uchar* flags, const global float* camera, global uint* bitmap, global int* zbuffer, const global float* F) {
+)+R(kernel void graphics_flags(const global uchar* flags, const global float* camera, global int* bitmap, global int* zbuffer, const global float* F) {
)+"#endif"+R( // FORCE_FIELD
const uint n = get_global_id(0);
const uchar flagsn = flags[n]; // cache flags
@@ -1930,7 +1930,7 @@ string opencl_c_container() { return R( // ########################## begin of O
calculate_indices(n, &x0, &xp, &xm, &y0, &yp, &ym, &z0, &zp, &zm);
const uint3 xyz = coordinates(n);
const float3 p = position(xyz);
- const uint c = // coloring scheme
+ const int c = // coloring scheme
flagsn_bo==TYPE_S ? COLOR_S : // solid boundary
((flagsn&TYPE_T)&&flagsn_bo==TYPE_E) ? color_mix(COLOR_T, COLOR_E, 0.5f) : // both temperature boundary and equilibrium boundary
((flagsn&TYPE_T)&&flagsn_bo==TYPE_MS) ? color_mix(COLOR_T, COLOR_M, 0.5f) : // both temperature boundary and moving boundary
@@ -1975,14 +1975,14 @@ string opencl_c_container() { return R( // ########################## begin of O
const float3 Fn = def_scale_F*(float3)(F[n], F[def_N+(ulong)n], F[2ul*def_N+(ulong)n]);
const float Fnl = length(Fn);
if(Fnl>0.0f) {
- const uint c = iron_color(255.0f*Fnl); // color boundaries depending on the force on them
+ const int c = iron_color(255.0f*Fnl); // color boundaries depending on the force on them
draw_line(p, p+5.0f*Fn, c, camera_cache, bitmap, zbuffer); // draw colored force vectors
}
}
)+"#endif"+R( // FORCE_FIELD
}
-)+R(kernel void graphics_field(const global uchar* flags, const global float* u, const global float* camera, global uint* bitmap, global int* zbuffer) {
+)+R(kernel void graphics_field(const global uchar* flags, const global float* u, const global float* camera, global int* bitmap, global int* zbuffer) {
const uint n = get_global_id(0);
)+"#ifndef MOVING_BOUNDARIES"+R(
if(flags[n]&(TYPE_S|TYPE_E|TYPE_I|TYPE_G)) return;
@@ -1995,22 +1995,29 @@ string opencl_c_container() { return R( // ########################## begin of O
float camera_cache[15]; // cache camera parameters in case the kernel draws more than one shape
for(uint i=0u; i<15u; i++) camera_cache[i] = camera[i];
const float3 p = position(coordinates(n));
- const uint c = iron_color(255.0f*def_scale_u*ul); // coloring by velocity
+ const int c = iron_color(255.0f*def_scale_u*ul); // coloring by velocity
draw_line(p-(0.5f/ul)*un, p+(0.5f/ul)*un, c, camera_cache, bitmap, zbuffer);
}
)+"#ifndef GRAPHICS_TEMPERATURE"+R(
-)+R(kernel void graphics_streamline(const global uchar* flags, const global float* u, const global float* camera, global uint* bitmap, global int* zbuffer) {
+)+R(kernel void graphics_streamline(const global uchar* flags, const global float* u, const global float* camera, global int* bitmap, global int* zbuffer) {
)+"#else"+R( // GRAPHICS_TEMPERATURE
-)+R(kernel void graphics_streamline(const global uchar* flags, const global float* u, const global float* camera, global uint* bitmap, global int* zbuffer, const global float* T) {
+)+R(kernel void graphics_streamline(const global uchar* flags, const global float* u, const global float* camera, global int* bitmap, global int* zbuffer, const global float* T) {
)+"#endif"+R( // GRAPHICS_TEMPERATURE
const uint n = get_global_id(0);
+)+"#ifndef D2Q9"+R(
if(n>=(uint)def_N/cb(def_streamline_sparse)) return;
const uint z = n/((def_Nx/def_streamline_sparse)*(def_Ny/def_streamline_sparse)); // disassemble 1D index to 3D coordinates
const uint t = n%((def_Nx/def_streamline_sparse)*(def_Ny/def_streamline_sparse));
const uint y = t/(def_Nx/def_streamline_sparse);
const uint x = t%(def_Nx/def_streamline_sparse);
float3 p = (float)def_streamline_sparse*((float3)((float)x+0.5f, (float)y+0.5f, (float)z+0.5f))-0.5f*((float3)((float)def_Nx, (float)def_Ny, (float)def_Nz));
+)+"#else"+R( // D2Q9
+ if(n>=(uint)def_N/sq(def_streamline_sparse)) return;
+ const uint y = n/(def_Nx/def_streamline_sparse); // disassemble 1D index to 3D coordinates
+ const uint x = n%(def_Nx/def_streamline_sparse);
+ float3 p = ((float3)((float)def_streamline_sparse*((float)x+0.5f), (float)def_streamline_sparse*((float)y+0.5f), 0.5f))-0.5f*((float3)((float)def_Nx, (float)def_Ny, (float)def_Nz));
+)+"#endif"+R( // D2Q9
float camera_cache[15]; // cache camera parameters in case the kernel draws more than one shape
for(uint i=0u; i<15u; i++) camera_cache[i] = camera[i];
//draw_circle(p, 0.5f*def_streamline_sparse, 0xFFFFFF, camera_cache, bitmap, zbuffer);
@@ -2028,16 +2035,16 @@ string opencl_c_container() { return R( // ########################## begin of O
p1 += (dt/ul)*un; // integrate forward in time
if(def_scale_u*ul<0.1f||p1.x<-0.5f*def_Nx||p1.x>0.5f*def_Nx||p1.y<-0.5f*def_Ny||p1.y>0.5f*def_Ny||p1.z<-0.5f*def_Nz||p1.z>0.5f*def_Nz) break;
)+"#ifndef GRAPHICS_TEMPERATURE"+R(
- const uint c = iron_color(255.0f*def_scale_u*ul);
+ const int c = iron_color(255.0f*def_scale_u*ul);
)+"#else"+R( // GRAPHICS_TEMPERATURE
- const uint c = iron_color(180.0f+250.0f*(T[n]-def_T_avg));
+ const int c = iron_color(180.0f+250.0f*(T[n]-def_T_avg));
)+"#endif"+R( // GRAPHICS_TEMPERATURE
draw_line(p0, p1, c, camera_cache, bitmap, zbuffer);
}
}
}
-)+R(kernel void graphics_q_field(const global uchar* flags, const global float* u, const global float* camera, global uint* bitmap, global int* zbuffer) {
+)+R(kernel void graphics_q_field(const global uchar* flags, const global float* u, const global float* camera, global int* bitmap, global int* zbuffer) {
const uint n = get_global_id(0);
if(flags[n]&(TYPE_S|TYPE_E|TYPE_I|TYPE_G)) return;
float3 un = load_u(n, u); // cache velocity
@@ -2047,11 +2054,11 @@ string opencl_c_container() { return R( // ########################## begin of O
float camera_cache[15]; // cache camera parameters in case the kernel draws more than one shape
for(uint i=0u; i<15u; i++) camera_cache[i] = camera[i];
const float3 p = position(coordinates(n));
- const uint c = rainbow_color(255.0f*2.0f*ul*def_scale_u); // coloring by velocity
+ const int c = rainbow_color(255.0f*2.0f*ul*def_scale_u); // coloring by velocity
draw_line(p-(0.5f/ul)*un, p+(0.5f/ul)*un, c, camera_cache, bitmap, zbuffer);
}
-)+R(kernel void graphics_q(const global uchar* flags, const global float* u, const global float* camera, global uint* bitmap, global int* zbuffer) {
+)+R(kernel void graphics_q(const global uchar* flags, const global float* u, const global float* camera, global int* bitmap, global int* zbuffer) {
const uint n = get_global_id(0);
const uint3 xyz = coordinates(n);
if(xyz.x==def_Nx-1u || xyz.y==def_Ny-1u || xyz.z==def_Nz-1u) return;
@@ -2132,30 +2139,30 @@ string opencl_c_container() { return R( // ########################## begin of O
const float3 p0 = triangles[3u*i ]; // triangle coordinates in [0,1] (local cell)
const float3 p1 = triangles[3u*i+1u];
const float3 p2 = triangles[3u*i+2u];
- const float3 p = (p0+p1+p2)/3.0f+offset, normal=cross(p1-p0, p2-p0);
- uint c0, c1, c2;
+ const float3 normal = cross(p1-p0, p2-p0);
+ int c0, c1, c2;
{
const float x1=p0.x, y1=p0.y, z1=p0.z, x0=1.0f-x1, y0=1.0f-y1, z0=1.0f-z1; // calculate interpolation factors
const float3 ui = (x0*y0*z0)*uj[0]+(x1*y0*z0)*uj[1]+(x1*y0*z1)*uj[2]+(x0*y0*z1)*uj[3]+(x0*y1*z0)*uj[4]+(x1*y1*z0)*uj[5]+(x1*y1*z1)*uj[6]+(x0*y1*z1)*uj[7]; // perform trilinear interpolation
- c0 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
+ c0 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p0+offset, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
} {
const float x1=p1.x, y1=p1.y, z1=p1.z, x0=1.0f-x1, y0=1.0f-y1, z0=1.0f-z1; // calculate interpolation factors
const float3 ui = (x0*y0*z0)*uj[0]+(x1*y0*z0)*uj[1]+(x1*y0*z1)*uj[2]+(x0*y0*z1)*uj[3]+(x0*y1*z0)*uj[4]+(x1*y1*z0)*uj[5]+(x1*y1*z1)*uj[6]+(x0*y1*z1)*uj[7]; // perform trilinear interpolation
- c1 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
+ c1 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p1+offset, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
} {
const float x1=p2.x, y1=p2.y, z1=p2.z, x0=1.0f-x1, y0=1.0f-y1, z0=1.0f-z1; // calculate interpolation factors
const float3 ui = (x0*y0*z0)*uj[0]+(x1*y0*z0)*uj[1]+(x1*y0*z1)*uj[2]+(x0*y0*z1)*uj[3]+(x0*y1*z0)*uj[4]+(x1*y1*z0)*uj[5]+(x1*y1*z1)*uj[6]+(x0*y1*z1)*uj[7]; // perform trilinear interpolation
- c2 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
+ c2 = lighting(rainbow_color(255.0f*2.0f*length(ui)*def_scale_u), p2+offset, normal, camera_cache); // rainbow_color(255.0f*2.0f*length(ui)*def_scale_u);
}
draw_triangle_interpolated(p0+offset, p1+offset, p2+offset, c0, c1, c2, camera_cache, bitmap, zbuffer); // draw triangle with interpolated colors
}
}
)+"#ifdef SURFACE"+R(
-)+R(kernel void graphics_rasterize_phi(const global float* phi, const global float* camera, global uint* bitmap, global int* zbuffer) { // marching cubes
+)+R(kernel void graphics_rasterize_phi(const global float* phi, const global float* camera, global int* bitmap, global int* zbuffer) { // marching cubes
const uint n = get_global_id(0);
const uint3 xyz = coordinates(n);
- if(xyz.x==def_Nx-1u || xyz.y==def_Ny-1u || xyz.z==def_Nz-1u) return;
+ if(xyz.x==def_Nx-1u||xyz.y==def_Ny-1u||xyz.z==def_Nz-1u) return;
uint j[8];
const uint x0 = xyz.x; // cube stencil
const uint xp = xyz.x+1u;
@@ -2184,7 +2191,7 @@ string opencl_c_container() { return R( // ########################## begin of O
const float3 p1 = triangles[3u*i+1u]+offset;
const float3 p2 = triangles[3u*i+2u]+offset;
const float3 p=(p0+p1+p2)/3.0f, normal=cross(p1-p0, p2-p0);
- const uint c = lighting(55<<16|155<<8|255, p, normal, camera_cache);
+ const int c = lighting(55<<16|155<<8|255, p, normal, camera_cache);
draw_triangle(p0, p1, p2, c, camera_cache, bitmap, zbuffer);
//draw_line(p0, p1, c, camera_cache, bitmap, zbuffer); // wireframe rendering
//draw_line(p0, p2, c, camera_cache, bitmap, zbuffer);
@@ -2192,8 +2199,8 @@ string opencl_c_container() { return R( // ########################## begin of O
}
}
-)+R(uint raytrace_phi_next_ray(const ray reflection, const ray transmission, const uint pixelcolor, const float reflectivity, const global float* phi, const global uchar* flags, const global uint* skybox) {
- uint color_reflect=pixelcolor, color_transmit=pixelcolor;
+)+R(int raytrace_phi_next_ray(const ray reflection, const ray transmission, const int pixelcolor, const float reflectivity, const global float* phi, const global uchar* flags, const global int* skybox) {
+ int color_reflect=pixelcolor, color_transmit=pixelcolor;
ray reflection_next, transmission_next;
float reflection_reflectivity, transmission_reflectivity;
if(raytrace_phi(reflection, &reflection_next, &transmission_next, &reflection_reflectivity, phi, flags, skybox, def_Nx, def_Ny, def_Nz)) {
@@ -2209,8 +2216,8 @@ string opencl_c_container() { return R( // ########################## begin of O
return color_mix(color_reflect, color_transmit, reflectivity);
}
-)+R(uint raytrace_phi_next_ray_mirror(const ray reflection, const uint pixelcolor, const global float* phi, const global uchar* flags, const global uint* skybox) {
- uint color_reflect = pixelcolor;
+)+R(int raytrace_phi_next_ray_mirror(const ray reflection, const int pixelcolor, const global float* phi, const global uchar* flags, const global int* skybox) {
+ int color_reflect = pixelcolor;
ray reflection_next;
if(raytrace_phi_mirror(reflection, &reflection_next, phi, flags, skybox, def_Nx, def_Ny, def_Nz)) {
color_reflect = skybox_color(reflection_next, skybox);
@@ -2220,7 +2227,7 @@ string opencl_c_container() { return R( // ########################## begin of O
return color_reflect;
}
-)+R(kernel void graphics_raytrace_phi(const global float* phi, const global uchar* flags, const global uint* skybox, const global float* camera, global uint* bitmap) { // marching cubes
+)+R(kernel void graphics_raytrace_phi(const global float* phi, const global uchar* flags, const global int* skybox, const global float* camera, global int* bitmap) { // marching cubes
const uint gid = get_global_id(0); // workgroup size alignment is critical
const uint lid = get_local_id(0); // make workgropus not horizontal stripes of pixels, but 8x8 rectangular (close to square) tiles
const uint lsi = get_local_size(0); // (50% performance boost due to more coalesced memory access)
@@ -2232,7 +2239,7 @@ string opencl_c_container() { return R( // ########################## begin of O
float camera_cache[15]; // cache parameters in case the kernel draws more than one shape
for(uint i=0u; i<15u; i++) camera_cache[i] = camera[i];
ray camray = get_camray(x, y, camera_cache);
- uint pixelcolor = 0u;
+ int pixelcolor = 0;
const float distance = intersect_cuboid(camray, (float3)(0.0f, 0.0f, 0.0f), (float)def_Nx, (float)def_Ny, (float)def_Nz);
camray.origin = camray.origin+fmax(distance, 0.0f)*camray.direction;
ray reflection, transmission; // reflection and transmission
diff --git a/src/lbm.cpp b/src/lbm.cpp
index 2c0f9f7b..0800d5e6 100644
--- a/src/lbm.cpp
+++ b/src/lbm.cpp
@@ -218,10 +218,10 @@ void LBM::run(const ulong steps) { // initializes the LBM simulation (copies dat
}
Clock clock;
for(ulong i=1ull; i<=steps; i++) { // run LBM in loop, runs infinitely long if steps = max_ulong
-#if defined(CONSOLE_GRAPHICS)||defined(WINDOWS_GRAPHICS)
+#if defined(INTERACTIVE_GRAPHICS)||defined(INTERACTIVE_GRAPHICS_ASCII)
while(!key_P&&running) sleep(0.016);
if(!running) break;
-#endif // CONSOLE_GRAPHICS || WINDOWS_GRAPHICS
+#endif // INTERACTIVE_GRAPHICS || INTERACTIVE_GRAPHICS_ASCII
clock.start();
do_time_step(); // execute one LBM time step
info.update(clock.stop());
@@ -563,26 +563,30 @@ void LBM::Graphics::default_settings() {
}
void LBM::Graphics::allocate(Device& device) {
- bitmap = Memory(device, camera.width*camera.height);
+ bitmap = Memory(device, camera.width*camera.height);
zbuffer = Memory(device, camera.width*camera.height, 1u, false);
camera_parameters = Memory(device, 15u);
kernel_clear = Kernel(device, bitmap.length(), "graphics_clear", bitmap, zbuffer);
- set_zoom(0.5f*(float)fmax(fmax(lbm->get_Nx(), lbm->get_Ny()), lbm->get_Nz()));
+ camera.set_zoom(0.5f*(float)fmax(fmax(lbm->get_Nx(), lbm->get_Ny()), lbm->get_Nz()));
default_settings();
- kernel_graphics_flags = Kernel(device, lbm->flags.length(), "graphics_flags", lbm->flags, camera_parameters, bitmap, zbuffer);
- kernel_graphics_field = Kernel(device, lbm->flags.length(), "graphics_field", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer);
- kernel_graphics_streamline = Kernel(device, lbm->flags.length()/(cb(GRAPHICS_STREAMLINE_SPARSE)), "graphics_streamline", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer);
- kernel_graphics_q = Kernel(device, lbm->flags.length(), "graphics_q", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer);
+ kernel_graphics_flags = Kernel(device, lbm->get_N(), "graphics_flags", lbm->flags, camera_parameters, bitmap, zbuffer);
+ kernel_graphics_field = Kernel(device, lbm->get_N(), "graphics_field", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer);
+#ifndef D2Q9
+ kernel_graphics_streamline = Kernel(device, lbm->get_N()/(cb(GRAPHICS_STREAMLINE_SPARSE)), "graphics_streamline", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer); // 3D
+#else // D2Q9
+ kernel_graphics_streamline = Kernel(device, lbm->get_N()/(sq(GRAPHICS_STREAMLINE_SPARSE)), "graphics_streamline", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer); // 2D
+#endif // D2Q9
+ kernel_graphics_q = Kernel(device, lbm->get_N(), "graphics_q", lbm->flags, lbm->u, camera_parameters, bitmap, zbuffer);
#ifdef FORCE_FIELD
kernel_graphics_flags.add_parameters(lbm->F);
#endif // FORCE_FIELD
#ifdef SURFACE
- skybox = Memory(device, skybox_image->width()*skybox_image->height(), 1u, (uint*)skybox_image->data());
- kernel_graphics_rasterize_phi = Kernel(device, lbm->phi.length(), "graphics_rasterize_phi", lbm->phi, camera_parameters, bitmap, zbuffer);
+ skybox = Memory(device, skybox_image->width()*skybox_image->height(), 1u, skybox_image->data());
+ kernel_graphics_rasterize_phi = Kernel(device, lbm->get_N(), "graphics_rasterize_phi", lbm->phi, camera_parameters, bitmap, zbuffer);
kernel_graphics_raytrace_phi = Kernel(device, bitmap.length(), "graphics_raytrace_phi", lbm->phi, lbm->flags, skybox, camera_parameters, bitmap);
#endif // SURFACE
@@ -600,11 +604,11 @@ bool LBM::Graphics::update_camera() {
}
return change; // return false if camera parameters remain unchanged
}
-void* LBM::Graphics::draw_frame() {
+int* LBM::Graphics::draw_frame() {
const bool camera_update = update_camera();
-#if defined(WINDOWS_GRAPHICS)||defined(CONSOLE_GRAPHICS)
- if(!camera_update&&!camera.key_update&&lbm->get_t()==t_last_frame) return (void*)bitmap.data(); // don't render a new frame if the scene hasn't changed since last frame
-#endif // WINDOWS_GRAPHICS or CONSOLE_GRAPHICS
+#if defined(INTERACTIVE_GRAPHICS)||defined(INTERACTIVE_GRAPHICS_ASCII)
+ if(!camera_update&&!camera.key_update&&lbm->get_t()==t_last_frame) return bitmap.data(); // don't render a new frame if the scene hasn't changed since last frame
+#endif // INTERACTIVE_GRAPHICS or INTERACTIVE_GRAPHICS_ASCII
t_last_frame = lbm->get_t();
#ifndef UPDATE_FIELDS
if(key_2||key_3||key_4) lbm->update_fields(); // only call update_fields() if the time step has changed since the last rendered frame
@@ -623,11 +627,11 @@ void* LBM::Graphics::draw_frame() {
if(key_4) kernel_graphics_q.run();
bitmap.read_from_device();
- return (void*)bitmap.data();
+ return bitmap.data();
}
string LBM::Graphics::device_defines() const { return
"\n #define GRAPHICS"
- "\n #define def_background_color " +to_string(GRAPHICS_BACKGROUND_COLOR)+"u"
+ "\n #define def_background_color " +to_string(GRAPHICS_BACKGROUND_COLOR)+""
"\n #define def_screen_width " +to_string(camera.width)+"u"
"\n #define def_screen_height " +to_string(camera.height)+"u"
"\n #define def_n " +to_string(1.333f)+"f" // refractive index of water
@@ -665,7 +669,7 @@ void LBM::Graphics::set_camera_centered(const float rx, const float ry, const fl
camera.rx = 0.5*pi+((double)rx*pi/180.0);
camera.ry = pi-((double)ry*pi/180.0);
camera.fov = clamp((float)fov, 1E-6f, 179.0f);
- set_zoom(0.5f*(float)fmax(fmax(lbm->get_Nx(), lbm->get_Ny()), lbm->get_Nz())/zoom);
+ camera.set_zoom(0.5f*(float)fmax(fmax(lbm->get_Nx(), lbm->get_Ny()), lbm->get_Nz())/zoom);
}
void LBM::Graphics::set_camera_free(const float3& p, const float rx, const float ry, const float fov) {
camera.free = true;
@@ -676,15 +680,15 @@ void LBM::Graphics::set_camera_free(const float3& p, const float rx, const float
camera.pos = p;
}
void LBM::Graphics::print_frame() { // preview current frame in console
-#ifndef CONSOLE_GRAPHICS
+#ifndef INTERACTIVE_GRAPHICS_ASCII
info.allow_rendering = false; // temporarily disable interactive rendering
draw_frame(); // make sure the frame is fully rendered
- Image* image = new Image(camera.width, camera.height, (int*)bitmap.data());
+ Image* image = new Image(camera.width, camera.height, bitmap.data());
println();
print_image(image);
delete image;
info.allow_rendering = true;
-#endif // CONSOLE_GRAPHICS
+#endif // INTERACTIVE_GRAPHICS_ASCII
}
void encode_image(Image* image, const string& filename, const string& extension, std::atomic_int* running_encoders) {
if(extension==".png") write_png(filename, image);
@@ -703,14 +707,14 @@ void LBM::Graphics::write_frame(const uint x1, const uint y1, const uint x2, con
const uint xa=max(min(x1, x2), 0u), xb=min(max(x1, x2), camera.width ); // sort coordinates if necessary
const uint ya=max(min(y1, y2), 0u), yb=min(max(y1, y2), camera.height);
Image* image = new Image(xb-xa, yb-ya); // create local copy of frame buffer
- for(uint y=0u; yheight(); y++) for(uint x=0u; xwidth(); x++) image->set_color(x, y, (int)bitmap[camera.width*(ya+y)+(xa+x)]);
-#ifndef CONSOLE_GRAPHICS
+ for(uint y=0u; yheight(); y++) for(uint x=0u; xwidth(); x++) image->set_color(x, y, bitmap[camera.width*(ya+y)+(xa+x)]);
+#ifndef INTERACTIVE_GRAPHICS_ASCII
if(print_preview) {
println();
print_image(image);
print_info("Image \""+filename+"\" saved.");
}
-#endif // CONSOLE_GRAPHICS
+#endif // INTERACTIVE_GRAPHICS_ASCII
running_encoders++;
thread encoder(encode_image, image, filename, extension, &running_encoders); // the main bottleneck in rendering images to the hard disk is .png encoding, so encode image in new thread
encoder.detach(); // detatch thread so it can run concurrently
diff --git a/src/lbm.hpp b/src/lbm.hpp
index b2f726aa..a9818aae 100644
--- a/src/lbm.hpp
+++ b/src/lbm.hpp
@@ -191,7 +191,7 @@ class LBM {
class Graphics {
private:
Kernel kernel_clear; // reset bitmap and zbuffer
- Memory bitmap; // bitmap for rendering
+ Memory bitmap; // bitmap for rendering
Memory zbuffer; // z-buffer for rendering
Memory camera_parameters; // contains camera position, rotation, field of view etc.
@@ -207,7 +207,7 @@ class LBM {
#ifdef SURFACE
const string path_skybox = get_exe_path()+"../skybox/skybox8k.png";
Image* skybox_image = nullptr;
- Memory skybox; // skybox for free surface raytracing
+ Memory skybox; // skybox for free surface raytracing
Kernel kernel_graphics_rasterize_phi; // rasterize free surface
Kernel kernel_graphics_raytrace_phi; // raytrace free surface
#endif // SURFACE
@@ -246,7 +246,7 @@ class LBM {
#endif // SURFACE
void allocate(Device& device); // allocate memory for bitmap and zbuffer
- void* draw_frame(); // main rendering function, calls rendering kernels
+ int* draw_frame(); // main rendering function, calls rendering kernels
string device_defines() const; // returns preprocessor constants for embedding in OpenCL C code
void set_camera_centered(const float rx=0.0f, const float ry=0.0f, const float fov=100.0f, const float zoom=1.0f); // set camera centered
diff --git a/src/main.cpp b/src/main.cpp
index 3108e661..b57c863f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,23 +6,23 @@
void main_label(const double frametime) {
if(info.allow_rendering) {
info.print_update();
- const Color c = Color(255-red(GRAPHICS_BACKGROUND_COLOR), 255-green(GRAPHICS_BACKGROUND_COLOR), 255-blue(GRAPHICS_BACKGROUND_COLOR));
- const int ox=-36*FONT_WIDTH-2, oy=-11*FONT_HEIGHT-3; // character size 5x10
+ const int c = color(255-red(GRAPHICS_BACKGROUND_COLOR), 255-green(GRAPHICS_BACKGROUND_COLOR), 255-blue(GRAPHICS_BACKGROUND_COLOR));
+ const int ox=-36*FONT_WIDTH-1, oy=-11*FONT_HEIGHT-1;
int i = 0;
const float Re = info.lbm->get_Re_max();
const double pn=(double)info.lbm->get_N(), mt=(double)info.device_transfer;
- draw_label(c, "Resolution " +alignr(25u, to_string(info.lbm->get_Nx())+"x"+to_string(info.lbm->get_Ny())+"x"+to_string(info.lbm->get_Nz())+" = "+to_string(info.lbm->get_N())), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- //draw_label(c, "Volume Force " +alignr(15u, info.lbm->get_fx())+","+alignr(15, info.lbm->get_fy())+", "+alignr(15, info.lbm->get_fz()), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "Kin. Viscosity " +alignr(21u, to_string(info.lbm->get_nu(), 8u)), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "Relaxation Time "+alignr(20u, to_string(info.lbm->get_tau(), 8u)), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "Reynolds Number "+alignr(20u, "Re < "+string(Re>=100.0f ? to_string(to_uint(Re)) : to_string(Re, 6u))), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "LBM Type " +alignr(27u, "D"+to_string(info.lbm->get_velocity_set()==9u?2:3)+"Q"+to_string(info.lbm->get_velocity_set())+" "+info.collision), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "RAM Usage " +alignr(26u, "CPU "+to_string(info.cpu_mem_required)+" MB, GPU "+to_string(info.gpu_mem_required)+" MB"), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, (info.steps==max_ulong ? "Elapsed Time " : "Remaining Time ")+alignr(21u, print_time(info.time())), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "Simulation Time "+alignr(20u, (units.si_t(1ull)==1.0f?to_string(info.lbm->get_t()):to_string(units.si_t(info.lbm->get_t()), 6u))+"s"), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "MLUPs " +alignr(30u, alignr(5u, to_uint(pn*1E-6/info.dt_smooth))+" ("+alignr(5u, to_uint(pn*mt*1E-9/info.dt_smooth))+" GB/s)"), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "Steps " +alignr(30u, alignr(10u, info.lbm->get_t())+" ("+alignr(5, to_uint(1.0/info.dt_smooth))+" Steps/s)"), camera.width+ox, camera.height+oy+i); i+=FONT_HEIGHT;
- draw_label(c, "FPS " +alignr(32u, alignr(4u, to_uint(1.0/frametime))+" ("+alignr(5u, camera.fps_limit)+" fps max)"), camera.width+ox, camera.height+oy+i);
+ draw_label(camera.width+ox, camera.height+oy+i, "Resolution " +alignr(25u, to_string(info.lbm->get_Nx())+"x"+to_string(info.lbm->get_Ny())+"x"+to_string(info.lbm->get_Nz())+" = "+to_string(info.lbm->get_N())), c); i+=FONT_HEIGHT;
+ //draw_label(camera.width+ox, camera.height+oy+i, "Volume Force " +alignr(15u, info.lbm->get_fx())+","+alignr(15, info.lbm->get_fy())+", "+alignr(15, info.lbm->get_fz()), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "Kin. Viscosity " +alignr(21u, to_string(info.lbm->get_nu(), 8u)), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "Relaxation Time "+alignr(20u, to_string(info.lbm->get_tau(), 8u)), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "Reynolds Number "+alignr(20u, "Re < "+string(Re>=100.0f ? to_string(to_uint(Re)) : to_string(Re, 6u))), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "LBM Type " +alignr(27u, "D"+to_string(info.lbm->get_velocity_set()==9u?2:3)+"Q"+to_string(info.lbm->get_velocity_set())+" "+info.collision), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "RAM Usage " +alignr(26u, "CPU "+to_string(info.cpu_mem_required)+" MB, GPU "+to_string(info.gpu_mem_required)+" MB"), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, (info.steps==max_ulong ? "Elapsed Time " : "Remaining Time ")+alignr(21u, print_time(info.time())), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "Simulation Time "+alignr(20u, (units.si_t(1ull)==1.0f?to_string(info.lbm->get_t()):to_string(units.si_t(info.lbm->get_t()), 6u))+"s"), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "MLUPs " +alignr(30u, alignr(5u, to_uint(pn*1E-6/info.dt_smooth))+" ("+alignr(5u, to_uint(pn*mt*1E-9/info.dt_smooth))+" GB/s)"), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "Steps " +alignr(30u, alignr(10u, info.lbm->get_t())+" ("+alignr(5, to_uint(1.0/info.dt_smooth))+" Steps/s)"), c); i+=FONT_HEIGHT;
+ draw_label(camera.width+ox, camera.height+oy+i, "FPS " +alignr(32u, alignr(4u, to_uint(1.0/frametime))+" ("+alignr(5u, camera.fps_limit)+" fps max)"), c);
}
}
diff --git a/src/opencl.hpp b/src/opencl.hpp
index 79ba9677..a0bff159 100644
--- a/src/opencl.hpp
+++ b/src/opencl.hpp
@@ -37,9 +37,9 @@ struct Device_Info {
max_constant_buffer = (uint)(cl_device.getInfo()/1024ull); // maximum constant buffer size in KB
compute_units = (uint)cl_device.getInfo(); // compute units (CUs) can contain multiple cores depending on the microarchitecture
clock_frequency = (uint)cl_device.getInfo(); // in MHz
- is_fp64_capable = (uint)cl_device.getInfo();
+ is_fp64_capable = (uint)cl_device.getInfo()*(uint)contains(cl_device.getInfo(), "cl_khr_fp64");
is_fp32_capable = (uint)cl_device.getInfo();
- is_fp16_capable = (uint)cl_device.getInfo();
+ is_fp16_capable = (uint)cl_device.getInfo()*(uint)contains(cl_device.getInfo(), "cl_khr_fp16");
is_int64_capable = (uint)cl_device.getInfo();
is_int32_capable = (uint)cl_device.getInfo();
is_int16_capable = (uint)cl_device.getInfo();
@@ -47,10 +47,10 @@ struct Device_Info {
is_cpu = cl_device.getInfo()==CL_DEVICE_TYPE_CPU;
is_gpu = cl_device.getInfo()==CL_DEVICE_TYPE_GPU;
const uint ipc = is_gpu?2u:32u; // IPC (instructions per cycle) is 2 for GPUs and 32 for most modern CPUs
- const bool nvidia_192_cores_per_cu = contains_any(to_lower(name), {" 6", " 7", "ro k", "la k"}) || (clock_frequency<1000u&&contains(to_lower(name), "titan")); // identify Kepler GPUs
- const bool nvidia_64_cores_per_cu = contains_any(to_lower(name), {"p100", "v100", "a100", "a30", " 16", " 20", "titan v", "titan rtx", "ro t", "la t", "ro rtx"}) && !contains(to_lower(name), "rtx a"); // identify P100, Volta, Turing, A100, A30
+ const bool nvidia_192_cores_per_cu = contains_any(to_lower(name), {"gt 6", "gt 7", "gtx 6", "gtx 7", "quadro k", "tesla k"}) || (clock_frequency<1000u&&contains(to_lower(name), "titan")); // identify Kepler GPUs
+ const bool nvidia_64_cores_per_cu = contains_any(to_lower(name), {"p100", "v100", "a100", "a30", " 16", " 20", "titan v", "titan rtx", "quadro t", "tesla t", "quadro rtx"}) && !contains(to_lower(name), "rtx a"); // identify P100, Volta, Turing, A100, A30
const bool amd_128_cores_per_dualcu = contains(to_lower(name), "gfx10"); // identify RDNA/RDNA2 GPUs where dual CUs are reported
- const float nvidia = (float)(contains(to_lower(vendor), "nvidia"))*(nvidia_192_cores_per_cu?192.0f:(nvidia_64_cores_per_cu?64.0f:128.0f)); // Nvidia GPUs have 192 cores/CU (Kepler), 128 cores/CU (Maxwell, Pascal, Ampere, Hopper, Ada) or 64 cores/CU (P100, Volta, Turing, A100, A30)
+ const float nvidia = (float)(contains(to_lower(vendor), "nvidia"))*(nvidia_64_cores_per_cu?64.0f:nvidia_192_cores_per_cu?192.0f:128.0f); // Nvidia GPUs have 192 cores/CU (Kepler), 128 cores/CU (Maxwell, Pascal, Ampere, Hopper, Ada) or 64 cores/CU (P100, Volta, Turing, A100, A30)
const float amd = (float)(contains_any(to_lower(vendor), {"amd", "advanced"}))*(is_gpu?(amd_128_cores_per_dualcu?128.0f:64.0f):0.5f); // AMD GPUs have 64 cores/CU (GCN, CDNA) or 128 cores/dualCU (RDNA, RDNA2), AMD CPUs (with SMT) have 1/2 core/CU
const float intel = (float)(contains(to_lower(vendor), "intel"))*(is_gpu?8.0f:0.5f); // Intel integrated GPUs usually have 8 cores/CU, Intel CPUs (with HT) have 1/2 core/CU
const float apple = (float)(contains(to_lower(vendor), "apple"))*(128.0f); // Apple ARM GPUs usually have 128 cores/CU
diff --git a/src/setup.cpp b/src/setup.cpp
index 609d5a69..57328b5e 100644
--- a/src/setup.cpp
+++ b/src/setup.cpp
@@ -27,7 +27,7 @@
/*void main_setup() { // 2D Taylor-Green vortices
// ######################################################### define simulation box size, viscosity and volume force ############################################################################
- LBM lbm(1024u, 1024u, 1u, 0.01f);
+ LBM lbm(1024u, 1024u, 1u, 0.02f);
// #############################################################################################################################################################################################
const uint N=lbm.get_N(), Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); for(uint n=0u, x=0u, y=0u, z=0u; n