diff options
| author | jussi | 2023-11-28 22:39:10 +0200 |
|---|---|---|
| committer | jussi | 2023-11-28 22:39:10 +0200 |
| commit | 21eb3f90c427b3b84801754e92bebb418a8d9391 (patch) | |
| tree | 5bb8662bcdaf4709b1b486323bd610e863e5816f | |
| parent | 2b330bbadbeb35807b4831ab6275f6e2867029b5 (diff) | |
| download | reilua-enhanced-21eb3f90c427b3b84801754e92bebb418a8d9391.tar.gz reilua-enhanced-21eb3f90c427b3b84801754e92bebb418a8d9391.tar.bz2 reilua-enhanced-21eb3f90c427b3b84801754e92bebb418a8d9391.zip | |
Platform specific API documentation generation.
| -rw-r--r-- | API.md | 469 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | ReiLua_API.lua | 199 | ||||
| -rw-r--r-- | changelog | 3 | ||||
| -rw-r--r-- | devnotes | 1 | ||||
| -rw-r--r-- | docgen.lua | 201 | ||||
| -rw-r--r-- | include/state.h | 4 | ||||
| -rw-r--r-- | src/gl.c | 2 | ||||
| -rw-r--r-- | src/lua_core.c | 87 | ||||
| -rw-r--r-- | src/platforms/core_desktop.c | 116 | ||||
| -rw-r--r-- | src/platforms/core_desktop_sdl.c | 110 |
11 files changed, 815 insertions, 379 deletions
@@ -257,89 +257,7 @@ Data buffer for C primitive types. Type should be one of the Buffer types. --- -## Events - -Content of event table received by RL.event. - -### Window events - ---- -> { type: RL.EVENT_WINDOW_SIZE, int width, int height } - - WindowSize Callback, runs when window is resized. - ---- - -> { type RL.EVENT_WINDOW_MAXIMIZE, int maximized } - - Window Maximize Callback, runs when window is maximized. - ---- - -> { type RL.EVENT_WINDOW_ICONYFY, int iconified } - - WindowIconify Callback, runs when window is minimized/restored. - ---- - -> { type RL.EVENT_WINDOW_FOCUS, int focused } - - WindowFocus Callback, runs when window get/lose focus. - ---- - -> { type RL.EVENT_WINDOW_DROP, int count, string{} paths } - - Window Drop Callback, runs when drop files into window. - ---- - -### Input events - ---- -> { type: RL.EVENT_KEY, int key, int scancode, int action, int mods } - - Keyboard Callback, runs on key pressed. - ---- - -> { type RL.EVENT_CHAR, int key } - - Char Key Callback, runs on key pressed (get char value). - ---- - -> { type RL.EVENT_MOUSE_BUTTON, int button, int action, int mods } - - Mouse Button Callback, runs on mouse button pressed. - ---- - -> { type RL.EVENT_MOUSE_CURSOR_POS, number x, number y } - - Cursor Position Callback, runs on mouse move. - ---- - -> { type RL.EVENT_MOUSE_SCROLL, number xoffset, number yoffset } - - Srolling Callback, runs on mouse wheel. - ---- - -> { type RL.EVENT_CURSOR_ENTER, int enter } - - Cursor Enter Callback, cursor enters client area. - ---- - -> { type RL.EVENT_JOYSTICK, int jid, int event } - - . - ---- - -## Globals - ConfigFlags +## Defines - System/Window config flags > FLAG_VSYNC_HINT = 64 Set to try enabling V-Sync on GPU @@ -431,7 +349,7 @@ Set to try enabling interlaced video format (for V3D) --- -## Globals - TraceLogLevel +## Defines - Trace log level > LOG_ALL = 0 Display all logs @@ -481,7 +399,7 @@ Disable logging --- -## Globals - KeyboardKey +## Defines - Keyboard keys (US keyboard layout) > KEY_NULL = 0 Key: NULL, used for no key pressed @@ -1143,7 +1061,7 @@ Key: Android volume down button --- -## Globals - MouseButtons +## Defines - Mouse buttons > MOUSE_BUTTON_LEFT = 0 Mouse button left @@ -1187,7 +1105,7 @@ Mouse button back (advanced mouse device) --- -## Globals - MouseCursor +## Defines - Mouse cursor > MOUSE_CURSOR_DEFAULT = 0 Default pointer shape @@ -1255,7 +1173,7 @@ The operation-not-allowed shape --- -## Globals - GamepadButtons +## Defines - Gamepad buttons > GAMEPAD_BUTTON_UNKNOWN = 0 Unknown button, just for error checking @@ -1365,7 +1283,7 @@ Gamepad joystick pressed button right --- -## Globals - GamepadAxis +## Defines - Gamepad axis > GAMEPAD_AXIS_LEFT_X = 0 Gamepad left stick X axis @@ -1403,7 +1321,7 @@ Gamepad back trigger right, pressure level: [1..-1] --- -## Globals - MapTypes +## Defines - Material map index > MATERIAL_MAP_ALBEDO = 0 Albedo material (same as: MATERIAL_MAP_DIFFUSE) @@ -1483,7 +1401,7 @@ Specular material (same as: MATERIAL_MAP_METALNESS) --- -## Globals - ShaderLocationIndex +## Defines - Shader location index > SHADER_LOC_VERTEX_POSITION = 0 Shader location: vertex attribute: position @@ -1653,7 +1571,7 @@ Shader location: sampler2d texture: specular (same as: SHADER_LOC_MAP_METALNESS) --- -## Globals - ShaderUniformDataType +## Defines - Shader uniform data type > SHADER_UNIFORM_FLOAT = 0 Shader uniform type: float @@ -1709,7 +1627,7 @@ Shader uniform type: sampler2d --- -## Globals - ShaderAttributeDataTypes +## Defines - Shader attribute data types > SHADER_ATTRIB_FLOAT = 0 Shader attribute type: float @@ -1735,7 +1653,7 @@ Shader attribute type: vec4 (4 float) --- -## Globals - PixelFormats +## Defines - Pixel formats > PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1 8 bit per pixel (no alpha) @@ -1863,7 +1781,7 @@ Shader attribute type: vec4 (4 float) --- -## Globals - TextureFilters +## Defines - Texture parameters: filter mode > TEXTURE_FILTER_POINT = 0 No filter, just pixel approximation @@ -1901,7 +1819,7 @@ Anisotropic filtering 16x --- -## Globals - TextureWrap +## Defines - Texture parameters: wrap mode > TEXTURE_WRAP_REPEAT = 0 Repeats texture in tiled mode @@ -1927,7 +1845,7 @@ Mirrors and clamps to border the texture in tiled mode --- -## Globals - CubemapLayout +## Defines - Cubemap layouts > CUBEMAP_LAYOUT_AUTO_DETECT = 0 Automatically detect layout type @@ -1965,7 +1883,7 @@ Layout is defined by a panorama image (equirrectangular map) --- -## Globals - FontType +## Defines - Font type, defines generation method > FONT_DEFAULT = 0 Default font generation, anti-aliased @@ -1985,7 +1903,7 @@ SDF font generation, requires external shader --- -## Globals - BlendModes +## Defines - Color blending modes (pre-defined) > BLEND_ALPHA = 0 Blend textures considering alpha (default) @@ -2035,7 +1953,7 @@ Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFa --- -## Globals - Gesture +## Defines - Gesture > GESTURE_NONE = 0 No gesture @@ -2103,7 +2021,7 @@ Pinch out gesture --- -## Globals - CameraMode +## Defines - Camera system modes > CAMERA_CUSTOM = 0 Custom camera @@ -2135,7 +2053,7 @@ Third person camera --- -## Globals - CameraProjections +## Defines - Camera projection > CAMERA_PERSPECTIVE = 0 Perspective projection @@ -2149,7 +2067,7 @@ Orthographic projection --- -## Globals - N-patchLayout +## Defines - N-patch layout > NPATCH_NINE_PATCH = 0 Npatch layout: 3x3 tiles @@ -2169,7 +2087,7 @@ Npatch layout: 3x1 tiles --- -## Globals - Colors +## Defines - Colors LIGHTGRAY = { 200, 200, 200, 255 } Light Gray @@ -2327,7 +2245,7 @@ My own White (raylib logo) --- -## Globals - Math +## Defines - Math > PI = 3.1415927410126 Pi @@ -2347,7 +2265,7 @@ Radians to degrees --- -## Globals - GuiControlState +## Defines - Gui control state > STATE_NORMAL = 0 --- @@ -2365,7 +2283,7 @@ Radians to degrees --- -## Globals - GuiControlTextAlignment +## Defines - Gui control text alignment > TEXT_ALIGN_LEFT = 0 --- @@ -2379,7 +2297,7 @@ Radians to degrees --- -## Globals - GuiControlTextAlignmentVertical +## Defines - Gui control text alignment vertical > TEXT_ALIGN_TOP = 0 --- @@ -2393,7 +2311,7 @@ Radians to degrees --- -## Globals - GuiControlTextWrapMode +## Defines - Gui control text wrap mode > TEXT_WRAP_NONE = 0 --- @@ -2407,7 +2325,7 @@ Radians to degrees --- -## Globals - GuiControl +## Defines - Gui controls > DEFAULT = 0 --- @@ -2483,7 +2401,7 @@ Uses: BUTTON, VALUEBOX --- -## Globals - GuiControlProperty +## Defines - Gui base properties for every control > BORDER_COLOR_NORMAL = 0 --- @@ -2545,7 +2463,7 @@ Uses: BUTTON, VALUEBOX --- -## Globals - GuiDefaultProperty +## Defines - Gui extended properties depend on control > TEXT_SIZE = 16 Text size (glyphs max height) @@ -2589,7 +2507,7 @@ Text wrap-mode inside text bounds --- -## Globals - GuiToggleProperty +## Defines - Gui Toggle/ToggleGroup > GROUP_PADDING = 16 ToggleGroup separation between toggles @@ -2597,7 +2515,7 @@ ToggleGroup separation between toggles --- -## Globals - GuiSliderProperty +## Defines - Gui Slider/SliderBar > SLIDER_WIDTH = 16 Slider size of internal bar @@ -2611,7 +2529,7 @@ Slider/SliderBar internal bar padding --- -## Globals - GuiProgressBarProperty +## Defines - Gui ProgressBar > PROGRESS_PADDING = 16 ProgressBar internal padding @@ -2619,7 +2537,7 @@ ProgressBar internal padding --- -## Globals - GuiScrollBarProperty +## Defines - Gui ScrollBar > ARROWS_SIZE = 16 --- @@ -2647,7 +2565,7 @@ ProgressBar internal padding --- -## Globals - GuiCheckBoxProperty +## Defines - Gui CheckBox > CHECK_PADDING = 16 CheckBox internal check padding @@ -2655,7 +2573,7 @@ CheckBox internal check padding --- -## Globals - GuiComboBoxProperty +## Defines - Gui ComboBox > COMBO_BUTTON_WIDTH = 16 ComboBox right button width @@ -2669,7 +2587,7 @@ ComboBox button separation --- -## Globals - GuiDropdownBoxProperty +## Defines - Gui DropdownBox > ARROW_PADDING = 16 DropdownBox arrow separation from border and items @@ -2683,7 +2601,7 @@ DropdownBox items separation --- -## Globals - TextBox/TextBoxMulti/ValueBox/Spinner +## Defines - Gui TextBox/TextBoxMulti/ValueBox/Spinner > TEXT_READONLY = 16 TextBox in read-only mode: 0-text editable, 1-text no-editable @@ -2691,7 +2609,7 @@ TextBox in read-only mode: 0-text editable, 1-text no-editable --- -## Globals - GuiSpinnerProperty +## Defines - Gui Spinner > SPIN_BUTTON_WIDTH = 16 Spinner left/right buttons width @@ -2705,7 +2623,7 @@ Spinner buttons separation --- -## Globals - GuiListViewProperty +## Defines - Gui ListView > LIST_ITEMS_HEIGHT = 16 ListView items height @@ -2731,7 +2649,7 @@ ListView scrollbar side (0-left, 1-right) --- -## Globals - GuiColorPickerProperty +## Defines - Gui ColorPicker > COLOR_SELECTOR_SIZE = 16 --- @@ -2761,7 +2679,7 @@ ColorPicker right hue bar selector overflow --- -## Globals - LightType +## Defines - Light type > LIGHT_DIRECTIONAL = 0 Directional light @@ -2775,7 +2693,7 @@ Point light --- -## Globals - RLGL +## Defines - RLGL Default internal render batch elements limits > RL_DEFAULT_BATCH_BUFFER_ELEMENTS = 8192 Default internal render batch elements limits @@ -2801,7 +2719,7 @@ Maximum number of textures units that can be activated on batch drawing (SetShad --- -## Globals - RLGL +## Defines - RLGL Internal Matrix stack > RL_MAX_MATRIX_STACK_SIZE = 32 Maximum size of internal Matrix stack @@ -2809,7 +2727,7 @@ Maximum size of internal Matrix stack --- -## Globals - RLGL +## Defines - RLGL Shader limits > RL_MAX_SHADER_LOCATIONS = 32 Maximum number of shader locations supported @@ -2817,7 +2735,7 @@ Maximum number of shader locations supported --- -## Globals - RLGL +## Defines - RLGL Projection matrix culling > RL_CULL_DISTANCE_NEAR = 0.01 Default projection matrix near cull distance @@ -2831,7 +2749,7 @@ Default projection matrix far cull distance --- -## Globals - RLGL +## Defines - RLGL Texture parameters > RL_TEXTURE_WRAP_S = 10242 GL_TEXTURE_WRAP_S @@ -2929,7 +2847,7 @@ GL_MIRROR_CLAMP_EXT --- -## Globals - RLGL +## Defines - RLGL Matrix modes (equivalent to OpenGL) > RL_MODELVIEW = 5888 GL_MODELVIEW @@ -2949,7 +2867,7 @@ GL_TEXTURE --- -## Globals - RLGL +## Defines - RLGL Primitive assembly draw modes > RL_LINES = 1 GL_LINES @@ -2969,7 +2887,7 @@ GL_QUADS --- -## Globals - RLGL +## Defines - RLGL GL equivalent data types > RL_UNSIGNED_BYTE = 5121 GL_UNSIGNED_BYTE @@ -2983,7 +2901,7 @@ GL_FLOAT --- -## Globals - RLGL +## Defines - RLGL GL buffer usage hint > RL_STREAM_DRAW = 35040 GL_STREAM_DRAW @@ -3039,7 +2957,7 @@ GL_DYNAMIC_COPY --- -## Globals - RLGL +## Defines - RLGL Shader type > RL_FRAGMENT_SHADER = 35632 GL_FRAGMENT_SHADER @@ -3059,7 +2977,7 @@ GL_COMPUTE_SHADER --- -## Globals - RLGL +## Defines - RLGL GlVersion > RL_ZERO = 0 GL_ZERO @@ -3151,7 +3069,7 @@ GL_ONE_MINUS_CONSTANT_ALPHA --- -## Globals - RLGL +## Defines - RLGL GL blending functions/equations > RL_FUNC_ADD = 32774 GL_FUNC_ADD @@ -3231,7 +3149,7 @@ GL_BLEND_COLOR --- -## Globals - RLGL +## Defines - RLGL GlVersion > RL_OPENGL_11 = 1 OpenGL 1.1 @@ -3263,7 +3181,7 @@ OpenGL ES 2.0 (GLSL 100) --- -## Globals - RLGL +## Defines - RLGL Framebuffer attachment type > RL_ATTACHMENT_COLOR_CHANNEL0 = 0 Framebuffer attachment type: color 0 @@ -3325,7 +3243,7 @@ Framebuffer attachment type: stencil --- -## Globals - RLGL +## Defines - RLGL Framebuffer texture attachment type > RL_ATTACHMENT_CUBEMAP_POSITIVE_X = 0 Framebuffer texture attachment type: cubemap, +X side @@ -3375,7 +3293,7 @@ Framebuffer texture attachment type: renderbuffer --- -## Globals - RLGL +## Defines - RLGL CullMode > RL_CULL_FACE_FRONT = 0 --- @@ -3385,7 +3303,7 @@ Framebuffer texture attachment type: renderbuffer --- -## Globals - OpenGL +## Defines - OpenGL > GL_COLOR_BUFFER_BIT = 16384 --- @@ -3407,7 +3325,7 @@ Framebuffer texture attachment type: renderbuffer --- -## Globals - CBuffer +## Defines - CBuffer Data types > BUFFER_UNSIGNED_CHAR = 0 C type unsigned char @@ -3457,6 +3375,145 @@ C type double --- +## Defines - Keyboard keys (US keyboard layout) +> GLFW_KEY_UNKNOWN = -1 + +Key: Unknown + +--- + + +## Defines - GLFW API tokens. +> GLFW_RELEASE = 0 + +The key or mouse button was released + +--- + +> GLFW_PRESS = 1 + +The key or mouse button was pressed + +--- + +> GLFW_REPEAT = 2 + +The key was held down until it repeated + +--- + +> GLFW_CONNECTED = 262145 + +Joystick connected + +--- + +> GLFW_DISCONNECTED = 262146 + +Joystick disconnected + +--- + + +## Defines - GLFW Window Events. +> GLFW_WINDOW_SIZE_EVENT = 0 + +GLFW event window size changed + +--- + +> GLFW_WINDOW_MAXIMIZE_EVENT = 1 + +GLFW event window maximize + +--- + +> GLFW_WINDOW_ICONYFY_EVENT = 2 + +GLFW event window iconify + +--- + +> GLFW_WINDOW_FOCUS_EVENT = 3 + +GLFW event window focus + +--- + +> GLFW_WINDOW_DROP_EVENT = 4 + +GLFW event window drop + +--- + + +## Defines - GLFW Input Events. +> GLFW_KEY_EVENT = 5 + +GLFW event keyboard key + +--- + +> GLFW_CHAR_EVENT = 6 + +GLFW event Unicode character + +--- + +> GLFW_MOUSE_BUTTON_EVENT = 7 + +GLFW event mouse button + +--- + +> GLFW_MOUSE_CURSOR_POS_EVENT = 8 + +GLFW event cursor position + +--- + +> GLFW_MOUSE_SCROLL_EVENT = 9 + +GLFW event mouse scroll + +--- + +> GLFW_CURSOR_ENTER_EVENT = 10 + +GLFW event cursor enter/leave + +--- + +> GLFW_JOYSTICK_EVENT = 11 + +GLFW event joystick + +--- + + +## Defines - GLFW Pen Tablet Events. NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445. + +assignGlobalInt = nil + +// GLFW event pen tablet data + +--- + + +assignGlobalInt = nil + +// GLFW event pen tablet cursor + +--- + + +assignGlobalInt = nil + +// GLFW event pen tablet proximity + +--- + + ## Core - Window-related functions --- @@ -9682,7 +9739,7 @@ Set eyes view offsets matrices for stereo rendering > RL.glBlitFramebuffer( RenderTexture srcTex, RenderTexture dstTex, Rectangle srcRect, Rectangle dstRect, int mask, int filter ) Copy a block of pixels from one framebuffer object to another. -Use -1 RenderTexture for window framebuffer. +Use -1 RenderTexture for window framebuffer --- @@ -9921,3 +9978,129 @@ Ease elastic in out - Success return float --- + +## GLFW Core - Input-related functions: keyboard + +--- + +> keyName = RL.GetKeyName( int key, int scancode ) + +This function returns the name of the specified printable key, encoded as UTF-8. +If the key is KEY_UNKNOWN, the scancode is used to identify the key, +otherwise the scancode is ignored. If you specify a non-printable key, +or KEY_UNKNOWN and a scancode that maps to a non-printable key, +this function returns nil but does not emit an error. + +- Success return string or nil + +--- + +> scancode = RL.GetKeyScancode( int key ) + +This function returns the platform-specific scancode of the specified key. +If the key is KEY_UNKNOWN or does not exist on the keyboard this method will return -1. + +- Success return int + +--- + +## Window events + +--- + +> GLFWwindowsizeEvent = { int type, int width, int height } + +Called when the window is resized. Type GLFW_WINDOW_SIZE_EVENT + +--- + +> GLFWwindowmaximizeEvent = { int type, int maximized } + +Called when the window is maximized or restored. Type GLFW_WINDOW_MAXIMIZE_EVENT + +--- + +> GLFWwindowiconifyEvent = { int type, int iconified } + +Called when the window is iconified or restored. Type GLFW_WINDOW_ICONYFY_EVENT + +--- + +> GLFWwindowfocusEvent = { int type, int focused } + +Called when the window gains or loses input focus. Type GLFW_WINDOW_FOCUS_EVENT + +--- + +> GLFWdropEvent = { int type, int count, string{} paths } + +Called when files are dropped to the window. Type GLFW_WINDOW_DROP_EVENT + +--- + +## Input events + +--- + +> GLFWkeyEvent = { int type, int key, int scancode, int action, int mods } + +Called when a physical key is pressed or released or when it repeats. Type GLFW_KEY_EVENT + +--- + +> GLFWcharEvent = { int type, int key } + +Unicode code points for key events that would have led to regular text input and generally behaves as a standard text field on that platform. Type GLFW_CHAR_EVENT + +--- + +> GLFWmousebuttonEvent = { int type, int button, int action, int mods } + +Called when a mouse button is pressed or released. Type GLFW_MOUSE_BUTTON_EVENT + +--- + +> GLFWcursorposEvent = { int type, float x, float y } + +Called when the cursor moves over the window. Type GLFW_MOUSE_CURSOR_POS_EVENT + +--- + +> GLFWscrollEvent = { int type, float xoffset, float yoffset } + +Called when the user scrolls, whether with a mouse wheel or touchpad gesture. Type GLFW_MOUSE_SCROLL_EVENT + +--- + +> GLFWcursorenterEvent = { int type, int enter } + +Called when the cursor enters or leaves the content area of a window. Type GLFW_CURSOR_ENTER_EVENT + +--- + +> GLFWjoystickEvent = { int type, int jid, int event } + +Called when a joystick is connected or disconnected. Type GLFW_JOYSTICK_EVENT + +--- + +> GLFWpentabletdataEvent = { int type, float x, float y, float z, float pressure, float pitch, float yaw, float roll } + +Called when the pen tablet data is updated. Type GLFW_PEN_TABLET_DATA_EVENT +NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 + +--- + +> GLFWpentabletcursorEvent = { int type, int identifier } + +Called when the pen tablet cursor has changed. Type GLFW_PEN_TABLET_CURSOR_EVENT +NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 + +--- + +> GLFWpentabletproximityEvent = { int type, int proxState } + +Called when the pen tablet proximity has changed. Type GLFW_PEN_TABLET_PROXIMITY_EVENT +NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 + +--- @@ -16,7 +16,7 @@ Included submodules. * Raymath * Lights * Easings -* RLGL WIP (Mostly done) +* RLGL List of some MISSING features that are planned to be included. For specific function, check API. diff --git a/ReiLua_API.lua b/ReiLua_API.lua index b5e57e4..98d656a 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -21,7 +21,7 @@ function RL.log( logLevel, message ) end ---This function will be called on program close. Cleanup could be done here. function RL.exit() end --- Globals - ConfigFlags +-- Defines - System/Window config flags ---Set to try enabling V-Sync on GPU RL.FLAG_VSYNC_HINT=64 @@ -54,7 +54,7 @@ RL.FLAG_MSAA_4X_HINT=32 ---Set to try enabling interlaced video format (for V3D) RL.FLAG_INTERLACED_HINT=65536 --- Globals - TraceLogLevel +-- Defines - Trace log level ---Display all logs RL.LOG_ALL=0 @@ -73,7 +73,7 @@ RL.LOG_FATAL=6 ---Disable logging RL.LOG_NONE=7 --- Globals - KeyboardKey +-- Defines - Keyboard keys (US keyboard layout) ---Key: NULL, used for no key pressed RL.KEY_NULL=0 @@ -296,7 +296,7 @@ RL.KEY_VOLUME_UP=24 ---Key: Android volume down button RL.KEY_VOLUME_DOWN=25 --- Globals - MouseButtons +-- Defines - Mouse buttons ---Mouse button left RL.MOUSE_BUTTON_LEFT=0 @@ -313,7 +313,7 @@ RL.MOUSE_BUTTON_FORWARD=5 ---Mouse button back (advanced mouse device) RL.MOUSE_BUTTON_BACK=6 --- Globals - MouseCursor +-- Defines - Mouse cursor ---Default pointer shape RL.MOUSE_CURSOR_DEFAULT=0 @@ -338,7 +338,7 @@ RL.MOUSE_CURSOR_RESIZE_ALL=9 ---The operation-not-allowed shape RL.MOUSE_CURSOR_NOT_ALLOWED=10 --- Globals - GamepadButtons +-- Defines - Gamepad buttons ---Unknown button, just for error checking RL.GAMEPAD_BUTTON_UNKNOWN=0 @@ -377,7 +377,7 @@ RL.GAMEPAD_BUTTON_LEFT_THUMB=16 ---Gamepad joystick pressed button right RL.GAMEPAD_BUTTON_RIGHT_THUMB=17 --- Globals - GamepadAxis +-- Defines - Gamepad axis ---Gamepad left stick X axis RL.GAMEPAD_AXIS_LEFT_X=0 @@ -392,7 +392,7 @@ RL.GAMEPAD_AXIS_LEFT_TRIGGER=4 ---Gamepad back trigger right, pressure level: [1..-1] RL.GAMEPAD_AXIS_RIGHT_TRIGGER=5 --- Globals - MapTypes +-- Defines - Material map index ---Albedo material (same as: MATERIAL_MAP_DIFFUSE) RL.MATERIAL_MAP_ALBEDO=0 @@ -421,7 +421,7 @@ RL.MATERIAL_MAP_DIFFUSE=0 ---Specular material (same as: MATERIAL_MAP_METALNESS) RL.MATERIAL_MAP_SPECULAR=1 --- Globals - ShaderLocationIndex +-- Defines - Shader location index ---Shader location: vertex attribute: position RL.SHADER_LOC_VERTEX_POSITION=0 @@ -480,7 +480,7 @@ RL.SHADER_LOC_MAP_DIFFUSE=15 ---Shader location: sampler2d texture: specular (same as: SHADER_LOC_MAP_METALNESS) RL.SHADER_LOC_MAP_SPECULAR=16 --- Globals - ShaderUniformDataType +-- Defines - Shader uniform data type ---Shader uniform type: float RL.SHADER_UNIFORM_FLOAT=0 @@ -501,7 +501,7 @@ RL.SHADER_UNIFORM_IVEC4=7 ---Shader uniform type: sampler2d RL.SHADER_UNIFORM_SAMPLER2D=8 --- Globals - ShaderAttributeDataTypes +-- Defines - Shader attribute data types ---Shader attribute type: float RL.SHADER_ATTRIB_FLOAT=0 @@ -512,7 +512,7 @@ RL.SHADER_ATTRIB_VEC3=2 ---Shader attribute type: vec4 (4 float) RL.SHADER_ATTRIB_VEC4=3 --- Globals - PixelFormats +-- Defines - Pixel formats ---8 bit per pixel (no alpha) RL.PIXELFORMAT_UNCOMPRESSED_GRAYSCALE=1 @@ -557,7 +557,7 @@ RL.PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA=23 ---2 bpp RL.PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA=24 --- Globals - TextureFilters +-- Defines - Texture parameters: filter mode ---No filter, just pixel approximation RL.TEXTURE_FILTER_POINT=0 @@ -572,7 +572,7 @@ RL.TEXTURE_FILTER_ANISOTROPIC_8X=4 ---Anisotropic filtering 16x RL.TEXTURE_FILTER_ANISOTROPIC_16X=5 --- Globals - TextureWrap +-- Defines - Texture parameters: wrap mode ---Repeats texture in tiled mode RL.TEXTURE_WRAP_REPEAT=0 @@ -583,7 +583,7 @@ RL.TEXTURE_WRAP_MIRROR_REPEAT=2 ---Mirrors and clamps to border the texture in tiled mode RL.TEXTURE_WRAP_MIRROR_CLAMP=3 --- Globals - CubemapLayout +-- Defines - Cubemap layouts ---Automatically detect layout type RL.CUBEMAP_LAYOUT_AUTO_DETECT=0 @@ -598,7 +598,7 @@ RL.CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE=4 ---Layout is defined by a panorama image (equirrectangular map) RL.CUBEMAP_LAYOUT_PANORAMA=5 --- Globals - FontType +-- Defines - Font type, defines generation method ---Default font generation, anti-aliased RL.FONT_DEFAULT=0 @@ -607,7 +607,7 @@ RL.FONT_BITMAP=1 ---SDF font generation, requires external shader RL.FONT_SDF=2 --- Globals - BlendModes +-- Defines - Color blending modes (pre-defined) ---Blend textures considering alpha (default) RL.BLEND_ALPHA=0 @@ -626,7 +626,7 @@ RL.BLEND_CUSTOM=6 ---Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()) RL.BLEND_CUSTOM_SEPARATE=7 --- Globals - Gesture +-- Defines - Gesture ---No gesture RL.GESTURE_NONE=0 @@ -651,7 +651,7 @@ RL.GESTURE_PINCH_IN=256 ---Pinch out gesture RL.GESTURE_PINCH_OUT=512 --- Globals - CameraMode +-- Defines - Camera system modes ---Custom camera RL.CAMERA_CUSTOM=0 @@ -664,14 +664,14 @@ RL.CAMERA_FIRST_PERSON=3 ---Third person camera RL.CAMERA_THIRD_PERSON=4 --- Globals - CameraProjections +-- Defines - Camera projection ---Perspective projection RL.CAMERA_PERSPECTIVE=0 ---Orthographic projection RL.CAMERA_ORTHOGRAPHIC=1 --- Globals - N-patchLayout +-- Defines - N-patch layout ---Npatch layout: 3x3 tiles RL.NPATCH_NINE_PATCH=0 @@ -680,7 +680,7 @@ RL.NPATCH_THREE_PATCH_VERTICAL=1 ---Npatch layout: 3x1 tiles RL.NPATCH_THREE_PATCH_HORIZONTAL=2 --- Globals - Colors +-- Defines - Colors ---Light Gray RL.LIGHTGRAY={200,200,200,255} @@ -735,7 +735,7 @@ RL.MAGENTA={255,0,255,255} ---My own White (raylib logo) RL.RAYWHITE={245,245,245,255} --- Globals - Math +-- Defines - Math ---Pi RL.PI=3.1415927410126 @@ -744,32 +744,32 @@ RL.DEG2RAD=0.017453292384744 ---Radians to degrees RL.RAD2DEG=57.295776367188 --- Globals - GuiControlState +-- Defines - Gui control state RL.STATE_NORMAL=0 RL.STATE_FOCUSED=1 RL.STATE_PRESSED=2 RL.STATE_DISABLED=3 --- Globals - GuiControlTextAlignment +-- Defines - Gui control text alignment RL.TEXT_ALIGN_LEFT=0 RL.TEXT_ALIGN_CENTER=1 RL.TEXT_ALIGN_RIGHT=2 --- Globals - GuiControlTextAlignmentVertical +-- Defines - Gui control text alignment vertical RL.TEXT_ALIGN_TOP=0 RL.TEXT_ALIGN_MIDDLE=1 RL.TEXT_ALIGN_BOTTOM=2 --- Globals - GuiControlTextWrapMode +-- Defines - Gui control text wrap mode RL.TEXT_WRAP_NONE=0 RL.TEXT_WRAP_CHAR=1 RL.TEXT_WRAP_WORD=2 --- Globals - GuiControl +-- Defines - Gui controls RL.DEFAULT=0 ---Used also for: LABELBUTTON @@ -793,7 +793,7 @@ RL.COLORPICKER=13 RL.SCROLLBAR=14 RL.STATUSBAR=15 --- Globals - GuiControlProperty +-- Defines - Gui base properties for every control RL.BORDER_COLOR_NORMAL=0 RL.BASE_COLOR_NORMAL=1 @@ -811,7 +811,7 @@ RL.BORDER_WIDTH=12 RL.TEXT_PADDING=13 RL.TEXT_ALIGNMENT=14 --- Globals - GuiDefaultProperty +-- Defines - Gui extended properties depend on control ---Text size (glyphs max height) RL.TEXT_SIZE=16 @@ -828,24 +828,24 @@ RL.TEXT_ALIGNMENT_VERTICAL=21 ---Text wrap-mode inside text bounds RL.TEXT_WRAP_MODE=22 --- Globals - GuiToggleProperty +-- Defines - Gui Toggle/ToggleGroup ---ToggleGroup separation between toggles RL.GROUP_PADDING=16 --- Globals - GuiSliderProperty +-- Defines - Gui Slider/SliderBar ---Slider size of internal bar RL.SLIDER_WIDTH=16 ---Slider/SliderBar internal bar padding RL.SLIDER_PADDING=17 --- Globals - GuiProgressBarProperty +-- Defines - Gui ProgressBar ---ProgressBar internal padding RL.PROGRESS_PADDING=16 --- Globals - GuiScrollBarProperty +-- Defines - Gui ScrollBar RL.ARROWS_SIZE=16 RL.ARROWS_VISIBLE=17 @@ -855,38 +855,38 @@ RL.SCROLL_SLIDER_SIZE=19 RL.SCROLL_PADDING=20 RL.SCROLL_SPEED=21 --- Globals - GuiCheckBoxProperty +-- Defines - Gui CheckBox ---CheckBox internal check padding RL.CHECK_PADDING=16 --- Globals - GuiComboBoxProperty +-- Defines - Gui ComboBox ---ComboBox right button width RL.COMBO_BUTTON_WIDTH=16 ---ComboBox button separation RL.COMBO_BUTTON_SPACING=17 --- Globals - GuiDropdownBoxProperty +-- Defines - Gui DropdownBox ---DropdownBox arrow separation from border and items RL.ARROW_PADDING=16 ---DropdownBox items separation RL.DROPDOWN_ITEMS_SPACING=17 --- Globals - TextBox/TextBoxMulti/ValueBox/Spinner +-- Defines - Gui TextBox/TextBoxMulti/ValueBox/Spinner ---TextBox in read-only mode: 0-text editable, 1-text no-editable RL.TEXT_READONLY=16 --- Globals - GuiSpinnerProperty +-- Defines - Gui Spinner ---Spinner left/right buttons width RL.SPIN_BUTTON_WIDTH=16 ---Spinner buttons separation RL.SPIN_BUTTON_SPACING=17 --- Globals - GuiListViewProperty +-- Defines - Gui ListView ---ListView items height RL.LIST_ITEMS_HEIGHT=16 @@ -897,7 +897,7 @@ RL.SCROLLBAR_WIDTH=18 ---ListView scrollbar side (0-left, 1-right) RL.SCROLLBAR_SIDE=19 --- Globals - GuiColorPickerProperty +-- Defines - Gui ColorPicker RL.COLOR_SELECTOR_SIZE=16 ---ColorPicker right hue bar width @@ -909,14 +909,14 @@ RL.HUEBAR_SELECTOR_HEIGHT=19 ---ColorPicker right hue bar selector overflow RL.HUEBAR_SELECTOR_OVERFLOW=20 --- Globals - LightType +-- Defines - Light type ---Directional light RL.LIGHT_DIRECTIONAL=0 ---Point light RL.LIGHT_POINT=1 --- Globals - RLGL +-- Defines - RLGL Default internal render batch elements limits ---Default internal render batch elements limits RL.RL_DEFAULT_BATCH_BUFFER_ELEMENTS=8192 @@ -927,24 +927,24 @@ RL.RL_DEFAULT_BATCH_DRAWCALLS=256 ---Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) RL.RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS=4 --- Globals - RLGL +-- Defines - RLGL Internal Matrix stack ---Maximum size of internal Matrix stack RL.RL_MAX_MATRIX_STACK_SIZE=32 --- Globals - RLGL +-- Defines - RLGL Shader limits ---Maximum number of shader locations supported RL.RL_MAX_SHADER_LOCATIONS=32 --- Globals - RLGL +-- Defines - RLGL Projection matrix culling ---Default projection matrix near cull distance RL.RL_CULL_DISTANCE_NEAR=0.01 ---Default projection matrix far cull distance RL.RL_CULL_DISTANCE_FAR=1000.0 --- Globals - RLGL +-- Defines - RLGL Texture parameters ---GL_TEXTURE_WRAP_S RL.RL_TEXTURE_WRAP_S=10242 @@ -979,7 +979,7 @@ RL.RL_TEXTURE_WRAP_MIRROR_REPEAT=33648 ---GL_MIRROR_CLAMP_EXT RL.RL_TEXTURE_WRAP_MIRROR_CLAMP=34626 --- Globals - RLGL +-- Defines - RLGL Matrix modes (equivalent to OpenGL) ---GL_MODELVIEW RL.RL_MODELVIEW=5888 @@ -988,7 +988,7 @@ RL.RL_PROJECTION=5889 ---GL_TEXTURE RL.RL_TEXTURE=5890 --- Globals - RLGL +-- Defines - RLGL Primitive assembly draw modes ---GL_LINES RL.RL_LINES=1 @@ -997,14 +997,14 @@ RL.RL_TRIANGLES=4 ---GL_QUADS RL.RL_QUADS=7 --- Globals - RLGL +-- Defines - RLGL GL equivalent data types ---GL_UNSIGNED_BYTE RL.RL_UNSIGNED_BYTE=5121 ---GL_FLOAT RL.RL_FLOAT=5126 --- Globals - RLGL +-- Defines - RLGL GL buffer usage hint ---GL_STREAM_DRAW RL.RL_STREAM_DRAW=35040 @@ -1025,7 +1025,7 @@ RL.RL_DYNAMIC_READ=35049 ---GL_DYNAMIC_COPY RL.RL_DYNAMIC_COPY=35050 --- Globals - RLGL +-- Defines - RLGL Shader type ---GL_FRAGMENT_SHADER RL.RL_FRAGMENT_SHADER=35632 @@ -1034,7 +1034,7 @@ RL.RL_VERTEX_SHADER=35633 ---GL_COMPUTE_SHADER RL.RL_COMPUTE_SHADER=37305 --- Globals - RLGL +-- Defines - RLGL GlVersion ---GL_ZERO RL.RL_ZERO=0 @@ -1067,7 +1067,7 @@ RL.RL_CONSTANT_ALPHA=32771 ---GL_ONE_MINUS_CONSTANT_ALPHA RL.RL_ONE_MINUS_CONSTANT_ALPHA=32772 --- Globals - RLGL +-- Defines - RLGL GL blending functions/equations ---GL_FUNC_ADD RL.RL_FUNC_ADD=32774 @@ -1096,7 +1096,7 @@ RL.RL_BLEND_SRC_ALPHA=32971 ---GL_BLEND_COLOR RL.RL_BLEND_COLOR=32773 --- Globals - RLGL +-- Defines - RLGL GlVersion ---OpenGL 1.1 RL.RL_OPENGL_11=1 @@ -1109,7 +1109,7 @@ RL.RL_OPENGL_43=4 ---OpenGL ES 2.0 (GLSL 100) RL.RL_OPENGL_ES_20=5 --- Globals - RLGL +-- Defines - RLGL Framebuffer attachment type ---Framebuffer attachment type: color 0 RL.RL_ATTACHMENT_COLOR_CHANNEL0=0 @@ -1132,7 +1132,7 @@ RL.RL_ATTACHMENT_DEPTH=100 ---Framebuffer attachment type: stencil RL.RL_ATTACHMENT_STENCIL=200 --- Globals - RLGL +-- Defines - RLGL Framebuffer texture attachment type ---Framebuffer texture attachment type: cubemap, +X side RL.RL_ATTACHMENT_CUBEMAP_POSITIVE_X=0 @@ -1151,12 +1151,12 @@ RL.RL_ATTACHMENT_TEXTURE2D=100 ---Framebuffer texture attachment type: renderbuffer RL.RL_ATTACHMENT_RENDERBUFFER=200 --- Globals - RLGL +-- Defines - RLGL CullMode RL.RL_CULL_FACE_FRONT=0 RL.RL_CULL_FACE_BACK=1 --- Globals - OpenGL +-- Defines - OpenGL RL.GL_COLOR_BUFFER_BIT=16384 RL.GL_DEPTH_BUFFER_BIT=256 @@ -1164,7 +1164,7 @@ RL.GL_STENCIL_BUFFER_BIT=1024 RL.GL_NEAREST=9728 RL.GL_LINEAR=9729 --- Globals - CBuffer +-- Defines - CBuffer Data types ---C type unsigned char RL.BUFFER_UNSIGNED_CHAR=0 @@ -1182,6 +1182,63 @@ RL.BUFFER_INT=5 RL.BUFFER_FLOAT=6 ---C type double RL.BUFFER_DOUBLE=7 + +-- Defines - Keyboard keys (US keyboard layout) + +---Key: Unknown +RL.GLFW_KEY_UNKNOWN=-1 + +-- Defines - GLFW API tokens. + +---The key or mouse button was released +RL.GLFW_RELEASE=0 +---The key or mouse button was pressed +RL.GLFW_PRESS=1 +---The key was held down until it repeated +RL.GLFW_REPEAT=2 +---Joystick connected +RL.GLFW_CONNECTED=262145 +---Joystick disconnected +RL.GLFW_DISCONNECTED=262146 + +-- Defines - GLFW Window Events. + +---GLFW event window size changed +RL.GLFW_WINDOW_SIZE_EVENT=0 +---GLFW event window maximize +RL.GLFW_WINDOW_MAXIMIZE_EVENT=1 +---GLFW event window iconify +RL.GLFW_WINDOW_ICONYFY_EVENT=2 +---GLFW event window focus +RL.GLFW_WINDOW_FOCUS_EVENT=3 +---GLFW event window drop +RL.GLFW_WINDOW_DROP_EVENT=4 + +-- Defines - GLFW Input Events. + +---GLFW event keyboard key +RL.GLFW_KEY_EVENT=5 +---GLFW event Unicode character +RL.GLFW_CHAR_EVENT=6 +---GLFW event mouse button +RL.GLFW_MOUSE_BUTTON_EVENT=7 +---GLFW event cursor position +RL.GLFW_MOUSE_CURSOR_POS_EVENT=8 +---GLFW event mouse scroll +RL.GLFW_MOUSE_SCROLL_EVENT=9 +---GLFW event cursor enter/leave +RL.GLFW_CURSOR_ENTER_EVENT=10 +---GLFW event joystick +RL.GLFW_JOYSTICK_EVENT=11 + +-- Defines - GLFW Pen Tablet Events. NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445. + +---// GLFW event pen tablet data +RL.assignGlobalInt=nil +---// GLFW event pen tablet cursor +RL.assignGlobalInt=nil +---// GLFW event pen tablet proximity +RL.assignGlobalInt=nil -- Core - Window-related functions ---Close window and unload OpenGL context and free all resources @@ -6735,7 +6792,7 @@ function RL.rlSetMatrixViewOffsetStereo( right, left ) end -- OpenGL - Framebuffer management ---Copy a block of pixels from one framebuffer object to another. ----Use -1 RenderTexture for window framebuffer. +---Use -1 RenderTexture for window framebuffer ---@param srcTex any ---@param dstTex any ---@param srcRect table @@ -6988,3 +7045,23 @@ function RL.EaseElasticOut( t, b, c, d ) end ---@return any value function RL.EaseElasticInOut( t, b, c, d ) end +-- GLFW Core - Input-related functions: keyboard + +---This function returns the name of the specified printable key, encoded as UTF-8. +---If the key is KEY_UNKNOWN, the scancode is used to identify the key, +---otherwise the scancode is ignored. If you specify a non-printable key, +---or KEY_UNKNOWN and a scancode that maps to a non-printable key, +---this function returns nil but does not emit an error. +---- Success return string or nil +---@param key integer +---@param scancode integer +---@return any keyName +function RL.GetKeyName( key, scancode ) end + +---This function returns the platform-specific scancode of the specified key. +---If the key is KEY_UNKNOWN or does not exist on the keyboard this method will return -1. +---- Success return int +---@param key integer +---@return any scancode +function RL.GetKeyScancode( key ) end + @@ -14,6 +14,7 @@ KEY CHANGES: - CHANGE: Renamed event enums. Events are now platform specific. - ADDED: SDL Events. - ADDED: Experimental GLFW Pen Touch events. Needs glfw PR https://github.com/glfw/glfw/pull/1445. + - ADDED: Platform specific API documentation generation. DETAILED CHANGES: - REMOVED: DrawLineBezierQuad, DrawLineBezierCubic. @@ -27,6 +28,8 @@ DETAILED CHANGES: - FIXED: Snake example after Vector2Angle change. - FIXED: Raygui edit mode selection. - CHANGE: Moved glfw headers to GLFW folder. + - CHANGE: Term globals changed to defines in documentation. + - CHANGE: Event documentation is now described in c files. ------------------------------------------------------------------------ Release: ReiLua version 0.6.0 Using Raylib 4.5 @@ -2,7 +2,6 @@ Current { } Backlog { - * Platform specific API documentation. * Platform desktop SDL. * Text input not working on gui. Could this be Raylib issue? * Haptic functions. @@ -1,6 +1,10 @@ ---Create api.md and ReiLua_API.lua files from c sources. +--[[ + Create api.md and ReiLua_API.lua files from c sources. --- Export each module as separate .md file. + To generate API for other platforms you need to change sourceFiles. +]]-- + +-- Export each module as separate .md file. Does not affect on ReiLua_API.lua file. local separate = false if arg ~= nil and arg[1] ~= nil and arg[1] == "-s" then @@ -232,100 +236,96 @@ ModelAnimation\n\n---\n" ) apiFile:write( "\n> Buffer = Buffer userdata\n\ Data buffer for C primitive types. Type should be one of the Buffer types.\n\n---\n" ) --- Events. - -apiFile:write( "\n## Events\n" ) -apiFile:write( "\nContent of event table received by RL.event.\n" ) -apiFile:write( "\n### Window events\n" ) -apiFile:write( "\n---\n> { type: RL.EVENT_WINDOW_SIZE, int width, int height }\n\n WindowSize Callback, runs when window is resized.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_WINDOW_MAXIMIZE, int maximized }\n\n Window Maximize Callback, runs when window is maximized.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_WINDOW_ICONYFY, int iconified }\n\n WindowIconify Callback, runs when window is minimized/restored.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_WINDOW_FOCUS, int focused }\n\n WindowFocus Callback, runs when window get/lose focus.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_WINDOW_DROP, int count, string{} paths }\n\n Window Drop Callback, runs when drop files into window.\n\n---\n" ) -apiFile:write( "\n### Input events\n" ) -apiFile:write( "\n---\n> { type: RL.EVENT_KEY, int key, int scancode, int action, int mods }\n\n Keyboard Callback, runs on key pressed.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_CHAR, int key }\n\n Char Key Callback, runs on key pressed (get char value).\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_MOUSE_BUTTON, int button, int action, int mods }\n\n Mouse Button Callback, runs on mouse button pressed.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_MOUSE_CURSOR_POS, number x, number y }\n\n Cursor Position Callback, runs on mouse move.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_MOUSE_SCROLL, number xoffset, number yoffset }\n\n Srolling Callback, runs on mouse wheel.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_CURSOR_ENTER, int enter }\n\n Cursor Enter Callback, cursor enters client area.\n\n---\n" ) -apiFile:write( "\n> { type RL.EVENT_JOYSTICK, int jid, int event }\n\n .\n\n---\n" ) - if separate then apiFile:close() end --- Globals. +-- Defines. -local srcFile = io.open( "../src/lua_core.c", "r" ) -local writing = false -local globalVariableCount = 0 +local definesCount = 0 +local sourceFiles = { + "lua_core", + "platforms/core_desktop", + -- "platforms/core_desktop_sdl", +} -repeat - line = srcFile:read( "*l" ) - local lineSplit = split( line, " " ) +for _, src in ipairs( sourceFiles ) do + local srcFile = io.open( "../src/"..src..".c", "r" ) + local writing = false - if line == "/*DOC_END*/" then - writing = false - break - end + if separate then + local splits = split( src, "/" ) - if writing then - if lineSplit[1] == "\t/*" then - apiFile:write( "\n## Globals - "..lineSplit[2].."\n" ) - luaApiFile:write( "\n-- Globals - "..lineSplit[2].."\n\n" ) - else - -- Remove comma from the end. - local globalName = lineSplit[2]:sub( 1, -2 ) - local value = RL[ globalName ] - local comment = lineSplit[6] -- First split after // - - if comment ~= nil then - local i = 7 - - while lineSplit[i] ~= nil do - comment = comment.." "..lineSplit[i] - i = i + 1 - end - luaApiFile:write( "---"..comment.."\n" ) - end - - globalVariableCount = globalVariableCount + 1 - - if value == nil then - apiFile:write( "\n"..globalName.." = nil\n\n" ) - luaApiFile:write( "RL."..globalName.."=nil\n" ) - elseif type( value ) == "table" then - -- All tables are colors. - apiFile:write( globalName.." = { " - ..math.tointeger( value[1] )..", "..math.tointeger( value[2] )..", " - ..math.tointeger( value[3] )..", "..math.tointeger( value[4] ).." }\n\n" ) - luaApiFile:write( "RL."..globalName.."={" - ..math.tointeger( value[1] )..","..math.tointeger( value[2] ).."," - ..math.tointeger( value[3] )..","..math.tointeger( value[4] ).."}\n" ) + apiFile = io.open( "../"..splits[ #splits ]..".md", "w" ) + end + + repeat + local line = srcFile:read( "*l" ) + local lineSplit = split( line, " " ) + + if line == "/*DOC_DEFINES_END*/" then + writing = false + break + end + + if writing then + if lineSplit[1] == "\t/*" then + local gategorySplit = split( line, "*" ) + apiFile:write( "\n## Defines - "..gategorySplit[2]:sub( 2, #gategorySplit[2] - 1 ).."\n" ) + luaApiFile:write( "\n-- Defines - "..gategorySplit[2]:sub( 2, #gategorySplit[2] - 1 ).."\n\n" ) else - apiFile:write( "> "..globalName.." = "..value.."\n\n" ) - luaApiFile:write( "RL."..globalName.."="..value.."\n" ) - end - - if comment ~= nil then - apiFile:write( comment.."\n\n" ) + -- Remove comma from the end. + local defineName = lineSplit[2]:sub( 1, -2 ) + local value = RL[ defineName ] + local comment = lineSplit[6] -- First split after // + + if comment ~= nil then + local i = 7 + + while lineSplit[i] ~= nil do + comment = comment.." "..lineSplit[i] + i = i + 1 + end + luaApiFile:write( "---"..comment.."\n" ) + end + + definesCount = definesCount + 1 + + if value == nil then + apiFile:write( "\n"..defineName.." = nil\n\n" ) + luaApiFile:write( "RL."..defineName.."=nil\n" ) + elseif type( value ) == "table" then + -- All tables are colors. + apiFile:write( defineName.." = { " + ..math.tointeger( value[1] )..", "..math.tointeger( value[2] )..", " + ..math.tointeger( value[3] )..", "..math.tointeger( value[4] ).." }\n\n" ) + luaApiFile:write( "RL."..defineName.."={" + ..math.tointeger( value[1] )..","..math.tointeger( value[2] ).."," + ..math.tointeger( value[3] )..","..math.tointeger( value[4] ).."}\n" ) + else + apiFile:write( "> "..defineName.." = "..value.."\n\n" ) + luaApiFile:write( "RL."..defineName.."="..value.."\n" ) + end + + if comment ~= nil then + apiFile:write( comment.."\n\n" ) + end + + apiFile:write( "---\n\n" ) end - - apiFile:write( "---\n\n" ) end - end - - if line == "/*DOC_START*/" then - writing = true - end -until line == nil + + if line == "/*DOC_DEFINES_START*/" then + writing = true + end + until line == nil -srcFile:close() + srcFile:close() +end --- Functions. +-- Functions and events. -local sourceFiles = { +sourceFiles = { "core", "shapes", "textures", @@ -338,18 +338,24 @@ local sourceFiles = { "rlgl", "gl", "easings", + "platforms/core_desktop", + -- "platforms/core_desktop_sdl", } local functionCount = 0 for _, src in ipairs( sourceFiles ) do - srcFile = io.open( "../src/"..src..".c", "r" ) + local srcFile = io.open( "../src/"..src..".c", "r" ) local line = "" local funcStr = "" local p = false + local event = false if separate then - apiFile = io.open( src..".md", "w" ) + local splits = split( src, "/" ) + + apiFile = io.open( "../"..splits[ #splits ]..".md", "a" ) + -- apiFile = io.open( "../"..src..".md", "w" ) end repeat @@ -358,20 +364,33 @@ for _, src in ipairs( sourceFiles ) do if line == "*/" then p = false apiFile:write( "\n---\n" ) - luaApiFile:write( funcStr.."\n" ) - funcStr = "" + + if not event then + luaApiFile:write( funcStr.."\n" ) + funcStr = "" + end + -- There should be not function definition after events. + elseif line == "/* Events. */" then + event = true end if p then apiFile:write( line.."\n" ) if line:sub( 1, 2 ) == "##" then - luaApiFile:write( "-- "..line:sub( 4 ).."\n" ) + if not event then + luaApiFile:write( "-- "..line:sub( 4 ).."\n" ) + end elseif line:sub( 1, 1 ) == ">" then - funcStr = parseFunction( line ) - functionCount = functionCount + 1 + -- Do not parse events. Only visible in API.md + if not event then + funcStr = parseFunction( line ) + functionCount = functionCount + 1 + end elseif line:sub( 1, 1 ) ~= "" then - luaApiFile:write( "---"..line.."\n" ) + if not event then + luaApiFile:write( "---"..line.."\n" ) + end end end @@ -392,4 +411,4 @@ if not separate then apiFile:close() end -print( "Parsed:\n"..globalVariableCount.." Global variables\n"..functionCount.." Functions" )
\ No newline at end of file +print( "Parsed:\n"..definesCount.." Defines\n"..functionCount.." Functions" ) diff --git a/include/state.h b/include/state.h index 0ebd828..4eb5dcd 100644 --- a/include/state.h +++ b/include/state.h @@ -17,13 +17,13 @@ typedef struct { int *RLGLcurrentShaderLocs; /* Events. */ #ifdef PLATFORM_DESKTOP - /* Window events. */ + /* Window events. */ GLFWwindowsizefun raylibWindowSizeCallback; GLFWwindowmaximizefun raylibWindowMaximizeCallback; GLFWwindowiconifyfun raylibWindowIconifyCallback; GLFWwindowfocusfun raylibWindowFocusCallback; GLFWdropfun raylibWindowDropCallback; - /* Input events. */ + /* Input events. */ GLFWkeyfun raylibKeyCallback; GLFWcharfun raylibCharCallback; GLFWmousebuttonfun raylibMouseButtonCallback; @@ -12,7 +12,7 @@ > RL.glBlitFramebuffer( RenderTexture srcTex, RenderTexture dstTex, Rectangle srcRect, Rectangle dstRect, int mask, int filter ) Copy a block of pixels from one framebuffer object to another. -Use -1 RenderTexture for window framebuffer. +Use -1 RenderTexture for window framebuffer */ int lglBlitFramebuffer( lua_State *L ) { if ( !( lua_isuserdata( L, 1 ) || lua_isnil( L, 1 ) ) || !( lua_isuserdata( L, 2 ) || lua_isnil( L, 2 ) ) ) { diff --git a/src/lua_core.c b/src/lua_core.c index e29a943..0874613 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -325,9 +325,9 @@ static void defineGlobals() { lua_setglobal( L, "RL" ); lua_getglobal( L, "RL" ); -/* Note! Docgen relyes on this line format. Splits info based on spaces. */ -/*DOC_START*/ - /* ConfigFlags */ +/* Note! Docgen relyes on this line format. */ +/*DOC_DEFINES_START*/ + /* System/Window config flags */ assignGlobalInt( FLAG_VSYNC_HINT, "FLAG_VSYNC_HINT" ); // Set to try enabling V-Sync on GPU assignGlobalInt( FLAG_FULLSCREEN_MODE, "FLAG_FULLSCREEN_MODE" ); // Set to run program in fullscreen assignGlobalInt( FLAG_WINDOW_RESIZABLE, "FLAG_WINDOW_RESIZABLE" ); // Set to allow resizable window @@ -343,7 +343,7 @@ static void defineGlobals() { assignGlobalInt( FLAG_WINDOW_MOUSE_PASSTHROUGH, "FLAG_WINDOW_MOUSE_PASSTHROUGH" ); // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED assignGlobalInt( FLAG_MSAA_4X_HINT, "FLAG_MSAA_4X_HINT" ); // Set to try enabling MSAA 4X assignGlobalInt( FLAG_INTERLACED_HINT, "FLAG_INTERLACED_HINT" ); // Set to try enabling interlaced video format (for V3D) - /* TraceLogLevel */ + /* Trace log level */ assignGlobalInt( LOG_ALL, "LOG_ALL" ); // Display all logs assignGlobalInt( LOG_TRACE, "LOG_TRACE" ); // Trace logging, intended for internal use only assignGlobalInt( LOG_DEBUG, "LOG_DEBUG" ); // Debug logging, used for internal debugging, it should be disabled on release builds @@ -352,7 +352,7 @@ static void defineGlobals() { assignGlobalInt( LOG_ERROR, "LOG_ERROR" ); // Error logging, used on unrecoverable failures assignGlobalInt( LOG_FATAL, "LOG_FATAL" ); // Fatal logging, used to abort program: exit(EXIT_FAILURE) assignGlobalInt( LOG_NONE, "LOG_NONE" ); // Disable logging - /* KeyboardKey */ + /* Keyboard keys (US keyboard layout) */ assignGlobalInt( KEY_NULL, "KEY_NULL" ); // Key: NULL, used for no key pressed assignGlobalInt( KEY_APOSTROPHE, "KEY_APOSTROPHE" ); // Key: ' assignGlobalInt( KEY_COMMA, "KEY_COMMA" ); // Key: , @@ -463,7 +463,7 @@ static void defineGlobals() { assignGlobalInt( KEY_MENU, "KEY_MENU" ); // Key: Android menu button assignGlobalInt( KEY_VOLUME_UP, "KEY_VOLUME_UP" ); // Key: Android volume up button assignGlobalInt( KEY_VOLUME_DOWN, "KEY_VOLUME_DOWN" ); // Key: Android volume down button - /* MouseButtons */ + /* Mouse buttons */ assignGlobalInt( MOUSE_BUTTON_LEFT, "MOUSE_BUTTON_LEFT" ); // Mouse button left assignGlobalInt( MOUSE_BUTTON_RIGHT, "MOUSE_BUTTON_RIGHT" ); // Mouse button right assignGlobalInt( MOUSE_BUTTON_MIDDLE, "MOUSE_BUTTON_MIDDLE" ); // Mouse button middle (pressed wheel) @@ -471,7 +471,7 @@ static void defineGlobals() { assignGlobalInt( MOUSE_BUTTON_EXTRA, "MOUSE_BUTTON_EXTRA" ); // Mouse button extra (advanced mouse device) assignGlobalInt( MOUSE_BUTTON_FORWARD, "MOUSE_BUTTON_FORWARD" ); // Mouse button forward (advanced mouse device) assignGlobalInt( MOUSE_BUTTON_BACK, "MOUSE_BUTTON_BACK" ); // Mouse button back (advanced mouse device) - /* MouseCursor */ + /* Mouse cursor */ assignGlobalInt( MOUSE_CURSOR_DEFAULT, "MOUSE_CURSOR_DEFAULT" ); // Default pointer shape assignGlobalInt( MOUSE_CURSOR_ARROW, "MOUSE_CURSOR_ARROW" ); // Arrow shape assignGlobalInt( MOUSE_CURSOR_IBEAM, "MOUSE_CURSOR_IBEAM" ); // Text writing cursor shape @@ -483,7 +483,7 @@ static void defineGlobals() { assignGlobalInt( MOUSE_CURSOR_RESIZE_NESW, "MOUSE_CURSOR_RESIZE_NESW" ); // The top-right to bottom-left diagonal resize/move arrow shape assignGlobalInt( MOUSE_CURSOR_RESIZE_ALL, "MOUSE_CURSOR_RESIZE_ALL" ); // The omnidirectional resize/move cursor shape assignGlobalInt( MOUSE_CURSOR_NOT_ALLOWED, "MOUSE_CURSOR_NOT_ALLOWED" ); // The operation-not-allowed shape - /* GamepadButtons */ + /* Gamepad buttons */ assignGlobalInt( GAMEPAD_BUTTON_UNKNOWN, "GAMEPAD_BUTTON_UNKNOWN" ); // Unknown button, just for error checking assignGlobalInt( GAMEPAD_BUTTON_LEFT_FACE_UP, "GAMEPAD_BUTTON_LEFT_FACE_UP" ); // Gamepad left DPAD up button assignGlobalInt( GAMEPAD_BUTTON_LEFT_FACE_RIGHT, "GAMEPAD_BUTTON_LEFT_FACE_RIGHT" ); // Gamepad left DPAD right button @@ -502,14 +502,14 @@ static void defineGlobals() { assignGlobalInt( GAMEPAD_BUTTON_MIDDLE_RIGHT, "GAMEPAD_BUTTON_MIDDLE_RIGHT" ); // Gamepad center buttons, right one (i.e. PS3: Start) assignGlobalInt( GAMEPAD_BUTTON_LEFT_THUMB, "GAMEPAD_BUTTON_LEFT_THUMB" ); // Gamepad joystick pressed button left assignGlobalInt( GAMEPAD_BUTTON_RIGHT_THUMB, "GAMEPAD_BUTTON_RIGHT_THUMB" ); // Gamepad joystick pressed button right - /* GamepadAxis */ + /* Gamepad axis */ assignGlobalInt( GAMEPAD_AXIS_LEFT_X, "GAMEPAD_AXIS_LEFT_X" ); // Gamepad left stick X axis assignGlobalInt( GAMEPAD_AXIS_LEFT_Y, "GAMEPAD_AXIS_LEFT_Y" ); // Gamepad left stick Y axis assignGlobalInt( GAMEPAD_AXIS_RIGHT_X, "GAMEPAD_AXIS_RIGHT_X" ); // Gamepad right stick X axis assignGlobalInt( GAMEPAD_AXIS_RIGHT_Y, "GAMEPAD_AXIS_RIGHT_Y" ); // Gamepad right stick Y axis assignGlobalInt( GAMEPAD_AXIS_LEFT_TRIGGER, "GAMEPAD_AXIS_LEFT_TRIGGER" ); // Gamepad back trigger left, pressure level: [1..-1] assignGlobalInt( GAMEPAD_AXIS_RIGHT_TRIGGER, "GAMEPAD_AXIS_RIGHT_TRIGGER" ); // Gamepad back trigger right, pressure level: [1..-1] - /* MapTypes */ + /* Material map index */ assignGlobalInt( MATERIAL_MAP_ALBEDO, "MATERIAL_MAP_ALBEDO" ); // Albedo material (same as: MATERIAL_MAP_DIFFUSE) assignGlobalInt( MATERIAL_MAP_METALNESS, "MATERIAL_MAP_METALNESS" ); // Metalness material (same as: MATERIAL_MAP_SPECULAR) assignGlobalInt( MATERIAL_MAP_NORMAL, "MATERIAL_MAP_NORMAL" ); // Normal material @@ -523,7 +523,7 @@ static void defineGlobals() { assignGlobalInt( MATERIAL_MAP_BRDF, "MATERIAL_MAP_BRDF" ); // Brdf material assignGlobalInt( MATERIAL_MAP_DIFFUSE, "MATERIAL_MAP_DIFFUSE" ); // Diffuce material (same as: MATERIAL_MAP_ALBEDO) assignGlobalInt( MATERIAL_MAP_SPECULAR, "MATERIAL_MAP_SPECULAR" ); // Specular material (same as: MATERIAL_MAP_METALNESS) - /* ShaderLocationIndex */ + /* Shader location index */ assignGlobalInt( SHADER_LOC_VERTEX_POSITION, "SHADER_LOC_VERTEX_POSITION" ); // Shader location: vertex attribute: position assignGlobalInt( SHADER_LOC_VERTEX_TEXCOORD01, "SHADER_LOC_VERTEX_TEXCOORD01" ); // Shader location: vertex attribute: texcoord01 assignGlobalInt( SHADER_LOC_VERTEX_TEXCOORD02, "SHADER_LOC_VERTEX_TEXCOORD02" ); // Shader location: vertex attribute: texcoord02 @@ -552,7 +552,7 @@ static void defineGlobals() { assignGlobalInt( SHADER_LOC_MAP_BRDF, "SHADER_LOC_MAP_BRDF" ); // Shader location: sampler2d texture: brdf assignGlobalInt( SHADER_LOC_MAP_DIFFUSE, "SHADER_LOC_MAP_DIFFUSE" ); // Shader location: sampler2d texture: diffuce (same as: SHADER_LOC_MAP_ALBEDO) assignGlobalInt( SHADER_LOC_MAP_SPECULAR, "SHADER_LOC_MAP_SPECULAR" ); // Shader location: sampler2d texture: specular (same as: SHADER_LOC_MAP_METALNESS) - /* ShaderUniformDataType */ + /* Shader uniform data type */ assignGlobalInt( SHADER_UNIFORM_FLOAT, "SHADER_UNIFORM_FLOAT" ); // Shader uniform type: float assignGlobalInt( SHADER_UNIFORM_VEC2, "SHADER_UNIFORM_VEC2" ); // Shader uniform type: vec2 (2 float) assignGlobalInt( SHADER_UNIFORM_VEC3, "SHADER_UNIFORM_VEC3" ); // Shader uniform type: vec3 (3 float) @@ -562,12 +562,12 @@ static void defineGlobals() { assignGlobalInt( SHADER_UNIFORM_IVEC3, "SHADER_UNIFORM_IVEC3" ); // Shader uniform type: ivec3 (3 int) assignGlobalInt( SHADER_UNIFORM_IVEC4, "SHADER_UNIFORM_IVEC4" ); // Shader uniform type: ivec4 (4 int) assignGlobalInt( SHADER_UNIFORM_SAMPLER2D, "SHADER_UNIFORM_SAMPLER2D" ); // Shader uniform type: sampler2d - /* ShaderAttributeDataTypes */ + /* Shader attribute data types */ assignGlobalInt( SHADER_ATTRIB_FLOAT, "SHADER_ATTRIB_FLOAT" ); // Shader attribute type: float assignGlobalInt( SHADER_ATTRIB_VEC2, "SHADER_ATTRIB_VEC2" ); // Shader attribute type: vec2 (2 float) assignGlobalInt( SHADER_ATTRIB_VEC3, "SHADER_ATTRIB_VEC3" ); // Shader attribute type: vec3 (3 float) assignGlobalInt( SHADER_ATTRIB_VEC4, "SHADER_ATTRIB_VEC4" ); // Shader attribute type: vec4 (4 float) - /* PixelFormats */ + /* Pixel formats */ assignGlobalInt( PIXELFORMAT_UNCOMPRESSED_GRAYSCALE, "PIXELFORMAT_UNCOMPRESSED_GRAYSCALE" ); // 8 bit per pixel (no alpha) assignGlobalInt( PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, "PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA" ); // 8*2 bpp (2 channels) assignGlobalInt( PIXELFORMAT_UNCOMPRESSED_R5G6B5, "PIXELFORMAT_UNCOMPRESSED_R5G6B5" ); // 16 bpp @@ -589,30 +589,30 @@ static void defineGlobals() { assignGlobalInt( PIXELFORMAT_COMPRESSED_PVRT_RGBA, "PIXELFORMAT_COMPRESSED_PVRT_RGBA" ); // 4 bpp assignGlobalInt( PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, "PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA" ); // 8 bpp assignGlobalInt( PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA, "PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA" ); // 2 bpp - /* TextureFilters */ + /* Texture parameters: filter mode */ assignGlobalInt( TEXTURE_FILTER_POINT, "TEXTURE_FILTER_POINT" ); // No filter, just pixel approximation assignGlobalInt( TEXTURE_FILTER_BILINEAR, "TEXTURE_FILTER_BILINEAR" ); // Linear filtering assignGlobalInt( TEXTURE_FILTER_TRILINEAR, "TEXTURE_FILTER_TRILINEAR" ); // Trilinear filtering (linear with mipmaps) assignGlobalInt( TEXTURE_FILTER_ANISOTROPIC_4X, "TEXTURE_FILTER_ANISOTROPIC_4X" ); // Anisotropic filtering 4x assignGlobalInt( TEXTURE_FILTER_ANISOTROPIC_8X, "TEXTURE_FILTER_ANISOTROPIC_8X" ); // Anisotropic filtering 8x assignGlobalInt( TEXTURE_FILTER_ANISOTROPIC_16X, "TEXTURE_FILTER_ANISOTROPIC_16X" ); // Anisotropic filtering 16x - /* TextureWrap */ + /* Texture parameters: wrap mode */ assignGlobalInt( TEXTURE_WRAP_REPEAT, "TEXTURE_WRAP_REPEAT" ); // Repeats texture in tiled mode assignGlobalInt( TEXTURE_WRAP_CLAMP, "TEXTURE_WRAP_CLAMP" ); // Clamps texture to edge pixel in tiled mode assignGlobalInt( TEXTURE_WRAP_MIRROR_REPEAT, "TEXTURE_WRAP_MIRROR_REPEAT" ); // Mirrors and repeats the texture in tiled mode assignGlobalInt( TEXTURE_WRAP_MIRROR_CLAMP, "TEXTURE_WRAP_MIRROR_CLAMP" ); // Mirrors and clamps to border the texture in tiled mode - /* CubemapLayout */ + /* Cubemap layouts */ assignGlobalInt( CUBEMAP_LAYOUT_AUTO_DETECT, "CUBEMAP_LAYOUT_AUTO_DETECT" ); // Automatically detect layout type assignGlobalInt( CUBEMAP_LAYOUT_LINE_VERTICAL, "CUBEMAP_LAYOUT_LINE_VERTICAL" ); // Layout is defined by a vertical line with faces assignGlobalInt( CUBEMAP_LAYOUT_LINE_HORIZONTAL, "CUBEMAP_LAYOUT_LINE_HORIZONTAL" ); // Layout is defined by a horizontal line with faces assignGlobalInt( CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, "CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR" ); // Layout is defined by a 3x4 cross with cubemap faces assignGlobalInt( CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, "CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE" ); // Layout is defined by a 4x3 cross with cubemap faces assignGlobalInt( CUBEMAP_LAYOUT_PANORAMA, "CUBEMAP_LAYOUT_PANORAMA" ); // Layout is defined by a panorama image (equirrectangular map) - /* FontType */ + /* Font type, defines generation method */ assignGlobalInt( FONT_DEFAULT, "FONT_DEFAULT" ); // Default font generation, anti-aliased assignGlobalInt( FONT_BITMAP, "FONT_BITMAP" ); // Bitmap font generation, no anti-aliasing assignGlobalInt( FONT_SDF, "FONT_SDF" ); // SDF font generation, requires external shader - /* BlendModes */ + /* Color blending modes (pre-defined) */ assignGlobalInt( BLEND_ALPHA, "BLEND_ALPHA" ); // Blend textures considering alpha (default) assignGlobalInt( BLEND_ADDITIVE, "BLEND_ADDITIVE" ); // Blend textures adding colors assignGlobalInt( BLEND_MULTIPLIED, "BLEND_MULTIPLIED" ); // Blend textures multiplying colors @@ -633,16 +633,16 @@ static void defineGlobals() { assignGlobalInt( GESTURE_SWIPE_DOWN, "GESTURE_SWIPE_DOWN" ); // Swipe down gesture assignGlobalInt( GESTURE_PINCH_IN, "GESTURE_PINCH_IN" ); // Pinch in gesture assignGlobalInt( GESTURE_PINCH_OUT, "GESTURE_PINCH_OUT" ); // Pinch out gesture - /* CameraMode */ + /* Camera system modes */ assignGlobalInt( CAMERA_CUSTOM, "CAMERA_CUSTOM" ); // Custom camera assignGlobalInt( CAMERA_FREE, "CAMERA_FREE" ); // Free camera assignGlobalInt( CAMERA_ORBITAL, "CAMERA_ORBITAL" ); // Orbital camera assignGlobalInt( CAMERA_FIRST_PERSON, "CAMERA_FIRST_PERSON" ); // First person camera assignGlobalInt( CAMERA_THIRD_PERSON, "CAMERA_THIRD_PERSON" ); // Third person camera - /* CameraProjections */ + /* Camera projection */ assignGlobalInt( CAMERA_PERSPECTIVE, "CAMERA_PERSPECTIVE" ); // Perspective projection assignGlobalInt( CAMERA_ORTHOGRAPHIC, "CAMERA_ORTHOGRAPHIC" ); // Orthographic projection - /* N-patchLayout */ + /* N-patch layout */ assignGlobalInt( NPATCH_NINE_PATCH, "NPATCH_NINE_PATCH" ); // Npatch layout: 3x3 tiles assignGlobalInt( NPATCH_THREE_PATCH_VERTICAL, "NPATCH_THREE_PATCH_VERTICAL" ); // Npatch layout: 1x3 tiles assignGlobalInt( NPATCH_THREE_PATCH_HORIZONTAL, "NPATCH_THREE_PATCH_HORIZONTAL" ); // Npatch layout: 3x1 tiles @@ -677,24 +677,24 @@ static void defineGlobals() { assignGlobalFloat( PI, "PI" ); // Pi assignGlobalFloat( DEG2RAD, "DEG2RAD" ); // Degrees to radians assignGlobalFloat( RAD2DEG, "RAD2DEG" ); // Radians to degrees - /* GuiControlState */ + /* Gui control state */ assignGlobalInt( STATE_NORMAL, "STATE_NORMAL" ); assignGlobalInt( STATE_FOCUSED, "STATE_FOCUSED" ); assignGlobalInt( STATE_PRESSED, "STATE_PRESSED" ); assignGlobalInt( STATE_DISABLED, "STATE_DISABLED" ); - /* GuiControlTextAlignment */ + /* Gui control text alignment */ assignGlobalInt( TEXT_ALIGN_LEFT, "TEXT_ALIGN_LEFT" ); assignGlobalInt( TEXT_ALIGN_CENTER, "TEXT_ALIGN_CENTER" ); assignGlobalInt( TEXT_ALIGN_RIGHT, "TEXT_ALIGN_RIGHT" ); - /* GuiControlTextAlignmentVertical */ + /* Gui control text alignment vertical */ assignGlobalInt( TEXT_ALIGN_TOP, "TEXT_ALIGN_TOP" ); assignGlobalInt( TEXT_ALIGN_MIDDLE, "TEXT_ALIGN_MIDDLE" ); assignGlobalInt( TEXT_ALIGN_BOTTOM, "TEXT_ALIGN_BOTTOM" ); - /* GuiControlTextWrapMode */ + /* Gui control text wrap mode */ assignGlobalInt( TEXT_WRAP_NONE, "TEXT_WRAP_NONE" ); assignGlobalInt( TEXT_WRAP_CHAR, "TEXT_WRAP_CHAR" ); assignGlobalInt( TEXT_WRAP_WORD, "TEXT_WRAP_WORD" ); - /* GuiControl */ + /* Gui controls */ assignGlobalInt( DEFAULT, "DEFAULT" ); assignGlobalInt( LABEL, "LABEL" ); // Used also for: LABELBUTTON assignGlobalInt( BUTTON, "BUTTON" ); @@ -711,7 +711,7 @@ static void defineGlobals() { assignGlobalInt( COLORPICKER, "COLORPICKER" ); assignGlobalInt( SCROLLBAR, "SCROLLBAR" ); assignGlobalInt( STATUSBAR, "STATUSBAR" ); - /* GuiControlProperty */ + /* Gui base properties for every control */ assignGlobalInt( BORDER_COLOR_NORMAL, "BORDER_COLOR_NORMAL" ); assignGlobalInt( BASE_COLOR_NORMAL, "BASE_COLOR_NORMAL" ); assignGlobalInt( TEXT_COLOR_NORMAL, "TEXT_COLOR_NORMAL" ); @@ -727,7 +727,7 @@ static void defineGlobals() { assignGlobalInt( BORDER_WIDTH, "BORDER_WIDTH" ); assignGlobalInt( TEXT_PADDING, "TEXT_PADDING" ); assignGlobalInt( TEXT_ALIGNMENT, "TEXT_ALIGNMENT" ); - /* GuiDefaultProperty */ + /* Gui extended properties depend on control */ assignGlobalInt( TEXT_SIZE, "TEXT_SIZE" ); // Text size (glyphs max height) assignGlobalInt( TEXT_SPACING, "TEXT_SPACING" ); // Text spacing between glyphs assignGlobalInt( LINE_COLOR, "LINE_COLOR" ); // Line control color @@ -735,45 +735,45 @@ static void defineGlobals() { assignGlobalInt( TEXT_LINE_SPACING, "TEXT_LINE_SPACING" ); // Text spacing between lines assignGlobalInt( TEXT_ALIGNMENT_VERTICAL, "TEXT_ALIGNMENT_VERTICAL" ); // Text vertical alignment inside text bounds (after border and padding) assignGlobalInt( TEXT_WRAP_MODE, "TEXT_WRAP_MODE" ); // Text wrap-mode inside text bounds - /* GuiToggleProperty */ + /* Gui Toggle/ToggleGroup */ assignGlobalInt( GROUP_PADDING, "GROUP_PADDING" ); // ToggleGroup separation between toggles - /* GuiSliderProperty */ + /* Gui Slider/SliderBar */ assignGlobalInt( SLIDER_WIDTH, "SLIDER_WIDTH" ); // Slider size of internal bar assignGlobalInt( SLIDER_PADDING, "SLIDER_PADDING" ); // Slider/SliderBar internal bar padding - /* GuiProgressBarProperty */ + /* Gui ProgressBar */ assignGlobalInt( PROGRESS_PADDING, "PROGRESS_PADDING" ); // ProgressBar internal padding - /* GuiScrollBarProperty */ + /* Gui ScrollBar */ assignGlobalInt( ARROWS_SIZE, "ARROWS_SIZE" ); assignGlobalInt( ARROWS_VISIBLE, "ARROWS_VISIBLE" ); assignGlobalInt( SCROLL_SLIDER_PADDING, "SCROLL_SLIDER_PADDING" ); // (SLIDERBAR, SLIDER_PADDING) assignGlobalInt( SCROLL_SLIDER_SIZE, "SCROLL_SLIDER_SIZE" ); assignGlobalInt( SCROLL_PADDING, "SCROLL_PADDING" ); assignGlobalInt( SCROLL_SPEED, "SCROLL_SPEED" ); - /* GuiCheckBoxProperty */ + /* Gui CheckBox */ assignGlobalInt( CHECK_PADDING, "CHECK_PADDING" ); // CheckBox internal check padding - /* GuiComboBoxProperty */ + /* Gui ComboBox */ assignGlobalInt( COMBO_BUTTON_WIDTH, "COMBO_BUTTON_WIDTH" ); // ComboBox right button width assignGlobalInt( COMBO_BUTTON_SPACING, "COMBO_BUTTON_SPACING" ); // ComboBox button separation - /* GuiDropdownBoxProperty */ + /* Gui DropdownBox */ assignGlobalInt( ARROW_PADDING, "ARROW_PADDING" ); // DropdownBox arrow separation from border and items assignGlobalInt( DROPDOWN_ITEMS_SPACING, "DROPDOWN_ITEMS_SPACING" ); // DropdownBox items separation - /* TextBox/TextBoxMulti/ValueBox/Spinner */ + /* Gui TextBox/TextBoxMulti/ValueBox/Spinner */ assignGlobalInt( TEXT_READONLY, "TEXT_READONLY" ); // TextBox in read-only mode: 0-text editable, 1-text no-editable - /* GuiSpinnerProperty */ + /* Gui Spinner */ assignGlobalInt( SPIN_BUTTON_WIDTH, "SPIN_BUTTON_WIDTH" ); // Spinner left/right buttons width assignGlobalInt( SPIN_BUTTON_SPACING, "SPIN_BUTTON_SPACING" ); // Spinner buttons separation - /* GuiListViewProperty */ + /* Gui ListView */ assignGlobalInt( LIST_ITEMS_HEIGHT, "LIST_ITEMS_HEIGHT" ); // ListView items height assignGlobalInt( LIST_ITEMS_SPACING, "LIST_ITEMS_SPACING" ); // ListView items separation assignGlobalInt( SCROLLBAR_WIDTH, "SCROLLBAR_WIDTH" ); // ListView scrollbar size (usually width) assignGlobalInt( SCROLLBAR_SIDE, "SCROLLBAR_SIDE" ); // ListView scrollbar side (0-left, 1-right) - /* GuiColorPickerProperty */ + /* Gui ColorPicker */ assignGlobalInt( COLOR_SELECTOR_SIZE, "COLOR_SELECTOR_SIZE" ); assignGlobalInt( HUEBAR_WIDTH, "HUEBAR_WIDTH" ); // ColorPicker right hue bar width assignGlobalInt( HUEBAR_PADDING, "HUEBAR_PADDING" ); // ColorPicker right hue bar separation from panel assignGlobalInt( HUEBAR_SELECTOR_HEIGHT, "HUEBAR_SELECTOR_HEIGHT" ); // ColorPicker right hue bar selector height assignGlobalInt( HUEBAR_SELECTOR_OVERFLOW, "HUEBAR_SELECTOR_OVERFLOW" ); // ColorPicker right hue bar selector overflow - /* LightType */ + /* Light type */ assignGlobalInt( LIGHT_DIRECTIONAL, "LIGHT_DIRECTIONAL" ); // Directional light assignGlobalInt( LIGHT_POINT, "LIGHT_POINT" ); // Point light /* RLGL Default internal render batch elements limits */ @@ -895,7 +895,7 @@ static void defineGlobals() { assignGlobalInt( GL_STENCIL_BUFFER_BIT, "GL_STENCIL_BUFFER_BIT" ); assignGlobalInt( GL_NEAREST, "GL_NEAREST" ); assignGlobalInt( GL_LINEAR, "GL_LINEAR" ); - /* CBuffer Data Types */ + /* CBuffer Data types */ assignGlobalInt( BUFFER_UNSIGNED_CHAR, "BUFFER_UNSIGNED_CHAR" ); // C type unsigned char assignGlobalInt( BUFFER_UNSIGNED_SHORT, "BUFFER_UNSIGNED_SHORT" ); // C type unsigned short assignGlobalInt( BUFFER_UNSIGNED_INT, "BUFFER_UNSIGNED_INT" ); // C type unsigned int @@ -904,8 +904,7 @@ static void defineGlobals() { assignGlobalInt( BUFFER_INT, "BUFFER_INT" ); // C type int assignGlobalInt( BUFFER_FLOAT, "BUFFER_FLOAT" ); // C type float assignGlobalInt( BUFFER_DOUBLE, "BUFFER_DOUBLE" ); // C type double -/*DOC_END*/ - +/*DOC_DEFINES_END*/ lua_pop( L, -1 ); } diff --git a/src/platforms/core_desktop.c b/src/platforms/core_desktop.c index 4ea871a..614062d 100644 --- a/src/platforms/core_desktop.c +++ b/src/platforms/core_desktop.c @@ -7,22 +7,22 @@ static void platformDefineGlobals() { lua_State *L = state->luaState; lua_getglobal( L, "RL" ); - - /* KeyboardKey */ +/*DOC_DEFINES_START*/ + /* Keyboard keys (US keyboard layout) */ assignGlobalInt( GLFW_KEY_UNKNOWN, "GLFW_KEY_UNKNOWN" ); // Key: Unknown - /* GLFW API tokens. */ + /* GLFW API tokens. */ assignGlobalInt( GLFW_RELEASE, "GLFW_RELEASE" ); // The key or mouse button was released assignGlobalInt( GLFW_PRESS, "GLFW_PRESS" ); // The key or mouse button was pressed assignGlobalInt( GLFW_REPEAT, "GLFW_REPEAT" ); // The key was held down until it repeated assignGlobalInt( GLFW_CONNECTED, "GLFW_CONNECTED" ); // Joystick connected assignGlobalInt( GLFW_DISCONNECTED, "GLFW_DISCONNECTED" ); // Joystick disconnected - /* Window Events. */ + /* GLFW Window Events. */ assignGlobalInt( GLFW_WINDOW_SIZE_EVENT, "GLFW_WINDOW_SIZE_EVENT" ); // GLFW event window size changed assignGlobalInt( GLFW_WINDOW_MAXIMIZE_EVENT, "GLFW_WINDOW_MAXIMIZE_EVENT" ); // GLFW event window maximize assignGlobalInt( GLFW_WINDOW_ICONYFY_EVENT, "GLFW_WINDOW_ICONYFY_EVENT" ); // GLFW event window iconify assignGlobalInt( GLFW_WINDOW_FOCUS_EVENT, "GLFW_WINDOW_FOCUS_EVENT" ); // GLFW event window focus assignGlobalInt( GLFW_WINDOW_DROP_EVENT, "GLFW_WINDOW_DROP_EVENT" ); // GLFW event window drop - /* Input Events. */ + /* GLFW Input Events. */ assignGlobalInt( GLFW_KEY_EVENT, "GLFW_KEY_EVENT" ); // GLFW event keyboard key assignGlobalInt( GLFW_CHAR_EVENT, "GLFW_CHAR_EVENT" ); // GLFW event Unicode character assignGlobalInt( GLFW_MOUSE_BUTTON_EVENT, "GLFW_MOUSE_BUTTON_EVENT" ); // GLFW event mouse button @@ -30,31 +30,24 @@ static void platformDefineGlobals() { assignGlobalInt( GLFW_MOUSE_SCROLL_EVENT, "GLFW_MOUSE_SCROLL_EVENT" ); // GLFW event mouse scroll assignGlobalInt( GLFW_CURSOR_ENTER_EVENT, "GLFW_CURSOR_ENTER_EVENT" ); // GLFW event cursor enter/leave assignGlobalInt( GLFW_JOYSTICK_EVENT, "GLFW_JOYSTICK_EVENT" ); // GLFW event joystick - /* Pen Tablet Events. NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445. */ + /* GLFW Pen Tablet Events. NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445. */ // assignGlobalInt( GLFW_PEN_TABLET_DATA_EVENT, "GLFW_PEN_TABLET_DATA_EVENT" ); // GLFW event pen tablet data // assignGlobalInt( GLFW_PEN_TABLET_CURSOR_EVENT, "GLFW_PEN_TABLET_CURSOR_EVENT" ); // GLFW event pen tablet cursor // assignGlobalInt( GLFW_PEN_TABLET_PROXIMITY_EVENT, "GLFW_PEN_TABLET_PROXIMITY_EVENT" ); // GLFW event pen tablet proximity - +/*DOC_DEFINES_END*/ lua_pop( L, -1 ); } /* Functions. */ /* -## Core - Input-related functions: keyboard. +## GLFW Core - Input-related functions: keyboard */ /* > keyName = RL.GetKeyName( int key, int scancode ) This function returns the name of the specified printable key, encoded as UTF-8. -This is typically the character that key would produce without any modifier keys, -intended for displaying key bindings to the user. For dead keys, it is typically -the diacritic it would add to a character. - -Do not use this function for text input. You will break text input for many -languages even if it happens to work for yours. - If the key is KEY_UNKNOWN, the scancode is used to identify the key, otherwise the scancode is ignored. If you specify a non-printable key, or KEY_UNKNOWN and a scancode that maps to a non-printable key, @@ -107,8 +100,15 @@ static void luaPlatformRegister() { /* Events. */ -/* Window events. */ +/* +## Window events +*/ + +/* +> GLFWwindowsizeEvent = { int type, int width, int height } +Called when the window is resized. Type GLFW_WINDOW_SIZE_EVENT +*/ static void windowSizeEvent( GLFWwindow *window, int width, int height ) { /* Pass through to raylib callback. */ state->raylibWindowSizeCallback( window, width, height ); @@ -140,6 +140,11 @@ static void windowSizeEvent( GLFWwindow *window, int width, int height ) { #if !defined( PLATFORM_WEB ) +/* +> GLFWwindowmaximizeEvent = { int type, int maximized } + +Called when the window is maximized or restored. Type GLFW_WINDOW_MAXIMIZE_EVENT +*/ static void windowMaximizeEvent( GLFWwindow *window, int maximized ) { /* Pass through to raylib callback. */ state->raylibWindowMaximizeCallback( window, maximized ); @@ -169,6 +174,11 @@ static void windowMaximizeEvent( GLFWwindow *window, int maximized ) { #endif +/* +> GLFWwindowiconifyEvent = { int type, int iconified } + +Called when the window is iconified or restored. Type GLFW_WINDOW_ICONYFY_EVENT +*/ static void windowIconyfyEvent( GLFWwindow *window, int iconified ) { /* Pass through to raylib callback. */ state->raylibWindowIconifyCallback( window, iconified ); @@ -196,6 +206,11 @@ static void windowIconyfyEvent( GLFWwindow *window, int iconified ) { lua_pop( L, -1 ); } +/* +> GLFWwindowfocusEvent = { int type, int focused } + +Called when the window gains or loses input focus. Type GLFW_WINDOW_FOCUS_EVENT +*/ static void windowFocusEvent( GLFWwindow *window, int focused ) { /* Pass through to raylib callback. */ state->raylibWindowFocusCallback( window, focused ); @@ -223,6 +238,11 @@ static void windowFocusEvent( GLFWwindow *window, int focused ) { lua_pop( L, -1 ); } +/* +> GLFWdropEvent = { int type, int count, string{} paths } + +Called when files are dropped to the window. Type GLFW_WINDOW_DROP_EVENT +*/ static void windowDropEvent( GLFWwindow *window, int count, const char **paths ) { /* Pass through to raylib callback. */ state->raylibWindowDropCallback( window, count, paths ); @@ -258,8 +278,15 @@ static void windowDropEvent( GLFWwindow *window, int count, const char **paths ) lua_pop( L, -1 ); } -/* Input events. */ +/* +## Input events +*/ + +/* +> GLFWkeyEvent = { int type, int key, int scancode, int action, int mods } +Called when a physical key is pressed or released or when it repeats. Type GLFW_KEY_EVENT +*/ static void keyInputEvent( GLFWwindow* window, int key, int scancode, int action, int mods ) { /* Pass through to raylib callback. */ state->raylibKeyCallback( window, key, scancode, action, mods ); @@ -293,6 +320,11 @@ static void keyInputEvent( GLFWwindow* window, int key, int scancode, int action lua_pop( L, -1 ); } +/* +> GLFWcharEvent = { int type, int key } + +Unicode code points for key events that would have led to regular text input and generally behaves as a standard text field on that platform. Type GLFW_CHAR_EVENT +*/ static void charInputEvent( GLFWwindow* window, unsigned int key ) { /* Pass through to raylib callback. */ state->raylibCharCallback( window, key ); @@ -320,6 +352,11 @@ static void charInputEvent( GLFWwindow* window, unsigned int key ) { lua_pop( L, -1 ); } +/* +> GLFWmousebuttonEvent = { int type, int button, int action, int mods } + +Called when a mouse button is pressed or released. Type GLFW_MOUSE_BUTTON_EVENT +*/ static void mouseButtonInputEvent( GLFWwindow* window, int button, int action, int mods ) { /* Pass through to raylib callback. */ state->raylibMouseButtonCallback( window, button, action, mods ); @@ -351,6 +388,11 @@ static void mouseButtonInputEvent( GLFWwindow* window, int button, int action, i lua_pop( L, -1 ); } +/* +> GLFWcursorposEvent = { int type, float x, float y } + +Called when the cursor moves over the window. Type GLFW_MOUSE_CURSOR_POS_EVENT +*/ static void mouseCursorPosInputEvent( GLFWwindow* window, double x, double y ) { /* Pass through to raylib callback. */ state->raylibMouseCursorPosCallback( window, x, y ); @@ -380,6 +422,11 @@ static void mouseCursorPosInputEvent( GLFWwindow* window, double x, double y ) { lua_pop( L, -1 ); } +/* +> GLFWscrollEvent = { int type, float xoffset, float yoffset } + +Called when the user scrolls, whether with a mouse wheel or touchpad gesture. Type GLFW_MOUSE_SCROLL_EVENT +*/ static void mouseScrollInputEvent( GLFWwindow* window, double xoffset, double yoffset ) { /* Pass through to raylib callback. */ state->raylibMouseScrollCallback( window, xoffset, yoffset ); @@ -409,6 +456,11 @@ static void mouseScrollInputEvent( GLFWwindow* window, double xoffset, double yo lua_pop( L, -1 ); } +/* +> GLFWcursorenterEvent = { int type, int enter } + +Called when the cursor enters or leaves the content area of a window. Type GLFW_CURSOR_ENTER_EVENT +*/ static void cursorEnterInputEvent( GLFWwindow* window, int enter ) { /* Pass through to raylib callback. */ state->raylibCursorEnterCallback( window, enter ); @@ -436,7 +488,12 @@ static void cursorEnterInputEvent( GLFWwindow* window, int enter ) { lua_pop( L, -1 ); } -static void joystickInputEvent( int jid, int event ) { +/* +> GLFWjoystickEvent = { int type, int jid, int event } + +Called when a joystick is connected or disconnected. Type GLFW_JOYSTICK_EVENT +*/ +static void joystickEvent( int jid, int event ) { /* Pass through to raylib callback. */ if ( state->raylibJoystickCallback != NULL ) { state->raylibJoystickCallback( jid, event ); @@ -467,7 +524,12 @@ static void joystickInputEvent( int jid, int event ) { lua_pop( L, -1 ); } -// /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */ +/* +> GLFWpentabletdataEvent = { int type, float x, float y, float z, float pressure, float pitch, float yaw, float roll } + +Called when the pen tablet data is updated. Type GLFW_PEN_TABLET_DATA_EVENT +NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 +*/ // static void penTabletDataEvent( double x, double y, double z, double pressure, double pitch, double yaw, double roll ) { // lua_State *L = state->luaState; @@ -504,7 +566,12 @@ static void joystickInputEvent( int jid, int event ) { // lua_pop( L, -1 ); // } -// /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */ +/* +> GLFWpentabletcursorEvent = { int type, int identifier } + +Called when the pen tablet cursor has changed. Type GLFW_PEN_TABLET_CURSOR_EVENT +NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 +*/ // static void penTabletCursorEvent( unsigned int identifier ) { // lua_State *L = state->luaState; @@ -529,7 +596,12 @@ static void joystickInputEvent( int jid, int event ) { // lua_pop( L, -1 ); // } -// /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */ +/* +> GLFWpentabletproximityEvent = { int type, int proxState } + +Called when the pen tablet proximity has changed. Type GLFW_PEN_TABLET_PROXIMITY_EVENT +NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 +*/ // static void penTabletProximityEvent( int proxState ) { // lua_State *L = state->luaState; @@ -571,7 +643,7 @@ static void platformRegisterEvents() { state->raylibMouseCursorPosCallback = glfwSetCursorPosCallback( GetWindowHandle(), mouseCursorPosInputEvent ); state->raylibMouseScrollCallback = glfwSetScrollCallback( GetWindowHandle(), mouseScrollInputEvent ); state->raylibCursorEnterCallback = glfwSetCursorEnterCallback( GetWindowHandle(), cursorEnterInputEvent ); - state->raylibJoystickCallback = glfwSetJoystickCallback( joystickInputEvent ); + state->raylibJoystickCallback = glfwSetJoystickCallback( joystickEvent ); /* NOTE! Experimental. Needs glfw PR https://github.com/glfw/glfw/pull/1445 */ // state->glfwtabletDataCallback = glfwSetPenTabletDataCallback( penTabletDataEvent ); // state->glfwtabletCursorCallback = glfwSetPenTabletCursorCallback( penTabletCursorEvent ); diff --git a/src/platforms/core_desktop_sdl.c b/src/platforms/core_desktop_sdl.c index aacccf5..f1483e5 100644 --- a/src/platforms/core_desktop_sdl.c +++ b/src/platforms/core_desktop_sdl.c @@ -7,18 +7,18 @@ static void platformDefineGlobals() { lua_State *L = state->luaState; lua_getglobal( L, "RL" ); - - /* KeyboardEvents */ +/*DOC_DEFINES_START*/ + /* Keyboard events */ assignGlobalInt( SDL_KEYDOWN, "SDL_KEYDOWN" ); // Key pressed assignGlobalInt( SDL_KEYUP, "SDL_KEYUP" ); // Key released - /* WindowEvents */ + /* Window events */ assignGlobalInt( SDL_WINDOWEVENT, "SDL_WINDOWEVENT" ); // Window state change - /* MouseEvents */ + /* Mouse events */ assignGlobalInt( SDL_MOUSEMOTION, "SDL_MOUSEMOTION" ); // Mouse moved assignGlobalInt( SDL_MOUSEBUTTONDOWN, "SDL_MOUSEBUTTONDOWN" ); // Mouse button pressed assignGlobalInt( SDL_MOUSEBUTTONUP, "SDL_MOUSEBUTTONUP" ); // Mouse button released assignGlobalInt( SDL_MOUSEWHEEL, "SDL_MOUSEWHEEL" ); // Mouse wheel motion - /* JoystickEvents */ + /* Joystick events */ assignGlobalInt( SDL_JOYAXISMOTION, "SDL_JOYAXISMOTION" ); // Joystick axis motion assignGlobalInt( SDL_JOYBALLMOTION, "SDL_JOYBALLMOTION" ); // Joystick trackball motion assignGlobalInt( SDL_JOYHATMOTION, "SDL_JOYHATMOTION" ); @@ -26,22 +26,22 @@ static void platformDefineGlobals() { assignGlobalInt( SDL_JOYBUTTONUP, "SDL_JOYBUTTONUP" ); // Joystick button released assignGlobalInt( SDL_JOYDEVICEADDED, "SDL_JOYDEVICEADDED" ); // Joystick connected assignGlobalInt( SDL_JOYDEVICEREMOVED, "SDL_JOYDEVICEREMOVED" ); // Joystick disconnected - /* ControllerEvents */ + /* Controller events */ assignGlobalInt( SDL_CONTROLLERAXISMOTION, "SDL_CONTROLLERAXISMOTION" ); // Controller axis motion assignGlobalInt( SDL_CONTROLLERBUTTONDOWN, "SDL_CONTROLLERBUTTONDOWN" ); // Controller button pressed assignGlobalInt( SDL_CONTROLLERBUTTONUP, "SDL_CONTROLLERBUTTONUP" ); // Controller button released assignGlobalInt( SDL_CONTROLLERDEVICEADDED, "SDL_CONTROLLERDEVICEADDED" ); // Controller connected assignGlobalInt( SDL_CONTROLLERDEVICEREMOVED, "SDL_CONTROLLERDEVICEREMOVED" ); // Controller disconnected assignGlobalInt( SDL_CONTROLLERDEVICEREMAPPED, "SDL_CONTROLLERDEVICEREMAPPED" ); // Controller mapping updated - /* TouchEvents */ + /* Touch events */ assignGlobalInt( SDL_FINGERDOWN, "SDL_FINGERDOWN" ); // User has touched input device assignGlobalInt( SDL_FINGERUP, "SDL_FINGERUP" ); // User stopped touching input device assignGlobalInt( SDL_FINGERMOTION, "SDL_FINGERMOTION" ); // User is dragging finger on input device - /* GestureEvents */ + /* Gesture events */ assignGlobalInt( SDL_DOLLARGESTURE, "SDL_DOLLARGESTURE" ); assignGlobalInt( SDL_DOLLARRECORD, "SDL_DOLLARRECORD" ); assignGlobalInt( SDL_MULTIGESTURE, "SDL_MULTIGESTURE" ); - /* WindowEventIDs */ + /* Window states */ assignGlobalInt( SDL_WINDOWEVENT_SHOWN, "SDL_WINDOWEVENT_SHOWN" ); assignGlobalInt( SDL_WINDOWEVENT_HIDDEN, "SDL_WINDOWEVENT_HIDDEN" ); assignGlobalInt( SDL_WINDOWEVENT_EXPOSED, "SDL_WINDOWEVENT_EXPOSED" ); @@ -58,10 +58,10 @@ static void platformDefineGlobals() { assignGlobalInt( SDL_WINDOWEVENT_CLOSE, "SDL_WINDOWEVENT_CLOSE" ); assignGlobalInt( SDL_WINDOWEVENT_TAKE_FOCUS, "SDL_WINDOWEVENT_TAKE_FOCUS" ); assignGlobalInt( SDL_WINDOWEVENT_HIT_TEST, "SDL_WINDOWEVENT_HIT_TEST" ); - /* KeyboardAndMouseState */ + /* Keyboard and mouse states */ assignGlobalInt( SDL_RELEASED, "SDL_RELEASED" ); assignGlobalInt( SDL_PRESSED, "SDL_PRESSED" ); - /* JoystickHatMotion */ + /* Joystick hat motion */ assignGlobalInt( SDL_HAT_LEFTUP, "SDL_HAT_LEFTUP" ); assignGlobalInt( SDL_HAT_UP, "SDL_HAT_UP" ); assignGlobalInt( SDL_HAT_RIGHTUP, "SDL_HAT_RIGHTUP" ); @@ -71,14 +71,14 @@ static void platformDefineGlobals() { assignGlobalInt( SDL_HAT_LEFTDOWN, "SDL_HAT_LEFTDOWN" ); assignGlobalInt( SDL_HAT_DOWN, "SDL_HAT_DOWN" ); assignGlobalInt( SDL_HAT_RIGHTDOWN, "SDL_HAT_RIGHTDOWN" ); - +/*DOC_DEFINES_END*/ lua_pop( L, -1 ); } /* Functions. */ /* -## Core - Input-related functions: keyboard. +## SDL Core - Input-related functions: keyboard. */ /* @@ -124,6 +124,10 @@ static void luaPlatformRegister() { /* Events. */ +/* +## SDL Events +*/ + /* This function is not thread safe so we don't use Lua inside it directly. It only adds events to another queue. */ static int SDLEventFilter( void *userdata, SDL_Event *event ) { /* SDL_EVENT_POLL_SENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */ @@ -163,6 +167,11 @@ static void platformSendEvents() { SDL_Event event = state->SDL_eventQueue[i]; switch ( event.type ) { +/* +> SDL_KeyboardEvent = { int type, int timestamp, int state, int repeat, int scancode, int sym, int mod } + +Event occurs whenever a user presses or releases a button on a keyboard. Type SDL_KEYUP or SDL_KEYDOWN +*/ case SDL_KEYUP: case SDL_KEYDOWN: { @@ -184,6 +193,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_WindowEvent = { int type, int timestamp, int event, int data1, int data2 } + +Event occurs when an event of type SDL_WINDOWEVENT is reported. Type SDL_WINDOWEVENT +*/ case SDL_WINDOWEVENT: { lua_createtable( L, 5, 0 ); @@ -200,6 +214,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_MouseMotionEvent = { int type, int timestamp, int which, int state, int x, int y, int xrel, int yrel } + +Event occurs whenever a user moves the mouse within the application window or when SDL_WarpMouseInWindow() is called. Type SDL_MOUSEMOTION +*/ case SDL_MOUSEMOTION: { lua_createtable( L, 8, 0 ); @@ -222,6 +241,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_MouseButtonEvent = { int type, int timestamp, int which, int button, int state, int x, int y } + +Event occurs whenever a user presses or releases a button on a mouse. Type SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP +*/ case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { @@ -243,6 +267,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_MouseWheelEvent = { int type, int timestamp, int which, int x, int y } + +Event occurs whenever a user moves the mouse wheel. Type SDL_MOUSEWHEEL +*/ case SDL_MOUSEWHEEL: { lua_createtable( L, 5, 0 ); @@ -259,6 +288,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_JoyAxisEvent = { int type, int timestamp, int which, int axis, int value } + +Event occurs whenever a user moves an axis on the joystick. Type SDL_JOYAXISMOTION +*/ case SDL_JOYAXISMOTION: { lua_createtable( L, 5, 0 ); @@ -275,6 +309,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_JoyBallEvent = { int type, int timestamp, int which, int ball, int xrel, int yrel } + +Event occurs when a user moves a trackball on the joystick. Type SDL_JOYBALLMOTION +*/ case SDL_JOYBALLMOTION: { lua_createtable( L, 6, 0 ); @@ -293,6 +332,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_JoyHatEvent = { int type, int timestamp, int which, int hat, int value } + +Event occurs whenever a user moves a hat on the joystick. Type SDL_JOYHATMOTION +*/ case SDL_JOYHATMOTION: { lua_createtable( L, 5, 0 ); @@ -309,6 +353,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_JoyButtonEvent = { int type, int timestamp, int which, int button, int state } + +Event occurs whenever a user presses or releases a button on a joystick. Type SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP +*/ case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: { @@ -326,6 +375,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_JoyDeviceEvent = { int type, int timestamp, int which } + +Event occurs whenever a user connects or disconnects a joystick. Type SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED +*/ case SDL_JOYDEVICEADDED: case SDL_JOYDEVICEREMOVED: { @@ -339,6 +393,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_ControllerAxisEvent = { int type, int timestamp, int which, int axis, int value } + +Event occurs whenever a user moves an axis on the controller. Type SDL_CONTROLLERAXISMOTION +*/ case SDL_CONTROLLERAXISMOTION: { lua_createtable( L, 5, 0 ); @@ -355,6 +414,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_ControllerButtonEvent = { int type, int timestamp, int which, int button, int state } + +Event occurs whenever a user presses or releases a button on a controller. Type SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP +*/ case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP: { @@ -372,6 +436,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_ControllerDeviceEvent = { int type, int timestamp, int which } + +Event occurs whenever a user connects, disconnects or remaps a controller. Type SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED or SDL_CONTROLLERDEVICEREMAPPED +*/ case SDL_CONTROLLERDEVICEADDED: case SDL_CONTROLLERDEVICEREMOVED: case SDL_CONTROLLERDEVICEREMAPPED: @@ -386,6 +455,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_TouchFingerEvent = { int type, int timestamp, int touchId, int fingerId, float x, float y, float dx, float dy, float pressure } + +Event occurs when an event of type SDL_FINGERMOTION, SDL_FINGERDOWN, or SDL_FINGERUP is reported. Type SDL_FINGERMOTION, SDL_FINGERDOWN or SDL_FINGERUP +*/ case SDL_FINGERMOTION: case SDL_FINGERDOWN: case SDL_FINGERUP: @@ -412,6 +486,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_MultiGestureEvent = { int type, int timestamp, int touchId, float dTheta, float dDist, float x, float y, int numFingers } + +Event occurs when type SDL_MULTIGESTURE is reported. Type SDL_MULTIGESTURE +*/ case SDL_MULTIGESTURE: { lua_createtable( L, 8, 0 ); @@ -434,6 +513,11 @@ static void platformSendEvents() { call = true; } break; +/* +> SDL_DollarGestureEvent = { int type, int timestamp, int touchId, int gestureId, int numFingers, float error, float x, float y } + +Event occurs an event of type SDL_DOLLARGESTURE or SDL_DOLLARRECORD is reported. Type SDL_DOLLARGESTURE or SDL_DOLLARRECORD +*/ case SDL_DOLLARGESTURE: case SDL_DOLLARRECORD: { |
