mirror of
https://github.com/raysan5/raylib.git
synced 2026-08-25 13:48:27 -04:00
Compare commits
49 Commits
1893226cb7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fb5c98293 | |||
| e4ccc91d4e | |||
| f3a471fd89 | |||
| 820b971eff | |||
| 5f58fbe6d7 | |||
| 5c5b357b4a | |||
| bcc834fc3e | |||
| 5b818bb318 | |||
| e1efefb7f4 | |||
| 2c0021ad89 | |||
| 9bde204f1d | |||
| 47231e37ef | |||
| 0088b85952 | |||
| 338458a92b | |||
| 3836f13878 | |||
| abe23bf82d | |||
| 6cceb2b873 | |||
| 86430c156c | |||
| 3b57140640 | |||
| f472c67bb2 | |||
| 23033d1f18 | |||
| d7225acd8e | |||
| af3045377a | |||
| f9e2215c49 | |||
| d75a6589f0 | |||
| 47c8e897ce | |||
| 1129d42b48 | |||
| c58072d595 | |||
| b98c4e031d | |||
| 9506b58633 | |||
| 44aa771cc0 | |||
| dad422a430 | |||
| ae83a50fb3 | |||
| 4f4b3aef45 | |||
| 6862f7b9ca | |||
| ad6b19a37c | |||
| bb474f69d8 | |||
| 77353e7f31 | |||
| fba8ea01f5 | |||
| 57917f1656 | |||
| d46a59367f | |||
| 868413839a | |||
| 1225932449 | |||
| f28c2221cc | |||
| 4245423cc1 | |||
| 9beca068b9 | |||
| 079cc2df09 | |||
| 388806f24d | |||
| b0005129c7 |
16
BINDINGS.md
16
BINDINGS.md
@ -8,7 +8,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| :--------------------------------------------------------------------------------------- | :--------------: | :------------------------------------------------------------------: | :------------------: |
|
||||
| [raylib](https://github.com/raysan5/raylib) | **6.0** | [C/C++](https://en.wikipedia.org/wiki/C_(programming_language)) | Zlib |
|
||||
| [raylib-ada](https://github.com/Fabien-Chouteau/raylib-ada) | **5.5** | [Ada](https://en.wikipedia.org/wiki/Ada_(programming_language)) | MIT |
|
||||
|[raylib-asm](https://github.com/gAndy50/ASMRay) | **6.0** | Assembly (x86) | Zlib |
|
||||
| [raylib-asm](https://github.com/gAndy50/ASMRay) | **6.0** | [Assembly (x86)](https://en.wikipedia.org/wiki/X86_assembly_language) | Zlib |
|
||||
| [raylib-beef](https://github.com/Starpelly/raylib-beef) | **5.5** | [Beef](https://www.beeflang.org) | MIT |
|
||||
| [raybit](https://github.com/Alex-Velez/raybit) | **5.0** | [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck) | MIT |
|
||||
| [raylib-c3](https://github.com/c3lang/vendor/tree/main/libraries/raylib6.c3l) | **6** | [C3](https://c3-lang.org) | MIT |
|
||||
@ -36,10 +36,11 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [raylib-elfscript](https://github.com/ohmtal/raylib-elfscript) | 6.0 | [ElfScript](https://github.com/ohmtal/ElfScript) | MIT |
|
||||
| [raylib-elle](https://github.com/acquitelol/elle/blob/rewrite/std/raylib.le) | **5.5** | [Elle](https://github.com/acquitelol/elle) | GPL-3.0 |
|
||||
| [raylib-factor](https://github.com/factor/factor/blob/master/extra/raylib/raylib.factor) | 5.5 | [Factor](https://factorcode.org) | BSD |
|
||||
| [raystar](https://github.com/RobertFlexx/raystar) | **6.0** | [F*](https://www.fstar-lang.org/) | EPL-2.0 |
|
||||
| [raylib4fb](https://github.com/mudhairless/raylib4fb) | **6.0** | [FreeBASIC](https://www.freebasic.net) | Zlib |
|
||||
| [raylib-freebasic](https://github.com/WIITD/raylib-freebasic) | **5.0** | [FreeBASIC](https://www.freebasic.net) | MIT |
|
||||
| [raylib.f](https://github.com/cthulhuology/raylib.f) | **5.5** | [Forth](https://forth.com) | Zlib |
|
||||
| [fortran-raylib](https://github.com/interkosmos/fortran-raylib) | **5.5** | [Fortran](https://fortran-lang.org) | ISC |
|
||||
| [fortran-raylib](https://github.com/interkosmos/fortran-raylib) | **6.0** | [Fortran](https://fortran-lang.org) | ISC |
|
||||
| [raylib-go](https://github.com/gen2brain/raylib-go) | **6.0** | [Go](https://golang.org) | Zlib |
|
||||
| [raylib-guile](https://github.com/petelliott/raylib-guile) | **auto** | [Guile](https://www.gnu.org/software/guile) | Zlib |
|
||||
| [gforth-raylib](https://github.com/ArnautDaniel/gforth-raylib) | 3.5 | [Gforth](https://gforth.org) | **???** |
|
||||
@ -59,6 +60,9 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [raylib-luajit](https://github.com/homma/raylib-luajit) | 5.5 | [Lua](http://www.lua.org) | MIT |
|
||||
| [raylib-luajit-generated](https://github.com/james2doyle/raylib-luajit-generated) | 5.5 | [Lua](http://www.lua.org) | MIT |
|
||||
| [raylib-matte](https://github.com/jcorks/raylib-matte) | 4.6-dev | [Matte](https://github.com/jcorks/matte) | **???** |
|
||||
| [raylib_mojo](https://github.com/willGuimont/raylib_mojo) | **6.0** | [Mojo](https://www.modular.com/mojo) | ZLib |
|
||||
| [raymojo](https://github.com/RobertFlexx/raymojo) | **6.0** | [Mojo](https://www.modular.com/mojo) | GPLv3 |
|
||||
| [raymod](https://github.com/RobertFlexx/raymod) | **6.0** | [Modula-2](https://en.wikipedia.org/wiki/Modula-2) / [Modula-3](https://en.wikipedia.org/wiki/Modula-3) | Apache-2.0 |
|
||||
| [Raylib.nelua](https://github.com/AuzFox/Raylib.nelua) | **5.5** | [nelua](https://nelua.io) | Zlib |
|
||||
| [raylib-bindings](https://github.com/vaiorabbit/raylib-bindings) | 5.6-dev | [Ruby](https://www.ruby-lang.org/en) | Zlib |
|
||||
| [naylib](https://github.com/planetis-m/naylib) | **5.6-dev** | [Nim](https://nim-lang.org) | MIT |
|
||||
@ -67,8 +71,9 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [raylib_odin_bindings](https://github.com/Deathbat2190/raylib_odin_bindings) | 4.0-dev | [Odin](https://odin-lang.org) | MIT |
|
||||
| [raylib-ocaml](https://github.com/tjammer/raylib-ocaml) | **6.0** | [OCaml](https://ocaml.org) | MIT |
|
||||
| [TurboRaylib](https://github.com/turborium/TurboRaylib) | 4.5 | [Object Pascal](https://en.wikipedia.org/wiki/Object_Pascal) | MIT |
|
||||
|[EuRaylib](https://github.com/gAndy50/EuRaylib6) | **6.0** |[openEuphoria(https://openeuphoria.org/) | Zlib |
|
||||
| [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **6.0** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal)/[Delphi](https://en.wikipedia.org/wiki/Delphi_(software)) | Zlib |
|
||||
| [Rayberon](https://github.com/RobertFlexx/Rayberon) | **6.0** | [Oberon-2](https://en.wikipedia.org/wiki/Oberon-2) | MIT |
|
||||
| [EuRaylib](https://github.com/gAndy50/EuRaylib6) | **6.0** | [openEuphoria](https://openeuphoria.org/) | Zlib |
|
||||
| [Ray4Laz](https://github.com/GuvaCode/Ray4Laz) | **6.0** | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib |
|
||||
| [Raylib.4.0.Pascal](https://github.com/sysrpl/Raylib.4.0.Pascal) | 4.0 | [Free Pascal](https://en.wikipedia.org/wiki/Free_Pascal) | Zlib |
|
||||
| [pyraylib](https://github.com/Ho011/pyraylib) | 3.7 | [Python](https://www.python.org) | Zlib |
|
||||
| [raylib-python-cffi](https://github.com/electronstudio/raylib-python-cffi) | **5.5** | [Python](https://www.python.org) | EPL-2.0 |
|
||||
@ -93,7 +98,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [raylib-v](https://github.com/vlang/raylib) | 5.5 | [V](https://vlang.io) | MIT/Unlicense |
|
||||
| [raylib.v](https://github.com/irishgreencitrus/raylib.v) | 4.2 | [V](https://vlang.io) | Zlib |
|
||||
| [raylib-vapi](https://github.com/lxmcf/raylib-vapi) | **6.0** | [Vala](https://vala.dev) | Zlib |
|
||||
| [raylib-wave](https://github.com/wavefnd/raylib-wave) | **auto** |[Wave](http://wave-lang.dev) | Zlib |
|
||||
| [raylib-wave](https://github.com/wavefnd/raylib-wave) | **auto** | [Wave](http://wave-lang.dev) | Zlib |
|
||||
| [raylib-wren](https://github.com/TSnake41/raylib-wren) | 4.5 | [Wren](http://wren.io) | ISC |
|
||||
| [raylib-zig](https://github.com/raylib-zig/raylib-zig) | **6.0** | [Zig](https://ziglang.org) | MIT |
|
||||
| [raylib.zig](https://github.com/ryupold/raylib.zig) | **5.1-dev** | [Zig](https://ziglang.org) | MIT |
|
||||
@ -112,6 +117,7 @@ Some people ported raylib to other languages in the form of bindings or wrappers
|
||||
| [Rayua](https://github.com/uiua-lang/rayua) | **5.5** | [Uiua](https://www.uiua.org/) | **???** |
|
||||
| [Target](https://github.com/FinnDemonCat/Target/tree/main/libs/raylib) | **5.5** | [Dart](https://dart.dev/) | Apache-2.0 license |
|
||||
| [gclang-raylib](https://github.com/gnuchanos/gcLang_Compiler/tree/main/windows_version/raylib_version)| **6.0** | [gclang](https://github.com/gnuchanos/gcLang_Compiler) | AGPL-3.0 |
|
||||
| [mach-raylib](https://github.com/angluca/mach-raylib) | **6.0-dev** | [Mach](https://machlang.org/) | MIT |
|
||||
|
||||
|
||||
### Utility Wrappers
|
||||
|
||||
11
README.md
11
README.md
@ -54,6 +54,17 @@ features
|
||||
- Bindings to [+70 programming languages](https://github.com/raysan5/raylib/blob/master/BINDINGS.md)!
|
||||
- **Free and open source**
|
||||
|
||||
limitations
|
||||
-----------
|
||||
|
||||
raylib presents some limitation by design for code simplicity, some forks, alternatives and samples are available to overcome most of them but it's up to the users to modify the library for their specific needs.
|
||||
|
||||
- Single window with single OpenGL context by default, no multi-window support
|
||||
- Window resize and move stops the rendering loop on platforms supporting a window
|
||||
- `RenderTextures` are flipped vertically, as provided by OpenGL, it's up to user to draw then flipped to screen
|
||||
- Font rasterization has lower quality than alternatives using `Freetype2`, `HarfBuzz` or `Slug`
|
||||
- Text drawing does not support RTL, ligatures or emojis
|
||||
|
||||
basic example
|
||||
--------------
|
||||
This is a basic raylib example, it creates a window and draws the text `"Congrats! You created your first window!"` in the middle of the screen. Check this example [running live on web here](https://www.raylib.com/examples/core/loader.html?name=core_basic_window).
|
||||
|
||||
@ -139,6 +139,7 @@ pub fn linkMacOS(b: *std.Build, mod: *std.Build.Module) void {
|
||||
mod.linkFramework("CoreGraphics", .{});
|
||||
mod.linkFramework("AppKit", .{});
|
||||
mod.linkFramework("IOKit", .{});
|
||||
mod.linkFramework("QuartzCore", .{});
|
||||
}
|
||||
|
||||
fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, options: Options) !*std.Build.Step.Compile {
|
||||
|
||||
@ -1,6 +1,18 @@
|
||||
# Setup the project and settings
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
project(examples)
|
||||
|
||||
# Include raylib's cmake helper functions, so the examples can also be
|
||||
# configured standalone (`cd examples && cmake .`) and not only as part
|
||||
# of the raylib project.
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake")
|
||||
include(AddIfFlagCompiles)
|
||||
|
||||
# Default to the Desktop platform when configured standalone.
|
||||
if (NOT DEFINED PLATFORM)
|
||||
set(PLATFORM "Desktop" CACHE STRING "Platform to build examples for")
|
||||
endif ()
|
||||
|
||||
# Directories that contain examples
|
||||
set(example_dirs
|
||||
audio
|
||||
@ -189,6 +201,7 @@ foreach (example_source ${example_sources})
|
||||
target_link_libraries(${example_name} "-framework IOKit")
|
||||
target_link_libraries(${example_name} "-framework Cocoa")
|
||||
target_link_libraries(${example_name} "-framework OpenGL")
|
||||
target_link_libraries(${example_name} "-framework QuartzCore")
|
||||
endif()
|
||||
|
||||
elseif (${PLATFORM} MATCHES "RGFW")
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
# > PLATFORM_DESKTOP_RGFW (RGFW backend):
|
||||
# - Windows (Win32, Win64)
|
||||
# - Linux (X11 desktop mode)
|
||||
# - macOS/OSX (x64, arm64 (not tested))
|
||||
# - macOS/OSX (x64, arm64)
|
||||
# - Others (not tested)
|
||||
# > PLATFORM_DESKTOP_WIN32 (native Win32):
|
||||
# - Windows (Win32, Win64)
|
||||
@ -314,6 +314,9 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
LDFLAGS += -L/opt/homebrew/lib -L$(RAYLIB_LIB_PATH)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
|
||||
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||
@ -418,7 +421,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# Libraries for OSX 10.9 desktop compiling
|
||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||
@ -496,7 +499,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
|
||||
# NOTE: Required packages: libegl1-mesa-dev
|
||||
LDFLAGS += -L../src
|
||||
LDLIBS = -lraylib -lm
|
||||
LDLIBS += -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo
|
||||
LDLIBS += -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
endif
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||
|
||||
@ -411,7 +411,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# Libraries for OSX 10.9 desktop compiling
|
||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||
@ -480,7 +480,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
|
||||
# NOTE: Required packages: libegl1-mesa-dev
|
||||
LDFLAGS += -L../src
|
||||
LDLIBS = -lraylib -lm
|
||||
LDLIBS += -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo
|
||||
LDLIBS += -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
endif
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||
|
||||
323
examples/models/models_mesh_uv_painting.c
Normal file
323
examples/models/models_mesh_uv_painting.c
Normal file
@ -0,0 +1,323 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - mesh uv painting
|
||||
*
|
||||
* Example demonstrates painting directly onto a mesh's texture: a ray is cast from the
|
||||
* mouse into the scene, the hit triangle is found, and the hit point is converted into
|
||||
* UV space using barycentric interpolation so a brush stroke can be drawn on the texture
|
||||
*
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
||||
*
|
||||
* Example contributed by PanicTitan (@PanicTitan) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2025 PanicTitan (@PanicTitan)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "raymath.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "raygui.h"
|
||||
|
||||
#include <math.h> // Required for: fabsf(), floorf()
|
||||
#include <stddef.h> // Required for: NULL
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Global Definitions
|
||||
//--------------------------------------------------------------------------------------
|
||||
#define CANVAS_SIZE 512
|
||||
#define PALETTE_COUNT 8
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//--------------------------------------------------------------------------------------
|
||||
typedef enum { TOOL_PAINT = 0, TOOL_PICKER } ToolMode;
|
||||
typedef enum { SHAPE_SPHERE = 0, SHAPE_CUBE, SHAPE_CYLINDER, SHAPE_TORUS } ShapeType;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static void ChangeShape(Model *model, BoundingBox *bbox, ShapeType *currentShape, ShapeType newShape, Texture2D canvasTexture);
|
||||
static bool GetMeshHitUV(Ray ray, Model model, BoundingBox bbox, Vector2 *outUV);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh uv painting");
|
||||
|
||||
Camera3D camera = { 0 };
|
||||
camera.position = (Vector3){ 0.0f, 3.5f, 6.5f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
// CPU-side canvas plus the GPU texture it gets pushed to after every stroke
|
||||
Image canvasImage = GenImageColor(CANVAS_SIZE, CANVAS_SIZE, RAYWHITE);
|
||||
Texture2D canvasTexture = LoadTextureFromImage(canvasImage);
|
||||
SetTextureFilter(canvasTexture, TEXTURE_FILTER_BILINEAR);
|
||||
|
||||
Model model = { 0 };
|
||||
BoundingBox modelBBox = { 0 };
|
||||
ShapeType currentShape = SHAPE_SPHERE;
|
||||
ChangeShape(&model, &modelBBox, ¤tShape, SHAPE_SPHERE, canvasTexture);
|
||||
|
||||
ToolMode currentTool = TOOL_PAINT;
|
||||
Color activeColor = RED;
|
||||
int brushRadius = 12;
|
||||
Vector2 lastHitUV = { 0 };
|
||||
bool hasLastHit = false;
|
||||
|
||||
Color palette[PALETTE_COUNT] = { RED, ORANGE, GOLD, LIME, SKYBLUE, PURPLE, DARKGRAY, WHITE };
|
||||
Rectangle uiPanelRec = { 10.0f, 10.0f, 230.0f, 490.0f };
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
Vector2 mousePos = GetMousePosition();
|
||||
bool isMouseOverUI = CheckCollisionPointRec(mousePos, uiPanelRec);
|
||||
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) UpdateCamera(&camera, CAMERA_THIRD_PERSON);
|
||||
|
||||
if (!isMouseOverUI && IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||
{
|
||||
Ray ray = GetScreenToWorldRay(mousePos, camera);
|
||||
Vector2 hitUV = { 0 };
|
||||
|
||||
if (GetMeshHitUV(ray, model, modelBBox, &hitUV))
|
||||
{
|
||||
int px = (int)(hitUV.x * CANVAS_SIZE);
|
||||
int py = (int)(hitUV.y * CANVAS_SIZE);
|
||||
|
||||
if (currentTool == TOOL_PAINT)
|
||||
{
|
||||
// Stroke from the last hit to this one, guarding against jumps across a UV seam
|
||||
if (hasLastHit && (fabsf(hitUV.x - lastHitUV.x) < 0.25f) && (fabsf(hitUV.y - lastHitUV.y) < 0.25f))
|
||||
{
|
||||
int lastPx = (int)(lastHitUV.x * CANVAS_SIZE);
|
||||
int lastPy = (int)(lastHitUV.y * CANVAS_SIZE);
|
||||
float dist = Vector2Distance((Vector2){ (float)lastPx, (float)lastPy }, (Vector2){ (float)px, (float)py });
|
||||
int steps = (int)(dist / 2.0f) + 1;
|
||||
|
||||
for (int i = 0; i <= steps; i++)
|
||||
{
|
||||
float t = (float)i / (float)steps;
|
||||
ImageDrawCircle(&canvasImage, (int)Lerp((float)lastPx, (float)px, t),
|
||||
(int)Lerp((float)lastPy, (float)py, t), brushRadius, activeColor);
|
||||
}
|
||||
}
|
||||
else ImageDrawCircle(&canvasImage, px, py, brushRadius, activeColor);
|
||||
|
||||
UpdateTexture(canvasTexture, canvasImage.data);
|
||||
lastHitUV = hitUV;
|
||||
hasLastHit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeColor = GetImageColor(canvasImage, px, py);
|
||||
currentTool = TOOL_PAINT;
|
||||
hasLastHit = false;
|
||||
}
|
||||
}
|
||||
else hasLastHit = false;
|
||||
}
|
||||
else hasLastHit = false;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground((Color){ 30, 32, 40, 255 });
|
||||
|
||||
BeginMode3D(camera);
|
||||
DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
||||
DrawGrid(10, 1.0f);
|
||||
EndMode3D();
|
||||
|
||||
// Side panel
|
||||
DrawRectangleRec(uiPanelRec, Fade(BLACK, 0.8f));
|
||||
DrawRectangleLinesEx(uiPanelRec, 2.0f, DARKGRAY);
|
||||
DrawText("MESH UV PAINTER", 25, 22, 20, GOLD);
|
||||
|
||||
// Tool selection toggles
|
||||
bool paintActive = (currentTool == TOOL_PAINT);
|
||||
bool pickerActive = (currentTool == TOOL_PICKER);
|
||||
if (GuiToggle((Rectangle){ 25, 55, 95, 32 }, "PAINT", &paintActive)) currentTool = TOOL_PAINT;
|
||||
if (GuiToggle((Rectangle){ 125, 55, 95, 32 }, "PICKER", &pickerActive)) currentTool = TOOL_PICKER;
|
||||
|
||||
// Shape selection toggles
|
||||
DrawText("Mesh Shape:", 25, 100, 10, LIGHTGRAY);
|
||||
bool sphereActive = (currentShape == SHAPE_SPHERE);
|
||||
bool cubeActive = (currentShape == SHAPE_CUBE);
|
||||
bool cylinderActive = (currentShape == SHAPE_CYLINDER);
|
||||
bool torusActive = (currentShape == SHAPE_TORUS);
|
||||
|
||||
if (GuiToggle((Rectangle){ 25, 120, 95, 28 }, "SPHERE", &sphereActive))
|
||||
ChangeShape(&model, &modelBBox, ¤tShape, SHAPE_SPHERE, canvasTexture);
|
||||
if (GuiToggle((Rectangle){ 125, 120, 95, 28 }, "CUBE", &cubeActive))
|
||||
ChangeShape(&model, &modelBBox, ¤tShape, SHAPE_CUBE, canvasTexture);
|
||||
if (GuiToggle((Rectangle){ 25, 153, 95, 28 }, "CYLINDER", &cylinderActive))
|
||||
ChangeShape(&model, &modelBBox, ¤tShape, SHAPE_CYLINDER, canvasTexture);
|
||||
if (GuiToggle((Rectangle){ 125, 153, 95, 28 }, "TORUS", &torusActive))
|
||||
ChangeShape(&model, &modelBBox, ¤tShape, SHAPE_TORUS, canvasTexture);
|
||||
|
||||
// Color display
|
||||
DrawText("Active Color:", 25, 195, 10, LIGHTGRAY);
|
||||
DrawRectangle(125, 193, 95, 20, activeColor);
|
||||
DrawRectangleLines(125, 193, 95, 20, WHITE);
|
||||
|
||||
// Color swatches
|
||||
DrawText("Palette Swatches:", 25, 225, 10, LIGHTGRAY);
|
||||
for (int i = 0; i < PALETTE_COUNT; i++)
|
||||
{
|
||||
Rectangle swatchRec = { 25.0f + (i%4)*48, 245.0f + (i/4)*45, 40.0f, 38.0f };
|
||||
DrawRectangleRec(swatchRec, palette[i]);
|
||||
DrawRectangleLinesEx(swatchRec, 1.0f, WHITE);
|
||||
if (CheckCollisionPointRec(mousePos, swatchRec) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) activeColor = palette[i];
|
||||
}
|
||||
|
||||
// Brush size buttons
|
||||
DrawText(TextFormat("Brush Size: %dpx", brushRadius), 25, 345, 10, LIGHTGRAY);
|
||||
if (GuiButton((Rectangle){ 25, 365, 95, 30 }, "SIZE -") && (brushRadius > 2)) brushRadius -= 2;
|
||||
if (GuiButton((Rectangle){ 125, 365, 95, 30 }, "SIZE +") && (brushRadius < 64)) brushRadius += 2;
|
||||
|
||||
// Canvas action buttons
|
||||
if (GuiButton((Rectangle){ 25, 410, 95, 30 }, "CLEAR"))
|
||||
{
|
||||
ImageClearBackground(&canvasImage, RAYWHITE);
|
||||
UpdateTexture(canvasTexture, canvasImage.data);
|
||||
}
|
||||
if (GuiButton((Rectangle){ 125, 410, 95, 30 }, "FILL"))
|
||||
{
|
||||
ImageClearBackground(&canvasImage, activeColor);
|
||||
UpdateTexture(canvasTexture, canvasImage.data);
|
||||
}
|
||||
|
||||
DrawText("Left click: paint / pick color | Right drag: orbit camera", 260, screenHeight - 25, 10, RAYWHITE);
|
||||
DrawFPS(screenWidth - 90, 15);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModel(model);
|
||||
UnloadImage(canvasImage);
|
||||
UnloadTexture(canvasTexture);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Unloads the current model and builds a new primitive shape in its place, sharing the
|
||||
// same canvas texture, and recomputes the transformed bounding box used for ray testing
|
||||
static void ChangeShape(Model *model, BoundingBox *bbox, ShapeType *currentShape, ShapeType newShape, Texture2D canvasTexture)
|
||||
{
|
||||
UnloadModel(*model);
|
||||
|
||||
Mesh mesh = { 0 };
|
||||
|
||||
switch (newShape)
|
||||
{
|
||||
case SHAPE_SPHERE: mesh = GenMeshSphere(1.5f, 32, 32); break;
|
||||
case SHAPE_CUBE: mesh = GenMeshCube(2.2f, 2.2f, 2.2f); break;
|
||||
case SHAPE_CYLINDER: mesh = GenMeshCylinder(1.2f, 2.5f, 24); break;
|
||||
case SHAPE_TORUS: mesh = GenMeshTorus(0.6f, 1.6f, 24, 36); break;
|
||||
default: mesh = GenMeshSphere(1.5f, 32, 32); break;
|
||||
}
|
||||
|
||||
*model = LoadModelFromMesh(mesh);
|
||||
|
||||
// GenMeshCylinder builds upward from y = 0; shift it down to center on the origin
|
||||
if (newShape == SHAPE_CYLINDER) model->transform = MatrixTranslate(0.0f, -1.25f, 0.0f);
|
||||
|
||||
model->materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = canvasTexture;
|
||||
|
||||
BoundingBox box = GetMeshBoundingBox(model->meshes[0]);
|
||||
box.min = Vector3Transform(box.min, model->transform);
|
||||
box.max = Vector3Transform(box.max, model->transform);
|
||||
*bbox = box;
|
||||
|
||||
*currentShape = newShape;
|
||||
}
|
||||
|
||||
// Raycasts against the model's mesh triangles and returns the UV coordinate of the
|
||||
// closest hit, interpolated from the hit triangle's vertices with barycentric weights
|
||||
static bool GetMeshHitUV(Ray ray, Model model, BoundingBox bbox, Vector2 *outUV)
|
||||
{
|
||||
if (!GetRayCollisionBox(ray, bbox).hit) return false; // Fast reject
|
||||
|
||||
Mesh mesh = model.meshes[0];
|
||||
float closestDistance = 1e9f;
|
||||
bool found = false;
|
||||
Vector2 hitUV = { 0 };
|
||||
|
||||
for (int tri = 0; tri < mesh.triangleCount; tri++)
|
||||
{
|
||||
int i0, i1, i2;
|
||||
|
||||
if (mesh.indices != NULL)
|
||||
{
|
||||
i0 = mesh.indices[3*tri + 0];
|
||||
i1 = mesh.indices[3*tri + 1];
|
||||
i2 = mesh.indices[3*tri + 2];
|
||||
}
|
||||
else { i0 = 3*tri; i1 = 3*tri + 1; i2 = 3*tri + 2; }
|
||||
|
||||
Vector3 a = Vector3Transform((Vector3){ mesh.vertices[3*i0], mesh.vertices[3*i0 + 1], mesh.vertices[3*i0 + 2] }, model.transform);
|
||||
Vector3 b = Vector3Transform((Vector3){ mesh.vertices[3*i1], mesh.vertices[3*i1 + 1], mesh.vertices[3*i1 + 2] }, model.transform);
|
||||
Vector3 c = Vector3Transform((Vector3){ mesh.vertices[3*i2], mesh.vertices[3*i2 + 1], mesh.vertices[3*i2 + 2] }, model.transform);
|
||||
|
||||
RayCollision hit = GetRayCollisionTriangle(ray, a, b, c);
|
||||
|
||||
if (hit.hit && (hit.distance < closestDistance))
|
||||
{
|
||||
closestDistance = hit.distance;
|
||||
found = true;
|
||||
|
||||
Vector2 uvA = { mesh.texcoords[2*i0], mesh.texcoords[2*i0 + 1] };
|
||||
Vector2 uvB = { mesh.texcoords[2*i1], mesh.texcoords[2*i1 + 1] };
|
||||
Vector2 uvC = { mesh.texcoords[2*i2], mesh.texcoords[2*i2 + 1] };
|
||||
|
||||
Vector3 w = Vector3Barycenter(hit.point, a, b, c);
|
||||
|
||||
hitUV.x = w.x*uvA.x + w.y*uvB.x + w.z*uvC.x;
|
||||
hitUV.y = w.x*uvA.y + w.y*uvB.y + w.z*uvC.y;
|
||||
|
||||
// Wrap into [0, 1] in case of minor floating point drift at UV seams
|
||||
hitUV.x -= floorf(hitUV.x);
|
||||
hitUV.y -= floorf(hitUV.y);
|
||||
}
|
||||
}
|
||||
|
||||
if (found && (outUV != NULL)) *outUV = hitUV;
|
||||
|
||||
return found;
|
||||
}
|
||||
BIN
examples/models/models_mesh_uv_painting.png
Normal file
BIN
examples/models/models_mesh_uv_painting.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
504
examples/models/models_procedural_decals.c
Normal file
504
examples/models/models_procedural_decals.c
Normal file
@ -0,0 +1,504 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [models] example - procedural decals
|
||||
*
|
||||
* Example demonstrates projecting decals onto a 3D mesh surface by transforming the
|
||||
* mesh's own triangles into the decal's local space and clipping them against a box,
|
||||
* using only procedurally generated geometry and textures (no external resource files)
|
||||
*
|
||||
* NOTE: This is the same clip-space decal projection idea used by models_decals.c
|
||||
* (in turn based on three.js' DecalGeometry), applied here to a generated mesh and
|
||||
* generated textures instead of a loaded model, so the example is fully self-contained
|
||||
*
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
||||
*
|
||||
* Example contributed by PanicTitan (@PanicTitan) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2025 PanicTitan (@PanicTitan)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "raygui.h"
|
||||
#include "raymath.h"
|
||||
|
||||
#include <stddef.h> // Required for: NULL
|
||||
#include <string.h> // Required for: memcpy()
|
||||
#include <math.h> // Required for: fabsf(), fminf()
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Global Definitions
|
||||
//--------------------------------------------------------------------------------------
|
||||
#define MAX_DECALS 256
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Growable triangle-soup buffer used while building a clipped decal mesh
|
||||
typedef struct MeshBuilder {
|
||||
int vertexCount;
|
||||
int vertexCapacity;
|
||||
Vector3 *vertices;
|
||||
Vector2 *uvs;
|
||||
} MeshBuilder;
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
static void AddTriangleToMeshBuilder(MeshBuilder *mb, Vector3 v0, Vector3 v1, Vector3 v2);
|
||||
static void FreeMeshBuilder(MeshBuilder *mb);
|
||||
static Mesh BuildMesh(MeshBuilder *mb);
|
||||
static Vector3 ClipSegment(Vector3 v0, Vector3 v1, Vector3 p, float s);
|
||||
static Mesh GenMeshDecal(Model model, Matrix projection, float decalSize, float decalOffset);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - procedural decals");
|
||||
|
||||
Camera3D camera = { 0 };
|
||||
camera.position = (Vector3){ 0.0f, 2.5f, 5.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
// Target model: a procedurally generated knot with a checkerboard skin
|
||||
Model model = LoadModelFromMesh(GenMeshTorus(0.8f, 1.8f, 32, 64));
|
||||
|
||||
Image checkerImage = GenImageChecked(512, 512, 32, 32, LIGHTGRAY, GRAY);
|
||||
Texture2D modelTexture = LoadTextureFromImage(checkerImage);
|
||||
UnloadImage(checkerImage);
|
||||
SetTextureFilter(modelTexture, TEXTURE_FILTER_BILINEAR);
|
||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = modelTexture;
|
||||
|
||||
BoundingBox modelBBox = GetMeshBoundingBox(model.meshes[0]);
|
||||
camera.target = Vector3Lerp(modelBBox.min, modelBBox.max, 0.5f);
|
||||
|
||||
float modelSize = fminf(fminf(fabsf(modelBBox.max.x - modelBBox.min.x),
|
||||
fabsf(modelBBox.max.y - modelBBox.min.y)), fabsf(modelBBox.max.z - modelBBox.min.z));
|
||||
|
||||
float decalSize = modelSize*0.35f;
|
||||
float decalOffset = 0.01f;
|
||||
|
||||
// Translucent cube previewing where the next decal will land
|
||||
Model placementCube = LoadModelFromMesh(GenMeshCube(decalSize, decalSize, decalSize));
|
||||
placementCube.materials[0].maps[0].color = LIME;
|
||||
|
||||
// Decal texture: a procedurally drawn target/bullseye, no image file needed
|
||||
Image decalImage = GenImageColor(128, 128, BLANK);
|
||||
ImageDrawCircle(&decalImage, 64, 64, 60, RED);
|
||||
ImageDrawCircle(&decalImage, 64, 64, 45, WHITE);
|
||||
ImageDrawCircle(&decalImage, 64, 64, 30, RED);
|
||||
ImageDrawCircle(&decalImage, 64, 64, 15, YELLOW);
|
||||
|
||||
Texture2D decalTexture = LoadTextureFromImage(decalImage);
|
||||
UnloadImage(decalImage);
|
||||
SetTextureFilter(decalTexture, TEXTURE_FILTER_BILINEAR);
|
||||
|
||||
Material decalMaterial = LoadMaterialDefault();
|
||||
decalMaterial.maps[MATERIAL_MAP_DIFFUSE].texture = decalTexture;
|
||||
decalMaterial.maps[MATERIAL_MAP_DIFFUSE].color = RAYWHITE;
|
||||
|
||||
bool showModel = true;
|
||||
Model decals[MAX_DECALS] = { 0 };
|
||||
int decalCount = 0;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) UpdateCamera(&camera, CAMERA_THIRD_PERSON);
|
||||
|
||||
// Cast a ray from the mouse and keep the closest point it hits on the model
|
||||
Ray ray = GetScreenToWorldRay(GetMousePosition(), camera);
|
||||
RayCollision collision = { 0 };
|
||||
|
||||
if (GetRayCollisionBox(ray, modelBBox).hit && (decalCount < MAX_DECALS))
|
||||
{
|
||||
for (int m = 0; m < model.meshCount; m++)
|
||||
{
|
||||
RayCollision meshHit = GetRayCollisionMesh(ray, model.meshes[m], model.transform);
|
||||
if (meshHit.hit && (!collision.hit || (meshHit.distance < collision.distance))) collision = meshHit;
|
||||
}
|
||||
}
|
||||
|
||||
// Project a new decal at the hit point, facing along the surface normal
|
||||
if (collision.hit && IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && (decalCount < MAX_DECALS))
|
||||
{
|
||||
Vector3 lookTarget = Vector3Add(collision.point, collision.normal);
|
||||
Matrix splat = MatrixLookAt(collision.point, lookTarget, (Vector3){ 0.0f, 1.0f, 0.0f });
|
||||
splat = MatrixMultiply(splat, MatrixRotateZ(DEG2RAD*(float)GetRandomValue(-180, 180)));
|
||||
|
||||
Mesh decalMesh = GenMeshDecal(model, splat, decalSize, decalOffset);
|
||||
|
||||
if (decalMesh.vertexCount > 0)
|
||||
{
|
||||
decals[decalCount] = LoadModelFromMesh(decalMesh);
|
||||
decals[decalCount].materials[0].maps[0] = decalMaterial.maps[0];
|
||||
decalCount++;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
if (showModel) DrawModel(model, Vector3Zero(), 1.0f, WHITE);
|
||||
|
||||
for (int i = 0; i < decalCount; i++) DrawModel(decals[i], Vector3Zero(), 1.0f, WHITE);
|
||||
|
||||
// Preview cube at the surface point currently under the mouse
|
||||
if (collision.hit)
|
||||
{
|
||||
Vector3 lookTarget = Vector3Add(collision.point, collision.normal);
|
||||
Matrix splat = MatrixLookAt(collision.point, lookTarget, (Vector3){ 0.0f, 1.0f, 0.0f });
|
||||
placementCube.transform = MatrixInvert(splat);
|
||||
DrawModel(placementCube, Vector3Zero(), 1.0f, Fade(WHITE, 0.5f));
|
||||
}
|
||||
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
EndMode3D();
|
||||
|
||||
// Vertex/triangle counts: base model vs total once decal geometry is added
|
||||
int baseVertices = 0, baseTriangles = 0;
|
||||
for (int i = 0; i < model.meshCount; i++)
|
||||
{
|
||||
baseVertices += model.meshes[i].vertexCount;
|
||||
baseTriangles += model.meshes[i].triangleCount;
|
||||
}
|
||||
|
||||
int totalVertices = baseVertices, totalTriangles = baseTriangles;
|
||||
for (int i = 0; i < decalCount; i++)
|
||||
{
|
||||
totalVertices += decals[i].meshes[0].vertexCount;
|
||||
totalTriangles += decals[i].meshes[0].triangleCount;
|
||||
}
|
||||
|
||||
int statX = screenWidth - 280;
|
||||
DrawText("Vertices", statX + 90, 10, 10, LIME);
|
||||
DrawText("Triangles", statX + 180, 10, 10, LIME);
|
||||
DrawText("Base Model", statX, 25, 10, LIME);
|
||||
DrawText(TextFormat("%d", baseVertices), statX + 90, 25, 10, LIME);
|
||||
DrawText(TextFormat("%d", baseTriangles), statX + 180, 25, 10, LIME);
|
||||
DrawText("TOTAL", statX, 40, 10, LIME);
|
||||
DrawText(TextFormat("%d", totalVertices), statX + 90, 40, 10, LIME);
|
||||
DrawText(TextFormat("%d", totalTriangles), statX + 180, 40, 10, LIME);
|
||||
|
||||
if (GuiButton((Rectangle){ 10, screenHeight - 80.0f, 100, 40 }, showModel ? "Hide Model" : "Show Model"))
|
||||
showModel = !showModel;
|
||||
|
||||
if (GuiButton((Rectangle){ 120, screenHeight - 80.0f, 100, 40 }, "Clear Decals"))
|
||||
{
|
||||
for (int i = 0; i < decalCount; i++) UnloadModel(decals[i]);
|
||||
decalCount = 0;
|
||||
}
|
||||
|
||||
DrawText("Left click: place decal | Right drag: orbit camera", 10, screenHeight - 25, 10, DARKGRAY);
|
||||
DrawFPS(10, 10);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
for (int i = 0; i < decalCount; i++) UnloadModel(decals[i]);
|
||||
|
||||
UnloadModel(placementCube);
|
||||
UnloadTexture(decalTexture);
|
||||
UnloadTexture(modelTexture);
|
||||
UnloadModel(model);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Appends a triangle to a growable mesh builder buffer, growing it in fixed-size chunks
|
||||
static void AddTriangleToMeshBuilder(MeshBuilder *mb, Vector3 v0, Vector3 v1, Vector3 v2)
|
||||
{
|
||||
if (mb->vertexCapacity <= (mb->vertexCount + 3))
|
||||
{
|
||||
int newVertexCapacity = (1 + (mb->vertexCapacity/256))*256;
|
||||
Vector3 *newVertices = (Vector3 *)MemAlloc(newVertexCapacity*sizeof(Vector3));
|
||||
|
||||
if (mb->vertexCapacity > 0)
|
||||
{
|
||||
memcpy(newVertices, mb->vertices, mb->vertexCount*sizeof(Vector3));
|
||||
MemFree(mb->vertices);
|
||||
}
|
||||
|
||||
mb->vertices = newVertices;
|
||||
mb->vertexCapacity = newVertexCapacity;
|
||||
}
|
||||
|
||||
int index = mb->vertexCount;
|
||||
mb->vertexCount += 3;
|
||||
|
||||
mb->vertices[index + 0] = v0;
|
||||
mb->vertices[index + 1] = v1;
|
||||
mb->vertices[index + 2] = v2;
|
||||
}
|
||||
|
||||
// Frees a mesh builder's backing buffers
|
||||
static void FreeMeshBuilder(MeshBuilder *mb)
|
||||
{
|
||||
if (mb->vertices != NULL) MemFree(mb->vertices);
|
||||
if (mb->uvs != NULL) MemFree(mb->uvs);
|
||||
*mb = (MeshBuilder){ 0 };
|
||||
}
|
||||
|
||||
// Converts a mesh builder's triangle soup into a standard uploaded raylib Mesh
|
||||
static Mesh BuildMesh(MeshBuilder *mb)
|
||||
{
|
||||
Mesh outMesh = { 0 };
|
||||
|
||||
outMesh.vertexCount = mb->vertexCount;
|
||||
outMesh.triangleCount = mb->vertexCount/3;
|
||||
outMesh.vertices = (float *)MemAlloc(outMesh.vertexCount*3*sizeof(float));
|
||||
if (mb->uvs != NULL) outMesh.texcoords = (float *)MemAlloc(outMesh.vertexCount*2*sizeof(float));
|
||||
|
||||
for (int i = 0; i < mb->vertexCount; i++)
|
||||
{
|
||||
outMesh.vertices[3*i + 0] = mb->vertices[i].x;
|
||||
outMesh.vertices[3*i + 1] = mb->vertices[i].y;
|
||||
outMesh.vertices[3*i + 2] = mb->vertices[i].z;
|
||||
|
||||
if (mb->uvs != NULL)
|
||||
{
|
||||
outMesh.texcoords[2*i + 0] = mb->uvs[i].x;
|
||||
outMesh.texcoords[2*i + 1] = mb->uvs[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
UploadMesh(&outMesh, false);
|
||||
|
||||
return outMesh;
|
||||
}
|
||||
|
||||
// Clips the segment [v0, v1] against the plane p.x = s, returning the intersection point
|
||||
static Vector3 ClipSegment(Vector3 v0, Vector3 v1, Vector3 p, float s)
|
||||
{
|
||||
float d0 = Vector3DotProduct(v0, p) - s;
|
||||
float d1 = Vector3DotProduct(v1, p) - s;
|
||||
float t = d0/(d0 - d1);
|
||||
|
||||
return Vector3Lerp(v0, v1, t);
|
||||
}
|
||||
|
||||
// Builds a decal mesh: the model's triangles are transformed into the decal's local space
|
||||
// (so the decal sits at the origin, facing +Z) and clipped against a decalSize-sided box,
|
||||
// following the same clip-space projection idea used by engines' decal systems (and by
|
||||
// three.js' DecalGeometry, which the technique is commonly traced back to). What's left
|
||||
// after clipping becomes the decal's own small mesh, UV-mapped from its local coordinates
|
||||
static Mesh GenMeshDecal(Model model, Matrix projection, float decalSize, float decalOffset)
|
||||
{
|
||||
Matrix invProj = MatrixInvert(projection);
|
||||
MeshBuilder meshBuilders[2] = { 0 };
|
||||
int mbIndex = 0;
|
||||
|
||||
// Gather triangles that land anywhere near the decal box; this is a loose, cheap
|
||||
// pre-filter meant to skip most of the model, the precise clip happens below
|
||||
for (int meshIndex = 0; meshIndex < model.meshCount; meshIndex++)
|
||||
{
|
||||
Mesh mesh = model.meshes[meshIndex];
|
||||
|
||||
for (int tri = 0; tri < mesh.triangleCount; tri++)
|
||||
{
|
||||
Vector3 vertices[3] = { 0 };
|
||||
|
||||
if (mesh.indices == NULL)
|
||||
{
|
||||
for (int v = 0; v < 3; v++)
|
||||
{
|
||||
vertices[v] = (Vector3){
|
||||
mesh.vertices[3*3*tri + 3*v + 0],
|
||||
mesh.vertices[3*3*tri + 3*v + 1],
|
||||
mesh.vertices[3*3*tri + 3*v + 2]
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int v = 0; v < 3; v++)
|
||||
{
|
||||
int idx = mesh.indices[3*tri + v];
|
||||
vertices[v] = (Vector3){
|
||||
mesh.vertices[3*idx + 0],
|
||||
mesh.vertices[3*idx + 1],
|
||||
mesh.vertices[3*idx + 2]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
int insideCount = 0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Vector3 v = Vector3Transform(vertices[i], projection);
|
||||
if ((fabsf(v.x) < decalSize) || (fabsf(v.y) <= decalSize) || (fabsf(v.z) <= decalSize)) insideCount++;
|
||||
vertices[i] = v;
|
||||
}
|
||||
|
||||
if (insideCount > 0) AddTriangleToMeshBuilder(&meshBuilders[mbIndex], vertices[0], vertices[1], vertices[2]);
|
||||
}
|
||||
}
|
||||
|
||||
// Clip the surviving triangles against each of the decal box's 6 faces in turn
|
||||
Vector3 planes[6] = {
|
||||
{ 1, 0, 0 }, { -1, 0, 0 },
|
||||
{ 0, 1, 0 }, { 0, -1, 0 },
|
||||
{ 0, 0, 1 }, { 0, 0, -1 }
|
||||
};
|
||||
|
||||
for (int face = 0; face < 6; face++)
|
||||
{
|
||||
mbIndex = 1 - mbIndex;
|
||||
|
||||
MeshBuilder *inMesh = &meshBuilders[1 - mbIndex];
|
||||
MeshBuilder *outMesh = &meshBuilders[mbIndex];
|
||||
|
||||
outMesh->vertexCount = 0;
|
||||
float s = 0.5f*decalSize;
|
||||
|
||||
for (int i = 0; i < inMesh->vertexCount; i += 3)
|
||||
{
|
||||
Vector3 nV1, nV2, nV3, nV4;
|
||||
|
||||
float d1 = Vector3DotProduct(inMesh->vertices[i + 0], planes[face]) - s;
|
||||
float d2 = Vector3DotProduct(inMesh->vertices[i + 1], planes[face]) - s;
|
||||
float d3 = Vector3DotProduct(inMesh->vertices[i + 2], planes[face]) - s;
|
||||
|
||||
int v1Out = (d1 > 0);
|
||||
int v2Out = (d2 > 0);
|
||||
int v3Out = (d3 > 0);
|
||||
int total = v1Out + v2Out + v3Out;
|
||||
|
||||
switch (total)
|
||||
{
|
||||
case 0:
|
||||
// Whole triangle is inside this face, keep it as-is
|
||||
AddTriangleToMeshBuilder(outMesh, inMesh->vertices[i], inMesh->vertices[i + 1], inMesh->vertices[i + 2]);
|
||||
break;
|
||||
case 1:
|
||||
// One corner is outside; clip it off, turning the triangle into a quad
|
||||
if (v1Out)
|
||||
{
|
||||
nV1 = inMesh->vertices[i + 1];
|
||||
nV2 = inMesh->vertices[i + 2];
|
||||
nV3 = ClipSegment(inMesh->vertices[i], nV1, planes[face], s);
|
||||
nV4 = ClipSegment(inMesh->vertices[i], nV2, planes[face], s);
|
||||
}
|
||||
|
||||
if (v2Out)
|
||||
{
|
||||
nV1 = inMesh->vertices[i];
|
||||
nV2 = inMesh->vertices[i + 2];
|
||||
nV3 = ClipSegment(inMesh->vertices[i + 1], nV1, planes[face], s);
|
||||
nV4 = ClipSegment(inMesh->vertices[i + 1], nV2, planes[face], s);
|
||||
|
||||
AddTriangleToMeshBuilder(outMesh, nV3, nV2, nV1);
|
||||
AddTriangleToMeshBuilder(outMesh, nV2, nV3, nV4);
|
||||
break;
|
||||
}
|
||||
|
||||
if (v3Out)
|
||||
{
|
||||
nV1 = inMesh->vertices[i];
|
||||
nV2 = inMesh->vertices[i + 1];
|
||||
nV3 = ClipSegment(inMesh->vertices[i + 2], nV1, planes[face], s);
|
||||
nV4 = ClipSegment(inMesh->vertices[i + 2], nV2, planes[face], s);
|
||||
}
|
||||
|
||||
AddTriangleToMeshBuilder(outMesh, nV1, nV2, nV3);
|
||||
AddTriangleToMeshBuilder(outMesh, nV4, nV3, nV2);
|
||||
break;
|
||||
case 2:
|
||||
// Two corners are outside; only the small corner near the surviving vertex remains
|
||||
if (!v1Out)
|
||||
{
|
||||
nV1 = inMesh->vertices[i];
|
||||
nV2 = ClipSegment(nV1, inMesh->vertices[i + 1], planes[face], s);
|
||||
nV3 = ClipSegment(nV1, inMesh->vertices[i + 2], planes[face], s);
|
||||
AddTriangleToMeshBuilder(outMesh, nV1, nV2, nV3);
|
||||
}
|
||||
|
||||
if (!v2Out)
|
||||
{
|
||||
nV1 = inMesh->vertices[i + 1];
|
||||
nV2 = ClipSegment(nV1, inMesh->vertices[i + 2], planes[face], s);
|
||||
nV3 = ClipSegment(nV1, inMesh->vertices[i], planes[face], s);
|
||||
AddTriangleToMeshBuilder(outMesh, nV1, nV2, nV3);
|
||||
}
|
||||
|
||||
if (!v3Out)
|
||||
{
|
||||
nV1 = inMesh->vertices[i + 2];
|
||||
nV2 = ClipSegment(nV1, inMesh->vertices[i], planes[face], s);
|
||||
nV3 = ClipSegment(nV1, inMesh->vertices[i + 1], planes[face], s);
|
||||
AddTriangleToMeshBuilder(outMesh, nV1, nV2, nV3);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// All 3 corners are outside this face, the triangle is fully clipped away
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MeshBuilder *finalMesh = &meshBuilders[mbIndex];
|
||||
Mesh decalMesh = { 0 };
|
||||
|
||||
if (finalMesh->vertexCount > 0)
|
||||
{
|
||||
finalMesh->uvs = (Vector2 *)MemAlloc(sizeof(Vector2)*finalMesh->vertexCount);
|
||||
|
||||
for (int i = 0; i < finalMesh->vertexCount; i++)
|
||||
{
|
||||
// Clipped coordinates run roughly (-decalSize/2 .. decalSize/2); remap to (0..1)
|
||||
finalMesh->uvs[i].x = (finalMesh->vertices[i].x/decalSize + 0.5f);
|
||||
finalMesh->uvs[i].y = (finalMesh->vertices[i].y/decalSize + 0.5f);
|
||||
|
||||
// Nudge slightly along the normal so the decal doesn't z-fight with the surface
|
||||
finalMesh->vertices[i].z -= decalOffset;
|
||||
finalMesh->vertices[i] = Vector3Transform(finalMesh->vertices[i], invProj);
|
||||
}
|
||||
|
||||
decalMesh = BuildMesh(finalMesh);
|
||||
}
|
||||
|
||||
FreeMeshBuilder(&meshBuilders[0]);
|
||||
FreeMeshBuilder(&meshBuilders[1]);
|
||||
|
||||
return decalMesh;
|
||||
}
|
||||
BIN
examples/models/models_procedural_decals.png
Normal file
BIN
examples/models/models_procedural_decals.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
153
examples/others/gl_scissor_shapes.c
Normal file
153
examples/others/gl_scissor_shapes.c
Normal file
@ -0,0 +1,153 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [others] example - scissor shapes
|
||||
*
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* Example originally created with raylib 6.0
|
||||
*
|
||||
* Example contributed by David Buzatto (@davidbuzatto) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2026 David Buzatto (@davidbuzatto)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include "rlgl.h"
|
||||
|
||||
#include <math.h> // Required for: sinf()
|
||||
|
||||
// BeginScissorMode() only clips to an axis-aligned rectangle, since it maps
|
||||
// directly to glScissor. Clipping to an arbitrary shape (the same idea as
|
||||
// Graphics2D.setClip(Shape) in Java2D) needs the stencil buffer instead:
|
||||
// the clip shape is rasterized into the stencil buffer first, then further
|
||||
// draws are only let through where the stencil was written.
|
||||
//
|
||||
// rlgl has no stencil wrapper (see raysan5/raylib discussion #2964), so this
|
||||
// example calls the handful of OpenGL 1.0 stencil functions directly - they
|
||||
// don't need glad/extension loading, same as glScissor doesn't.
|
||||
#if defined(__APPLE__)
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#if !defined(APIENTRY)
|
||||
#if defined(_WIN32)
|
||||
#define APIENTRY __stdcall
|
||||
#else
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(WINGDIAPI) && defined(_WIN32)
|
||||
#define WINGDIAPI __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
// mask is a callback instead of a fixed shape, so the clip region can be any
|
||||
// combination of Draw* calls (circle, polygon, text, several shapes together)
|
||||
typedef void (*ScissorMaskDrawFunc)(void *userData);
|
||||
|
||||
static void BeginScissorModeShape(ScissorMaskDrawFunc mask, void *userData)
|
||||
{
|
||||
rlDrawRenderBatchActive(); // Flush before touching stencil state
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilMask(0xFF);
|
||||
|
||||
// Pass 1: rasterize the mask into the stencil buffer only, no color write
|
||||
rlColorMask(false, false, false, false);
|
||||
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
||||
mask(userData);
|
||||
rlDrawRenderBatchActive(); // Flush the mask draw
|
||||
|
||||
// Pass 2: subsequent draws only survive where the stencil was written
|
||||
rlColorMask(true, true, true, true);
|
||||
glStencilFunc(GL_EQUAL, 1, 0xFF);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
}
|
||||
|
||||
static void EndScissorModeShape(void)
|
||||
{
|
||||
rlDrawRenderBatchActive();
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
// Two example mask shapes, drawn in WHITE (the color is irrelevant here,
|
||||
// only the stencil write from pass 1 matters)
|
||||
typedef struct { Vector2 center; float radius; } CircleMask;
|
||||
static void DrawCircleMask(void *userData)
|
||||
{
|
||||
CircleMask *m = (CircleMask *)userData;
|
||||
DrawCircleV(m->center, m->radius, WHITE);
|
||||
}
|
||||
|
||||
typedef struct { Vector2 center; float radius; int sides; } PolyMask;
|
||||
static void DrawPolyMask(void *userData)
|
||||
{
|
||||
PolyMask *m = (PolyMask *)userData;
|
||||
DrawPoly(m->center, m->sides, m->radius, 0.0f, WHITE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [others] example - scissor shapes");
|
||||
|
||||
Vector2 circleCenter = { screenWidth/2.0f - 120, screenHeight/2.0f };
|
||||
Vector2 hexCenter = { screenWidth/2.0f + 120, screenHeight/2.0f };
|
||||
float maskRadius = 100.0f;
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
circleCenter.y = screenHeight/2.0f + sinf((float)GetTime())*40.0f;
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Circle-shaped clip: the full-screen rectangle only shows inside the circle
|
||||
CircleMask circleMask = { circleCenter, maskRadius };
|
||||
BeginScissorModeShape(DrawCircleMask, &circleMask);
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, BLUE);
|
||||
EndScissorModeShape();
|
||||
|
||||
// Hexagon-shaped clip: same mechanism, a different mask shape
|
||||
PolyMask hexMask = { hexCenter, maskRadius, 6 };
|
||||
BeginScissorModeShape(DrawPolyMask, &hexMask);
|
||||
DrawRectangle(0, 0, screenWidth, screenHeight, ORANGE);
|
||||
EndScissorModeShape();
|
||||
|
||||
DrawText("BeginScissorMode() only clips to a rectangle (glScissor)", 10, 10, 10, DARKGRAY);
|
||||
DrawText("This clips to arbitrary shapes instead, using the stencil buffer", 10, 25, 10, DARKGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
examples/others/gl_scissor_shapes.png
Normal file
BIN
examples/others/gl_scissor_shapes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@ -24,7 +24,7 @@
|
||||
*
|
||||
* APPLE COMPILATION:
|
||||
* gcc -o rlgl_standalone rlgl_standalone.c -I../../src -Iexternal/include -Lexternal/lib \
|
||||
* -lglfw3 -framework CoreVideo -framework OpenGL -framework IOKit -framework Cocoa
|
||||
* -lglfw3 -framework CoreVideo -framework OpenGL -framework IOKit -framework Cocoa -framework QuartzCore
|
||||
* -Wno-deprecated-declarations -std=c99 -DGRAPHICS_API_OPENGL_33
|
||||
*
|
||||
*
|
||||
|
||||
44
examples/shaders/resources/shaders/glsl100/lights_bloom.fs
Normal file
44
examples/shaders/resources/shaders/glsl100/lights_bloom.fs
Normal file
@ -0,0 +1,44 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
// Input values from vertex shader
|
||||
varying vec3 fragPosition;
|
||||
varying vec3 fragNormal;
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec3 viewPos;
|
||||
uniform vec3 lightPositions[8];
|
||||
uniform vec3 lightColors[8];
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texColor = texture2D(texture0, fragTexCoord);
|
||||
vec3 norm = normalize(fragNormal);
|
||||
vec3 viewDir = normalize(viewPos - fragPosition);
|
||||
|
||||
vec3 ambient = 0.05*texColor.rgb;
|
||||
vec3 totalDiffuse = vec3(0.0);
|
||||
vec3 totalSpecular = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
vec3 lightDir = normalize(lightPositions[i] - fragPosition);
|
||||
float dist = length(lightPositions[i] - fragPosition);
|
||||
float attenuation = 1.0/(1.0 + 0.8*dist + 0.4*dist*dist);
|
||||
|
||||
// Diffuse shading
|
||||
float diff = max(dot(norm, lightDir), 0.0);
|
||||
totalDiffuse += diff*lightColors[i]*attenuation*1.2;
|
||||
|
||||
// Blinn-Phong specular
|
||||
vec3 halfwayDir = normalize(lightDir + viewDir);
|
||||
float spec = pow(max(dot(norm, halfwayDir), 0.0), 32.0);
|
||||
totalSpecular += spec*lightColors[i]*attenuation*0.8;
|
||||
}
|
||||
|
||||
vec3 result = ambient + (totalDiffuse*texColor.rgb) + totalSpecular;
|
||||
gl_FragColor = vec4(result, texColor.a);
|
||||
}
|
||||
23
examples/shaders/resources/shaders/glsl100/lights_bloom.vs
Normal file
23
examples/shaders/resources/shaders/glsl100/lights_bloom.vs
Normal file
@ -0,0 +1,23 @@
|
||||
#version 100
|
||||
|
||||
// Input vertex attributes
|
||||
attribute vec3 vertexPosition;
|
||||
attribute vec2 vertexTexCoord;
|
||||
attribute vec3 vertexNormal;
|
||||
|
||||
// Output values to fragment shader
|
||||
varying vec3 fragPosition;
|
||||
varying vec3 fragNormal;
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 matModel;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
fragNormal = normalize(vec3(matModel*vec4(vertexNormal, 0.0)));
|
||||
fragTexCoord = vertexTexCoord;
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
#version 100
|
||||
|
||||
precision mediump float;
|
||||
|
||||
varying vec2 fragTexCoord;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D(texture0, fragTexCoord);
|
||||
|
||||
// High-pass threshold blur: only pixels brighter than 0.75 in any channel contribute
|
||||
vec4 bloom = vec4(0.0);
|
||||
vec2 texel = vec2(1.0/1280.0, 1.0/720.0)*2.5;
|
||||
|
||||
for (int x = -2; x <= 2; x++)
|
||||
{
|
||||
for (int y = -2; y <= 2; y++)
|
||||
{
|
||||
vec4 smp = texture2D(texture0, fragTexCoord + vec2(float(x), float(y))*texel);
|
||||
float brightness = max(smp.r, max(smp.g, smp.b));
|
||||
if (brightness > 0.75) bloom += smp;
|
||||
}
|
||||
}
|
||||
bloom /= 25.0;
|
||||
|
||||
// Combine original with the bloom glow, then Reinhard tone-map back to [0, 1]
|
||||
vec3 hdr = color.rgb + bloom.rgb*1.2;
|
||||
vec3 ldr = hdr/(hdr + vec3(1.0));
|
||||
|
||||
gl_FragColor = vec4(ldr, color.a);
|
||||
}
|
||||
44
examples/shaders/resources/shaders/glsl330/lights_bloom.fs
Normal file
44
examples/shaders/resources/shaders/glsl330/lights_bloom.fs
Normal file
@ -0,0 +1,44 @@
|
||||
#version 330
|
||||
|
||||
// Input values from vertex shader
|
||||
in vec3 fragPosition;
|
||||
in vec3 fragNormal;
|
||||
in vec2 fragTexCoord;
|
||||
|
||||
out vec4 finalColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec3 viewPos;
|
||||
uniform vec3 lightPositions[8];
|
||||
uniform vec3 lightColors[8];
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texColor = texture(texture0, fragTexCoord);
|
||||
vec3 norm = normalize(fragNormal);
|
||||
vec3 viewDir = normalize(viewPos - fragPosition);
|
||||
|
||||
vec3 ambient = 0.05*texColor.rgb;
|
||||
vec3 totalDiffuse = vec3(0.0);
|
||||
vec3 totalSpecular = vec3(0.0);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
vec3 lightDir = normalize(lightPositions[i] - fragPosition);
|
||||
float dist = length(lightPositions[i] - fragPosition);
|
||||
float attenuation = 1.0/(1.0 + 0.8*dist + 0.4*dist*dist);
|
||||
|
||||
// Diffuse shading
|
||||
float diff = max(dot(norm, lightDir), 0.0);
|
||||
totalDiffuse += diff*lightColors[i]*attenuation*1.2;
|
||||
|
||||
// Blinn-Phong specular
|
||||
vec3 halfwayDir = normalize(lightDir + viewDir);
|
||||
float spec = pow(max(dot(norm, halfwayDir), 0.0), 32.0);
|
||||
totalSpecular += spec*lightColors[i]*attenuation*0.8;
|
||||
}
|
||||
|
||||
vec3 result = ambient + (totalDiffuse*texColor.rgb) + totalSpecular;
|
||||
finalColor = vec4(result, texColor.a);
|
||||
}
|
||||
23
examples/shaders/resources/shaders/glsl330/lights_bloom.vs
Normal file
23
examples/shaders/resources/shaders/glsl330/lights_bloom.vs
Normal file
@ -0,0 +1,23 @@
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec3 vertexNormal;
|
||||
|
||||
// Output values to fragment shader
|
||||
out vec3 fragPosition;
|
||||
out vec3 fragNormal;
|
||||
out vec2 fragTexCoord;
|
||||
|
||||
// Input uniform values
|
||||
uniform mat4 mvp;
|
||||
uniform mat4 matModel;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
|
||||
fragNormal = normalize(vec3(matModel*vec4(vertexNormal, 0.0)));
|
||||
fragTexCoord = vertexTexCoord;
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
#version 330
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
out vec4 finalColor;
|
||||
|
||||
uniform sampler2D texture0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture(texture0, fragTexCoord);
|
||||
|
||||
// High-pass threshold blur: only pixels brighter than 0.75 in any channel contribute
|
||||
vec4 bloom = vec4(0.0);
|
||||
vec2 texel = vec2(1.0/1280.0, 1.0/720.0)*2.5;
|
||||
|
||||
for (int x = -2; x <= 2; x++)
|
||||
{
|
||||
for (int y = -2; y <= 2; y++)
|
||||
{
|
||||
vec4 smp = texture(texture0, fragTexCoord + vec2(float(x), float(y))*texel);
|
||||
float brightness = max(smp.r, max(smp.g, smp.b));
|
||||
if (brightness > 0.75) bloom += smp;
|
||||
}
|
||||
}
|
||||
bloom /= 25.0;
|
||||
|
||||
// Combine original with the bloom glow, then Reinhard tone-map back to [0, 1]
|
||||
vec3 hdr = color.rgb + bloom.rgb*1.2;
|
||||
vec3 ldr = hdr/(hdr + vec3(1.0));
|
||||
|
||||
finalColor = vec4(ldr, color.a);
|
||||
}
|
||||
185
examples/shaders/shaders_lights_bloom.c
Normal file
185
examples/shaders/shaders_lights_bloom.c
Normal file
@ -0,0 +1,185 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shaders] example - forward multi-lighting with bloom
|
||||
*
|
||||
* Example demonstrates forward multi-point lighting (8 point lights, attenuation and
|
||||
* Blinn-Phong specular) combined with a threshold-based bloom pass and Reinhard tone
|
||||
* mapping, applied as a full-screen post-process pass
|
||||
*
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* Example uses resources/shaders/glsl100 and resources/shaders/glsl330, shared with the
|
||||
* rest of the shaders examples
|
||||
*
|
||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
||||
*
|
||||
* Example contributed by PanicTitan (@PanicTitan) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2025 PanicTitan (@PanicTitan)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "raymath.h"
|
||||
#include "rlgl.h"
|
||||
|
||||
#include <math.h> // Required for: sinf(), cosf()
|
||||
|
||||
#if defined(PLATFORM_DESKTOP)
|
||||
#define GLSL_VERSION 330
|
||||
#else // PLATFORM_ANDROID, PLATFORM_WEB
|
||||
#define GLSL_VERSION 100
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Global Definitions
|
||||
//--------------------------------------------------------------------------------------
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT | FLAG_VSYNC_HINT);
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - forward multi-lighting bloom");
|
||||
|
||||
Camera3D camera = { 0 };
|
||||
camera.position = (Vector3){ 0.0f, 5.0f, 9.0f };
|
||||
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
|
||||
// Forward multi-light shader and bloom post-process shader, both loaded from the
|
||||
// resources folder shared with the rest of the shaders examples. If the GLSL version
|
||||
// guessed from the PLATFORM_DESKTOP build flag turns out to be wrong for whatever
|
||||
// raylib was built against, linking fails and silently falls back to the default
|
||||
// shader - so this retries once with the other version, and either way the result
|
||||
// is checked explicitly and reported on screen rather than staying silently wrong
|
||||
Shader lightShader = LoadShader(TextFormat("resources/shaders/glsl%i/lights_bloom.vs", GLSL_VERSION),
|
||||
TextFormat("resources/shaders/glsl%i/lights_bloom.fs", GLSL_VERSION));
|
||||
Shader bloomShader = LoadShader(0, TextFormat("resources/shaders/glsl%i/lights_bloom_post.fs", GLSL_VERSION));
|
||||
|
||||
// Load models from generated cube mesh and plane
|
||||
// NOTE: Meshes are automatically unloaded on UnloadModel()
|
||||
Model cube = LoadModelFromMesh(GenMeshCube(2.0f, 2.0f, 2.0f));
|
||||
Model floor = LoadModelFromMesh(GenMeshPlane(14.0f, 14.0f, 1, 1));
|
||||
cube.materials[0].shader = lightShader;
|
||||
floor.materials[0].shader = lightShader;
|
||||
|
||||
int lightPosLoc = GetShaderLocation(lightShader, "lightPositions");
|
||||
int lightColLoc = GetShaderLocation(lightShader, "lightColors");
|
||||
int viewPosLoc = GetShaderLocation(lightShader, "viewPos");
|
||||
|
||||
Vector3 lightPositions[MAX_LIGHTS] = { 0 };
|
||||
Vector3 lightColors[MAX_LIGHTS] = {
|
||||
{ 1.0f, 0.2f, 0.2f }, // Red
|
||||
{ 0.2f, 1.0f, 0.3f }, // Green
|
||||
{ 0.2f, 0.5f, 1.0f }, // Blue
|
||||
{ 1.0f, 0.8f, 0.1f }, // Yellow
|
||||
{ 1.0f, 0.1f, 0.8f }, // Magenta
|
||||
{ 0.1f, 1.0f, 1.0f }, // Cyan
|
||||
{ 1.0f, 0.4f, 0.1f }, // Orange
|
||||
{ 0.7f, 0.2f, 1.0f }, // Purple
|
||||
};
|
||||
|
||||
SetShaderValueV(lightShader, lightColLoc, lightColors, SHADER_UNIFORM_VEC3, MAX_LIGHTS);
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||
|
||||
float time = (float)GetTime();
|
||||
|
||||
// Orbital path for each point light, its own radius/height offset by index
|
||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||
{
|
||||
float angle = (i/(float)MAX_LIGHTS)*2.0f*PI + time*0.6f;
|
||||
float radius = 4.2f + sinf(time*1.2f + i)*0.4f;
|
||||
float height = 1.0f + sinf(time*1.8f + i)*0.6f;
|
||||
|
||||
lightPositions[i] = (Vector3){ sinf(angle)*radius, height, cosf(angle)*radius };
|
||||
}
|
||||
|
||||
SetShaderValueV(lightShader, lightPosLoc, lightPositions, SHADER_UNIFORM_VEC3, MAX_LIGHTS);
|
||||
SetShaderValue(lightShader, viewPosLoc, &camera.position, SHADER_UNIFORM_VEC3);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
// Render the lit scene to an offscreen texture
|
||||
BeginTextureMode(target);
|
||||
|
||||
ClearBackground((Color){ 12, 12, 18, 255 });
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawModel(cube, (Vector3){ 0.0f, 1.0f, 0.0f }, 1.0f, GRAY);
|
||||
DrawModel(floor, (Vector3){ 0.0f, 0.0f, 0.0f }, 1.0f, DARKGRAY);
|
||||
DrawGrid(10, 1.0f);
|
||||
|
||||
// Glowing bulbs mark each light's position
|
||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||
{
|
||||
Color bulbColor = (Color){
|
||||
(unsigned char)(lightColors[i].x*255),
|
||||
(unsigned char)(lightColors[i].y*255),
|
||||
(unsigned char)(lightColors[i].z*255),
|
||||
255 };
|
||||
|
||||
DrawSphere(lightPositions[i], 0.15f, bulbColor);
|
||||
}
|
||||
|
||||
EndMode3D();
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
// Present the offscreen texture through the bloom + tone mapping shader
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(BLACK);
|
||||
|
||||
Rectangle srcRec = { 0, 0, (float)target.texture.width, (float)-target.texture.height };
|
||||
|
||||
BeginShaderMode(bloomShader);
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
DrawTextureRec(target.texture, srcRec, (Vector2){ 0, 0 }, WHITE);
|
||||
EndShaderMode();
|
||||
|
||||
DrawText("BALANCED MULTI-LIGHT + REINHARD TONE MAPPED BLOOM", 20, 20, 20, GREEN);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadModel(cube);
|
||||
UnloadModel(floor);
|
||||
UnloadShader(lightShader);
|
||||
UnloadShader(bloomShader);
|
||||
UnloadRenderTexture(target);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
examples/shaders/shaders_lights_bloom.png
Normal file
BIN
examples/shaders/shaders_lights_bloom.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 203 KiB |
@ -68,7 +68,7 @@ int main(void)
|
||||
SetShaderValue(shadowShader, lightDirLoc, &lightDir, SHADER_UNIFORM_VEC3);
|
||||
SetShaderValue(shadowShader, lightColLoc, &lightColorNormalized, SHADER_UNIFORM_VEC4);
|
||||
int ambientLoc = GetShaderLocation(shadowShader, "ambient");
|
||||
float ambient[4] = {0.1f, 0.1f, 0.1f, 1.0f};
|
||||
float ambient[4] = { 0.1f, 0.1f, 0.1f, 1.0f };
|
||||
SetShaderValue(shadowShader, ambientLoc, ambient, SHADER_UNIFORM_VEC4);
|
||||
int lightVPLoc = GetShaderLocation(shadowShader, "lightVP");
|
||||
int shadowMapLoc = GetShaderLocation(shadowShader, "shadowMap");
|
||||
@ -81,7 +81,7 @@ int main(void)
|
||||
for (int i = 0; i < robot.materialCount; i++) robot.materials[i].shader = shadowShader;
|
||||
|
||||
int animCount = 0;
|
||||
ModelAnimation *anims = LoadModelAnimations("resources/models/robot.glb", &animCount);
|
||||
ModelAnimation* anims = LoadModelAnimations("resources/models/robot.glb", &animCount);
|
||||
|
||||
RenderTexture2D shadowMap = LoadShadowmapRenderTexture(SHADOWMAP_RESOLUTION, SHADOWMAP_RESOLUTION);
|
||||
|
||||
@ -111,9 +111,11 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
float deltaTime = GetFrameTime();
|
||||
|
||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||
|
||||
// send the updated camera position to the shader so that it can calculate the correct lighting for the scene
|
||||
Vector3 cameraPos = camera.position;
|
||||
SetShaderValue(shadowShader, shadowShader.locs[SHADER_LOC_VECTOR_VIEW], &cameraPos, SHADER_UNIFORM_VEC3);
|
||||
UpdateCamera(&camera, CAMERA_ORBITAL);
|
||||
|
||||
frameCounter++;
|
||||
frameCounter %= (anims[0].keyframeCount);
|
||||
@ -160,6 +162,7 @@ int main(void)
|
||||
EndMode3D();
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
lightViewProj = MatrixMultiply(lightView, lightProj);
|
||||
|
||||
// PASS 02: Draw the scene into main framebuffer, using the generated shadowmap
|
||||
|
||||
407
examples/shapes/shapes_outlines_testbed.c
Normal file
407
examples/shapes/shapes_outlines_testbed.c
Normal file
@ -0,0 +1,407 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [shapes] example - outlines testbed
|
||||
*
|
||||
* Example complexity rating: [★★★☆] 3/4
|
||||
*
|
||||
* Example originally created with raylib 6.1, last time updated with raylib 6.1
|
||||
*
|
||||
* Example contributed by Matthew Roush (@MatthewRoush) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2026 Matthew Roush (@MatthewRoush)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "raymath.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#include "raygui.h" // Required for GUI controls
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define COLOR_FILLED DARKBLUE
|
||||
#define COLOR_OUTLINE YELLOW
|
||||
|
||||
#define SHAPE_SPACING 14.0f
|
||||
#define SHAPE_SIZE 46.0f
|
||||
#define BOX_SPACING 10.0f
|
||||
|
||||
#define MOUSE_CAMERA_ZOOM_SPEED 0.3f
|
||||
#define KEYBOARD_CAMERA_MOVE_SPEED 10.0f
|
||||
#define KEYBOARD_CAMERA_ZOOM_SPEED 0.1f
|
||||
|
||||
#define CAMERA_ZOOM_MIN 0.1f
|
||||
#define CAMERA_ZOOM_MAX 1000.0f
|
||||
|
||||
// The shapes are ordered according to their order in this enum, left to right
|
||||
enum {
|
||||
ORDER_RECTANGLE = 0,
|
||||
ORDER_RECTANGLE_ROUNDED,
|
||||
ORDER_CIRCLE,
|
||||
ORDER_ELLIPSE,
|
||||
ORDER_CIRCLE_SECTOR,
|
||||
ORDER_RING,
|
||||
ORDER_TRIANGLE,
|
||||
ORDER_POLYGON,
|
||||
COUNT_SHAPES
|
||||
};
|
||||
|
||||
// The line style groups are ordered according to their order in this enum, top to bottom
|
||||
enum {
|
||||
ORDER_LINES = 0,
|
||||
ORDER_LINES_EX_WORLD,
|
||||
ORDER_LINES_EX_SCREEN,
|
||||
};
|
||||
|
||||
#define BOX_WIDTH (SHAPE_SIZE*COUNT_SHAPES + SHAPE_SPACING*(COUNT_SHAPES - 1) + BOX_SPACING*2.0f)
|
||||
#define BOX_HEIGHT (SHAPE_SIZE + BOX_SPACING*2.0f)
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - outlines testbed");
|
||||
|
||||
Camera2D camera = { .zoom = 1 };
|
||||
|
||||
// User configurable options while running the program.
|
||||
float lineOpacity = 130;
|
||||
float lineThickness = 4.0f;
|
||||
float rectangleRoundness = 0.4f;
|
||||
float rectangleSegments = 9;
|
||||
float ellipseRadiusY = 0.5f;
|
||||
float circleStartAngle = 20.0f;
|
||||
float circleEndAngle = 270.0f;
|
||||
float circleSegments = 36;
|
||||
float ringInnerRadiusScale = 0.3f;
|
||||
float polygonSides = 6;
|
||||
|
||||
bool disableMouseControl = false;
|
||||
|
||||
const Rectangle optionsBackground = { 510, 0, 290, 450 };
|
||||
|
||||
const Vector2 zoomPoint = {((float)screenWidth - optionsBackground.width)/2.0f, (float)screenHeight/2.0f};
|
||||
|
||||
GuiSetStyle(LABEL, TEXT_COLOR_NORMAL, ColorToInt(WHITE));
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
const Vector2 mousePosScreen = GetMousePosition();
|
||||
const Vector2 mouseWheelVec = GetMouseWheelMoveV();
|
||||
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && CheckCollisionPointRec(mousePosScreen, optionsBackground)) disableMouseControl = true;
|
||||
|
||||
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) disableMouseControl = false;
|
||||
|
||||
if (!disableMouseControl) {
|
||||
if (mouseWheelVec.y != 0.0f) {
|
||||
const Vector2 prevWorldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
|
||||
camera.zoom *= exp2f(MOUSE_CAMERA_ZOOM_SPEED*mouseWheelVec.y); // Constant zoom rate
|
||||
camera.zoom = Clamp(camera.zoom, CAMERA_ZOOM_MIN, CAMERA_ZOOM_MAX);
|
||||
|
||||
const Vector2 worldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
camera.target = Vector2Add(camera.target, Vector2Subtract(prevWorldZoomPoint, worldZoomPoint));
|
||||
}
|
||||
|
||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) {
|
||||
const Vector2 mouseDelta = GetMouseDelta();
|
||||
camera.target.x -= mouseDelta.x/camera.zoom;
|
||||
camera.target.y -= mouseDelta.y/camera.zoom;
|
||||
|
||||
const int mouseMaxX = (int)optionsBackground.x;
|
||||
const int mouseMaxY = screenHeight;
|
||||
|
||||
int newX = (int)mousePosScreen.x;
|
||||
int newY = (int)mousePosScreen.y;
|
||||
|
||||
// In C, the '%' operator computes the remainder, we want the modulus
|
||||
newX = (newX%mouseMaxX + mouseMaxX)%mouseMaxX;
|
||||
newY = (newY%mouseMaxY + mouseMaxY)%mouseMaxY;
|
||||
|
||||
if ((newX != (int)mousePosScreen.x) || (newY != (int)mousePosScreen.y)) SetMousePosition(newX, newY);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyDown(KEY_A)) camera.target.x -= KEYBOARD_CAMERA_MOVE_SPEED/camera.zoom;
|
||||
if (IsKeyDown(KEY_D)) camera.target.x += KEYBOARD_CAMERA_MOVE_SPEED/camera.zoom;
|
||||
if (IsKeyDown(KEY_W)) camera.target.y -= KEYBOARD_CAMERA_MOVE_SPEED/camera.zoom;
|
||||
if (IsKeyDown(KEY_S)) camera.target.y += KEYBOARD_CAMERA_MOVE_SPEED/camera.zoom;
|
||||
|
||||
if (IsKeyDown(KEY_UP))
|
||||
{
|
||||
const Vector2 prevWorldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
|
||||
camera.zoom *= exp2f(KEYBOARD_CAMERA_ZOOM_SPEED);
|
||||
camera.zoom = Clamp(camera.zoom, CAMERA_ZOOM_MIN, CAMERA_ZOOM_MAX);
|
||||
|
||||
const Vector2 worldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
camera.target = Vector2Add(camera.target, Vector2Subtract(prevWorldZoomPoint, worldZoomPoint));
|
||||
}
|
||||
if (IsKeyDown(KEY_DOWN))
|
||||
{
|
||||
const Vector2 prevWorldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
|
||||
camera.zoom *= exp2f(-KEYBOARD_CAMERA_ZOOM_SPEED);
|
||||
camera.zoom = Clamp(camera.zoom, CAMERA_ZOOM_MIN, CAMERA_ZOOM_MAX);
|
||||
|
||||
const Vector2 worldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
camera.target = Vector2Add(camera.target, Vector2Subtract(prevWorldZoomPoint, worldZoomPoint));
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_Z))
|
||||
{
|
||||
const Vector2 zoomPoint = {((float)screenWidth - optionsBackground.width)/2.0f, (float)screenHeight/2.0f};
|
||||
const Vector2 prevWorldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
const Vector2 worldZoomPoint = GetScreenToWorld2D(zoomPoint, camera);
|
||||
camera.target = Vector2Add(camera.target, Vector2Subtract(prevWorldZoomPoint, worldZoomPoint));
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_C)) camera.target = (Vector2){ 0 };
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground((Color){ 50, 50, 55, 255 });
|
||||
|
||||
Color colorOutline = COLOR_OUTLINE;
|
||||
colorOutline.a = (unsigned char)lineOpacity;
|
||||
|
||||
BeginMode2D(camera);
|
||||
|
||||
const float shapeOffset = BOX_SPACING*2.0f;
|
||||
const float shapePaddingX = SHAPE_SIZE + SHAPE_SPACING;
|
||||
const float shapePaddingY = SHAPE_SIZE + SHAPE_SPACING + BOX_SPACING*2.0f;
|
||||
|
||||
const float radiusX = SHAPE_SIZE/2.0f;
|
||||
const float radiusY = radiusX*ellipseRadiusY;
|
||||
|
||||
const float ringOuterRadius = SHAPE_SIZE/2.0f;
|
||||
const float ringInnerRadius = ringOuterRadius*ringInnerRadiusScale;
|
||||
|
||||
const Vector2 triangleVertex0Offset = { 0.0f, SHAPE_SIZE*0.8f };
|
||||
const Vector2 triangleVertex1Offset = { SHAPE_SIZE*0.6f, SHAPE_SIZE };
|
||||
const Vector2 triangleVertex2Offset = { SHAPE_SIZE, 0.0f };
|
||||
|
||||
// ----------------------------------------
|
||||
// Draw*Lines()
|
||||
float posY = shapeOffset + shapePaddingY*ORDER_LINES;
|
||||
|
||||
// Rectangle
|
||||
float posX = shapeOffset + shapePaddingX*ORDER_RECTANGLE;
|
||||
DrawRectangleRec((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, COLOR_FILLED);
|
||||
DrawRectangleLines(posX, posY, SHAPE_SIZE, SHAPE_SIZE, colorOutline);
|
||||
|
||||
// Rectangle Rounded
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RECTANGLE_ROUNDED;
|
||||
DrawRectangleRounded((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, rectangleRoundness, (int)rectangleSegments, COLOR_FILLED);
|
||||
DrawRectangleRoundedLines((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, rectangleRoundness, (int)rectangleSegments, colorOutline);
|
||||
|
||||
// Circle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_CIRCLE;
|
||||
DrawCircleV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, COLOR_FILLED);
|
||||
DrawCircleLinesV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, colorOutline);
|
||||
|
||||
// Ellipse
|
||||
posX = shapeOffset + shapePaddingX*ORDER_ELLIPSE;
|
||||
DrawEllipseV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, radiusY, COLOR_FILLED);
|
||||
DrawEllipseLinesV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, radiusY, colorOutline);
|
||||
|
||||
// Circle Sector
|
||||
posX = shapeOffset + shapePaddingX*ORDER_CIRCLE_SECTOR;
|
||||
DrawCircleSector((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, circleStartAngle, circleEndAngle, (int)circleSegments, COLOR_FILLED);
|
||||
DrawCircleSectorLines((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, circleStartAngle, circleEndAngle, (int)circleSegments, colorOutline);
|
||||
|
||||
// Ring
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RING;
|
||||
DrawRing((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, ringInnerRadius, ringOuterRadius, circleStartAngle, circleEndAngle, (int)circleSegments, COLOR_FILLED);
|
||||
DrawRingLines((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, ringInnerRadius, ringOuterRadius, circleStartAngle, circleEndAngle, (int)circleSegments, colorOutline);
|
||||
|
||||
// Triangle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_TRIANGLE;
|
||||
DrawTriangle((Vector2){ posX + triangleVertex0Offset.x, posY + triangleVertex0Offset.y },
|
||||
(Vector2){ posX + triangleVertex1Offset.x, posY + triangleVertex1Offset.y },
|
||||
(Vector2){ posX + triangleVertex2Offset.x, posY + triangleVertex2Offset.y },
|
||||
COLOR_FILLED);
|
||||
DrawTriangleLines((Vector2){ posX + triangleVertex0Offset.x, posY + triangleVertex0Offset.y },
|
||||
(Vector2){ posX + triangleVertex1Offset.x, posY + triangleVertex1Offset.y },
|
||||
(Vector2){ posX + triangleVertex2Offset.x, posY + triangleVertex2Offset.y },
|
||||
colorOutline);
|
||||
|
||||
// Polygon
|
||||
posX = shapeOffset + shapePaddingX*ORDER_POLYGON;
|
||||
DrawPoly((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, (int)polygonSides, radiusX, 0.0f, COLOR_FILLED);
|
||||
DrawPolyLines((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, (int)polygonSides, radiusX, 0.0f, colorOutline);
|
||||
|
||||
// Group the shapes
|
||||
GuiGroupBox((Rectangle){ shapeOffset - BOX_SPACING, posY - BOX_SPACING, BOX_WIDTH, BOX_HEIGHT }, "Draw*Lines()");
|
||||
// ----------------------------------------
|
||||
|
||||
// ----------------------------------------
|
||||
// Draw*LinesEx() with world space pixel thickness
|
||||
posY = shapeOffset + shapePaddingY*ORDER_LINES_EX_WORLD;
|
||||
|
||||
// Rectangle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RECTANGLE;
|
||||
DrawRectangleRec((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, COLOR_FILLED);
|
||||
DrawRectangleLinesEx((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, lineThickness, colorOutline);
|
||||
|
||||
// Rectangle Rounded
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RECTANGLE_ROUNDED;
|
||||
DrawRectangleRounded((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, rectangleRoundness, (int)rectangleSegments, COLOR_FILLED);
|
||||
DrawRectangleRoundedLinesEx((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, rectangleRoundness, (int)rectangleSegments, lineThickness, colorOutline);
|
||||
|
||||
// Circle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_CIRCLE;
|
||||
DrawCircleV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, COLOR_FILLED);
|
||||
DrawCircleLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, lineThickness, colorOutline);
|
||||
|
||||
// Ellipse
|
||||
posX = shapeOffset + shapePaddingX*ORDER_ELLIPSE;
|
||||
DrawEllipseV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, radiusY, COLOR_FILLED);
|
||||
DrawEllipseLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, radiusY, lineThickness, colorOutline);
|
||||
|
||||
// Circle Sector
|
||||
posX = shapeOffset + shapePaddingX*ORDER_CIRCLE_SECTOR;
|
||||
DrawCircleSector((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, circleStartAngle, circleEndAngle, (int)circleSegments, COLOR_FILLED);
|
||||
DrawCircleSectorLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, circleStartAngle, circleEndAngle, (int)circleSegments, lineThickness, colorOutline);
|
||||
|
||||
// Ring
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RING;
|
||||
DrawRing((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, ringInnerRadius, ringOuterRadius, circleStartAngle, circleEndAngle, (int)circleSegments, COLOR_FILLED);
|
||||
DrawRingLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, ringInnerRadius, ringOuterRadius, circleStartAngle, circleEndAngle, (int)circleSegments, lineThickness, colorOutline);
|
||||
|
||||
// Triangle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_TRIANGLE;
|
||||
DrawTriangle((Vector2){ posX + triangleVertex0Offset.x, posY + triangleVertex0Offset.y },
|
||||
(Vector2){ posX + triangleVertex1Offset.x, posY + triangleVertex1Offset.y },
|
||||
(Vector2){ posX + triangleVertex2Offset.x, posY + triangleVertex2Offset.y },
|
||||
COLOR_FILLED);
|
||||
DrawTriangleLinesEx((Vector2){ posX + triangleVertex0Offset.x, posY + triangleVertex0Offset.y },
|
||||
(Vector2){ posX + triangleVertex1Offset.x, posY + triangleVertex1Offset.y },
|
||||
(Vector2){ posX + triangleVertex2Offset.x, posY + triangleVertex2Offset.y },
|
||||
lineThickness, colorOutline);
|
||||
|
||||
// Polygon
|
||||
posX = shapeOffset + shapePaddingX*ORDER_POLYGON;
|
||||
DrawPoly((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, (int)polygonSides, radiusX, 0.0f, COLOR_FILLED);
|
||||
DrawPolyLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, (int)polygonSides, radiusX, 0.0f, lineThickness, colorOutline);
|
||||
|
||||
// Group the shapes
|
||||
GuiGroupBox((Rectangle){ shapeOffset - BOX_SPACING, posY - BOX_SPACING, BOX_WIDTH, BOX_HEIGHT }, "Draw*LinesEx() with *world space* pixel thickness");
|
||||
// ----------------------------------------
|
||||
|
||||
// ----------------------------------------
|
||||
// Draw*LinesEx() with screen space pixel thickness
|
||||
posY = shapeOffset + shapePaddingY*ORDER_LINES_EX_SCREEN;
|
||||
|
||||
float constantThickness = lineThickness/camera.zoom;
|
||||
|
||||
// Rectangle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RECTANGLE;
|
||||
DrawRectangleRec((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, COLOR_FILLED);
|
||||
DrawRectangleLinesEx((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, constantThickness, colorOutline);
|
||||
|
||||
// Rectangle Rounded
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RECTANGLE_ROUNDED;
|
||||
DrawRectangleRounded((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, rectangleRoundness, (int)rectangleSegments, COLOR_FILLED);
|
||||
DrawRectangleRoundedLinesEx((Rectangle){ posX, posY, SHAPE_SIZE, SHAPE_SIZE }, rectangleRoundness, (int)rectangleSegments, constantThickness, colorOutline);
|
||||
|
||||
// Circle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_CIRCLE;
|
||||
DrawCircleV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, COLOR_FILLED);
|
||||
DrawCircleLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, constantThickness, colorOutline);
|
||||
|
||||
// Ellipse
|
||||
posX = shapeOffset + shapePaddingX*ORDER_ELLIPSE;
|
||||
DrawEllipseV((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, radiusY, COLOR_FILLED);
|
||||
DrawEllipseLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, radiusY, constantThickness, colorOutline);
|
||||
|
||||
// Circle Sector
|
||||
posX = shapeOffset + shapePaddingX*ORDER_CIRCLE_SECTOR;
|
||||
DrawCircleSector((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, circleStartAngle, circleEndAngle, (int)circleSegments, COLOR_FILLED);
|
||||
DrawCircleSectorLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, radiusX, circleStartAngle, circleEndAngle, (int)circleSegments, constantThickness, colorOutline);
|
||||
|
||||
// Ring
|
||||
posX = shapeOffset + shapePaddingX*ORDER_RING;
|
||||
DrawRing((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, ringInnerRadius, ringOuterRadius, circleStartAngle, circleEndAngle, (int)circleSegments, COLOR_FILLED);
|
||||
DrawRingLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, ringInnerRadius, ringOuterRadius, circleStartAngle, circleEndAngle, (int)circleSegments, constantThickness, colorOutline);
|
||||
|
||||
// Triangle
|
||||
posX = shapeOffset + shapePaddingX*ORDER_TRIANGLE;
|
||||
DrawTriangle((Vector2){ posX + triangleVertex0Offset.x, posY + triangleVertex0Offset.y },
|
||||
(Vector2){ posX + triangleVertex1Offset.x, posY + triangleVertex1Offset.y },
|
||||
(Vector2){ posX + triangleVertex2Offset.x, posY + triangleVertex2Offset.y },
|
||||
COLOR_FILLED);
|
||||
DrawTriangleLinesEx((Vector2){ posX + triangleVertex0Offset.x, posY + triangleVertex0Offset.y },
|
||||
(Vector2){ posX + triangleVertex1Offset.x, posY + triangleVertex1Offset.y },
|
||||
(Vector2){ posX + triangleVertex2Offset.x, posY + triangleVertex2Offset.y },
|
||||
constantThickness, colorOutline);
|
||||
|
||||
// Polygon
|
||||
posX = shapeOffset + shapePaddingX*ORDER_POLYGON;
|
||||
DrawPoly((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, (int)polygonSides, radiusX, 0.0f, COLOR_FILLED);
|
||||
DrawPolyLinesEx((Vector2){ posX + SHAPE_SIZE/2.0f, posY + SHAPE_SIZE/2.0f }, (int)polygonSides, radiusX, 0.0f, constantThickness, colorOutline);
|
||||
|
||||
// Group the shapes
|
||||
GuiGroupBox((Rectangle){ shapeOffset - BOX_SPACING, posY - BOX_SPACING, BOX_WIDTH, BOX_HEIGHT }, "Draw*LinesEx() with *screen space* pixel thickness");
|
||||
// ----------------------------------------
|
||||
|
||||
EndMode2D();
|
||||
|
||||
DrawRectangleRec(optionsBackground, Fade(DARKGRAY, 0.75f));
|
||||
|
||||
DrawRectangleRec((Rectangle){ optionsBackground.x, 360, optionsBackground.width, 90 }, Fade(BLACK, 0.4f));
|
||||
DrawLineEx((Vector2){ optionsBackground.x, 360 }, (Vector2){ optionsBackground.x + optionsBackground.width, 360 }, 1.0f, BLACK);
|
||||
|
||||
DrawText("Move with the mouse or WASD keys", (int)optionsBackground.x + 10, 370, 10, ORANGE);
|
||||
DrawText("Zoom with the mouse or UP and DOWN keys", (int)optionsBackground.x + 10, 390, 10, ORANGE);
|
||||
DrawText("Press C to reset position", (int)optionsBackground.x + 10, 410, 10, ORANGE);
|
||||
DrawText("Press Z to reset zoom", (int)optionsBackground.x + 10, 430, 10, ORANGE);
|
||||
|
||||
DrawLineEx((Vector2){ optionsBackground.x, optionsBackground.y }, (Vector2){ optionsBackground.x, optionsBackground.y + optionsBackground.height }, 1.0f, BLACK);
|
||||
|
||||
GuiSliderBar((Rectangle){ 605, 10, 150, 25 }, "Line Opacity" , TextFormat("%d" , (int)lineOpacity) , &lineOpacity , 0 , 255);
|
||||
GuiSliderBar((Rectangle){ 605, 45, 150, 25 }, "Thickness" , TextFormat("%.2f", lineThickness) , &lineThickness , -20.0f , 40.0f);
|
||||
GuiSliderBar((Rectangle){ 605, 80, 150, 25 }, "Rect Roundness" , TextFormat("%.2f", rectangleRoundness) , &rectangleRoundness , -1.0f , 2.0f);
|
||||
GuiSliderBar((Rectangle){ 605, 115, 150, 25 }, "Rect Segments" , TextFormat("%d" , (int)rectangleSegments), &rectangleSegments , -1 , 100);
|
||||
GuiSliderBar((Rectangle){ 605, 150, 150, 25 }, "Ellipse Radius Y", TextFormat("%.2f", ellipseRadiusY) , &ellipseRadiusY , 0.0f , 1.25f);
|
||||
GuiSliderBar((Rectangle){ 605, 185, 150, 25 }, "Start Angle" , TextFormat("%.2f", circleStartAngle) , &circleStartAngle , -360.0f, 360.0f);
|
||||
GuiSliderBar((Rectangle){ 605, 220, 150, 25 }, "End Angle" , TextFormat("%.2f", circleEndAngle) , &circleEndAngle , -360.0f, 360.0f);
|
||||
GuiSliderBar((Rectangle){ 605, 255, 150, 25 }, "Circle Segments" , TextFormat("%d" , (int)circleSegments) , &circleSegments , -1 , 100);
|
||||
GuiSliderBar((Rectangle){ 605, 290, 150, 25 }, "Ring Radius" , TextFormat("%.2f", ringInnerRadiusScale) , &ringInnerRadiusScale, -1.0f , 2.0f);
|
||||
GuiSliderBar((Rectangle){ 605, 325, 150, 25 }, "Poly Sides" , TextFormat("%d" , (int)polygonSides) , &polygonSides , -1 , 100);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
examples/shapes/shapes_outlines_testbed.png
Normal file
BIN
examples/shapes/shapes_outlines_testbed.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
242
examples/textures/textures_portal_window.c
Normal file
242
examples/textures/textures_portal_window.c
Normal file
@ -0,0 +1,242 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [textures] example - portal window
|
||||
*
|
||||
* Example demonstrates rendering a second scene to a texture and projecting it onto a
|
||||
* quad to create the illusion of a portal window looking into another place. The second
|
||||
* scene is rendered with an off-axis ("oblique frustum") projection matched to the
|
||||
* viewer's actual position relative to the window, so the illusion holds up correctly
|
||||
* as the player moves and looks around, rather than only looking right from one spot
|
||||
*
|
||||
* Example complexity rating: [★★★★] 4/4
|
||||
*
|
||||
* Example originally created with raylib 6.0, last time updated with raylib 6.0
|
||||
*
|
||||
* Example contributed by PanicTitan (@PanicTitan) and reviewed by Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2025 PanicTitan (@PanicTitan)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include "raymath.h"
|
||||
#include "rlgl.h"
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//------------------------------------------------------------------------------------
|
||||
// Begin portal mode 3D view
|
||||
static void BeginPortalMode3D(Vector3 eye, Vector3 bottomLeft, Vector3 bottomRight, Vector3 topLeft, float nearPlane, float farPlane);
|
||||
// End portal 3D mode and returns to default 2D orthographic mode
|
||||
static void EndPortalMode3D(void);
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [textures] example - portal window");
|
||||
|
||||
// Camera to navigate the "real world" (Dimension A)
|
||||
Camera3D camera = { 0 };
|
||||
camera.position = (Vector3){ 0.0f, 2.5f, 7.0f };
|
||||
camera.target = (Vector3){ 0.0f, 1.8f, 0.0f };
|
||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
||||
camera.fovy = 45.0f;
|
||||
camera.projection = CAMERA_PERSPECTIVE;
|
||||
|
||||
// The archway opening, in Dimension A world space (used both to draw the frame and
|
||||
// as the window rectangle the oblique projection is built from)
|
||||
Vector3 archBottomLeft = { -1.5f, 0.0f, 0.0f };
|
||||
Vector3 archBottomRight = { 1.5f, 0.0f, 0.0f };
|
||||
Vector3 archTopLeft = { -1.5f, 4.0f, 0.0f };
|
||||
|
||||
// The archway sits at portalA and looks out onto portalB, far away in world space.
|
||||
// Every frame, Dimension B gets rendered to a texture using the same relative eye
|
||||
// and window position, shifted by the offset between the two portals
|
||||
Vector3 portalA = { 0.0f, 0.0f, 0.0f };
|
||||
Vector3 portalB = { 0.0f, 0.0f, -60.0f };
|
||||
RenderTexture2D portalView = LoadRenderTexture(480, 640);
|
||||
|
||||
DisableCursor(); // Lock cursor for first-person free camera controls
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_FREE);
|
||||
float time = (float)GetTime();
|
||||
|
||||
// Eye and window corners, shifted into Dimension B so they match the player's
|
||||
// actual position and viewing angle relative to the archway
|
||||
Vector3 offset = Vector3Subtract(portalB, portalA);
|
||||
Vector3 eyeInB = Vector3Add(camera.position, offset);
|
||||
Vector3 blInB = Vector3Add(archBottomLeft, offset);
|
||||
Vector3 brInB = Vector3Add(archBottomRight, offset);
|
||||
Vector3 tlInB = Vector3Add(archTopLeft, offset);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
// Render Dimension B into an offscreen texture, using an oblique projection so
|
||||
// its perspective lines up with the archway exactly as the real camera sees it
|
||||
BeginTextureMode(portalView);
|
||||
|
||||
ClearBackground((Color){ 10, 5, 20, 255 });
|
||||
|
||||
BeginPortalMode3D(eyeInB, blInB, brInB, tlInB, 0.05f, 100.0f);
|
||||
|
||||
DrawGrid(30, 0.8f);
|
||||
|
||||
// Floating pulsing core sphere
|
||||
Vector3 corePos = Vector3Add(portalB, (Vector3){ 0.0f, 2.0f + sinf(time * 2.5f) * 0.4f, -4.0f });
|
||||
DrawSphere(corePos, 1.2f, PURPLE);
|
||||
DrawSphereWires(corePos, 1.25f, 16, 16, MAGENTA);
|
||||
|
||||
// Orbiting cubes
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float angle = time * 1.5f + i * (PI / 2.0f);
|
||||
Vector3 pos = Vector3Add(portalB, (Vector3){
|
||||
sinf(angle) * 2.5f,
|
||||
2.0f + cosf(time * 3.0f + i) * 0.5f,
|
||||
-4.0f + cosf(angle) * 2.5f });
|
||||
|
||||
DrawCube(pos, 0.5f, 0.5f, 0.5f, LIME);
|
||||
DrawCubeWires(pos, 0.52f, 0.52f, 0.52f, DARKGREEN);
|
||||
}
|
||||
|
||||
EndPortalMode3D();
|
||||
|
||||
EndTextureMode();
|
||||
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
BeginMode3D(camera);
|
||||
|
||||
DrawGrid(20, 1.0f);
|
||||
|
||||
// Side pillars
|
||||
DrawCube((Vector3){ -3.5f, 2.0f, 0.0f }, 0.8f, 4.0f, 0.8f, DARKGRAY);
|
||||
DrawCubeWires((Vector3){ -3.5f, 2.0f, 0.0f }, 0.8f, 4.0f, 0.8f, ORANGE);
|
||||
DrawCube((Vector3){ 3.5f, 2.0f, 0.0f }, 0.8f, 4.0f, 0.8f, DARKGRAY);
|
||||
DrawCubeWires((Vector3){ 3.5f, 2.0f, 0.0f }, 0.8f, 4.0f, 0.8f, ORANGE);
|
||||
|
||||
// Golden archway frame and solid base
|
||||
DrawCubeWires((Vector3){ 0.0f, 2.0f, 0.0f }, 3.2f, 4.2f, 0.2f, GOLD);
|
||||
DrawCube((Vector3){ 0.0f, 0.05f, 0.0f }, 3.4f, 0.1f, 0.6f, MAROON);
|
||||
|
||||
// Solid backing wall, only ever seen if looking at the archway from behind
|
||||
DrawCube((Vector3){ 0.0f, 2.0f, -0.05f }, 3.1f, 4.1f, 0.05f, MAROON);
|
||||
|
||||
// The portal opening itself: a plain quad textured with the Dimension B
|
||||
// render, filling the archway exactly, so nothing "leaks" outside its shape
|
||||
rlSetTexture(portalView.texture.id);
|
||||
rlBegin(RL_QUADS);
|
||||
rlColor4ub(255, 255, 255, 255);
|
||||
rlNormal3f(0.0f, 0.0f, 1.0f);
|
||||
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(archBottomLeft.x, archBottomLeft.y, archBottomLeft.z);
|
||||
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(archBottomRight.x, archBottomRight.y, archBottomRight.z);
|
||||
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(archBottomRight.x, 4.0f, archBottomRight.z);
|
||||
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(archTopLeft.x, archTopLeft.y, archTopLeft.z);
|
||||
rlEnd();
|
||||
rlSetTexture(0);
|
||||
|
||||
EndMode3D();
|
||||
|
||||
// HUD overlay
|
||||
DrawRectangle(15, 15, 520, 100, Fade(BLACK, 0.75f));
|
||||
DrawRectangleLines(15, 15, 520, 100, GOLD);
|
||||
DrawText("PORTAL WINDOW", 28, 25, 20, GOLD);
|
||||
DrawText("Look through the golden arch into Dimension B", 28, 52, 20, RAYWHITE);
|
||||
DrawText("Controls: Mouse to look | WASD to move", 28, 80, 20, GRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
UnloadRenderTexture(portalView);
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Starts a 3D mode using an off-axis ("oblique frustum") projection, built directly from
|
||||
// an eye point and 3 corners of a rectangular window, instead of a fovy centered straight
|
||||
// ahead of the camera. This is the standard technique for rendering a scene as seen through
|
||||
// a window that isn't necessarily faced head-on (also used for multi-monitor and VR
|
||||
// rendering) - the key difference from a normal Camera3D is that the frustum is allowed
|
||||
// to be asymmetric, so perspective lines through the window line up correctly from any
|
||||
// eye position, instead of behaving like a flat image pasted onto the window
|
||||
static void BeginPortalMode3D(Vector3 eye, Vector3 bottomLeft, Vector3 bottomRight, Vector3 topLeft, float nearPlane, float farPlane)
|
||||
{
|
||||
Vector3 right = Vector3Normalize(Vector3Subtract(bottomRight, bottomLeft));
|
||||
Vector3 up = Vector3Normalize(Vector3Subtract(topLeft, bottomLeft));
|
||||
Vector3 normal = Vector3Normalize(Vector3CrossProduct(right, up));
|
||||
|
||||
// Vectors from the eye to 3 corners of the window, used to project the window onto
|
||||
// the near plane and read off how far it extends left/right/bottom/top of the eye
|
||||
Vector3 toBL = Vector3Subtract(bottomLeft, eye);
|
||||
Vector3 toBR = Vector3Subtract(bottomRight, eye);
|
||||
Vector3 toTL = Vector3Subtract(topLeft, eye);
|
||||
|
||||
float dist = -Vector3DotProduct(toBL, normal);
|
||||
if (dist < 0.01f) dist = 0.01f; // Keep the eye from crossing the window plane
|
||||
|
||||
float scale = nearPlane/dist;
|
||||
|
||||
rlDrawRenderBatchActive();
|
||||
|
||||
rlMatrixMode(RL_PROJECTION);
|
||||
rlPushMatrix();
|
||||
rlSetMatrixProjection(MatrixFrustum(
|
||||
Vector3DotProduct(right, toBL)*scale, Vector3DotProduct(right, toBR)*scale,
|
||||
Vector3DotProduct(up, toBL)*scale, Vector3DotProduct(up, toTL)*scale,
|
||||
nearPlane, farPlane));
|
||||
|
||||
// View orientation is fixed to the window's own plane (looking straight through it
|
||||
// along its normal), NOT aimed at any target - that's what the asymmetric frustum
|
||||
// above is for, and is what lets the eye move off to one side without distorting
|
||||
rlMatrixMode(RL_MODELVIEW);
|
||||
rlLoadIdentity();
|
||||
rlMultMatrixf(MatrixToFloat(MatrixLookAt(eye, Vector3Subtract(eye, normal), up)));
|
||||
|
||||
rlEnableDepthTest();
|
||||
}
|
||||
|
||||
// End portal 3D mode and returns to default 2D orthographic mode
|
||||
// NOTE: Similar implementation to EndMode3D()
|
||||
static void EndPortalMode3D(void)
|
||||
{
|
||||
rlDrawRenderBatchActive(); // Update and draw internal render batch
|
||||
|
||||
rlMatrixMode(RL_PROJECTION); // Switch to projection matrix
|
||||
rlPopMatrix(); // Restore previous matrix (projection) from matrix stack
|
||||
|
||||
rlMatrixMode(RL_MODELVIEW); // Switch back to modelview matrix
|
||||
rlLoadIdentity(); // Reset current matrix (modelview)
|
||||
|
||||
rlDisableDepthTest(); // Disable DEPTH_TEST for 2D
|
||||
}
|
||||
BIN
examples/textures/textures_portal_window.png
Normal file
BIN
examples/textures/textures_portal_window.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@ -38,4 +38,5 @@ if (APPLE)
|
||||
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
||||
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
||||
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
||||
target_link_libraries(${PROJECT_NAME} "-framework QuartzCore")
|
||||
endif()
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
<Add option="-framework IOKit" />
|
||||
<Add option="-framework CoreAudio" />
|
||||
<Add option="-framework CoreVideo" />
|
||||
<Add option="-framework QuartzCore" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (Mac)">
|
||||
@ -44,6 +45,7 @@
|
||||
<Add option="-framework IOKit" />
|
||||
<Add option="-framework CoreAudio" />
|
||||
<Add option="-framework CoreVideo" />
|
||||
<Add option="-framework QuartzCore" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (Linux)">
|
||||
|
||||
@ -357,7 +357,7 @@
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\src\external\glfw\include</AdditionalIncludeDirectories>
|
||||
<CompileAs>CompileAsC</CompileAs>
|
||||
<DebugInformationFormat />
|
||||
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
@ -321,7 +321,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# Libraries for OSX 10.9 desktop compiling
|
||||
# NOTE: Required packages: libopenal-dev libegl1-mesa-dev
|
||||
LDLIBS = -lraylib -framework OpenGL -framework OpenAL -framework Cocoa -framework IOKit
|
||||
LDLIBS = -lraylib -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
# Libraries for FreeBSD, OpenBSD, NetBSD, DragonFly desktop compiling
|
||||
|
||||
@ -89,13 +89,13 @@ OUTPUT_DIR="builds/osx"
|
||||
COMPILATION_FLAGS="-std=c99 -O2 -flto"
|
||||
FINAL_COMPILE_FLAGS="-s"
|
||||
WARNING_FLAGS="-Wall -Wextra -Wpedantic"
|
||||
LINK_FLAGS="-flto -framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa"
|
||||
LINK_FLAGS="-flto -framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa -framework QuartzCore"
|
||||
# Debug changes to flags
|
||||
if [ -n "$BUILD_DEBUG" ]; then
|
||||
OUTPUT_DIR="builds-debug/osx"
|
||||
COMPILATION_FLAGS="-std=c99 -O0 -g"
|
||||
FINAL_COMPILE_FLAGS=""
|
||||
LINK_FLAGS="-framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa"
|
||||
LINK_FLAGS="-framework OpenGL -framework OpenAL -framework IOKit -framework CoreVideo -framework Cocoa -framework QuartzCore"
|
||||
fi
|
||||
|
||||
# Display what we're doing
|
||||
|
||||
@ -114,6 +114,20 @@ if (NOT BUILD_SHARED_LIBS)
|
||||
|
||||
if (NOT glfw3_FOUND)
|
||||
list(REMOVE_ITEM raylib_install_private_libs glfw)
|
||||
|
||||
# Bundled GLFW links its Cocoa backend frameworks privately, so they
|
||||
# must be propagated to consumers of the static library, whose final
|
||||
# link line would otherwise miss them. Only the Desktop platform uses
|
||||
# bundled GLFW; other platforms (e.g. Memory) have no Cocoa/GLFW symbols.
|
||||
if (APPLE AND PLATFORM STREQUAL "Desktop")
|
||||
find_library(COCOA_FRAMEWORK Cocoa)
|
||||
find_library(IOKIT_FRAMEWORK IOKit)
|
||||
find_library(QUARTZCORE_FRAMEWORK QuartzCore)
|
||||
list(APPEND raylib_install_private_libs
|
||||
${COCOA_FRAMEWORK}
|
||||
${IOKIT_FRAMEWORK}
|
||||
${QUARTZCORE_FRAMEWORK})
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
foreach(lib IN LISTS raylib_install_private_libs)
|
||||
|
||||
@ -655,7 +655,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
|
||||
#LDLIBS += -latomic
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo
|
||||
LDLIBS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreAudio -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
ifeq ($(PLATFORM_OS),BSD)
|
||||
LDLIBS = -lGL -lpthread
|
||||
@ -707,7 +707,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
|
||||
ifeq ($(PLATFORM_OS),OSX)
|
||||
# Libraries for Debian MacOS desktop compiling
|
||||
# NOTE: Required packages: libegl1-mesa-dev
|
||||
LDLIBS += -lm -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo
|
||||
LDLIBS += -lm -framework Foundation -framework AppKit -framework IOKit -framework OpenGL -framework CoreVideo -framework QuartzCore
|
||||
endif
|
||||
endif
|
||||
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
|
||||
|
||||
7
src/external/fix_win32_compatibility.h
vendored
7
src/external/fix_win32_compatibility.h
vendored
@ -2,7 +2,7 @@
|
||||
*
|
||||
* fix_win32_compatibility.h Utility to help include windows.h with raylib projects
|
||||
*
|
||||
* Useage: #include "fix_win32_compatibility.h" any library that uses windows.h
|
||||
* Usage: #include "fix_win32_compatibility.h" any library that uses windows.h
|
||||
* order is critical, this must be done before raylib
|
||||
*
|
||||
* LICENSE: MIT
|
||||
@ -32,7 +32,7 @@
|
||||
#pragma once
|
||||
|
||||
// move the windows functions to new names
|
||||
// note that you can't call these functions or structures from your code, but you should not neeed to
|
||||
// note that you can't call these functions or structures from your code, but you should not need to
|
||||
#define CloseWindow CloseWindowWin32
|
||||
#define Rectangle RectangleWin32
|
||||
#define ShowCursor ShowCursorWin32
|
||||
@ -46,8 +46,9 @@
|
||||
// include windows
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <playsoundapi.h>
|
||||
|
||||
// remove all our redfintions so that raylib can define them properly
|
||||
// remove all our redefinitions so that raylib can define them properly
|
||||
#undef CloseWindow
|
||||
#undef Rectangle
|
||||
#undef ShowCursor
|
||||
|
||||
8
src/external/glfw/CMake/GenerateMappings.cmake
vendored
Normal file → Executable file
8
src/external/glfw/CMake/GenerateMappings.cmake
vendored
Normal file → Executable file
@ -1,6 +1,8 @@
|
||||
# Usage:
|
||||
# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
|
||||
|
||||
cmake_policy(VERSION 3.16)
|
||||
|
||||
set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
|
||||
set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
|
||||
set(template_path "${CMAKE_ARGV3}")
|
||||
@ -22,8 +24,9 @@ if (status_code)
|
||||
endif()
|
||||
|
||||
file(STRINGS "${source_path}" lines)
|
||||
foreach(line ${lines})
|
||||
if (line MATCHES "^[0-9a-fA-F]")
|
||||
list(FILTER lines INCLUDE REGEX "^[0-9a-fA-F]")
|
||||
|
||||
foreach(line IN LISTS lines)
|
||||
if (line MATCHES "platform:Windows")
|
||||
if (GLFW_WIN32_MAPPINGS)
|
||||
string(APPEND GLFW_WIN32_MAPPINGS "\n")
|
||||
@ -40,7 +43,6 @@ foreach(line ${lines})
|
||||
endif()
|
||||
string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
|
||||
|
||||
0
src/external/glfw/CMake/Info.plist.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/Info.plist.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/cmake_uninstall.cmake.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/cmake_uninstall.cmake.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/glfw3.pc.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/glfw3.pc.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/glfw3Config.cmake.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/glfw3Config.cmake.in
vendored
Normal file → Executable file
0
src/external/glfw/CMake/i686-w64-mingw32-clang.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/i686-w64-mingw32-clang.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/i686-w64-mingw32.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/i686-w64-mingw32.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/modules/FindEpollShim.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/modules/FindEpollShim.cmake
vendored
Normal file → Executable file
18
src/external/glfw/CMake/modules/FindOSMesa.cmake
vendored
18
src/external/glfw/CMake/modules/FindOSMesa.cmake
vendored
@ -1,18 +0,0 @@
|
||||
# Try to find OSMesa on a Unix system
|
||||
#
|
||||
# This will define:
|
||||
#
|
||||
# OSMESA_LIBRARIES - Link these to use OSMesa
|
||||
# OSMESA_INCLUDE_DIR - Include directory for OSMesa
|
||||
#
|
||||
# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
|
||||
|
||||
if (NOT WIN32)
|
||||
|
||||
find_package (PkgConfig)
|
||||
pkg_check_modules (PKG_OSMESA QUIET osmesa)
|
||||
|
||||
set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS})
|
||||
set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES})
|
||||
|
||||
endif ()
|
||||
0
src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/x86_64-w64-mingw32.cmake
vendored
Normal file → Executable file
0
src/external/glfw/CMake/x86_64-w64-mingw32.cmake
vendored
Normal file → Executable file
35
src/external/glfw/CMakeLists.txt
vendored
Normal file → Executable file
35
src/external/glfw/CMakeLists.txt
vendored
Normal file → Executable file
@ -1,14 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR)
|
||||
cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR)
|
||||
|
||||
project(GLFW VERSION 3.4.0 LANGUAGES C)
|
||||
|
||||
if (POLICY CMP0069)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
|
||||
if (POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
project(GLFW VERSION 3.5.1 LANGUAGES C HOMEPAGE_URL "https://www.glfw.org/")
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
@ -46,11 +38,7 @@ set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING
|
||||
"Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)")
|
||||
|
||||
if (GLFW_LIBRARY_TYPE)
|
||||
if (GLFW_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
set(GLFW_BUILD_SHARED_LIBRARY TRUE)
|
||||
else()
|
||||
set(GLFW_BUILD_SHARED_LIBRARY FALSE)
|
||||
endif()
|
||||
string(COMPARE EQUAL "${GLFW_LIBRARY_TYPE}" "SHARED" GLFW_BUILD_SHARED_LIBRARY)
|
||||
else()
|
||||
set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS})
|
||||
endif()
|
||||
@ -80,24 +68,7 @@ endif()
|
||||
# This is here because it also applies to tests and examples
|
||||
#--------------------------------------------------------------------
|
||||
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.15)
|
||||
foreach (flag CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
|
||||
if (flag MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
if (flag MATCHES "/MDd")
|
||||
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
else()
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
23
src/external/glfw/CONTRIBUTORS.md
vendored
Normal file → Executable file
23
src/external/glfw/CONTRIBUTORS.md
vendored
Normal file → Executable file
@ -6,10 +6,12 @@ excludes other invaluable contributions like language bindings and text and
|
||||
video tutorials.
|
||||
|
||||
- Bobyshev Alexander
|
||||
- Alzathar
|
||||
- Laurent Aphecetche
|
||||
- Matt Arsenault
|
||||
- Takuro Ashie
|
||||
- ashishgamedev
|
||||
- avagordon01
|
||||
- David Avedissian
|
||||
- Luca Bacci
|
||||
- Keith Bauer
|
||||
@ -23,6 +25,7 @@ video tutorials.
|
||||
- Denis Bernard
|
||||
- BiBi
|
||||
- Doug Binks
|
||||
- bitb4ker
|
||||
- blanco
|
||||
- Waris Boonyasiriwat
|
||||
- Kyle Brenneman
|
||||
@ -33,6 +36,7 @@ video tutorials.
|
||||
- Nicolas Caramelli
|
||||
- David Carlier
|
||||
- Arturo Castro
|
||||
- Jose Luis Cercós Pita
|
||||
- Chi-kwan Chan
|
||||
- Victor Chernyakin
|
||||
- TheChocolateOre
|
||||
@ -48,11 +52,15 @@ video tutorials.
|
||||
- Andrew Corrigan
|
||||
- Bailey Cosier
|
||||
- Noel Cower
|
||||
- James Cowgill
|
||||
- CuriouserThing
|
||||
- Bill Currie
|
||||
- Jason Daly
|
||||
- danhambleton
|
||||
- danijel1023
|
||||
- Jarrod Davis
|
||||
- Aaron Day
|
||||
- decce
|
||||
- Olivier Delannoy
|
||||
- Paul R. Deppe
|
||||
- Michael Dickens
|
||||
@ -65,14 +73,18 @@ video tutorials.
|
||||
- Robin Eklind
|
||||
- Jan Ekström
|
||||
- Siavash Eliasi
|
||||
- er-azh
|
||||
- Jan Hendrik Farr
|
||||
- Ahmad Fatoum
|
||||
- Nikita Fediuchin
|
||||
- Felipe Ferreira
|
||||
- Michael Fogleman
|
||||
- Folling
|
||||
- forworldm
|
||||
- Jason Francis
|
||||
- Gerald Franz
|
||||
- Mário Freitas
|
||||
- Friz64
|
||||
- GeO4d
|
||||
- Marcus Geelnard
|
||||
- Gegy
|
||||
@ -88,6 +100,7 @@ video tutorials.
|
||||
- Andrew Gutekanst
|
||||
- Stephen Gutekanst
|
||||
- Jonathan Hale
|
||||
- halx99
|
||||
- Daniel Hauser
|
||||
- hdf89shfdfs
|
||||
- Moritz Heinemann
|
||||
@ -118,6 +131,7 @@ video tutorials.
|
||||
- Josh Kilmer
|
||||
- Byunghoon Kim
|
||||
- Cameron King
|
||||
- knokko
|
||||
- Peter Knut
|
||||
- Christoph Kubisch
|
||||
- Yuri Kunde Schlesner
|
||||
@ -153,8 +167,10 @@ video tutorials.
|
||||
- Bryce Mehring
|
||||
- Jonathan Mercier
|
||||
- Marcel Metz
|
||||
- Lucas Michaudel
|
||||
- Liam Middlebrook
|
||||
- mightgoyardstill
|
||||
- Mihail
|
||||
- Ave Milia
|
||||
- Icyllis Milica
|
||||
- Jonathan Miller
|
||||
@ -168,6 +184,7 @@ video tutorials.
|
||||
- Jon Morton
|
||||
- Pierre Moulon
|
||||
- Martins Mozeiko
|
||||
- Tomáš Mráz
|
||||
- Pascal Muetschard
|
||||
- James Murphy
|
||||
- Julian Møller
|
||||
@ -214,6 +231,7 @@ video tutorials.
|
||||
- Philip Rideout
|
||||
- Eddie Ringle
|
||||
- Max Risuhin
|
||||
- road2react
|
||||
- Joe Roback
|
||||
- Jorge Rodriguez
|
||||
- Jari Ronkainen
|
||||
@ -221,12 +239,13 @@ video tutorials.
|
||||
- Ed Ropple
|
||||
- Aleksey Rybalkin
|
||||
- Mikko Rytkönen
|
||||
- saikyun
|
||||
- Riku Salminen
|
||||
- Yoshinori Sano
|
||||
- Brandon Schaefer
|
||||
- Sebastian Schuberth
|
||||
- Scr3amer
|
||||
- Jan Schuerkamp
|
||||
- Jan Schürkamp
|
||||
- Christian Sdunek
|
||||
- Matt Sealey
|
||||
- Steve Sexton
|
||||
@ -275,10 +294,12 @@ video tutorials.
|
||||
- Corentin Wallez
|
||||
- Torsten Walluhn
|
||||
- Patrick Walton
|
||||
- Ivor Wanders
|
||||
- Jim Wang
|
||||
- Xo Wang
|
||||
- Andre Weissflog
|
||||
- Jay Weisskopf
|
||||
- Drew Weymouth
|
||||
- Frank Wille
|
||||
- Andy Williams
|
||||
- Joel Winarske
|
||||
|
||||
0
src/external/glfw/LICENSE.md
vendored
Normal file → Executable file
0
src/external/glfw/LICENSE.md
vendored
Normal file → Executable file
208
src/external/glfw/README.md
vendored
Normal file → Executable file
208
src/external/glfw/README.md
vendored
Normal file → Executable file
@ -1,18 +1,198 @@
|
||||
# GLFW (modified for raylib)
|
||||
# GLFW
|
||||
|
||||
This directory contains a modification of GLFW, whose official website and
|
||||
upstream repository are https://glfw.org and https://github.com/glfw/glfw,
|
||||
respectively.
|
||||
[](https://github.com/glfw/glfw/actions)
|
||||
[](https://ci.appveyor.com/project/elmindreda/glfw)
|
||||
|
||||
In this modification, some static functions sharing the same name in different
|
||||
platforms have been renamed so all of GLFW's source files can be combined into
|
||||
one (as done by ``rglfw.c``). Also, the Null platform, which is not used by
|
||||
raylib, has been disabled. The renamed functions are:
|
||||
## Introduction
|
||||
|
||||
``
|
||||
createKeyTables()
|
||||
translateKey()
|
||||
acquireMonitor()
|
||||
releaseMonitor()
|
||||
``
|
||||
GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan
|
||||
application development. It provides a simple, platform-independent API for
|
||||
creating windows, contexts and surfaces, reading input, handling events, etc.
|
||||
|
||||
GLFW is written primarily in C99, with parts of macOS support being written in
|
||||
Objective-C.
|
||||
|
||||
GLFW supports Windows, macOS and Linux, and also works on many other Unix-like
|
||||
systems. On Linux both Wayland and X11 are supported.
|
||||
|
||||
GLFW is licensed under the [zlib/libpng
|
||||
license](https://www.glfw.org/license.html).
|
||||
|
||||
You can [download](https://www.glfw.org/download.html) the latest stable release
|
||||
as source or Windows and macOS binaries. There are [release
|
||||
tags](https://github.com/glfw/glfw/releases) with source and binary archives
|
||||
attached for every version since 3.0.
|
||||
|
||||
The [documentation](https://www.glfw.org/docs/latest/) is available online and is
|
||||
also included in source and binary archives, except those generated
|
||||
automatically by Github. The documentation contains guides, a tutorial and the
|
||||
API reference. The [release
|
||||
notes](https://www.glfw.org/docs/latest/news.html) list the new features,
|
||||
caveats and deprecations in the latest release. The [version
|
||||
history](https://www.glfw.org/changelog.html) lists every user-visible change
|
||||
for every release.
|
||||
|
||||
GLFW exists because of the contributions of [many people](CONTRIBUTORS.md)
|
||||
around the world, whether by reporting bugs, providing community support, adding
|
||||
features, reviewing or testing code, debugging, proofreading docs, suggesting
|
||||
features or fixing bugs.
|
||||
|
||||
|
||||
## System requirements
|
||||
|
||||
GLFW supports Windows 7 and later and macOS 10.11 and later. On GNOME Wayland,
|
||||
window decorations will be very basic unless the
|
||||
[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor) package is
|
||||
installed. Linux and other Unix-like systems running X11 are supported even
|
||||
without a desktop environment or modern extensions, although some features
|
||||
require a clipboard manager or a modern window manager.
|
||||
|
||||
See the [compatibility guide](https://www.glfw.org/docs/latest/compat.html)
|
||||
for more detailed information.
|
||||
|
||||
|
||||
## Compiling GLFW
|
||||
|
||||
GLFW supports compilation with Visual C++ (2013 and later), GCC and Clang. Both
|
||||
Clang-CL and MinGW-w64 are supported. Other C99 compilers will likely also
|
||||
work, but this is not regularly tested.
|
||||
|
||||
There are [pre-compiled binaries](https://www.glfw.org/download.html)
|
||||
available for Windows and macOS.
|
||||
|
||||
GLFW itself needs only CMake and the headers and libraries for your operating
|
||||
system and window system. No other SDKs are required.
|
||||
|
||||
See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for
|
||||
more information about compiling GLFW and the exact dependencies required for
|
||||
each window system.
|
||||
|
||||
The examples and test programs depend on a number of tiny libraries. These are
|
||||
bundled in the `deps/` directory. The repository has no submodules.
|
||||
|
||||
- [getopt\_port](https://github.com/kimgr/getopt_port/) for examples
|
||||
with command-line options
|
||||
- [TinyCThread](https://github.com/tinycthread/tinycthread) for threaded
|
||||
examples
|
||||
- [glad2](https://github.com/Dav1dde/glad) for loading OpenGL and Vulkan
|
||||
functions
|
||||
- [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
|
||||
examples
|
||||
- [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI
|
||||
- [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
|
||||
|
||||
The documentation is generated with [Doxygen](https://doxygen.org/) when the
|
||||
library is built, provided CMake could find a sufficiently new version of it
|
||||
during configuration.
|
||||
|
||||
|
||||
## Using GLFW
|
||||
|
||||
See the [HTML documentation](https://www.glfw.org/docs/latest/) for a tutorial,
|
||||
guides and the API reference.
|
||||
|
||||
|
||||
## Contributing to GLFW
|
||||
|
||||
See the [contribution
|
||||
guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
|
||||
more information.
|
||||
|
||||
The `master` branch is the stable integration branch and _should_ always compile
|
||||
and run on all supported platforms. Details of a newly added feature,
|
||||
including the public API, may change until it has been included in a release.
|
||||
|
||||
The `latest` branch is equivalent to the [highest numbered](https://semver.org/)
|
||||
release, although it may not always point to the same commit as the tag for that
|
||||
release.
|
||||
|
||||
The `ci` branch is used to trigger continuous integration jobs for code under
|
||||
testing and should never be relied on for any purpose.
|
||||
|
||||
|
||||
## Reporting bugs
|
||||
|
||||
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
|
||||
Please check the [contribution
|
||||
guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
|
||||
information on what to include when reporting a bug.
|
||||
|
||||
|
||||
## Changelog since 3.5
|
||||
|
||||
None.
|
||||
|
||||
## Changelog since 3.4
|
||||
|
||||
- Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond
|
||||
the limit of the mouse button tokens to be reported (#2423)
|
||||
- Added `glfwGetEGLConfig` function to query the `EGLConfig` of a window (#2045)
|
||||
- Added `glfwGetGLXFBConfig` function to query the `GLXFBConfig` of a window (#1925)
|
||||
- Updated minimum CMake version to 3.16 (#2541)
|
||||
- Removed support for building with original MinGW (#2540)
|
||||
- [Win32] Removed support for Windows XP and Vista (#2505)
|
||||
- [Win32] Bugfix: Media keys were reported with a scancode of 256 (#1768,#2417,#2625)
|
||||
- [Cocoa] Added `QuartzCore` framework as link-time dependency
|
||||
- [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506)
|
||||
- [Cocoa] Bugfix: Cmd+Period, Ctrl+Tab and Ctrl+Esc key events were not emitted
|
||||
(#1362,#2278)
|
||||
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed
|
||||
- [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517)
|
||||
- [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault
|
||||
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
|
||||
- [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727)
|
||||
- [Wayland] Bugfix: Memory would leak if reading a data offer failed midway
|
||||
- [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over
|
||||
fallback decorations
|
||||
- [Wayland] Bugfix: Fallback decorations would report scroll events
|
||||
- [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568)
|
||||
- [Wayland] Bugfix: Fallback decorations would show menu at wrong position
|
||||
- [Wayland] Bugfix: The cursor was not updated when clicking through from
|
||||
a modal to a fallback decoration
|
||||
- [Wayland] Bugfix: The cursor position was not updated when clicking through
|
||||
from a modal to the content area
|
||||
- [Wayland] Bugfix: free modules at end of terminate function to resolve
|
||||
potential segmentation fault (#2744)
|
||||
- [Wayland] Bugfix: Confining or disabling the cursor could segfault on
|
||||
compositors without `pointer-constraints-unstable-v1`
|
||||
- [Wayland] Bugfix: Key repeat did not function on very old compositors
|
||||
- [Wayland] Bugfix: The `libwayland-client` library was not unloaded at termination
|
||||
- [Wayland] Bugfix: Scroll events were sent twice on some versions of GNOME (#2494)
|
||||
- [Wayland] Bugfix: Two-dimensional scroll input was emitted as separate axes
|
||||
- [Wayland] Bugfix: Mouse wheel scroll distance was incorrect on some compositors
|
||||
- [Wayland] Bugfix: `glfwSwapBuffers` would halt with nonzero swap interval when window
|
||||
was suspended (#1350,#2582,#2640,#2719,#2723,#2800,#2827)
|
||||
- [Wayland] Bugfix: `glfwPostEmptyEvent` would leak a callback proxy (#2836)
|
||||
- [Wayland] Bugfix: `glfwHideWindow` did not always send its request immediately
|
||||
- [Wayland] Bugfix: Some event types were not always processed by `glfwPollEvents` or
|
||||
`glfwWait*Events` (#2793,#2795)
|
||||
- [Wayland] Bugfix: Scaled framebuffer size was sometimes incorect (#2713,#2810)
|
||||
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
|
||||
- [X11] Bugfix: Occasional crash when an idle display awakes (#2766)
|
||||
- [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale
|
||||
less than 1 (#2754)
|
||||
- [X11] Bugfix: Clamp width and height to >= 1 to prevent BadValue error and app exit
|
||||
- [X11] Bugfix: Floating windows silently became non-floating when hidden (#2276)
|
||||
- [X11] Bugfix: The `libXext` library was not unloaded at termination
|
||||
- [Linux] Bugfix: The header for `ioctl` was only implicitly included (#2778)
|
||||
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
|
||||
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
|
||||
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
|
||||
`GLFW_NATIVE_CONTEXT_API` (#2518)
|
||||
|
||||
|
||||
## Contact
|
||||
|
||||
On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
|
||||
well as news, documentation and other information about the project.
|
||||
|
||||
If you have questions related to the use of GLFW, we have a
|
||||
[forum](https://discourse.glfw.org/).
|
||||
|
||||
If you have a bug to report, a patch to submit or a feature you'd like to
|
||||
request, please file it in the
|
||||
[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
|
||||
|
||||
Finally, if you're interested in helping out with the development of GLFW or
|
||||
porting it to your favorite platform, join us on the forum or GitHub.
|
||||
|
||||
|
||||
230
src/external/glfw/deps/getopt.c
vendored
230
src/external/glfw/deps/getopt.c
vendored
@ -1,230 +0,0 @@
|
||||
/* Copyright (c) 2012, Kim Gräsman
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Kim Gräsman nor the names of contributors may be used
|
||||
* to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
const int no_argument = 0;
|
||||
const int required_argument = 1;
|
||||
const int optional_argument = 2;
|
||||
|
||||
char* optarg;
|
||||
int optopt;
|
||||
/* The variable optind [...] shall be initialized to 1 by the system. */
|
||||
int optind = 1;
|
||||
int opterr;
|
||||
|
||||
static char* optcursor = NULL;
|
||||
|
||||
/* Implemented based on [1] and [2] for optional arguments.
|
||||
optopt is handled FreeBSD-style, per [3].
|
||||
Other GNU and FreeBSD extensions are purely accidental.
|
||||
|
||||
[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
|
||||
[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
|
||||
[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
|
||||
*/
|
||||
int getopt(int argc, char* const argv[], const char* optstring) {
|
||||
int optchar = -1;
|
||||
const char* optdecl = NULL;
|
||||
|
||||
optarg = NULL;
|
||||
opterr = 0;
|
||||
optopt = 0;
|
||||
|
||||
/* Unspecified, but we need it to avoid overrunning the argv bounds. */
|
||||
if (optind >= argc)
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called argv[optind] is a null pointer, getopt()
|
||||
shall return -1 without changing optind. */
|
||||
if (argv[optind] == NULL)
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called *argv[optind] is not the character '-',
|
||||
getopt() shall return -1 without changing optind. */
|
||||
if (*argv[optind] != '-')
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called argv[optind] points to the string "-",
|
||||
getopt() shall return -1 without changing optind. */
|
||||
if (strcmp(argv[optind], "-") == 0)
|
||||
goto no_more_optchars;
|
||||
|
||||
/* If, when getopt() is called argv[optind] points to the string "--",
|
||||
getopt() shall return -1 after incrementing optind. */
|
||||
if (strcmp(argv[optind], "--") == 0) {
|
||||
++optind;
|
||||
goto no_more_optchars;
|
||||
}
|
||||
|
||||
if (optcursor == NULL || *optcursor == '\0')
|
||||
optcursor = argv[optind] + 1;
|
||||
|
||||
optchar = *optcursor;
|
||||
|
||||
/* FreeBSD: The variable optopt saves the last known option character
|
||||
returned by getopt(). */
|
||||
optopt = optchar;
|
||||
|
||||
/* The getopt() function shall return the next option character (if one is
|
||||
found) from argv that matches a character in optstring, if there is
|
||||
one that matches. */
|
||||
optdecl = strchr(optstring, optchar);
|
||||
if (optdecl) {
|
||||
/* [I]f a character is followed by a colon, the option takes an
|
||||
argument. */
|
||||
if (optdecl[1] == ':') {
|
||||
optarg = ++optcursor;
|
||||
if (*optarg == '\0') {
|
||||
/* GNU extension: Two colons mean an option takes an
|
||||
optional arg; if there is text in the current argv-element
|
||||
(i.e., in the same word as the option name itself, for example,
|
||||
"-oarg"), then it is returned in optarg, otherwise optarg is set
|
||||
to zero. */
|
||||
if (optdecl[2] != ':') {
|
||||
/* If the option was the last character in the string pointed to by
|
||||
an element of argv, then optarg shall contain the next element
|
||||
of argv, and optind shall be incremented by 2. If the resulting
|
||||
value of optind is greater than argc, this indicates a missing
|
||||
option-argument, and getopt() shall return an error indication.
|
||||
|
||||
Otherwise, optarg shall point to the string following the
|
||||
option character in that element of argv, and optind shall be
|
||||
incremented by 1.
|
||||
*/
|
||||
if (++optind < argc) {
|
||||
optarg = argv[optind];
|
||||
} else {
|
||||
/* If it detects a missing option-argument, it shall return the
|
||||
colon character ( ':' ) if the first character of optstring
|
||||
was a colon, or a question-mark character ( '?' ) otherwise.
|
||||
*/
|
||||
optarg = NULL;
|
||||
optchar = (optstring[0] == ':') ? ':' : '?';
|
||||
}
|
||||
} else {
|
||||
optarg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
optcursor = NULL;
|
||||
}
|
||||
} else {
|
||||
/* If getopt() encounters an option character that is not contained in
|
||||
optstring, it shall return the question-mark ( '?' ) character. */
|
||||
optchar = '?';
|
||||
}
|
||||
|
||||
if (optcursor == NULL || *++optcursor == '\0')
|
||||
++optind;
|
||||
|
||||
return optchar;
|
||||
|
||||
no_more_optchars:
|
||||
optcursor = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Implementation based on [1].
|
||||
|
||||
[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
|
||||
*/
|
||||
int getopt_long(int argc, char* const argv[], const char* optstring,
|
||||
const struct option* longopts, int* longindex) {
|
||||
const struct option* o = longopts;
|
||||
const struct option* match = NULL;
|
||||
int num_matches = 0;
|
||||
size_t argument_name_length = 0;
|
||||
const char* current_argument = NULL;
|
||||
int retval = -1;
|
||||
|
||||
optarg = NULL;
|
||||
optopt = 0;
|
||||
|
||||
if (optind >= argc)
|
||||
return -1;
|
||||
|
||||
if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0)
|
||||
return getopt(argc, argv, optstring);
|
||||
|
||||
/* It's an option; starts with -- and is longer than two chars. */
|
||||
current_argument = argv[optind] + 2;
|
||||
argument_name_length = strcspn(current_argument, "=");
|
||||
for (; o->name; ++o) {
|
||||
if (strncmp(o->name, current_argument, argument_name_length) == 0) {
|
||||
match = o;
|
||||
++num_matches;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_matches == 1) {
|
||||
/* If longindex is not NULL, it points to a variable which is set to the
|
||||
index of the long option relative to longopts. */
|
||||
if (longindex)
|
||||
*longindex = (int) (match - longopts);
|
||||
|
||||
/* If flag is NULL, then getopt_long() shall return val.
|
||||
Otherwise, getopt_long() returns 0, and flag shall point to a variable
|
||||
which shall be set to val if the option is found, but left unchanged if
|
||||
the option is not found. */
|
||||
if (match->flag)
|
||||
*(match->flag) = match->val;
|
||||
|
||||
retval = match->flag ? 0 : match->val;
|
||||
|
||||
if (match->has_arg != no_argument) {
|
||||
optarg = strchr(argv[optind], '=');
|
||||
if (optarg != NULL)
|
||||
++optarg;
|
||||
|
||||
if (match->has_arg == required_argument) {
|
||||
/* Only scan the next argv for required arguments. Behavior is not
|
||||
specified, but has been observed with Ubuntu and Mac OSX. */
|
||||
if (optarg == NULL && ++optind < argc) {
|
||||
optarg = argv[optind];
|
||||
}
|
||||
|
||||
if (optarg == NULL)
|
||||
retval = ':';
|
||||
}
|
||||
} else if (strchr(argv[optind], '=')) {
|
||||
/* An argument was provided to a non-argument option.
|
||||
I haven't seen this specified explicitly, but both GNU and BSD-based
|
||||
implementations show this behavior.
|
||||
*/
|
||||
retval = '?';
|
||||
}
|
||||
} else {
|
||||
/* Unknown option or ambiguous match. */
|
||||
retval = '?';
|
||||
}
|
||||
|
||||
++optind;
|
||||
return retval;
|
||||
}
|
||||
57
src/external/glfw/deps/getopt.h
vendored
57
src/external/glfw/deps/getopt.h
vendored
@ -1,57 +0,0 @@
|
||||
/* Copyright (c) 2012, Kim Gräsman
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Kim Gräsman nor the names of contributors may be used
|
||||
* to endorse or promote products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_GETOPT_PORT_H
|
||||
#define INCLUDED_GETOPT_PORT_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const int no_argument;
|
||||
extern const int required_argument;
|
||||
extern const int optional_argument;
|
||||
|
||||
extern char* optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
struct option {
|
||||
const char* name;
|
||||
int has_arg;
|
||||
int* flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
int getopt(int argc, char* const argv[], const char* optstring);
|
||||
|
||||
int getopt_long(int argc, char* const argv[],
|
||||
const char* optstring, const struct option* longopts, int* longindex);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // INCLUDED_GETOPT_PORT_H
|
||||
5996
src/external/glfw/deps/glad/gl.h
vendored
5996
src/external/glfw/deps/glad/gl.h
vendored
File diff suppressed because it is too large
Load Diff
1805
src/external/glfw/deps/glad/gles2.h
vendored
1805
src/external/glfw/deps/glad/gles2.h
vendored
File diff suppressed because it is too large
Load Diff
6330
src/external/glfw/deps/glad/vulkan.h
vendored
6330
src/external/glfw/deps/glad/vulkan.h
vendored
File diff suppressed because it is too large
Load Diff
117
src/external/glfw/deps/mingw/_mingw_dxhelper.h
vendored
117
src/external/glfw/deps/mingw/_mingw_dxhelper.h
vendored
@ -1,117 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
|
||||
#define NONAMELESSUNION 1
|
||||
#endif
|
||||
#if defined(NONAMELESSSTRUCT) && \
|
||||
!defined(NONAMELESSUNION)
|
||||
#define NONAMELESSUNION 1
|
||||
#endif
|
||||
#if defined(NONAMELESSUNION) && \
|
||||
!defined(NONAMELESSSTRUCT)
|
||||
#define NONAMELESSSTRUCT 1
|
||||
#endif
|
||||
#if !defined(__GNU_EXTENSION)
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#define __GNU_EXTENSION __extension__
|
||||
#else
|
||||
#define __GNU_EXTENSION
|
||||
#endif
|
||||
#endif /* __extension__ */
|
||||
|
||||
#ifndef __ANONYMOUS_DEFINED
|
||||
#define __ANONYMOUS_DEFINED
|
||||
#if defined(__GNUC__) || defined(__GNUG__)
|
||||
#define _ANONYMOUS_UNION __extension__
|
||||
#define _ANONYMOUS_STRUCT __extension__
|
||||
#else
|
||||
#define _ANONYMOUS_UNION
|
||||
#define _ANONYMOUS_STRUCT
|
||||
#endif
|
||||
#ifndef NONAMELESSUNION
|
||||
#define _UNION_NAME(x)
|
||||
#define _STRUCT_NAME(x)
|
||||
#else /* NONAMELESSUNION */
|
||||
#define _UNION_NAME(x) x
|
||||
#define _STRUCT_NAME(x) x
|
||||
#endif
|
||||
#endif /* __ANONYMOUS_DEFINED */
|
||||
|
||||
#ifndef DUMMYUNIONNAME
|
||||
# ifdef NONAMELESSUNION
|
||||
# define DUMMYUNIONNAME u
|
||||
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
|
||||
# define DUMMYUNIONNAME2 u2
|
||||
# define DUMMYUNIONNAME3 u3
|
||||
# define DUMMYUNIONNAME4 u4
|
||||
# define DUMMYUNIONNAME5 u5
|
||||
# define DUMMYUNIONNAME6 u6
|
||||
# define DUMMYUNIONNAME7 u7
|
||||
# define DUMMYUNIONNAME8 u8
|
||||
# define DUMMYUNIONNAME9 u9
|
||||
# else /* NONAMELESSUNION */
|
||||
# define DUMMYUNIONNAME
|
||||
# define DUMMYUNIONNAME1 /* Wine uses this variant */
|
||||
# define DUMMYUNIONNAME2
|
||||
# define DUMMYUNIONNAME3
|
||||
# define DUMMYUNIONNAME4
|
||||
# define DUMMYUNIONNAME5
|
||||
# define DUMMYUNIONNAME6
|
||||
# define DUMMYUNIONNAME7
|
||||
# define DUMMYUNIONNAME8
|
||||
# define DUMMYUNIONNAME9
|
||||
# endif
|
||||
#endif /* DUMMYUNIONNAME */
|
||||
|
||||
#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */
|
||||
# ifdef NONAMELESSUNION
|
||||
# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */
|
||||
# else
|
||||
# define DUMMYUNIONNAME1 /* Wine uses this variant */
|
||||
# endif
|
||||
#endif /* DUMMYUNIONNAME1 */
|
||||
|
||||
#ifndef DUMMYSTRUCTNAME
|
||||
# ifdef NONAMELESSUNION
|
||||
# define DUMMYSTRUCTNAME s
|
||||
# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */
|
||||
# define DUMMYSTRUCTNAME2 s2
|
||||
# define DUMMYSTRUCTNAME3 s3
|
||||
# define DUMMYSTRUCTNAME4 s4
|
||||
# define DUMMYSTRUCTNAME5 s5
|
||||
# else
|
||||
# define DUMMYSTRUCTNAME
|
||||
# define DUMMYSTRUCTNAME1 /* Wine uses this variant */
|
||||
# define DUMMYSTRUCTNAME2
|
||||
# define DUMMYSTRUCTNAME3
|
||||
# define DUMMYSTRUCTNAME4
|
||||
# define DUMMYSTRUCTNAME5
|
||||
# endif
|
||||
#endif /* DUMMYSTRUCTNAME */
|
||||
|
||||
/* These are for compatibility with the Wine source tree */
|
||||
|
||||
#ifndef WINELIB_NAME_AW
|
||||
# ifdef __MINGW_NAME_AW
|
||||
# define WINELIB_NAME_AW __MINGW_NAME_AW
|
||||
# else
|
||||
# ifdef UNICODE
|
||||
# define WINELIB_NAME_AW(func) func##W
|
||||
# else
|
||||
# define WINELIB_NAME_AW(func) func##A
|
||||
# endif
|
||||
# endif
|
||||
#endif /* WINELIB_NAME_AW */
|
||||
|
||||
#ifndef DECL_WINELIB_TYPE_AW
|
||||
# ifdef __MINGW_TYPEDEF_AW
|
||||
# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW
|
||||
# else
|
||||
# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
|
||||
# endif
|
||||
#endif /* DECL_WINELIB_TYPE_AW */
|
||||
|
||||
2467
src/external/glfw/deps/mingw/dinput.h
vendored
2467
src/external/glfw/deps/mingw/dinput.h
vendored
File diff suppressed because it is too large
Load Diff
239
src/external/glfw/deps/mingw/xinput.h
vendored
239
src/external/glfw/deps/mingw/xinput.h
vendored
@ -1,239 +0,0 @@
|
||||
/*
|
||||
* The Wine project - Xinput Joystick Library
|
||||
* Copyright 2008 Andrew Fenn
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_XINPUT_H
|
||||
#define __WINE_XINPUT_H
|
||||
|
||||
#include <windef.h>
|
||||
|
||||
/*
|
||||
* Bitmasks for the joysticks buttons, determines what has
|
||||
* been pressed on the joystick, these need to be mapped
|
||||
* to whatever device you're using instead of an xbox 360
|
||||
* joystick
|
||||
*/
|
||||
|
||||
#define XINPUT_GAMEPAD_DPAD_UP 0x0001
|
||||
#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
|
||||
#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
|
||||
#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
|
||||
#define XINPUT_GAMEPAD_START 0x0010
|
||||
#define XINPUT_GAMEPAD_BACK 0x0020
|
||||
#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
|
||||
#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
|
||||
#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
|
||||
#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
|
||||
#define XINPUT_GAMEPAD_A 0x1000
|
||||
#define XINPUT_GAMEPAD_B 0x2000
|
||||
#define XINPUT_GAMEPAD_X 0x4000
|
||||
#define XINPUT_GAMEPAD_Y 0x8000
|
||||
|
||||
/*
|
||||
* Defines the flags used to determine if the user is pushing
|
||||
* down on a button, not holding a button, etc
|
||||
*/
|
||||
|
||||
#define XINPUT_KEYSTROKE_KEYDOWN 0x0001
|
||||
#define XINPUT_KEYSTROKE_KEYUP 0x0002
|
||||
#define XINPUT_KEYSTROKE_REPEAT 0x0004
|
||||
|
||||
/*
|
||||
* Defines the codes which are returned by XInputGetKeystroke
|
||||
*/
|
||||
|
||||
#define VK_PAD_A 0x5800
|
||||
#define VK_PAD_B 0x5801
|
||||
#define VK_PAD_X 0x5802
|
||||
#define VK_PAD_Y 0x5803
|
||||
#define VK_PAD_RSHOULDER 0x5804
|
||||
#define VK_PAD_LSHOULDER 0x5805
|
||||
#define VK_PAD_LTRIGGER 0x5806
|
||||
#define VK_PAD_RTRIGGER 0x5807
|
||||
#define VK_PAD_DPAD_UP 0x5810
|
||||
#define VK_PAD_DPAD_DOWN 0x5811
|
||||
#define VK_PAD_DPAD_LEFT 0x5812
|
||||
#define VK_PAD_DPAD_RIGHT 0x5813
|
||||
#define VK_PAD_START 0x5814
|
||||
#define VK_PAD_BACK 0x5815
|
||||
#define VK_PAD_LTHUMB_PRESS 0x5816
|
||||
#define VK_PAD_RTHUMB_PRESS 0x5817
|
||||
#define VK_PAD_LTHUMB_UP 0x5820
|
||||
#define VK_PAD_LTHUMB_DOWN 0x5821
|
||||
#define VK_PAD_LTHUMB_RIGHT 0x5822
|
||||
#define VK_PAD_LTHUMB_LEFT 0x5823
|
||||
#define VK_PAD_LTHUMB_UPLEFT 0x5824
|
||||
#define VK_PAD_LTHUMB_UPRIGHT 0x5825
|
||||
#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
|
||||
#define VK_PAD_LTHUMB_DOWNLEFT 0x5827
|
||||
#define VK_PAD_RTHUMB_UP 0x5830
|
||||
#define VK_PAD_RTHUMB_DOWN 0x5831
|
||||
#define VK_PAD_RTHUMB_RIGHT 0x5832
|
||||
#define VK_PAD_RTHUMB_LEFT 0x5833
|
||||
#define VK_PAD_RTHUMB_UPLEFT 0x5834
|
||||
#define VK_PAD_RTHUMB_UPRIGHT 0x5835
|
||||
#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
|
||||
#define VK_PAD_RTHUMB_DOWNLEFT 0x5837
|
||||
|
||||
/*
|
||||
* Deadzones are for analogue joystick controls on the joypad
|
||||
* which determine when input should be assumed to be in the
|
||||
* middle of the pad. This is a threshold to stop a joypad
|
||||
* controlling the game when the player isn't touching the
|
||||
* controls.
|
||||
*/
|
||||
|
||||
#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
|
||||
#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
|
||||
#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
|
||||
|
||||
|
||||
/*
|
||||
* Defines what type of abilities the type of joystick has
|
||||
* DEVTYPE_GAMEPAD is available for all joysticks, however
|
||||
* there may be more specific identifiers for other joysticks
|
||||
* which are being used.
|
||||
*/
|
||||
|
||||
#define XINPUT_DEVTYPE_GAMEPAD 0x01
|
||||
#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
|
||||
#define XINPUT_DEVSUBTYPE_WHEEL 0x02
|
||||
#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
|
||||
#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
|
||||
#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
|
||||
#define XINPUT_DEVSUBTYPE_GUITAR 0x06
|
||||
#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
|
||||
|
||||
/*
|
||||
* These are used with the XInputGetCapabilities function to
|
||||
* determine the abilities to the joystick which has been
|
||||
* plugged in.
|
||||
*/
|
||||
|
||||
#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
|
||||
#define XINPUT_FLAG_GAMEPAD 0x00000001
|
||||
|
||||
/*
|
||||
* Defines the status of the battery if one is used in the
|
||||
* attached joystick. The first two define if the joystick
|
||||
* supports a battery. Disconnected means that the joystick
|
||||
* isn't connected. Wired shows that the joystick is a wired
|
||||
* joystick.
|
||||
*/
|
||||
|
||||
#define BATTERY_DEVTYPE_GAMEPAD 0x00
|
||||
#define BATTERY_DEVTYPE_HEADSET 0x01
|
||||
#define BATTERY_TYPE_DISCONNECTED 0x00
|
||||
#define BATTERY_TYPE_WIRED 0x01
|
||||
#define BATTERY_TYPE_ALKALINE 0x02
|
||||
#define BATTERY_TYPE_NIMH 0x03
|
||||
#define BATTERY_TYPE_UNKNOWN 0xFF
|
||||
#define BATTERY_LEVEL_EMPTY 0x00
|
||||
#define BATTERY_LEVEL_LOW 0x01
|
||||
#define BATTERY_LEVEL_MEDIUM 0x02
|
||||
#define BATTERY_LEVEL_FULL 0x03
|
||||
|
||||
/*
|
||||
* How many joysticks can be used with this library. Games that
|
||||
* use the xinput library will not go over this number.
|
||||
*/
|
||||
|
||||
#define XUSER_MAX_COUNT 4
|
||||
#define XUSER_INDEX_ANY 0x000000FF
|
||||
|
||||
/*
|
||||
* Defines the structure of an xbox 360 joystick.
|
||||
*/
|
||||
|
||||
typedef struct _XINPUT_GAMEPAD {
|
||||
WORD wButtons;
|
||||
BYTE bLeftTrigger;
|
||||
BYTE bRightTrigger;
|
||||
SHORT sThumbLX;
|
||||
SHORT sThumbLY;
|
||||
SHORT sThumbRX;
|
||||
SHORT sThumbRY;
|
||||
} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
|
||||
|
||||
typedef struct _XINPUT_STATE {
|
||||
DWORD dwPacketNumber;
|
||||
XINPUT_GAMEPAD Gamepad;
|
||||
} XINPUT_STATE, *PXINPUT_STATE;
|
||||
|
||||
/*
|
||||
* Defines the structure of how much vibration is set on both the
|
||||
* right and left motors in a joystick. If you're not using a 360
|
||||
* joystick you will have to map these to your device.
|
||||
*/
|
||||
|
||||
typedef struct _XINPUT_VIBRATION {
|
||||
WORD wLeftMotorSpeed;
|
||||
WORD wRightMotorSpeed;
|
||||
} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
|
||||
|
||||
/*
|
||||
* Defines the structure for what kind of abilities the joystick has
|
||||
* such abilities are things such as if the joystick has the ability
|
||||
* to send and receive audio, if the joystick is in fact a driving
|
||||
* wheel or perhaps if the joystick is some kind of dance pad or
|
||||
* guitar.
|
||||
*/
|
||||
|
||||
typedef struct _XINPUT_CAPABILITIES {
|
||||
BYTE Type;
|
||||
BYTE SubType;
|
||||
WORD Flags;
|
||||
XINPUT_GAMEPAD Gamepad;
|
||||
XINPUT_VIBRATION Vibration;
|
||||
} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
|
||||
|
||||
/*
|
||||
* Defines the structure for a joystick input event which is
|
||||
* retrieved using the function XInputGetKeystroke
|
||||
*/
|
||||
typedef struct _XINPUT_KEYSTROKE {
|
||||
WORD VirtualKey;
|
||||
WCHAR Unicode;
|
||||
WORD Flags;
|
||||
BYTE UserIndex;
|
||||
BYTE HidCode;
|
||||
} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
|
||||
|
||||
typedef struct _XINPUT_BATTERY_INFORMATION
|
||||
{
|
||||
BYTE BatteryType;
|
||||
BYTE BatteryLevel;
|
||||
} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void WINAPI XInputEnable(WINBOOL);
|
||||
DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
|
||||
DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
|
||||
DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
|
||||
DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
|
||||
DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
|
||||
DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __WINE_XINPUT_H */
|
||||
0
src/external/glfw/deps/wayland/fractional-scale-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/fractional-scale-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/idle-inhibit-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/pointer-constraints-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/relative-pointer-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/viewporter.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/viewporter.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/wayland.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/wayland.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/xdg-activation-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/xdg-activation-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/xdg-decoration-unstable-v1.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/xdg-shell.xml
vendored
Normal file → Executable file
0
src/external/glfw/deps/wayland/xdg-shell.xml
vendored
Normal file → Executable file
234
src/external/glfw/include/GLFW/glfw3.h
vendored
Normal file → Executable file
234
src/external/glfw/include/GLFW/glfw3.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* GLFW 3.4 - www.glfw.org
|
||||
* GLFW 3.5 - www.glfw.org
|
||||
* A library for OpenGL, window and input
|
||||
*------------------------------------------------------------------------
|
||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||
@ -291,14 +291,14 @@ extern "C" {
|
||||
* features are added to the API but it remains backward-compatible.
|
||||
* @ingroup init
|
||||
*/
|
||||
#define GLFW_VERSION_MINOR 4
|
||||
#define GLFW_VERSION_MINOR 5
|
||||
/*! @brief The revision number of the GLFW header.
|
||||
*
|
||||
* The revision number of the GLFW header. This is incremented when a bug fix
|
||||
* release is made that does not contain any API changes.
|
||||
* @ingroup init
|
||||
*/
|
||||
#define GLFW_VERSION_REVISION 0
|
||||
#define GLFW_VERSION_REVISION 1
|
||||
/*! @} */
|
||||
|
||||
/*! @brief One.
|
||||
@ -1154,6 +1154,7 @@ extern "C" {
|
||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
|
||||
#define GLFW_LOCK_KEY_MODS 0x00033004
|
||||
#define GLFW_RAW_MOUSE_MOTION 0x00033005
|
||||
#define GLFW_UNLIMITED_MOUSE_BUTTONS 0x00033006
|
||||
|
||||
#define GLFW_CURSOR_NORMAL 0x00034001
|
||||
#define GLFW_CURSOR_HIDDEN 0x00034002
|
||||
@ -1227,13 +1228,13 @@ extern "C" {
|
||||
* The top-left to bottom-right diagonal resize/move shape. This is usually
|
||||
* a diagonal double-headed arrow.
|
||||
*
|
||||
* @note @macos This shape is provided by a private system API and may fail
|
||||
* @note __macOS:__ This shape is provided by a private system API and may fail
|
||||
* with @ref GLFW_CURSOR_UNAVAILABLE in the future.
|
||||
*
|
||||
* @note @wayland This shape is provided by a newer standard not supported by
|
||||
* @note __Wayland:__ This shape is provided by a newer standard not supported by
|
||||
* all cursor themes.
|
||||
*
|
||||
* @note @x11 This shape is provided by a newer standard not supported by all
|
||||
* @note __X11:__ This shape is provided by a newer standard not supported by all
|
||||
* cursor themes.
|
||||
*/
|
||||
#define GLFW_RESIZE_NWSE_CURSOR 0x00036007
|
||||
@ -1242,13 +1243,13 @@ extern "C" {
|
||||
* The top-right to bottom-left diagonal resize/move shape. This is usually
|
||||
* a diagonal double-headed arrow.
|
||||
*
|
||||
* @note @macos This shape is provided by a private system API and may fail
|
||||
* @note __macOS:__ This shape is provided by a private system API and may fail
|
||||
* with @ref GLFW_CURSOR_UNAVAILABLE in the future.
|
||||
*
|
||||
* @note @wayland This shape is provided by a newer standard not supported by
|
||||
* @note __Wayland:__ This shape is provided by a newer standard not supported by
|
||||
* all cursor themes.
|
||||
*
|
||||
* @note @x11 This shape is provided by a newer standard not supported by all
|
||||
* @note __X11:__ This shape is provided by a newer standard not supported by all
|
||||
* cursor themes.
|
||||
*/
|
||||
#define GLFW_RESIZE_NESW_CURSOR 0x00036008
|
||||
@ -1263,10 +1264,10 @@ extern "C" {
|
||||
* The operation-not-allowed shape. This is usually a circle with a diagonal
|
||||
* line through it.
|
||||
*
|
||||
* @note @wayland This shape is provided by a newer standard not supported by
|
||||
* @note __Wayland:__ This shape is provided by a newer standard not supported by
|
||||
* all cursor themes.
|
||||
*
|
||||
* @note @x11 This shape is provided by a newer standard not supported by all
|
||||
* @note __X11:__ This shape is provided by a newer standard not supported by all
|
||||
* cursor themes.
|
||||
*/
|
||||
#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A
|
||||
@ -1343,6 +1344,10 @@ extern "C" {
|
||||
#define GLFW_PLATFORM_NULL 0x00060005
|
||||
/*! @} */
|
||||
|
||||
/* Reserved platform define for external Emscripten ports: 0x00060006
|
||||
* See https://github.com/pongasoft/emscripten-glfw
|
||||
*/
|
||||
|
||||
#define GLFW_DONT_CARE -1
|
||||
|
||||
|
||||
@ -1628,7 +1633,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
|
||||
* @sa @ref glfwSetWindowSizeCallback
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -1648,7 +1653,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
|
||||
* @sa @ref glfwSetWindowCloseCallback
|
||||
*
|
||||
* @since Added in version 2.5.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -1668,7 +1673,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
|
||||
* @sa @ref glfwSetWindowRefreshCallback
|
||||
*
|
||||
* @since Added in version 2.5.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -1799,7 +1804,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo
|
||||
* @sa @ref glfwSetMouseButtonCallback
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle and modifier mask parameters.
|
||||
* __GLFW 3:__ Added window handle and modifier mask parameters.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -1890,7 +1895,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffse
|
||||
* @sa @ref glfwSetKeyCallback
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle, scancode and modifier mask parameters.
|
||||
* __GLFW 3:__ Added window handle, scancode and modifier mask parameters.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -1911,7 +1916,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int actio
|
||||
* @sa @ref glfwSetCharCallback
|
||||
*
|
||||
* @since Added in version 2.4.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -2019,7 +2024,7 @@ typedef void (* GLFWjoystickfun)(int jid, int event);
|
||||
* @sa @ref glfwGetVideoModes
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added refresh rate member.
|
||||
* __GLFW 3:__ Added refresh rate member.
|
||||
*
|
||||
* @ingroup monitor
|
||||
*/
|
||||
@ -2082,7 +2087,7 @@ typedef struct GLFWgammaramp
|
||||
* @sa @ref window_icon
|
||||
*
|
||||
* @since Added in version 2.1.
|
||||
* @glfw3 Removed format and bytes-per-pixel members.
|
||||
* __GLFW 3:__ Removed format and bytes-per-pixel members.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -2182,12 +2187,12 @@ typedef struct GLFWallocator
|
||||
* @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @macos This function will change the current directory of the
|
||||
* @remark __macOS:__ This function will change the current directory of the
|
||||
* application to the `Contents/Resources` subdirectory of the application's
|
||||
* bundle, if present. This can be disabled with the @ref
|
||||
* GLFW_COCOA_CHDIR_RESOURCES init hint.
|
||||
*
|
||||
* @remark @macos This function will create the main menu and dock icon for the
|
||||
* @remark __macOS:__ This function will create the main menu and dock icon for the
|
||||
* application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to
|
||||
* contain a menu bar. Otherwise a minimal menu bar is created manually with
|
||||
* common commands like Hide, Quit and About. The About entry opens a minimal
|
||||
@ -2202,7 +2207,7 @@ typedef struct GLFWallocator
|
||||
* to something other than `wayland` or `x11`, the regular detection mechanism
|
||||
* will be used instead.
|
||||
*
|
||||
* @remark @x11 This function will set the `LC_CTYPE` category of the
|
||||
* @remark __X11:__ This function will set the `LC_CTYPE` category of the
|
||||
* application locale according to the current environment if that category is
|
||||
* still "C". This is because the "C" locale breaks Unicode text input.
|
||||
*
|
||||
@ -2678,7 +2683,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark @win32 On Windows 8 and earlier the physical size is calculated from
|
||||
* @remark __Win32:__ On Windows 8 and earlier the physical size is calculated from
|
||||
* the current resolution and system DPI instead of querying the monitor EDID data.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -2712,7 +2717,7 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland Fractional scaling information is not yet available for
|
||||
* @remark __Wayland:__ Fractional scaling information is not yet available for
|
||||
* monitors, so this function only returns integer content scales.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -2860,7 +2865,7 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
|
||||
* @sa @ref glfwGetVideoMode
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Changed to return an array of modes for a specific monitor.
|
||||
* __GLFW 3:__ Changed to return an array of modes for a specific monitor.
|
||||
*
|
||||
* @ingroup monitor
|
||||
*/
|
||||
@ -2914,8 +2919,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE,
|
||||
* @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
||||
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
* @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function
|
||||
* cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
@ -2938,8 +2943,8 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR
|
||||
* and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
||||
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
|
||||
* @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function
|
||||
* cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while
|
||||
* returning `NULL`.
|
||||
*
|
||||
* @pointer_lifetime The returned structure and its arrays are allocated and
|
||||
@ -2980,10 +2985,10 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
|
||||
* @remark The size of the specified gamma ramp should match the size of the
|
||||
* current ramp for that monitor.
|
||||
*
|
||||
* @remark @win32 The gamma ramp size must be 256.
|
||||
* @remark __Win32:__ The gamma ramp size must be 256.
|
||||
*
|
||||
* @remark @wayland Gamma handling is a privileged protocol, this function
|
||||
* will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
* @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function
|
||||
* cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @pointer_lifetime The specified gamma ramp is copied before this function
|
||||
* returns.
|
||||
@ -3158,32 +3163,32 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
||||
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @win32 Window creation will fail if the Microsoft GDI software
|
||||
* @remark __Win32:__ Window creation will fail if the Microsoft GDI software
|
||||
* OpenGL implementation is the only one available.
|
||||
*
|
||||
* @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
|
||||
* @remark __Win32:__ If the executable has an icon resource named `GLFW_ICON,` it
|
||||
* will be set as the initial icon for the window. If no such icon is present,
|
||||
* the `IDI_APPLICATION` icon will be used instead. To set a different icon,
|
||||
* see @ref glfwSetWindowIcon.
|
||||
*
|
||||
* @remark @win32 The context to share resources with must not be current on
|
||||
* @remark __Win32:__ The context to share resources with must not be current on
|
||||
* any other thread.
|
||||
*
|
||||
* @remark @macos The OS only supports core profile contexts for OpenGL
|
||||
* @remark __macOS:__ The OS only supports core profile contexts for OpenGL
|
||||
* versions 3.2 and later. Before creating an OpenGL context of version 3.2 or
|
||||
* later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
|
||||
* hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all
|
||||
* on macOS.
|
||||
*
|
||||
* @remark @macos The GLFW window has no icon, as it is not a document
|
||||
* @remark __macOS:__ The GLFW window has no icon, as it is not a document
|
||||
* window, but the dock icon will be the same as the application bundle's icon.
|
||||
* For more information on bundles, see the
|
||||
* [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
|
||||
*
|
||||
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
|
||||
*
|
||||
* @remark @macos On OS X 10.10 and later the window frame will not be rendered
|
||||
* at full resolution on Retina displays unless the
|
||||
* @remark __macOS:__ The window frame will not be rendered at full resolution
|
||||
* on Retina displays unless the
|
||||
* [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint)
|
||||
* hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
|
||||
* application bundle's `Info.plist`. For more information, see
|
||||
@ -3194,11 +3199,11 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
||||
*
|
||||
* [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
|
||||
*
|
||||
* @remark @macos When activating frame autosaving with
|
||||
* @remark __macOS:__ When activating frame autosaving with
|
||||
* [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
|
||||
* window size and position may be overridden by previously saved values.
|
||||
*
|
||||
* @remark @wayland GLFW uses [libdecor][] where available to create its window
|
||||
* @remark __Wayland:__ GLFW uses [libdecor][] where available to create its window
|
||||
* decorations. This in turn uses server-side XDG decorations where available
|
||||
* and provides high quality client-side decorations on compositors like GNOME.
|
||||
* If both XDG decorations and libdecor are unavailable, GLFW falls back to
|
||||
@ -3207,15 +3212,15 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
||||
*
|
||||
* [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor
|
||||
*
|
||||
* @remark @x11 Some window managers will not respect the placement of
|
||||
* @remark __X11:__ Some window managers will not respect the placement of
|
||||
* initially hidden windows.
|
||||
*
|
||||
* @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
|
||||
* @remark __X11:__ Due to the asynchronous nature of X11, it may take a moment for
|
||||
* a window to reach its requested state. This means you may not be able to
|
||||
* query the final size, position or other attributes directly after window
|
||||
* creation.
|
||||
*
|
||||
* @remark @x11 The class part of the `WM_CLASS` window property will by
|
||||
* @remark __X11:__ The class part of the `WM_CLASS` window property will by
|
||||
* default be set to the window title passed to this function. The instance
|
||||
* part will use the contents of the `RESOURCE_NAME` environment variable, if
|
||||
* present and not empty, or fall back to the window title. Set the
|
||||
@ -3348,7 +3353,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @macos The window title will not be updated until the next time you
|
||||
* @remark __macOS:__ The window title will not be updated until the next time you
|
||||
* process events.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3357,7 +3362,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window);
|
||||
* @sa @ref glfwGetWindowTitle
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -3391,14 +3396,14 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
|
||||
* @pointer_lifetime The specified image data is copied before this function
|
||||
* returns.
|
||||
*
|
||||
* @remark @macos Regular windows do not have icons on macOS. This function
|
||||
* @remark __macOS:__ Regular windows do not have icons on macOS. This function
|
||||
* will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as
|
||||
* the application bundle's icon. For more information on bundles, see the
|
||||
* [Bundle Programming Guide][bundle-guide] in the Mac Developer Library.
|
||||
*
|
||||
* [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/
|
||||
*
|
||||
* @remark @wayland There is no existing protocol to change an icon, the
|
||||
* @remark __Wayland:__ There is no existing protocol to change an icon, the
|
||||
* window will thus inherit the one defined in the application's desktop file.
|
||||
* This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
@ -3429,8 +3434,8 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @wayland There is no way for an application to retrieve the global
|
||||
* position of its windows. This function will emit @ref
|
||||
* @remark __Wayland:__ Window positions are not currently part of any common
|
||||
* Wayland protocol, so this function cannot be implemented and will emit @ref
|
||||
* GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3463,8 +3468,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @wayland There is no way for an application to set the global
|
||||
* position of its windows. This function will emit @ref
|
||||
* @remark __Wayland:__ Window positions are not currently part of any common
|
||||
* Wayland protocol, so this function cannot be implemented and will emit @ref
|
||||
* GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3473,7 +3478,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
|
||||
* @sa @ref glfwGetWindowPos
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -3503,7 +3508,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
|
||||
* @sa @ref glfwSetWindowSize
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -3538,7 +3543,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
|
||||
* @remark If you set size limits and an aspect ratio that conflict, the
|
||||
* results are undefined.
|
||||
*
|
||||
* @remark @wayland The size limits will not be applied until the window is
|
||||
* @remark __Wayland:__ The size limits will not be applied until the window is
|
||||
* actually resized, either by the user or by the compositor.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3581,7 +3586,7 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minhe
|
||||
* @remark If you set size limits and an aspect ratio that conflict, the
|
||||
* results are undefined.
|
||||
*
|
||||
* @remark @wayland The aspect ratio will not be applied until the window is
|
||||
* @remark __Wayland:__ The aspect ratio will not be applied until the window is
|
||||
* actually resized, either by the user or by the compositor.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3627,7 +3632,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
|
||||
* @sa @ref glfwSetWindowMonitor
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -3777,7 +3782,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @wayland There is no way to set an opacity factor for a window.
|
||||
* @remark __Wayland:__ There is no way to set an opacity factor for a window.
|
||||
* This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3806,10 +3811,6 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
|
||||
* be able to restore it. This is a design decision of the xdg-shell
|
||||
* protocol.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_iconify
|
||||
@ -3817,7 +3818,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
|
||||
* @sa @ref glfwMaximizeWindow
|
||||
*
|
||||
* @since Added in version 2.1.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -3837,6 +3838,10 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark __Wayland:__ Restoring a window from maximization is not currently
|
||||
* part of any common Wayland protocol, so this function can only restore
|
||||
* windows from maximization.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_iconify
|
||||
@ -3844,7 +3849,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
|
||||
* @sa @ref glfwMaximizeWindow
|
||||
*
|
||||
* @since Added in version 2.1.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -3891,7 +3896,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland Because Wayland wants every frame of the desktop to be
|
||||
* @remark __Wayland:__ Because Wayland wants every frame of the desktop to be
|
||||
* complete, this function does not immediately make the window visible.
|
||||
* Instead it will become visible the next time the window framebuffer is
|
||||
* updated after this call.
|
||||
@ -3954,7 +3959,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @wayland The compositor will likely ignore focus requests unless
|
||||
* @remark __Wayland:__ The compositor will likely ignore focus requests unless
|
||||
* another window created by the same application already has input focus.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -3982,7 +3987,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* window);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @macos Attention is requested to the application as a whole, not the
|
||||
* @remark __macOS:__ Attention is requested to the application as a whole, not the
|
||||
* specific window.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -4057,8 +4062,8 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
|
||||
* affected by any resizing or mode switching, although you may need to update
|
||||
* your viewport if the framebuffer size has changed.
|
||||
*
|
||||
* @remark @wayland The desired window position is ignored, as there is no way
|
||||
* for an application to set this property.
|
||||
* @remark __Wayland:__ Window positions are not currently part of any common
|
||||
* Wayland protocol. The window position arguments are ignored.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
@ -4095,8 +4100,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int
|
||||
* errors. However, this function should not fail as long as it is passed
|
||||
* valid arguments and the library has been [initialized](@ref intro_init).
|
||||
*
|
||||
* @remark @wayland The Wayland protocol provides no way to check whether a
|
||||
* window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`.
|
||||
* @remark __Wayland:__ Checking whether a window is iconified is not currently
|
||||
* part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute
|
||||
* cannot be implemented and is always `GLFW_FALSE`.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
@ -4138,7 +4144,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
|
||||
* @remark Calling @ref glfwGetWindowAttrib will always return the latest
|
||||
* value, even if that value is ignored by the current mode of the window.
|
||||
*
|
||||
* @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
|
||||
* @remark __Wayland:__ The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is
|
||||
* not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -4218,8 +4224,8 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark @wayland This callback will never be called, as there is no way for
|
||||
* an application to know its global position.
|
||||
* @remark __Wayland:__ This callback will not be called. The Wayland protocol
|
||||
* provides no way to be notified of when a window is moved.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
@ -4257,7 +4263,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow
|
||||
* @sa @ref window_size
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter and return value.
|
||||
* __GLFW 3:__ Added window handle parameter and return value.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -4289,7 +4295,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark @macos Selecting Quit from the application menu will trigger the
|
||||
* @remark __macOS:__ Selecting Quit from the application menu will trigger the
|
||||
* close callback for all windows.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -4297,7 +4303,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind
|
||||
* @sa @ref window_close
|
||||
*
|
||||
* @since Added in version 2.5.
|
||||
* @glfw3 Added window handle parameter and return value.
|
||||
* __GLFW 3:__ Added window handle parameter and return value.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -4333,7 +4339,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi
|
||||
* @sa @ref window_refresh
|
||||
*
|
||||
* @since Added in version 2.5.
|
||||
* @glfw3 Added window handle parameter and return value.
|
||||
* __GLFW 3:__ Added window handle parameter and return value.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -4394,6 +4400,10 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||
*
|
||||
* @remark __Wayland:__ This callback will not be called. The Wayland protocol
|
||||
* provides no way to be notified of when a window is iconified, and no way to
|
||||
* check whether a window is currently iconified.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
*
|
||||
* @sa @ref window_iconify
|
||||
@ -4514,7 +4524,8 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow*
|
||||
* GLFW will pass those events on to the application callbacks before
|
||||
* returning.
|
||||
*
|
||||
* Event processing is not required for joystick input to work.
|
||||
* Event processing is not required to receive joystick input. Joystick state
|
||||
* is polled when a joystick input or gamepad input function is called.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
@ -4559,7 +4570,8 @@ GLFWAPI void glfwPollEvents(void);
|
||||
* GLFW will pass those events on to the application callbacks before
|
||||
* returning.
|
||||
*
|
||||
* Event processing is not required for joystick input to work.
|
||||
* Event processing is not required to receive joystick input. Joystick state
|
||||
* is polled when a joystick input or gamepad input function is called.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
@ -4606,7 +4618,8 @@ GLFWAPI void glfwWaitEvents(void);
|
||||
* GLFW will pass those events on to the application callbacks before
|
||||
* returning.
|
||||
*
|
||||
* Event processing is not required for joystick input to work.
|
||||
* Event processing is not required to receive joystick input. Joystick state
|
||||
* is polled when a joystick input or gamepad input function is called.
|
||||
*
|
||||
* @param[in] timeout The maximum amount of time, in seconds, to wait.
|
||||
*
|
||||
@ -4676,8 +4689,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
||||
*
|
||||
* This function sets an input mode option for the specified window. The mode
|
||||
* must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
|
||||
* @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
|
||||
* @ref GLFW_RAW_MOUSE_MOTION.
|
||||
* @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS
|
||||
* @ref GLFW_RAW_MOUSE_MOTION, or @ref GLFW_UNLIMITED_MOUSE_BUTTONS.
|
||||
*
|
||||
* If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
|
||||
* modes:
|
||||
@ -4717,6 +4730,11 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
||||
* attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref
|
||||
* glfwRawMouseMotionSupported to check for support.
|
||||
*
|
||||
* If the mode is `GLFW_UNLIMITED_MOUSE_BUTTONS`, the value must be either
|
||||
* `GLFW_TRUE` to disable the mouse button limit when calling the mouse button
|
||||
* callback, or `GLFW_FALSE` to limit the mouse buttons sent to the callback
|
||||
* to the mouse button token values up to `GLFW_MOUSE_BUTTON_LAST`.
|
||||
*
|
||||
* @param[in] window The window whose input mode to set.
|
||||
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
|
||||
* `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
|
||||
@ -4894,7 +4912,7 @@ GLFWAPI int glfwGetKeyScancode(int key);
|
||||
* @sa @ref input_key
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -4911,8 +4929,11 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
|
||||
* returns `GLFW_PRESS` the first time you call it for a mouse button that was
|
||||
* pressed, even if that mouse button has already been released.
|
||||
*
|
||||
* The @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode does not effect the
|
||||
* limit on buttons which can be polled with this function.
|
||||
*
|
||||
* @param[in] window The desired window.
|
||||
* @param[in] button The desired [mouse button](@ref buttons).
|
||||
* @param[in] button The desired [mouse button token](@ref buttons).
|
||||
* @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
@ -4923,7 +4944,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
|
||||
* @sa @ref input_mouse_button
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -4993,7 +5014,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
|
||||
*
|
||||
* @remark @wayland This function will only work when the cursor mode is
|
||||
* @remark __Wayland:__ This function will only work when the cursor mode is
|
||||
* `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE.
|
||||
*
|
||||
* @thread_safety This function must only be called from the main thread.
|
||||
@ -5191,7 +5212,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
|
||||
* @sa @ref input_key
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter and return value.
|
||||
* __GLFW 3:__ Added window handle parameter and return value.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -5234,7 +5255,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
|
||||
* @sa @ref input_char
|
||||
*
|
||||
* @since Added in version 2.4.
|
||||
* @glfw3 Added window handle parameter and return value.
|
||||
* __GLFW 3:__ Added window handle parameter and return value.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -5288,10 +5309,15 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
|
||||
* is called when a mouse button is pressed or released.
|
||||
*
|
||||
* When a window loses input focus, it will generate synthetic mouse button
|
||||
* release events for all pressed mouse buttons. You can tell these events
|
||||
* from user-generated events by the fact that the synthetic ones are generated
|
||||
* after the focus loss event has been processed, i.e. after the
|
||||
* [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
|
||||
* release events for all pressed mouse buttons with associated button tokens.
|
||||
* You can tell these events from user-generated events by the fact that the
|
||||
* synthetic ones are generated after the focus loss event has been processed,
|
||||
* i.e. after the [window focus callback](@ref glfwSetWindowFocusCallback) has
|
||||
* been called.
|
||||
*
|
||||
* The reported `button` value can be higher than `GLFW_MOUSE_BUTTON_LAST` if
|
||||
* the button does not have an associated [button token](@ref buttons) and the
|
||||
* @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set.
|
||||
*
|
||||
* @param[in] window The window whose callback to set.
|
||||
* @param[in] callback The new callback, or `NULL` to remove the currently set
|
||||
@ -5313,7 +5339,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
|
||||
* @sa @ref input_mouse_button
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter and return value.
|
||||
* __GLFW 3:__ Added window handle parameter and return value.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -5543,7 +5569,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
|
||||
* @sa @ref joystick_button
|
||||
*
|
||||
* @since Added in version 2.2.
|
||||
* @glfw3 Changed to return a dynamic array.
|
||||
* __GLFW 3:__ Changed to return a dynamic array.
|
||||
*
|
||||
* @ingroup input
|
||||
*/
|
||||
@ -5907,7 +5933,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @win32 The clipboard on Windows has a single global lock for reading and
|
||||
* @remark __Win32:__ The clipboard on Windows has a single global lock for reading and
|
||||
* writing. GLFW tries to acquire it a few times, which is almost always enough. If it
|
||||
* cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
|
||||
* It is safe to try this multiple times.
|
||||
@ -5940,7 +5966,7 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @win32 The clipboard on Windows has a single global lock for reading and
|
||||
* @remark __Win32:__ The clipboard on Windows has a single global lock for reading and
|
||||
* writing. GLFW tries to acquire it a few times, which is almost always enough. If it
|
||||
* cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns.
|
||||
* It is safe to try this multiple times.
|
||||
@ -6148,6 +6174,10 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark __Wayland:__ When the swap interval is greater than zero and the
|
||||
* window is not in view, this function may take a few extra milliseconds to
|
||||
* return.
|
||||
*
|
||||
* @remark __EGL:__ The context of the specified window must be current on the
|
||||
* calling thread.
|
||||
*
|
||||
@ -6157,7 +6187,7 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
|
||||
* @sa @ref glfwSwapInterval
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
* @glfw3 Added window handle parameter.
|
||||
* __GLFW 3:__ Added window handle parameter.
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
@ -6424,7 +6454,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
|
||||
*
|
||||
* @remark @macos This function currently always returns `GLFW_TRUE`, as the
|
||||
* @remark __macOS:__ This function currently always returns `GLFW_TRUE`, as the
|
||||
* `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide
|
||||
* a `vkGetPhysicalDevice*PresentationSupport` type function.
|
||||
*
|
||||
@ -6482,15 +6512,15 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys
|
||||
* @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
|
||||
* eliminate almost all occurrences of these errors.
|
||||
*
|
||||
* @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the
|
||||
* @remark __macOS:__ GLFW prefers the `VK_EXT_metal_surface` extension, with the
|
||||
* `VK_MVK_macos_surface` extension as a fallback. The name of the selected
|
||||
* extension, if any, is included in the array returned by @ref
|
||||
* glfwGetRequiredInstanceExtensions.
|
||||
*
|
||||
* @remark @macos This function creates and sets a `CAMetalLayer` instance for
|
||||
* @remark __macOS:__ This function creates and sets a `CAMetalLayer` instance for
|
||||
* the window content view, which is required for MoltenVK to function.
|
||||
*
|
||||
* @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension,
|
||||
* @remark __X11:__ By default GLFW prefers the `VK_KHR_xcb_surface` extension,
|
||||
* with the `VK_KHR_xlib_surface` extension as a fallback. You can make
|
||||
* `VK_KHR_xlib_surface` the preferred extension by setting the
|
||||
* [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init
|
||||
|
||||
48
src/external/glfw/include/GLFW/glfw3native.h
vendored
Normal file → Executable file
48
src/external/glfw/include/GLFW/glfw3native.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
/*************************************************************************
|
||||
* GLFW 3.4 - www.glfw.org
|
||||
* GLFW 3.5 - www.glfw.org
|
||||
* A library for OpenGL, window and input
|
||||
*------------------------------------------------------------------------
|
||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||
@ -478,6 +478,29 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
||||
|
||||
/*! @brief Retrieves the `GLXFBConfig` of the specified window's `GLXWindow`.
|
||||
*
|
||||
* @param[in] window The window whose `GLXWindow` to query.
|
||||
* @param[out] config The `GLXFBConfig` of the window `GLXWindow`, if available.
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE.
|
||||
*
|
||||
* @remark `GLXFBConfig` is an opaque type. Unlike other GLFW functions, the
|
||||
* @p config out parameter is not cleared on error, as core GLX does not define
|
||||
* any invalid value.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.5
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* window, GLXFBConfig* config);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
||||
@ -586,6 +609,29 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
||||
|
||||
/*! @brief Retrieves the `EGLConfig` of the specified window's `EGLSurface`.
|
||||
*
|
||||
* @param[in] window The window whose `EGLSurface` to query.
|
||||
* @param[out] config The `EGLConfig` of the window `EGLSurface`, if available.
|
||||
* @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
|
||||
* [error](@ref error_handling) occurred.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_NO_WINDOW_CONTEXT.
|
||||
*
|
||||
* @remark `EGLConfig` is an opaque type. Unlike other GLFW functions, the @p
|
||||
* config out parameter is not cleared on error, as core EGL does not define
|
||||
* any invalid value.
|
||||
*
|
||||
* @thread_safety This function may be called from any thread. Access is not
|
||||
* synchronized.
|
||||
*
|
||||
* @since Added in version 3.5.
|
||||
*
|
||||
* @ingroup native
|
||||
*/
|
||||
GLFWAPI int glfwGetEGLConfig(GLFWwindow* window, EGLConfig* config);
|
||||
#endif
|
||||
|
||||
#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
|
||||
|
||||
68
src/external/glfw/src/CMakeLists.txt
vendored
Normal file → Executable file
68
src/external/glfw/src/CMakeLists.txt
vendored
Normal file → Executable file
@ -10,7 +10,7 @@ add_library(glfw ${GLFW_LIBRARY_TYPE}
|
||||
# The time, thread and module code is shared between all backends on a given OS,
|
||||
# including the null backend, which still needs those bits to be functional
|
||||
if (APPLE)
|
||||
target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h
|
||||
target_sources(glfw PRIVATE macos_time.h macos_time.c posix_thread.h
|
||||
posix_module.c posix_thread.c)
|
||||
elseif (WIN32)
|
||||
target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c
|
||||
@ -30,6 +30,7 @@ add_custom_target(update_mappings
|
||||
set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3")
|
||||
|
||||
if (GLFW_BUILD_COCOA)
|
||||
enable_language(OBJC)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_COCOA)
|
||||
target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m
|
||||
cocoa_joystick.m cocoa_monitor.m cocoa_window.m
|
||||
@ -45,15 +46,15 @@ endif()
|
||||
|
||||
if (GLFW_BUILD_X11)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_X11)
|
||||
target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c
|
||||
target_sources(glfw PRIVATE x11_platform.h x11_init.c
|
||||
x11_monitor.c x11_window.c xkb_unicode.c
|
||||
glx_context.c)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_WAYLAND)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND)
|
||||
target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c
|
||||
wl_monitor.c wl_window.c xkb_unicode.c)
|
||||
target_sources(glfw PRIVATE wl_platform.h wl_init.c
|
||||
wl_monitor.c wl_window.c)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND)
|
||||
@ -137,13 +138,6 @@ target_include_directories(glfw PRIVATE
|
||||
"${GLFW_BINARY_DIR}/src")
|
||||
target_link_libraries(glfw PRIVATE Threads::Threads)
|
||||
|
||||
# Workaround for CMake not knowing about .m files before version 3.16
|
||||
if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE)
|
||||
set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m
|
||||
cocoa_window.m nsgl_context.m PROPERTIES
|
||||
LANGUAGE C)
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_WIN32)
|
||||
list(APPEND glfw_PKG_LIBS "-lgdi32")
|
||||
endif()
|
||||
@ -151,10 +145,11 @@ endif()
|
||||
if (GLFW_BUILD_COCOA)
|
||||
target_link_libraries(glfw PRIVATE "-framework Cocoa"
|
||||
"-framework IOKit"
|
||||
"-framework CoreFoundation")
|
||||
"-framework QuartzCore")
|
||||
|
||||
set(glfw_PKG_DEPS "")
|
||||
set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
|
||||
list(APPEND glfw_PKG_LIBS "-framework Cocoa"
|
||||
"-framework IOKit"
|
||||
"-framework QuartzCore")
|
||||
endif()
|
||||
|
||||
if (GLFW_BUILD_WAYLAND)
|
||||
@ -239,6 +234,11 @@ if (UNIX AND NOT APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
target_link_libraries(glfw PRIVATE "-framework CoreFoundation")
|
||||
list(APPEND glfw_PKG_LIBS "-framework CoreFoundation")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (GLFW_USE_HYBRID_HPG)
|
||||
target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG)
|
||||
@ -260,24 +260,6 @@ if (GLFW_BUILD_WIN32)
|
||||
target_compile_definitions(glfw PRIVATE UNICODE _UNICODE)
|
||||
endif()
|
||||
|
||||
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
|
||||
# the inclusion of stddef.h (by glfw3.h), which is itself included before
|
||||
# win32_platform.h. We define them here until a saner solution can be found
|
||||
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
|
||||
if (MINGW)
|
||||
target_compile_definitions(glfw PRIVATE WINVER=0x0501)
|
||||
endif()
|
||||
|
||||
# Workaround for legacy MinGW not providing XInput and DirectInput
|
||||
if (MINGW)
|
||||
include(CheckIncludeFile)
|
||||
check_include_file(dinput.h DINPUT_H_FOUND)
|
||||
check_include_file(xinput.h XINPUT_H_FOUND)
|
||||
if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
|
||||
target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Workaround for the MS CRT deprecating parts of the standard library
|
||||
if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC")
|
||||
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
@ -291,10 +273,6 @@ endif()
|
||||
if (GLFW_BUILD_SHARED_LIBRARY)
|
||||
if (WIN32)
|
||||
if (MINGW)
|
||||
# Remove the dependency on the shared version of libgcc
|
||||
# NOTE: MinGW-w64 has the correct default but MinGW needs this
|
||||
target_link_libraries(glfw PRIVATE "-static-libgcc")
|
||||
|
||||
# Remove the lib prefix on the DLL (but not the import library)
|
||||
set_target_properties(glfw PROPERTIES PREFIX "")
|
||||
|
||||
@ -312,30 +290,34 @@ if (GLFW_BUILD_SHARED_LIBRARY)
|
||||
if (MINGW)
|
||||
# Enable link-time exploit mitigation features enabled by default on MSVC
|
||||
include(CheckCCompilerFlag)
|
||||
include(CMakePushCheckState)
|
||||
|
||||
# Compatibility with data execution prevention (DEP)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
|
||||
check_c_compiler_flag("" _GLFW_HAS_DEP)
|
||||
if (_GLFW_HAS_DEP)
|
||||
target_link_libraries(glfw PRIVATE "-Wl,--nxcompat")
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
|
||||
# Compatibility with address space layout randomization (ASLR)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
|
||||
check_c_compiler_flag("" _GLFW_HAS_ASLR)
|
||||
if (_GLFW_HAS_ASLR)
|
||||
target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase")
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
|
||||
# Compatibility with 64-bit address space layout randomization (ASLR)
|
||||
cmake_push_check_state()
|
||||
set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
|
||||
check_c_compiler_flag("" _GLFW_HAS_64ASLR)
|
||||
if (_GLFW_HAS_64ASLR)
|
||||
target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va")
|
||||
endif()
|
||||
|
||||
# Clear flags again to avoid breaking later tests
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
@ -344,12 +326,8 @@ if (GLFW_BUILD_SHARED_LIBRARY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(arg ${glfw_PKG_DEPS})
|
||||
string(APPEND deps " ${arg}")
|
||||
endforeach()
|
||||
foreach(arg ${glfw_PKG_LIBS})
|
||||
string(APPEND libs " ${arg}")
|
||||
endforeach()
|
||||
list(JOIN glfw_PKG_DEPS " " deps)
|
||||
list(JOIN glfw_PKG_LIBS " " libs)
|
||||
|
||||
set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL
|
||||
"GLFW pkg-config Requires.private")
|
||||
|
||||
44
src/external/glfw/src/cocoa_init.m
vendored
Normal file → Executable file
44
src/external/glfw/src/cocoa_init.m
vendored
Normal file → Executable file
@ -1,8 +1,7 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS (modified for raylib) - www.glfw.org; www.raylib.com
|
||||
// GLFW 3.5 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
@ -176,7 +175,7 @@ static void createMenuBar(void)
|
||||
|
||||
// Create key code translation tables
|
||||
//
|
||||
static void createKeyTablesCocoa(void)
|
||||
static void createKeyTables(void)
|
||||
{
|
||||
memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
|
||||
memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
|
||||
@ -451,41 +450,6 @@ static GLFWbool initializeTIS(void)
|
||||
|
||||
@end // GLFWApplicationDelegate
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* _glfwLoadLocalVulkanLoaderCocoa(void)
|
||||
{
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
if (!bundle)
|
||||
return NULL;
|
||||
|
||||
CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle);
|
||||
if (!frameworksUrl)
|
||||
return NULL;
|
||||
|
||||
CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent(
|
||||
kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false);
|
||||
if (!loaderUrl)
|
||||
{
|
||||
CFRelease(frameworksUrl);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char path[PATH_MAX];
|
||||
void* handle = NULL;
|
||||
|
||||
if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1))
|
||||
handle = _glfwPlatformLoadModule(path);
|
||||
|
||||
CFRelease(loaderUrl);
|
||||
CFRelease(frameworksUrl);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -619,7 +583,7 @@ int _glfwInitCocoa(void)
|
||||
name:NSTextInputContextKeyboardSelectionDidChangeNotification
|
||||
object:nil];
|
||||
|
||||
createKeyTablesCocoa();
|
||||
createKeyTables();
|
||||
|
||||
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
|
||||
if (!_glfw.ns.eventSource)
|
||||
@ -689,6 +653,8 @@ void _glfwTerminateCocoa(void)
|
||||
_glfwTerminateEGL();
|
||||
_glfwTerminateOSMesa();
|
||||
|
||||
memset(&_glfw.ns, 0, sizeof(_glfw.ns));
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
|
||||
2
src/external/glfw/src/cocoa_joystick.h
vendored
Normal file → Executable file
2
src/external/glfw/src/cocoa_joystick.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Cocoa - www.glfw.org
|
||||
// GLFW 3.5 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
2
src/external/glfw/src/cocoa_joystick.m
vendored
Normal file → Executable file
2
src/external/glfw/src/cocoa_joystick.m
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Cocoa - www.glfw.org
|
||||
// GLFW 3.5 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
||||
|
||||
14
src/external/glfw/src/cocoa_monitor.m
vendored
Normal file → Executable file
14
src/external/glfw/src/cocoa_monitor.m
vendored
Normal file → Executable file
@ -1,9 +1,8 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS (modified for raylib) - www.glfw.org; www.raylib.com
|
||||
// GLFW 3.5 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
@ -33,6 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <IOKit/graphics/IOGraphicsLib.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
@ -137,7 +137,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode)
|
||||
if (flags & kDisplayModeStretchedFlag)
|
||||
return GLFW_FALSE;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED == 101100
|
||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
|
||||
CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
|
||||
@ -164,7 +164,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||
if (result.refreshRate == 0)
|
||||
result.refreshRate = (int) round(fallbackRefreshRate);
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED == 101100
|
||||
CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
|
||||
if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
|
||||
{
|
||||
@ -180,7 +180,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
|
||||
result.blueBits = 8;
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED == 101100
|
||||
CFRelease(format);
|
||||
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
|
||||
return result;
|
||||
@ -628,7 +628,6 @@ void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
|
||||
|
||||
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||
@ -637,6 +636,9 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
|
||||
return kCGNullDirectDisplay;
|
||||
}
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
return monitor->ns.displayID;
|
||||
}
|
||||
|
||||
|
||||
4
src/external/glfw/src/cocoa_platform.h
vendored
Normal file → Executable file
4
src/external/glfw/src/cocoa_platform.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
// GLFW 3.5 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@ -291,8 +291,6 @@ void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor);
|
||||
|
||||
float _glfwTransformYCocoa(float y);
|
||||
|
||||
void* _glfwLoadLocalVulkanLoaderCocoa(void);
|
||||
|
||||
GLFWbool _glfwInitNSGL(void);
|
||||
void _glfwTerminateNSGL(void);
|
||||
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
|
||||
89
src/external/glfw/src/cocoa_window.m
vendored
Normal file → Executable file
89
src/external/glfw/src/cocoa_window.m
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
// GLFW 3.5 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@ -28,8 +28,11 @@
|
||||
|
||||
#if defined(_GLFW_COCOA)
|
||||
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
// HACK: This enum value is missing from framework headers on OS X 10.11 despite
|
||||
// having been (according to documentation) added in Mac OS X 10.7
|
||||
@ -111,7 +114,7 @@ static void updateCursorMode(_GLFWwindow* window)
|
||||
|
||||
// Make the specified window and its video mode active on its monitor
|
||||
//
|
||||
static void acquireMonitorCocoa(_GLFWwindow* window)
|
||||
static void acquireMonitor(_GLFWwindow* window)
|
||||
{
|
||||
_glfwSetVideoModeCocoa(window->monitor, &window->videoMode);
|
||||
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||
@ -127,7 +130,7 @@ static void acquireMonitorCocoa(_GLFWwindow* window)
|
||||
|
||||
// Remove the window and restore the original video mode
|
||||
//
|
||||
static void releaseMonitorCocoa(_GLFWwindow* window)
|
||||
static void releaseMonitor(_GLFWwindow* window)
|
||||
{
|
||||
if (window->monitor->window != window)
|
||||
return;
|
||||
@ -158,7 +161,7 @@ static int translateFlags(NSUInteger flags)
|
||||
|
||||
// Translates a macOS keycode to a GLFW keycode
|
||||
//
|
||||
static int translateKeyCocoa(unsigned int key)
|
||||
static int translateKey(unsigned int key)
|
||||
{
|
||||
if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0]))
|
||||
return GLFW_KEY_UNKNOWN;
|
||||
@ -277,7 +280,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
- (void)windowDidMiniaturize:(NSNotification *)notification
|
||||
{
|
||||
if (window->monitor)
|
||||
releaseMonitorCocoa(window);
|
||||
releaseMonitor(window);
|
||||
|
||||
_glfwInputWindowIconify(window, GLFW_TRUE);
|
||||
}
|
||||
@ -285,7 +288,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
- (void)windowDidDeminiaturize:(NSNotification *)notification
|
||||
{
|
||||
if (window->monitor)
|
||||
acquireMonitorCocoa(window);
|
||||
acquireMonitor(window);
|
||||
|
||||
_glfwInputWindowIconify(window, GLFW_FALSE);
|
||||
}
|
||||
@ -309,7 +312,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
|
||||
- (void)windowDidChangeOcclusionState:(NSNotification* )notification
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
|
||||
if ([window->ns.object respondsToSelector:@selector(occlusionState)])
|
||||
{
|
||||
if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
|
||||
@ -317,7 +319,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
else
|
||||
window->ns.occluded = GLFW_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@ -561,7 +562,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
|
||||
- (void)keyDown:(NSEvent *)event
|
||||
{
|
||||
const int key = translateKeyCocoa([event keyCode]);
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags([event modifierFlags]);
|
||||
|
||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||
@ -574,7 +575,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
int action;
|
||||
const unsigned int modifierFlags =
|
||||
[event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
||||
const int key = translateKeyCocoa([event keyCode]);
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags(modifierFlags);
|
||||
const NSUInteger keyFlag = translateKeyToModifierFlag(key);
|
||||
|
||||
@ -593,11 +594,39 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
|
||||
- (void)keyUp:(NSEvent *)event
|
||||
{
|
||||
const int key = translateKeyCocoa([event keyCode]);
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags([event modifierFlags]);
|
||||
_glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
|
||||
}
|
||||
|
||||
- (BOOL)performKeyEquivalent:(NSEvent *)event
|
||||
{
|
||||
// HACK: Some key combinations are consumed before reaching keyDown:
|
||||
// so we claim those events and emit them here
|
||||
const int key = translateKey([event keyCode]);
|
||||
const int mods = translateFlags([event modifierFlags]);
|
||||
|
||||
if (mods & GLFW_MOD_CONTROL)
|
||||
{
|
||||
if (key == GLFW_KEY_TAB || key == GLFW_KEY_ESCAPE)
|
||||
{
|
||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (mods & GLFW_MOD_SUPER)
|
||||
{
|
||||
if (key == GLFW_KEY_PERIOD)
|
||||
{
|
||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return [super performKeyEquivalent:event];
|
||||
}
|
||||
|
||||
- (void)scrollWheel:(NSEvent *)event
|
||||
{
|
||||
double deltaX = [event scrollingDeltaX];
|
||||
@ -883,7 +912,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
|
||||
[window->ns.object setContentView:window->ns.view];
|
||||
[window->ns.object makeFirstResponder:window->ns.view];
|
||||
[window->ns.object setTitle:@(wndconfig->title)];
|
||||
[window->ns.object setTitle:@(window->title)];
|
||||
[window->ns.object setDelegate:window->ns.delegate];
|
||||
[window->ns.object setAcceptsMouseMovedEvents:YES];
|
||||
[window->ns.object setRestorable:NO];
|
||||
@ -966,7 +995,7 @@ GLFWbool _glfwCreateWindowCocoa(_GLFWwindow* window,
|
||||
{
|
||||
_glfwShowWindowCocoa(window);
|
||||
_glfwFocusWindowCocoa(window);
|
||||
acquireMonitorCocoa(window);
|
||||
acquireMonitor(window);
|
||||
|
||||
if (wndconfig->centerCursor)
|
||||
_glfwCenterCursorInContentArea(window);
|
||||
@ -996,7 +1025,7 @@ void _glfwDestroyWindowCocoa(_GLFWwindow* window)
|
||||
[window->ns.object orderOut:nil];
|
||||
|
||||
if (window->monitor)
|
||||
releaseMonitorCocoa(window);
|
||||
releaseMonitor(window);
|
||||
|
||||
if (window->context.destroy)
|
||||
window->context.destroy(window);
|
||||
@ -1083,7 +1112,7 @@ void _glfwSetWindowSizeCocoa(_GLFWwindow* window, int width, int height)
|
||||
if (window->monitor)
|
||||
{
|
||||
if (window->monitor->window == window)
|
||||
acquireMonitorCocoa(window);
|
||||
acquireMonitor(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1252,7 +1281,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
||||
if (monitor)
|
||||
{
|
||||
if (monitor->window == window)
|
||||
acquireMonitorCocoa(window);
|
||||
acquireMonitor(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1270,7 +1299,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
||||
}
|
||||
|
||||
if (window->monitor)
|
||||
releaseMonitorCocoa(window);
|
||||
releaseMonitor(window);
|
||||
|
||||
_glfwInputWindowMonitor(window, monitor);
|
||||
|
||||
@ -1308,7 +1337,7 @@ void _glfwSetWindowMonitorCocoa(_GLFWwindow* window,
|
||||
[window->ns.object setLevel:NSMainMenuWindowLevel + 1];
|
||||
[window->ns.object setHasShadow:NO];
|
||||
|
||||
acquireMonitorCocoa(window);
|
||||
acquireMonitor(window);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1949,19 +1978,8 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
|
||||
// HACK: Dynamically load Core Animation to avoid adding an extra
|
||||
// dependency for the majority who don't use MoltenVK
|
||||
NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
|
||||
if (!bundle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to find QuartzCore.framework");
|
||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||
}
|
||||
|
||||
// NOTE: Create the layer here as makeBackingLayer should not return nil
|
||||
window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
|
||||
window->ns.layer = [CAMetalLayer layer];
|
||||
if (!window->ns.layer)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -2026,9 +2044,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
|
||||
}
|
||||
|
||||
return err;
|
||||
#else
|
||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||
#endif
|
||||
|
||||
} // autoreleasepool
|
||||
}
|
||||
@ -2040,7 +2055,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance,
|
||||
|
||||
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||
@ -2050,12 +2064,14 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
|
||||
return nil;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
return window->ns.object;
|
||||
}
|
||||
|
||||
GLFWAPI id glfwGetCocoaView(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||
@ -2065,6 +2081,9 @@ GLFWAPI id glfwGetCocoaView(GLFWwindow* handle)
|
||||
return nil;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
return window->ns.view;
|
||||
}
|
||||
|
||||
|
||||
36
src/external/glfw/src/context.c
vendored
Normal file → Executable file
36
src/external/glfw/src/context.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -195,7 +195,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
{
|
||||
current = alternatives + i;
|
||||
|
||||
if (desired->stereo > 0 && current->stereo == 0)
|
||||
if (desired->stereo && !current->stereo)
|
||||
{
|
||||
// Stereo is a hard constraint
|
||||
continue;
|
||||
@ -359,7 +359,7 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
window->context.source = ctxconfig->source;
|
||||
window->context.client = GLFW_OPENGL_API;
|
||||
|
||||
previous = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
glfwMakeContextCurrent((GLFWwindow*) window);
|
||||
if (_glfwPlatformGetTls(&_glfw.contextSlot) != window)
|
||||
return GLFW_FALSE;
|
||||
@ -368,7 +368,12 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||
window->context.getProcAddress("glGetIntegerv");
|
||||
window->context.GetString = (PFNGLGETSTRINGPROC)
|
||||
window->context.getProcAddress("glGetString");
|
||||
if (!window->context.GetIntegerv || !window->context.GetString)
|
||||
window->context.Flush = (PFNGLFLUSHPROC)
|
||||
window->context.getProcAddress("glFlush");
|
||||
|
||||
if (!window->context.GetIntegerv ||
|
||||
!window->context.GetString ||
|
||||
!window->context.Flush)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
|
||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||
@ -615,12 +620,12 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions
|
||||
|
||||
GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow *) handle;
|
||||
_GLFWwindow* previous;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
previous = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFWwindow* previous;
|
||||
|
||||
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
|
||||
if (window && window->context.client == GLFW_NO_API)
|
||||
{
|
||||
@ -642,16 +647,16 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
|
||||
GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return (GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
return _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow *) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.client == GLFW_NO_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
|
||||
@ -668,7 +673,7 @@ GLFWAPI void glfwSwapInterval(int interval)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
if (!window)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
|
||||
@ -686,7 +691,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
if (!window)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
|
||||
@ -752,7 +757,7 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
if (!window)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_CURRENT_CONTEXT,
|
||||
@ -762,3 +767,4 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
|
||||
|
||||
return window->context.getProcAddress(procname);
|
||||
}
|
||||
|
||||
|
||||
158
src/external/glfw/src/egl_context.c
vendored
Normal file → Executable file
158
src/external/glfw/src/egl_context.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 EGL - www.glfw.org
|
||||
// GLFW 3.5 EGL - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -92,7 +92,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
||||
EGLConfig* nativeConfigs;
|
||||
_GLFWfbconfig* usableConfigs;
|
||||
const _GLFWfbconfig* closest;
|
||||
int i, nativeCount, usableCount, apiBit;
|
||||
int i, nativeCount, usableCount, apiBit, surfaceTypeBit;
|
||||
GLFWbool wrongApiAvailable = GLFW_FALSE;
|
||||
|
||||
if (ctxconfig->client == GLFW_OPENGL_ES_API)
|
||||
@ -105,6 +105,11 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
||||
else
|
||||
apiBit = EGL_OPENGL_BIT;
|
||||
|
||||
if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA)
|
||||
surfaceTypeBit = EGL_PBUFFER_BIT;
|
||||
else
|
||||
surfaceTypeBit = EGL_WINDOW_BIT;
|
||||
|
||||
if (fbconfig->stereo)
|
||||
{
|
||||
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Stereo rendering not supported");
|
||||
@ -118,10 +123,10 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
nativeConfigs = (EGLConfig *)_glfw_calloc(nativeCount, sizeof(EGLConfig));
|
||||
nativeConfigs = _glfw_calloc(nativeCount, sizeof(EGLConfig));
|
||||
eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
|
||||
|
||||
usableConfigs = (_GLFWfbconfig *)_glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||
usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig));
|
||||
usableCount = 0;
|
||||
|
||||
for (i = 0; i < nativeCount; i++)
|
||||
@ -133,8 +138,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
|
||||
if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
|
||||
continue;
|
||||
|
||||
// Only consider window EGLConfigs
|
||||
if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
|
||||
if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & surfaceTypeBit))
|
||||
continue;
|
||||
|
||||
#if defined(_GLFW_X11)
|
||||
@ -250,6 +254,12 @@ static void makeContextCurrentEGL(_GLFWwindow* window)
|
||||
getEGLErrorString(eglGetError()));
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(_GLFW_WAYLAND)
|
||||
// NOTE: Disable EGL vsync so we can substitute our own that includes a timeout
|
||||
if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
|
||||
eglSwapInterval(_glfw.egl.display, 0);
|
||||
#endif // _GLFW_WAYLAND
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -283,6 +293,15 @@ static void swapBuffersEGL(_GLFWwindow* window)
|
||||
// NOTE: Swapping buffers on a hidden window on Wayland makes it visible
|
||||
if (!window->wl.visible)
|
||||
return;
|
||||
|
||||
// NOTE: We wait for a frame manually so we can add a timeout,
|
||||
// as the EGL implementation will wait indefinitely
|
||||
if (window->wl.egl.interval > 0)
|
||||
{
|
||||
window->context.Flush();
|
||||
if (!_glfwWaitForEGLFrameWayland(window))
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -291,6 +310,16 @@ static void swapBuffersEGL(_GLFWwindow* window)
|
||||
|
||||
static void swapIntervalEGL(int interval)
|
||||
{
|
||||
#if defined(_GLFW_WAYLAND)
|
||||
if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
assert(window != NULL);
|
||||
window->wl.egl.interval = interval;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
eglSwapInterval(_glfw.egl.display, interval);
|
||||
}
|
||||
|
||||
@ -308,18 +337,19 @@ static int extensionSupportedEGL(const char* extension)
|
||||
|
||||
static GLFWglproc getProcAddressEGL(const char* procname)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow *)_glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.egl.client)
|
||||
{
|
||||
GLFWglproc proc = (GLFWglproc)
|
||||
_glfwPlatformGetModuleSymbol(window->context.egl.client, procname);
|
||||
const GLFWglproc proc = (GLFWglproc) eglGetProcAddress(procname);
|
||||
if (proc)
|
||||
return proc;
|
||||
|
||||
if (!_glfw.egl.KHR_get_all_proc_addresses)
|
||||
{
|
||||
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
||||
assert(window != NULL);
|
||||
|
||||
return _glfwPlatformGetModuleSymbol(window->context.egl.client, procname);
|
||||
}
|
||||
|
||||
return eglGetProcAddress(procname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void destroyContextEGL(_GLFWwindow* window)
|
||||
@ -328,13 +358,10 @@ static void destroyContextEGL(_GLFWwindow* window)
|
||||
// as it will make XCloseDisplay segfault
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11 ||
|
||||
window->context.client != GLFW_OPENGL_API)
|
||||
{
|
||||
if (window->context.egl.client)
|
||||
{
|
||||
_glfwPlatformFreeModule(window->context.egl.client);
|
||||
window->context.egl.client = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (window->context.egl.surface)
|
||||
{
|
||||
@ -354,8 +381,6 @@ static void destroyContextEGL(_GLFWwindow* window)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialize EGL
|
||||
//
|
||||
GLFWbool _glfwInitEGL(void)
|
||||
{
|
||||
int i;
|
||||
@ -365,10 +390,10 @@ GLFWbool _glfwInitEGL(void)
|
||||
{
|
||||
#if defined(_GLFW_EGL_LIBRARY)
|
||||
_GLFW_EGL_LIBRARY,
|
||||
#elif defined(_GLFW_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
"libEGL.dll",
|
||||
"EGL.dll",
|
||||
#elif defined(_GLFW_COCOA)
|
||||
#elif defined(__APPLE__)
|
||||
"libEGL.dylib",
|
||||
#elif defined(__CYGWIN__)
|
||||
"libEGL-1.so",
|
||||
@ -420,6 +445,8 @@ GLFWbool _glfwInitEGL(void)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext");
|
||||
_glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface");
|
||||
_glfw.egl.CreatePbufferSurface = (PFN_eglCreatePbufferSurface)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreatePbufferSurface");
|
||||
_glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
|
||||
_glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent");
|
||||
_glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
|
||||
@ -442,6 +469,7 @@ GLFWbool _glfwInitEGL(void)
|
||||
!_glfw.egl.DestroySurface ||
|
||||
!_glfw.egl.DestroyContext ||
|
||||
!_glfw.egl.CreateWindowSurface ||
|
||||
!_glfw.egl.CreatePbufferSurface ||
|
||||
!_glfw.egl.MakeCurrent ||
|
||||
!_glfw.egl.SwapBuffers ||
|
||||
!_glfw.egl.SwapInterval ||
|
||||
@ -477,6 +505,8 @@ GLFWbool _glfwInitEGL(void)
|
||||
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
|
||||
_glfw.egl.ANGLE_platform_angle_metal =
|
||||
_glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
|
||||
_glfw.egl.MESA_platform_surfaceless =
|
||||
_glfwStringInExtensionString("EGL_MESA_platform_surfaceless", extensions);
|
||||
}
|
||||
|
||||
if (_glfw.egl.EXT_platform_base)
|
||||
@ -536,8 +566,6 @@ GLFWbool _glfwInitEGL(void)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
// Terminate EGL
|
||||
//
|
||||
void _glfwTerminateEGL(void)
|
||||
{
|
||||
if (_glfw.egl.display)
|
||||
@ -546,7 +574,8 @@ void _glfwTerminateEGL(void)
|
||||
_glfw.egl.display = EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
if (_glfw.egl.handle)
|
||||
// Free modules only after all wayland termination functions are called
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND)
|
||||
{
|
||||
_glfwPlatformFreeModule(_glfw.egl.handle);
|
||||
_glfw.egl.handle = NULL;
|
||||
@ -560,8 +589,6 @@ void _glfwTerminateEGL(void)
|
||||
attribs[index++] = v; \
|
||||
}
|
||||
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
@ -648,7 +675,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
if (ctxconfig->noerror)
|
||||
{
|
||||
if (_glfw.egl.KHR_create_context_no_error)
|
||||
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
|
||||
SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, true);
|
||||
}
|
||||
|
||||
if (mask)
|
||||
@ -708,20 +735,36 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent);
|
||||
}
|
||||
|
||||
if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA)
|
||||
{
|
||||
int width, height;
|
||||
_glfw.platform.getFramebufferSize(window, &width, &height);
|
||||
|
||||
SET_ATTRIB(EGL_WIDTH, width);
|
||||
SET_ATTRIB(EGL_HEIGHT, height);
|
||||
}
|
||||
|
||||
SET_ATTRIB(EGL_NONE, EGL_NONE);
|
||||
|
||||
native = _glfw.platform.getEGLNativeWindow(window);
|
||||
// HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
|
||||
// despite reporting EGL_EXT_platform_base
|
||||
if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
|
||||
if (!_glfw.egl.platform || _glfw.egl.platform == EGL_PLATFORM_ANGLE_ANGLE)
|
||||
{
|
||||
// HACK: Also use non-platform function for ANGLE, as it does not
|
||||
// implement eglCreatePlatformWindowSurfaceEXT despite reporting
|
||||
// support for EGL_EXT_platform_base
|
||||
window->context.egl.surface =
|
||||
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
|
||||
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
|
||||
}
|
||||
else if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA)
|
||||
{
|
||||
// HACK: Use a pbuffer surface as the default framebuffer
|
||||
window->context.egl.surface =
|
||||
eglCreatePbufferSurface(_glfw.egl.display, config, attribs);
|
||||
}
|
||||
else
|
||||
{
|
||||
window->context.egl.surface =
|
||||
eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
|
||||
eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
|
||||
}
|
||||
|
||||
if (window->context.egl.surface == EGL_NO_SURFACE)
|
||||
@ -743,10 +786,10 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
{
|
||||
#if defined(_GLFW_GLESV1_LIBRARY)
|
||||
_GLFW_GLESV1_LIBRARY,
|
||||
#elif defined(_GLFW_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
"GLESv1_CM.dll",
|
||||
"libGLES_CM.dll",
|
||||
#elif defined(_GLFW_COCOA)
|
||||
#elif defined(__APPLE__)
|
||||
"libGLESv1_CM.dylib",
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libGLESv1_CM.so",
|
||||
@ -760,10 +803,10 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
{
|
||||
#if defined(_GLFW_GLESV2_LIBRARY)
|
||||
_GLFW_GLESV2_LIBRARY,
|
||||
#elif defined(_GLFW_WIN32)
|
||||
#elif defined(_WIN32)
|
||||
"GLESv2.dll",
|
||||
"libGLESv2.dll",
|
||||
#elif defined(_GLFW_COCOA)
|
||||
#elif defined(__APPLE__)
|
||||
"libGLESv2.dylib",
|
||||
#elif defined(__CYGWIN__)
|
||||
"libGLESv2-2.so",
|
||||
@ -778,8 +821,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
{
|
||||
#if defined(_GLFW_OPENGL_LIBRARY)
|
||||
_GLFW_OPENGL_LIBRARY,
|
||||
#elif defined(_GLFW_WIN32)
|
||||
#elif defined(_GLFW_COCOA)
|
||||
#elif defined(_WIN32)
|
||||
#elif defined(__APPLE__)
|
||||
#elif defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
"libGL.so",
|
||||
#else
|
||||
@ -883,28 +926,63 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
|
||||
|
||||
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow *) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_EGL_CONTEXT_API)
|
||||
{
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND ||
|
||||
window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return EGL_NO_CONTEXT;
|
||||
}
|
||||
}
|
||||
|
||||
return window->context.egl.handle;
|
||||
}
|
||||
|
||||
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow *) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_EGL_CONTEXT_API)
|
||||
{
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND ||
|
||||
window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
}
|
||||
|
||||
return window->context.egl.surface;
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetEGLConfig(GLFWwindow* handle, EGLConfig* config)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
assert(config != NULL);
|
||||
|
||||
if (window->context.source != GLFW_EGL_CONTEXT_API)
|
||||
{
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND ||
|
||||
window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
*config = window->context.egl.config;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
|
||||
0
src/external/glfw/src/glfw.rc.in
vendored
Normal file → Executable file
0
src/external/glfw/src/glfw.rc.in
vendored
Normal file → Executable file
73
src/external/glfw/src/glx_context.c
vendored
Normal file → Executable file
73
src/external/glfw/src/glx_context.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 GLX - www.glfw.org
|
||||
// GLFW 3.5 GLX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -119,9 +119,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
|
||||
u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
|
||||
|
||||
u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
|
||||
|
||||
if (getGLXFBConfigAttrib(n, GLX_STEREO))
|
||||
u->stereo = GLFW_TRUE;
|
||||
u->stereo = getGLXFBConfigAttrib(n, GLX_STEREO);
|
||||
|
||||
if (_glfw.glx.ARB_multisample)
|
||||
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
|
||||
@ -253,8 +251,6 @@ static void destroyContextGLX(_GLFWwindow* window)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialize GLX
|
||||
//
|
||||
GLFWbool _glfwInitGLX(void)
|
||||
{
|
||||
const char* sonames[] =
|
||||
@ -369,7 +365,7 @@ GLFWbool _glfwInitGLX(void)
|
||||
getProcAddressGLX("glXSwapIntervalEXT");
|
||||
|
||||
if (_glfw.glx.SwapIntervalEXT)
|
||||
_glfw.glx.EXT_swap_control = GLFW_TRUE;
|
||||
_glfw.glx.EXT_swap_control = true;
|
||||
}
|
||||
|
||||
if (extensionSupportedGLX("GLX_SGI_swap_control"))
|
||||
@ -378,7 +374,7 @@ GLFWbool _glfwInitGLX(void)
|
||||
getProcAddressGLX("glXSwapIntervalSGI");
|
||||
|
||||
if (_glfw.glx.SwapIntervalSGI)
|
||||
_glfw.glx.SGI_swap_control = GLFW_TRUE;
|
||||
_glfw.glx.SGI_swap_control = true;
|
||||
}
|
||||
|
||||
if (extensionSupportedGLX("GLX_MESA_swap_control"))
|
||||
@ -387,17 +383,17 @@ GLFWbool _glfwInitGLX(void)
|
||||
getProcAddressGLX("glXSwapIntervalMESA");
|
||||
|
||||
if (_glfw.glx.SwapIntervalMESA)
|
||||
_glfw.glx.MESA_swap_control = GLFW_TRUE;
|
||||
_glfw.glx.MESA_swap_control = true;
|
||||
}
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_multisample"))
|
||||
_glfw.glx.ARB_multisample = GLFW_TRUE;
|
||||
_glfw.glx.ARB_multisample = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
|
||||
_glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
|
||||
_glfw.glx.ARB_framebuffer_sRGB = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
|
||||
_glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
|
||||
_glfw.glx.EXT_framebuffer_sRGB = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_create_context"))
|
||||
{
|
||||
@ -405,39 +401,34 @@ GLFWbool _glfwInitGLX(void)
|
||||
getProcAddressGLX("glXCreateContextAttribsARB");
|
||||
|
||||
if (_glfw.glx.CreateContextAttribsARB)
|
||||
_glfw.glx.ARB_create_context = GLFW_TRUE;
|
||||
_glfw.glx.ARB_create_context = true;
|
||||
}
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
|
||||
_glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
|
||||
_glfw.glx.ARB_create_context_robustness = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
|
||||
_glfw.glx.ARB_create_context_profile = GLFW_TRUE;
|
||||
_glfw.glx.ARB_create_context_profile = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
|
||||
_glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
|
||||
_glfw.glx.EXT_create_context_es2_profile = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
|
||||
_glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
|
||||
_glfw.glx.ARB_create_context_no_error = true;
|
||||
|
||||
if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
|
||||
_glfw.glx.ARB_context_flush_control = GLFW_TRUE;
|
||||
_glfw.glx.ARB_context_flush_control = true;
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
// Terminate GLX
|
||||
//
|
||||
void _glfwTerminateGLX(void)
|
||||
{
|
||||
// NOTE: This function must not call any X11 functions, as it is called
|
||||
// after XCloseDisplay (see _glfwTerminateX11 for details)
|
||||
|
||||
if (_glfw.glx.handle)
|
||||
{
|
||||
_glfwPlatformFreeModule(_glfw.glx.handle);
|
||||
_glfw.glx.handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define SET_ATTRIB(a, v) \
|
||||
@ -447,8 +438,6 @@ void _glfwTerminateGLX(void)
|
||||
attribs[index++] = v; \
|
||||
}
|
||||
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
@ -626,6 +615,8 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
window->context.glx.fbconfig = native;
|
||||
|
||||
window->context.makeCurrent = makeContextCurrentGLX;
|
||||
window->context.swapBuffers = swapBuffersGLX;
|
||||
window->context.swapInterval = swapIntervalGLX;
|
||||
@ -677,7 +668,6 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
||||
|
||||
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
|
||||
@ -686,6 +676,9 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
@ -697,7 +690,6 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
|
||||
|
||||
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(None);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
|
||||
@ -706,6 +698,9 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
|
||||
return None;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
@ -715,5 +710,29 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
|
||||
return window->context.glx.window;
|
||||
}
|
||||
|
||||
GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* handle, GLXFBConfig* config)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_X11)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
assert(config != NULL);
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
*config = window->context.glx.fbconfig;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
#endif // _GLFW_X11
|
||||
|
||||
|
||||
10
src/external/glfw/src/init.c
vendored
Normal file → Executable file
10
src/external/glfw/src/init.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -49,18 +49,18 @@ static GLFWerrorfun _glfwErrorCallback;
|
||||
static GLFWallocator _glfwInitAllocator;
|
||||
static _GLFWinitconfig _glfwInitHints =
|
||||
{
|
||||
.hatButtons = GLFW_TRUE,
|
||||
.hatButtons = true,
|
||||
.angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE,
|
||||
.platformID = GLFW_ANY_PLATFORM,
|
||||
.vulkanLoader = NULL,
|
||||
.ns =
|
||||
{
|
||||
.menubar = GLFW_TRUE,
|
||||
.chdir = GLFW_TRUE
|
||||
.menubar = true,
|
||||
.chdir = true
|
||||
},
|
||||
.x11 =
|
||||
{
|
||||
.xcbVulkanSurface = GLFW_TRUE,
|
||||
.xcbVulkanSurface = true,
|
||||
},
|
||||
.wl =
|
||||
{
|
||||
|
||||
92
src/external/glfw/src/input.c
vendored
Normal file → Executable file
92
src/external/glfw/src/input.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -333,10 +333,8 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool
|
||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(xoffset > -FLT_MAX);
|
||||
assert(xoffset < FLT_MAX);
|
||||
assert(yoffset > -FLT_MAX);
|
||||
assert(yoffset < FLT_MAX);
|
||||
assert(isfinite(xoffset));
|
||||
assert(isfinite(yoffset));
|
||||
|
||||
if (window->callbacks.scroll)
|
||||
window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
|
||||
@ -348,20 +346,22 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(button >= 0);
|
||||
assert(button <= GLFW_MOUSE_BUTTON_LAST);
|
||||
assert(action == GLFW_PRESS || action == GLFW_RELEASE);
|
||||
assert(mods == (mods & GLFW_MOD_MASK));
|
||||
|
||||
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||
if (button < 0 || (!window->disableMouseButtonLimit && button > GLFW_MOUSE_BUTTON_LAST))
|
||||
return;
|
||||
|
||||
if (!window->lockKeyMods)
|
||||
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
|
||||
|
||||
if (button <= GLFW_MOUSE_BUTTON_LAST)
|
||||
{
|
||||
if (action == GLFW_RELEASE && window->stickyMouseButtons)
|
||||
window->mouseButtons[button] = _GLFW_STICK;
|
||||
else
|
||||
window->mouseButtons[button] = (char) action;
|
||||
}
|
||||
|
||||
if (window->callbacks.mouseButton)
|
||||
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
|
||||
@ -373,10 +373,8 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
||||
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
|
||||
{
|
||||
assert(window != NULL);
|
||||
assert(xpos > -FLT_MAX);
|
||||
assert(xpos < FLT_MAX);
|
||||
assert(ypos > -FLT_MAX);
|
||||
assert(ypos < FLT_MAX);
|
||||
assert(isfinite(xpos));
|
||||
assert(isfinite(ypos));
|
||||
|
||||
if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
|
||||
return;
|
||||
@ -434,6 +432,7 @@ void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
|
||||
assert(js != NULL);
|
||||
assert(axis >= 0);
|
||||
assert(axis < js->axisCount);
|
||||
assert(isfinite(value));
|
||||
|
||||
js->axes[axis] = value;
|
||||
}
|
||||
@ -559,11 +558,11 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window)
|
||||
|
||||
GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case GLFW_CURSOR:
|
||||
@ -576,6 +575,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
|
||||
return window->lockKeyMods;
|
||||
case GLFW_RAW_MOUSE_MOTION:
|
||||
return window->rawMouseMotion;
|
||||
case GLFW_UNLIMITED_MOUSE_BUTTONS:
|
||||
return window->disableMouseButtonLimit;
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||
@ -584,11 +585,11 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
|
||||
|
||||
GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case GLFW_CURSOR:
|
||||
@ -683,6 +684,12 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
||||
_glfw.platform.setRawMouseMotion(window, value);
|
||||
return;
|
||||
}
|
||||
|
||||
case GLFW_UNLIMITED_MOUSE_BUTTONS:
|
||||
{
|
||||
window->disableMouseButtonLimit = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||
@ -734,11 +741,11 @@ GLFWAPI int glfwGetKeyScancode(int key)
|
||||
|
||||
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
|
||||
|
||||
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
|
||||
@ -757,11 +764,11 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
|
||||
|
||||
GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
|
||||
|
||||
if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
|
||||
@ -780,9 +787,6 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
|
||||
|
||||
GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
if (ypos)
|
||||
@ -790,6 +794,9 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
if (xpos)
|
||||
@ -803,13 +810,12 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
|
||||
|
||||
GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
|
||||
ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
|
||||
if (!isfinite(xpos) || !isfinite(ypos))
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
"Invalid cursor position %f %f",
|
||||
@ -897,10 +903,10 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
|
||||
|
||||
GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
||||
{
|
||||
_GLFWcursor* cursor = (_GLFWcursor*) handle;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWcursor* cursor = (_GLFWcursor*) handle;
|
||||
|
||||
if (cursor == NULL)
|
||||
return;
|
||||
|
||||
@ -932,12 +938,12 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
|
||||
|
||||
GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) windowHandle;
|
||||
_GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
window->cursor = cursor;
|
||||
|
||||
_glfw.platform.setCursor(window, cursor);
|
||||
@ -945,30 +951,33 @@ GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
|
||||
|
||||
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
@ -976,10 +985,11 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmods
|
||||
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
||||
GLFWmousebuttonfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
@ -987,10 +997,11 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
|
||||
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||
GLFWcursorposfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
@ -998,10 +1009,11 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
|
||||
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
||||
GLFWcursorenterfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
@ -1009,20 +1021,22 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
|
||||
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
|
||||
GLFWscrollfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
_GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun);
|
||||
return cbfun;
|
||||
}
|
||||
@ -1481,7 +1495,7 @@ GLFWAPI void glfwSetTime(double time)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (time != time || time < 0.0 || time > 18446744073.0)
|
||||
if (!isfinite(time) || time < 0.0 || time > 18446744073.0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
|
||||
return;
|
||||
|
||||
114
src/external/glfw/src/internal.h
vendored
Normal file → Executable file
114
src/external/glfw/src/internal.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -48,6 +48,8 @@
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include "../include/GLFW/glfw3.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define _GLFW_INSERT_FIRST 0
|
||||
#define _GLFW_INSERT_LAST 1
|
||||
|
||||
@ -107,6 +109,7 @@ typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
|
||||
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
|
||||
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
|
||||
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
|
||||
typedef void (APIENTRY * PFNGLFLUSHPROC)(void);
|
||||
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
@ -150,6 +153,9 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
|
||||
#define EGL_NO_DISPLAY ((EGLDisplay) 0)
|
||||
#define EGL_NO_CONTEXT ((EGLContext) 0)
|
||||
#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
|
||||
#define EGL_PBUFFER_BIT 0x0001
|
||||
#define EGL_WIDTH 0x3057
|
||||
#define EGL_HEIGHT 0x3056
|
||||
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
|
||||
@ -181,6 +187,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
|
||||
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
|
||||
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
|
||||
#define EGL_PLATFORM_SURFACELESS_MESA 0x31dd
|
||||
|
||||
typedef int EGLint;
|
||||
typedef unsigned int EGLBoolean;
|
||||
@ -205,6 +212,7 @@ typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLCon
|
||||
typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
|
||||
typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
|
||||
typedef EGLSurface (APIENTRY * PFN_eglCreatePbufferSurface)(EGLDisplay,EGLContext,const EGLint*);
|
||||
typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
|
||||
typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
|
||||
typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
|
||||
@ -221,6 +229,7 @@ typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*);
|
||||
#define eglDestroySurface _glfw.egl.DestroySurface
|
||||
#define eglDestroyContext _glfw.egl.DestroyContext
|
||||
#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
|
||||
#define eglCreatePbufferSurface _glfw.egl.CreatePbufferSurface
|
||||
#define eglMakeCurrent _glfw.egl.MakeCurrent
|
||||
#define eglSwapBuffers _glfw.egl.SwapBuffers
|
||||
#define eglSwapInterval _glfw.egl.SwapInterval
|
||||
@ -277,6 +286,7 @@ typedef enum VkStructureType
|
||||
VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
|
||||
VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
|
||||
VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
|
||||
VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000,
|
||||
VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
|
||||
} VkStructureType;
|
||||
|
||||
@ -365,16 +375,16 @@ struct _GLFWerror
|
||||
//
|
||||
struct _GLFWinitconfig
|
||||
{
|
||||
GLFWbool hatButtons;
|
||||
bool hatButtons;
|
||||
int angleType;
|
||||
int platformID;
|
||||
PFN_vkGetInstanceProcAddr vulkanLoader;
|
||||
struct {
|
||||
GLFWbool menubar;
|
||||
GLFWbool chdir;
|
||||
bool menubar;
|
||||
bool chdir;
|
||||
} ns;
|
||||
struct {
|
||||
GLFWbool xcbVulkanSurface;
|
||||
bool xcbVulkanSurface;
|
||||
} x11;
|
||||
struct {
|
||||
int libdecorMode;
|
||||
@ -393,19 +403,18 @@ struct _GLFWwndconfig
|
||||
int ypos;
|
||||
int width;
|
||||
int height;
|
||||
const char* title;
|
||||
GLFWbool resizable;
|
||||
GLFWbool visible;
|
||||
GLFWbool decorated;
|
||||
GLFWbool focused;
|
||||
GLFWbool autoIconify;
|
||||
GLFWbool floating;
|
||||
GLFWbool maximized;
|
||||
GLFWbool centerCursor;
|
||||
GLFWbool focusOnShow;
|
||||
GLFWbool mousePassthrough;
|
||||
GLFWbool scaleToMonitor;
|
||||
GLFWbool scaleFramebuffer;
|
||||
bool resizable;
|
||||
bool visible;
|
||||
bool decorated;
|
||||
bool focused;
|
||||
bool autoIconify;
|
||||
bool floating;
|
||||
bool maximized;
|
||||
bool centerCursor;
|
||||
bool focusOnShow;
|
||||
bool mousePassthrough;
|
||||
bool scaleToMonitor;
|
||||
bool scaleFramebuffer;
|
||||
struct {
|
||||
char frameName[256];
|
||||
} ns;
|
||||
@ -414,8 +423,8 @@ struct _GLFWwndconfig
|
||||
char instanceName[256];
|
||||
} x11;
|
||||
struct {
|
||||
GLFWbool keymenu;
|
||||
GLFWbool showDefault;
|
||||
bool keymenu;
|
||||
bool showDefault;
|
||||
} win32;
|
||||
struct {
|
||||
char appId[256];
|
||||
@ -434,15 +443,15 @@ struct _GLFWctxconfig
|
||||
int source;
|
||||
int major;
|
||||
int minor;
|
||||
GLFWbool forward;
|
||||
GLFWbool debug;
|
||||
GLFWbool noerror;
|
||||
bool forward;
|
||||
bool debug;
|
||||
bool noerror;
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
_GLFWwindow* share;
|
||||
struct {
|
||||
GLFWbool offline;
|
||||
bool offline;
|
||||
} nsgl;
|
||||
};
|
||||
|
||||
@ -467,11 +476,11 @@ struct _GLFWfbconfig
|
||||
int accumBlueBits;
|
||||
int accumAlphaBits;
|
||||
int auxBuffers;
|
||||
GLFWbool stereo;
|
||||
bool stereo;
|
||||
int samples;
|
||||
GLFWbool sRGB;
|
||||
GLFWbool doublebuffer;
|
||||
GLFWbool transparent;
|
||||
bool sRGB;
|
||||
bool doublebuffer;
|
||||
bool transparent;
|
||||
uintptr_t handle;
|
||||
};
|
||||
|
||||
@ -490,6 +499,7 @@ struct _GLFWcontext
|
||||
PFNGLGETSTRINGIPROC GetStringi;
|
||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||
PFNGLGETSTRINGPROC GetString;
|
||||
PFNGLFLUSHPROC Flush;
|
||||
|
||||
void (*makeCurrent)(_GLFWwindow*);
|
||||
void (*swapBuffers)(_GLFWwindow*);
|
||||
@ -544,6 +554,7 @@ struct _GLFWwindow
|
||||
GLFWbool stickyKeys;
|
||||
GLFWbool stickyMouseButtons;
|
||||
GLFWbool lockKeyMods;
|
||||
GLFWbool disableMouseButtonLimit;
|
||||
int cursorMode;
|
||||
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||
char keys[GLFW_KEY_LAST + 1];
|
||||
@ -796,21 +807,22 @@ struct _GLFWlibrary
|
||||
EGLint major, minor;
|
||||
GLFWbool prefix;
|
||||
|
||||
GLFWbool KHR_create_context;
|
||||
GLFWbool KHR_create_context_no_error;
|
||||
GLFWbool KHR_gl_colorspace;
|
||||
GLFWbool KHR_get_all_proc_addresses;
|
||||
GLFWbool KHR_context_flush_control;
|
||||
GLFWbool EXT_client_extensions;
|
||||
GLFWbool EXT_platform_base;
|
||||
GLFWbool EXT_platform_x11;
|
||||
GLFWbool EXT_platform_wayland;
|
||||
GLFWbool EXT_present_opaque;
|
||||
GLFWbool ANGLE_platform_angle;
|
||||
GLFWbool ANGLE_platform_angle_opengl;
|
||||
GLFWbool ANGLE_platform_angle_d3d;
|
||||
GLFWbool ANGLE_platform_angle_vulkan;
|
||||
GLFWbool ANGLE_platform_angle_metal;
|
||||
bool KHR_create_context;
|
||||
bool KHR_create_context_no_error;
|
||||
bool KHR_gl_colorspace;
|
||||
bool KHR_get_all_proc_addresses;
|
||||
bool KHR_context_flush_control;
|
||||
bool EXT_client_extensions;
|
||||
bool EXT_platform_base;
|
||||
bool EXT_platform_x11;
|
||||
bool EXT_platform_wayland;
|
||||
bool EXT_present_opaque;
|
||||
bool ANGLE_platform_angle;
|
||||
bool ANGLE_platform_angle_opengl;
|
||||
bool ANGLE_platform_angle_d3d;
|
||||
bool ANGLE_platform_angle_vulkan;
|
||||
bool ANGLE_platform_angle_metal;
|
||||
bool MESA_platform_surfaceless;
|
||||
|
||||
void* handle;
|
||||
|
||||
@ -825,6 +837,7 @@ struct _GLFWlibrary
|
||||
PFN_eglDestroySurface DestroySurface;
|
||||
PFN_eglDestroyContext DestroyContext;
|
||||
PFN_eglCreateWindowSurface CreateWindowSurface;
|
||||
PFN_eglCreatePbufferSurface CreatePbufferSurface;
|
||||
PFN_eglMakeCurrent MakeCurrent;
|
||||
PFN_eglSwapBuffers SwapBuffers;
|
||||
PFN_eglSwapInterval SwapInterval;
|
||||
@ -853,13 +866,14 @@ struct _GLFWlibrary
|
||||
void* handle;
|
||||
char* extensions[2];
|
||||
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
|
||||
GLFWbool KHR_surface;
|
||||
GLFWbool KHR_win32_surface;
|
||||
GLFWbool MVK_macos_surface;
|
||||
GLFWbool EXT_metal_surface;
|
||||
GLFWbool KHR_xlib_surface;
|
||||
GLFWbool KHR_xcb_surface;
|
||||
GLFWbool KHR_wayland_surface;
|
||||
bool KHR_surface;
|
||||
bool KHR_win32_surface;
|
||||
bool MVK_macos_surface;
|
||||
bool EXT_metal_surface;
|
||||
bool KHR_xlib_surface;
|
||||
bool KHR_xcb_surface;
|
||||
bool KHR_wayland_surface;
|
||||
bool EXT_headless_surface;
|
||||
} vk;
|
||||
|
||||
struct {
|
||||
|
||||
3
src/external/glfw/src/linux_joystick.c
vendored
Normal file → Executable file
3
src/external/glfw/src/linux_joystick.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Linux - www.glfw.org
|
||||
// GLFW 3.5 Linux - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -32,6 +32,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
|
||||
2
src/external/glfw/src/linux_joystick.h
vendored
Normal file → Executable file
2
src/external/glfw/src/linux_joystick.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 Linux - www.glfw.org
|
||||
// GLFW 3.5 Linux - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
|
||||
//
|
||||
|
||||
10
src/external/glfw/src/cocoa_time.c → src/external/glfw/src/macos_time.c
vendored
Normal file → Executable file
10
src/external/glfw/src/cocoa_time.c → src/external/glfw/src/macos_time.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
// GLFW 3.5 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#if defined(GLFW_BUILD_COCOA_TIMER)
|
||||
#if defined(GLFW_BUILD_MACOS_TIMER)
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
@ -40,7 +40,7 @@ void _glfwPlatformInitTimer(void)
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
|
||||
_glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
|
||||
_glfw.timer.macos.frequency = (info.denom * 1e9) / info.numer;
|
||||
}
|
||||
|
||||
uint64_t _glfwPlatformGetTimerValue(void)
|
||||
@ -50,8 +50,8 @@ uint64_t _glfwPlatformGetTimerValue(void)
|
||||
|
||||
uint64_t _glfwPlatformGetTimerFrequency(void)
|
||||
{
|
||||
return _glfw.timer.ns.frequency;
|
||||
return _glfw.timer.macos.frequency;
|
||||
}
|
||||
|
||||
#endif // GLFW_BUILD_COCOA_TIMER
|
||||
#endif // GLFW_BUILD_MACOS_TIMER
|
||||
|
||||
10
src/external/glfw/src/cocoa_time.h → src/external/glfw/src/macos_time.h
vendored
Normal file → Executable file
10
src/external/glfw/src/cocoa_time.h → src/external/glfw/src/macos_time.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
// GLFW 3.5 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2021 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@ -24,12 +24,12 @@
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns;
|
||||
#define GLFW_MACOS_LIBRARY_TIMER_STATE _GLFWtimerMacOS macos;
|
||||
|
||||
// Cocoa-specific global timer data
|
||||
// macOS-specific global timer data
|
||||
//
|
||||
typedef struct _GLFWtimerNS
|
||||
typedef struct _GLFWtimerMacOS
|
||||
{
|
||||
uint64_t frequency;
|
||||
} _GLFWtimerNS;
|
||||
} _GLFWtimerMacOS;
|
||||
|
||||
2116
src/external/glfw/src/mappings.h
vendored
Normal file → Executable file
2116
src/external/glfw/src/mappings.h
vendored
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
2
src/external/glfw/src/mappings.h.in
vendored
Normal file → Executable file
2
src/external/glfw/src/mappings.h.in
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
62
src/external/glfw/src/monitor.c
vendored
Normal file → Executable file
62
src/external/glfw/src/monitor.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -325,9 +325,6 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
|
||||
|
||||
GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
if (ypos)
|
||||
@ -335,6 +332,9 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_glfw.platform.getMonitorPos(monitor, xpos, ypos);
|
||||
}
|
||||
|
||||
@ -342,9 +342,6 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
||||
int* xpos, int* ypos,
|
||||
int* width, int* height)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (xpos)
|
||||
*xpos = 0;
|
||||
if (ypos)
|
||||
@ -356,14 +353,14 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (widthMM)
|
||||
*widthMM = 0;
|
||||
if (heightMM)
|
||||
@ -371,6 +368,9 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int*
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (widthMM)
|
||||
*widthMM = monitor->widthMM;
|
||||
if (heightMM)
|
||||
@ -380,42 +380,46 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int*
|
||||
GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
|
||||
float* xscale, float* yscale)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (xscale)
|
||||
*xscale = 0.f;
|
||||
if (yscale)
|
||||
*yscale = 0.f;
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_glfw.platform.getMonitorContentScale(monitor, xscale, yscale);
|
||||
}
|
||||
|
||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return monitor->name;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
monitor->userPointer = pointer;
|
||||
}
|
||||
|
||||
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return monitor->userPointer;
|
||||
}
|
||||
|
||||
@ -428,14 +432,15 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||
|
||||
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
assert(count != NULL);
|
||||
|
||||
*count = 0;
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (!refreshVideoModes(monitor))
|
||||
return NULL;
|
||||
|
||||
@ -445,11 +450,11 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
|
||||
|
||||
GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
if (!_glfw.platform.getVideoMode(monitor, &monitor->currentMode))
|
||||
return NULL;
|
||||
|
||||
@ -462,13 +467,15 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
||||
unsigned short* values;
|
||||
GLFWgammaramp ramp;
|
||||
const GLFWgammaramp* original;
|
||||
assert(handle != NULL);
|
||||
|
||||
assert(gamma > 0.f);
|
||||
assert(gamma <= FLT_MAX);
|
||||
assert(isfinite(gamma));
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
|
||||
assert(handle != NULL);
|
||||
|
||||
if (!isfinite(gamma) || gamma <= 0.f)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
|
||||
return;
|
||||
@ -505,11 +512,11 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
||||
|
||||
GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_glfwFreeGammaArrays(&monitor->currentRamp);
|
||||
if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp))
|
||||
return NULL;
|
||||
@ -519,8 +526,6 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
|
||||
|
||||
GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||
{
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
assert(ramp != NULL);
|
||||
assert(ramp->size > 0);
|
||||
assert(ramp->red != NULL);
|
||||
@ -529,6 +534,9 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
|
||||
|
||||
_GLFW_REQUIRE_INIT();
|
||||
|
||||
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||
assert(monitor != NULL);
|
||||
|
||||
if (ramp->size <= 0)
|
||||
{
|
||||
_glfwInputError(GLFW_INVALID_VALUE,
|
||||
|
||||
26
src/external/glfw/src/nsgl_context.m
vendored
Normal file → Executable file
26
src/external/glfw/src/nsgl_context.m
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 macOS - www.glfw.org
|
||||
// GLFW 3.5 macOS - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
static void makeContextCurrentNSGL(_GLFWwindow* window)
|
||||
{
|
||||
@ -127,8 +128,6 @@ static void destroyContextNSGL(_GLFWwindow* window)
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Initialize OpenGL support
|
||||
//
|
||||
GLFWbool _glfwInitNSGL(void)
|
||||
{
|
||||
if (_glfw.nsgl.framework)
|
||||
@ -146,14 +145,10 @@ GLFWbool _glfwInitNSGL(void)
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
// Terminate OpenGL support
|
||||
//
|
||||
void _glfwTerminateNSGL(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Create the OpenGL context
|
||||
//
|
||||
GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
@ -182,16 +177,16 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
// Context robustness modes (GL_KHR_robustness) are not yet supported by
|
||||
// Context robustness modes (GL_KHR_robustness) are not supported by
|
||||
// macOS but are not a hard constraint, so ignore and continue
|
||||
|
||||
// Context release behaviors (GL_KHR_context_flush_control) are not yet
|
||||
// Context release behaviors (GL_KHR_context_flush_control) are not
|
||||
// supported by macOS but are not a hard constraint, so ignore and continue
|
||||
|
||||
// Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not
|
||||
// Debug contexts (GL_KHR_debug) are not supported by macOS but are not
|
||||
// a hard constraint, so ignore and continue
|
||||
|
||||
// No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
|
||||
// No-error contexts (GL_KHR_no_error) are not supported by macOS but
|
||||
// are not a hard constraint, so ignore and continue
|
||||
|
||||
#define ADD_ATTRIB(a) \
|
||||
@ -217,14 +212,11 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching);
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||
if (ctxconfig->major >= 4)
|
||||
{
|
||||
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
|
||||
}
|
||||
else
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
if (ctxconfig->major >= 3)
|
||||
else if (ctxconfig->major >= 3)
|
||||
{
|
||||
SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
|
||||
}
|
||||
@ -361,7 +353,6 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
|
||||
GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(nil);
|
||||
|
||||
if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA)
|
||||
@ -371,6 +362,9 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
|
||||
return nil;
|
||||
}
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_NATIVE_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
|
||||
3
src/external/glfw/src/null_init.c
vendored
Normal file → Executable file
3
src/external/glfw/src/null_init.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -260,5 +260,6 @@ void _glfwTerminateNull(void)
|
||||
free(_glfw.null.clipboardString);
|
||||
_glfwTerminateOSMesa();
|
||||
_glfwTerminateEGL();
|
||||
memset(&_glfw.null, 0, sizeof(_glfw.null));
|
||||
}
|
||||
|
||||
|
||||
2
src/external/glfw/src/null_joystick.c
vendored
Normal file → Executable file
2
src/external/glfw/src/null_joystick.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
2
src/external/glfw/src/null_joystick.h
vendored
Normal file → Executable file
2
src/external/glfw/src/null_joystick.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
|
||||
2
src/external/glfw/src/null_monitor.c
vendored
Normal file → Executable file
2
src/external/glfw/src/null_monitor.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
|
||||
13
src/external/glfw/src/null_platform.h
vendored
Normal file → Executable file
13
src/external/glfw/src/null_platform.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -156,6 +156,17 @@
|
||||
#define GLFW_NULL_SC_MENU 120
|
||||
#define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU
|
||||
|
||||
typedef VkFlags VkHeadlessSurfaceCreateFlagsEXT;
|
||||
|
||||
typedef struct VkHeadlessSurfaceCreateInfoEXT
|
||||
{
|
||||
VkStructureType sType;
|
||||
const void* pNext;
|
||||
VkHeadlessSurfaceCreateFlagsEXT flags;
|
||||
} VkHeadlessSurfaceCreateInfoEXT;
|
||||
|
||||
typedef VkResult (APIENTRY *PFN_vkCreateHeadlessSurfaceEXT)(VkInstance,const VkHeadlessSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
|
||||
|
||||
// Null-specific per-window data
|
||||
//
|
||||
typedef struct _GLFWwindowNull
|
||||
|
||||
55
src/external/glfw/src/null_window.c
vendored
Normal file → Executable file
55
src/external/glfw/src/null_window.c
vendored
Normal file → Executable file
@ -1,9 +1,8 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 (modified for raylib) - www.glfw.org; www.raylib.com
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
@ -29,6 +28,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
|
||||
{
|
||||
@ -60,12 +60,12 @@ static void fitToMonitor(_GLFWwindow* window)
|
||||
window->null.height = mode.height;
|
||||
}
|
||||
|
||||
static void acquireMonitorNull(_GLFWwindow* window)
|
||||
static void acquireMonitor(_GLFWwindow* window)
|
||||
{
|
||||
_glfwInputMonitorWindow(window->monitor, window);
|
||||
}
|
||||
|
||||
static void releaseMonitorNull(_GLFWwindow* window)
|
||||
static void releaseMonitor(_GLFWwindow* window)
|
||||
{
|
||||
if (window->monitor->window != window)
|
||||
return;
|
||||
@ -148,7 +148,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
|
||||
{
|
||||
_glfwShowWindowNull(window);
|
||||
_glfwFocusWindowNull(window);
|
||||
acquireMonitorNull(window);
|
||||
acquireMonitor(window);
|
||||
|
||||
if (wndconfig->centerCursor)
|
||||
_glfwCenterCursorInContentArea(window);
|
||||
@ -169,7 +169,7 @@ GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
|
||||
void _glfwDestroyWindowNull(_GLFWwindow* window)
|
||||
{
|
||||
if (window->monitor)
|
||||
releaseMonitorNull(window);
|
||||
releaseMonitor(window);
|
||||
|
||||
if (_glfw.null.focusedWindow == window)
|
||||
_glfw.null.focusedWindow = NULL;
|
||||
@ -204,14 +204,14 @@ void _glfwSetWindowMonitorNull(_GLFWwindow* window,
|
||||
}
|
||||
|
||||
if (window->monitor)
|
||||
releaseMonitorNull(window);
|
||||
releaseMonitor(window);
|
||||
|
||||
_glfwInputWindowMonitor(window, monitor);
|
||||
|
||||
if (window->monitor)
|
||||
{
|
||||
window->null.visible = GLFW_TRUE;
|
||||
acquireMonitorNull(window);
|
||||
acquireMonitor(window);
|
||||
fitToMonitor(window);
|
||||
}
|
||||
else
|
||||
@ -341,7 +341,7 @@ void _glfwIconifyWindowNull(_GLFWwindow* window)
|
||||
_glfwInputWindowIconify(window, GLFW_TRUE);
|
||||
|
||||
if (window->monitor)
|
||||
releaseMonitorNull(window);
|
||||
releaseMonitor(window);
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ void _glfwRestoreWindowNull(_GLFWwindow* window)
|
||||
_glfwInputWindowIconify(window, GLFW_FALSE);
|
||||
|
||||
if (window->monitor)
|
||||
acquireMonitorNull(window);
|
||||
acquireMonitor(window);
|
||||
}
|
||||
else if (window->null.maximized)
|
||||
{
|
||||
@ -553,12 +553,15 @@ const char* _glfwGetClipboardStringNull(void)
|
||||
|
||||
EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
|
||||
{
|
||||
if (_glfw.egl.EXT_platform_base && _glfw.egl.MESA_platform_surfaceless)
|
||||
return EGL_PLATFORM_SURFACELESS_MESA;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
|
||||
{
|
||||
return 0;
|
||||
return EGL_DEFAULT_DISPLAY;
|
||||
}
|
||||
|
||||
EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
|
||||
@ -700,13 +703,18 @@ int _glfwGetKeyScancodeNull(int key)
|
||||
|
||||
void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
|
||||
{
|
||||
if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_headless_surface)
|
||||
return;
|
||||
|
||||
extensions[0] = "VK_KHR_surface";
|
||||
extensions[1] = "VK_EXT_headless_surface";
|
||||
}
|
||||
|
||||
GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
|
||||
VkPhysicalDevice device,
|
||||
uint32_t queuefamily)
|
||||
{
|
||||
return GLFW_FALSE;
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
|
||||
@ -714,7 +722,28 @@ VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
|
||||
const VkAllocationCallbacks* allocator,
|
||||
VkSurfaceKHR* surface)
|
||||
{
|
||||
// This seems like the most appropriate error to return here
|
||||
PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT =
|
||||
(PFN_vkCreateHeadlessSurfaceEXT)
|
||||
vkGetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT");
|
||||
if (!vkCreateHeadlessSurfaceEXT)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"Null: Vulkan instance missing VK_EXT_headless_surface extension");
|
||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||
}
|
||||
|
||||
VkHeadlessSurfaceCreateInfoEXT sci;
|
||||
memset(&sci, 0, sizeof(sci));
|
||||
sci.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT;
|
||||
|
||||
const VkResult err = vkCreateHeadlessSurfaceEXT(instance, &sci, allocator, surface);
|
||||
if (err)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Null: Failed to create Vulkan surface: %s",
|
||||
_glfwGetVulkanResultString(err));
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
19
src/external/glfw/src/osmesa_context.c
vendored
Normal file → Executable file
19
src/external/glfw/src/osmesa_context.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 OSMesa - www.glfw.org
|
||||
// GLFW 3.5 OSMesa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2016 Google Inc.
|
||||
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -180,11 +180,8 @@ GLFWbool _glfwInitOSMesa(void)
|
||||
|
||||
void _glfwTerminateOSMesa(void)
|
||||
{
|
||||
if (_glfw.osmesa.handle)
|
||||
{
|
||||
_glfwPlatformFreeModule(_glfw.osmesa.handle);
|
||||
_glfw.osmesa.handle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#define SET_ATTRIB(a, v) \
|
||||
@ -296,11 +293,12 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
|
||||
{
|
||||
void* mesaBuffer;
|
||||
GLint mesaWidth, mesaHeight, mesaFormat;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
@ -335,11 +333,12 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
|
||||
{
|
||||
void* mesaBuffer;
|
||||
GLint mesaWidth, mesaHeight, mesaBytes;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
@ -369,9 +368,11 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
|
||||
|
||||
GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
assert(window != NULL);
|
||||
|
||||
if (window->context.source != GLFW_OSMESA_CONTEXT_API)
|
||||
{
|
||||
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
||||
|
||||
14
src/external/glfw/src/platform.c
vendored
Normal file → Executable file
14
src/external/glfw/src/platform.c
vendored
Normal file → Executable file
@ -1,9 +1,8 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 (modified for raylib) - www.glfw.org; www.raylib.com
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
// Copyright (c) 2024 M374LX <wilsalx@gmail.com>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
@ -75,6 +74,15 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
// Only allow the Null platform if specifically requested
|
||||
if (desiredID == GLFW_PLATFORM_NULL)
|
||||
return _glfwConnectNull(desiredID, platform);
|
||||
else if (count == 0)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
#if defined(_GLFW_WAYLAND) && defined(_GLFW_X11)
|
||||
if (desiredID == GLFW_ANY_PLATFORM)
|
||||
{
|
||||
@ -179,8 +187,6 @@ GLFWAPI const char* glfwGetVersionString(void)
|
||||
" OSMesa"
|
||||
#if defined(__MINGW64_VERSION_MAJOR)
|
||||
" MinGW-w64"
|
||||
#elif defined(__MINGW32__)
|
||||
" MinGW"
|
||||
#elif defined(_MSC_VER)
|
||||
" VisualC"
|
||||
#endif
|
||||
|
||||
13
src/external/glfw/src/platform.h
vendored
Normal file → Executable file
13
src/external/glfw/src/platform.h
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 - www.glfw.org
|
||||
// GLFW 3.5 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
|
||||
@ -28,7 +28,7 @@
|
||||
#if defined(GLFW_BUILD_WIN32_TIMER) || \
|
||||
defined(GLFW_BUILD_WIN32_MODULE) || \
|
||||
defined(GLFW_BUILD_WIN32_THREAD) || \
|
||||
defined(GLFW_BUILD_COCOA_TIMER) || \
|
||||
defined(GLFW_BUILD_MACOS_TIMER) || \
|
||||
defined(GLFW_BUILD_POSIX_TIMER) || \
|
||||
defined(GLFW_BUILD_POSIX_MODULE) || \
|
||||
defined(GLFW_BUILD_POSIX_THREAD) || \
|
||||
@ -184,7 +184,7 @@
|
||||
#if defined(_WIN32)
|
||||
#define GLFW_BUILD_WIN32_TIMER
|
||||
#elif defined(__APPLE__)
|
||||
#define GLFW_BUILD_COCOA_TIMER
|
||||
#define GLFW_BUILD_MACOS_TIMER
|
||||
#else
|
||||
#define GLFW_BUILD_POSIX_TIMER
|
||||
#endif
|
||||
@ -192,9 +192,9 @@
|
||||
#if defined(GLFW_BUILD_WIN32_TIMER)
|
||||
#include "win32_time.h"
|
||||
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE
|
||||
#elif defined(GLFW_BUILD_COCOA_TIMER)
|
||||
#include "cocoa_time.h"
|
||||
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE
|
||||
#elif defined(GLFW_BUILD_MACOS_TIMER)
|
||||
#include "macos_time.h"
|
||||
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_MACOS_LIBRARY_TIMER_STATE
|
||||
#elif defined(GLFW_BUILD_POSIX_TIMER)
|
||||
#include "posix_time.h"
|
||||
#define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE
|
||||
@ -207,6 +207,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(_GLFW_WAYLAND) || defined(_GLFW_X11)
|
||||
#include "posix_poll.h"
|
||||
#define GLFW_BUILD_POSIX_POLL
|
||||
#endif
|
||||
|
||||
|
||||
3
src/external/glfw/src/posix_module.c
vendored
Normal file → Executable file
3
src/external/glfw/src/posix_module.c
vendored
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
//========================================================================
|
||||
// GLFW 3.4 POSIX - www.glfw.org
|
||||
// GLFW 3.5 POSIX - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2021 Camilla Löwy <elmindreda@glfw.org>
|
||||
//
|
||||
@ -41,6 +41,7 @@ void* _glfwPlatformLoadModule(const char* path)
|
||||
|
||||
void _glfwPlatformFreeModule(void* module)
|
||||
{
|
||||
if (module)
|
||||
dlclose(module);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user