Commit graph

1183 commits

Author SHA1 Message Date
alexei-zebra
01ed8b7dc5
Fix 2D batch drawing with a stale texture binding
Batch2D cached the bound texture and skipped the bind when the cache
matched, but the render pipeline binds textures of its own and leaves a
non-zero texture unit active. A rectangle drawn without a texture (the
hud hotbar background and slot tiles) was then modulated by whatever
texture was left bound, which made the hotbar darken for a single frame
on every window resize.

The batch now draws from texture unit 0 and compares the cached texture
with the actual binding instead of trusting the cache.
2026-10-10 12:23:42 +03:00
alexei-zebra
b5416d1219
Fix the issues found while reviewing the Wayland frame work
A review of the branch turned up a number of defects, gaps and leftovers;
this commit addresses all of them.

Defects:
- the shadow uniform array held seven entries while eight locations were
  written, so the last one landed outside the object;
- CursorShape::LAST stayed in the middle of the enum after the new corner
  shapes were appended, which made the GLFW cursor table read out of
  bounds; the extra shapes are now mapped onto the ones GLFW knows, and
  the table is only filled for those;
- GlStateGuard asked glIsEnabled for an attribute pname, so it always got
  GL_INVALID_ENUM and never restored the vertex attribute arrays;
- the early returns in wayland_window_initialize left the global window
  and input pointers dangling when falling back to GLFW;
- the icon textures were listed nowhere, so none of them ever loaded;
- a shader failure disabled the shadow after the surface had already been
  sized for it, and VOXEL_DECORATIONS outlived the switch cleanup.

Behavior:
- the keyboard now releases every pressed key when it loses focus, and a
  repeat rate of zero means no repeat;
- the fourth UTF-8 lead byte is decoded with the right mask, control
  characters no longer reach text fields, and a vanished clipboard offer
  clears the cached text;
- compositor side decorations disable ours again instead of leaving two
  titles, the window destructor releases the rest of the state, and the
  content inset is computed before the GUI acts so the HUD and the
  container never disagree for a frame; the HUD clamps it;
- the window controls fall back to minimize, maximize and close, and the
  icons are drawn from textures only.

Cleanups: one monotonic timer instead of three, one vertex shader shared
by both renderers with a link check, one button layout parser, the inset
rule moved into Screen, the scissor stack moved into the base Window
(about 110 duplicated lines), named shadow and evdev constants, trimmed
includes, a README note about the Wayland dependencies, and the long
lines introduced by this branch wrapped.
2026-10-10 12:23:42 +03:00
alexei-zebra
c269d6efb3
Give the Wayland window an Adwaita-like frame
The engine-drawn title bar grew to 48 px with 24x24 window controls,
12 px away from the edge and from each other, all sharing one hover
highlight. The controls use textures now (gui/cross, gui/minimize_w,
gui/maximize_w and gui/restore_w when maximized) with the vector icons
kept as a fallback, and the title is centred in the bar, clamped to the
free space between the button groups.

The bar now sits inside invisible margins that carry a drop shadow, so
the window is resizable from outside the visible frame: the surface is
content plus twice SHADOW_MARGIN and xdg_surface.set_window_geometry
tells the compositor which part is the window. The shadow follows
Adwaita's window shadow: a Gaussian blur of 7 px (sigma 3.5) expanded by
1 px, rgba(0,0,0,0.5) focused and 0.3 in the backdrop, plus a 1 px
hairline, symmetric on all four sides - a 16 px wide frame would show a
fatter tail than the reference. Margins exist only while the window is
decorated by us and not maximized or fullscreen.

The engine composes the frame itself: it renders exactly as before, then
the backend copies the frame into a texture, clears the surface, draws
the shadow and puts the content in place with alpha forced to 1, which
keeps the frame opaque without touching a single render pass. Only
frames the engine actually drew are cached, and the EGL window is
resized before its surface size is asked for, so no frame is composed
from a buffer the compositor just replaced - that was the one frame
blink after a resize.

Resize cursors match GNOME: directional shapes for edges and corners
(w/e/n/s/ne/nw/se/sw) instead of the double-headed diagonals, with the
extra CursorShape values appended so the existing GLFW indices stay.

Measured: window 1123x751 opens as saved, fullscreen round trip returns
the same size with the settings untouched, the shadow alpha profile is
0.20/0.10/0.03 at 1/4/7 px from the edge against Adwaita's 0.21/0.095/
0.055, all four sides equal, menu layout baseline unchanged (706),
no errors in the log.
2026-10-10 12:23:41 +03:00
alexei-zebra
6c2192b5d8
Draw the window title bar by the engine
The native Wayland backend had no window controls: no title, no close
button, no way to move or resize the window, and the fullscreen toggle
could throw the window to another monitor. GNOME does not implement
zxdg_decoration_manager_v1, so there is nobody to draw a frame for us:
the backend now falls back to its own decorations when the compositor
offers no server side ones, and the engine draws the visible part.

The bar itself is drawn by the engine (WindowBar.cpp) through the usual
batch and font, so it uses the same assets as the rest of the UI and the
backend only owns the behaviour: hit zones, cursor shapes, click
interception and the xdg-shell requests. Its geometry follows the
desktop's button layout, read and subscribed through
xdg-desktop-portal over sd-bus (libsystemd is an optional dependency,
gsettings is only a startup fallback).

Controls behave like they do elsewhere:
- pressing anywhere on the bar starts a move once the pointer leaves a
  5 px radius, so dragging works from the buttons as well;
- a button acts on release, only if the pointer stayed on it;
- a double click on the bar toggles maximize;
- the top edge and the top corners resize, the top 8 px of the sides,
  the sides and the bottom are 8 px wide resize strips;
- right and middle clicks and the scroll wheel over the bar never reach
  the game.

The in-game user interface is offset below the bar while menus keep the
whole window, so the translucent bar shows the menu background through
itself and never covers the HUD. The HUD lays its elements out against
the content height and the cursor is translated once, which fixes items
following the mouse one row above the pointer in game.

The window size is now written to the settings when the window is
resized in windowed mode and applied on the first configure, so the
window opens with the size it was left with, and leaving fullscreen or
borderless mode restores it instead of overwriting the settings with the
fullscreen size (an unconditional unmaximize made the compositor restore
the maximized geometry).

Measured: menu layout unchanged (706 bright pixels in the same place),
gui viewport 1123x751 in menus against 1123x721 in game, 1123x751 ->
2560x1080 -> 1123x751 round trip keeps the settings, a saved 1000x640
opens as 1000x640, no errors in the log.
2026-10-10 12:23:41 +03:00
alexei-zebra
14fa7e5fd2
fix building without the Wayland backend
The backend sources live in window/wayland and were picked up by the
global source glob, so a build with VOXELENGINE_WAYLAND=OFF (and any
non-Linux build, where the option is skipped entirely) tried to compile
them and failed on the generated protocol headers.

They are now collected separately and added to the target only when the
backend is enabled.

Also restores the CRLF line endings of Engine.cpp, GUI.hpp and
input.cpp, which were rewritten with LF and made their diffs look like
whole-file rewrites.
2026-10-10 12:23:31 +03:00
alexei-zebra
3b337241f5
draw window decorations with the engine GUI
The bar used to be drawn by the Wayland backend with its own shader,
bitmap font and textures, straight into the engine's GL frame. That
leaked GL state (the batch caches bound textures, so the engine kept
sampling the backend texture and all text turned into solid white
rectangles) and it duplicated fonts and styling.

Now the backend only owns the behaviour: hit zones, cursor shapes,
click interception and the compositor requests (move, resize,
minimize, maximize/restore, close). The bar itself is drawn by the
engine in WindowBar.cpp through the regular Batch2D/Font path, so it
looks like the rest of the UI.

Window gained getTitle(), getDecorationHeight() and
getDecorationHoveredButton(); GLFW keeps the defaults, so X11 and
Windows are unaffected. The backend's decoration drawing (bitmap font,
shader, quad batches) is removed: WaylandBar.cpp went from 630 to 140
lines.

Fixes found while debugging:
- GlStateGuard was defined but never used after the file split, so the
  stretched frame left its texture bound and broke text rendering after
  a window mode change; it is now applied around the cache capture and
  the stretched frame;
- takeScreenshot() now reads the front buffer and restores the read
  buffer afterwards.
2026-10-10 12:23:18 +03:00
MihailRis
521ebf43ab remove incorrect fix 2026-10-10 11:36:31 +03:00
MihailRis
f036979dc0
Merge pull request #1007 from Astazium/ui-fixes
ui fixes
2026-10-10 11:34:34 +03:00
MihailRis
ef85592e21 fix chunks render limits 2026-10-05 21:21:33 +03:00
Astazium
5a0a1cf326 ui fixes 2026-09-30 20:43:43 +03:00
boolean-false
7211e99bc8 fix text width and caret positioning in text boxes 2026-09-29 20:31:14 +07:00
boolean-false
64ba1dad4e fix glyph positions 2026-09-27 17:33:55 +07:00
MihailRis
4946a25ca5
Merge pull request #990 from MihailRis/recursion-related-fixes
fix recursion-related bugs
2026-09-26 21:06:57 +03:00
MihailRis
c3b50b5ab2 fix recursive iframe 2026-09-26 20:28:20 +03:00
MihailRis
4f1411b005 fix infinite recursion on moveInto used to move to descendant node 2026-09-26 19:51:08 +03:00
MihailRis
e467c85adc add 'enable-fog' setting 2026-09-26 19:13:08 +03:00
MihailRis
56d2ab9f14 fix custom model blocks with disabled ambient-occlusion 2026-09-19 20:04:30 +03:00
MihailRis
e306624260 fix hand items lighting 2026-09-19 19:41:11 +03:00
MihailRis
8911cded07 add 'lighting-mode' entity property 2026-09-19 18:13:15 +03:00
MihailRis
69edfc8c8a add 'frame' argument to gui.screenshot 2026-09-17 22:07:18 +03:00
MihailRis
dbeeef90a8 cleanup a bit 2026-09-16 23:31:37 +03:00
MihailRis
ae082abaa2 feat: allow passing rgba color to entity skeletons and block wraps 2026-09-16 23:28:03 +03:00
MihailRis
eca7eeadee Merge branch 'main' into animation 2026-09-06 20:11:24 +03:00
MihailRis
9989f81196 fix weather effects render 2026-09-06 19:36:35 +03:00
MihailRis
8c1d8bd794 Merge branch 'main' into animation 2026-08-30 20:13:38 +03:00
MihailRis
bf50c37b82 fix containers scroll 2026-08-28 00:04:43 +03:00
MihailRis
8214f1bd09 fix blocks render at the top of the world 2026-08-26 18:06:05 +03:00
MihailRis
05fc09a244 Merge branch 'main' into animation 2026-08-26 12:30:31 +03:00
MihailRis
4c3bb93dc3 fix Panel::cropToContent 2026-08-25 21:09:02 +03:00
MihailRis
ab3c1e1b0c Merge branch 'main' into animation 2026-08-23 12:39:46 +03:00
MihailRis
f2018334cb fix Texture::reload 2026-08-22 17:39:01 +03:00
MihailRis
d20e9fcb40 Merge branch 'main' into animation 2026-08-22 00:36:25 +03:00
MihailRis
bd4d5f0e4b fix panel extra interval at end 2026-08-20 20:44:10 +03:00
MihailRis
1186011dcf Merge branch 'main' into animation 2026-08-18 23:37:27 +03:00
MihailRis
d54bb5bf54 change: flip the planet 2026-08-17 22:20:25 +03:00
MihailRis
22a9ab4b7a fix region again 2026-08-17 19:50:38 +03:00
MihailRis
98326627f5 revert "fix vcm texture sides"
This reverts commit 38bebac37e.
2026-08-17 17:27:03 +03:00
MihailRis
fa0f87349b fix blank texture overwritten by screen frame output 2026-08-17 17:19:54 +03:00
Neveix
3b3bf8e878
Inventory enhancements #897: 2, 5, 9, 11, 12 (#931)
* implement a bit

* change shift to ctrl

* add enhancement #2

* add ctrl-interaction with content access

* fix libinventory.move bug (none checking)

* fix p.5

* move shareinv logic into inventory_utils

* add inventory utils

* small refactor

* fix iframe.src = ""

---------

Co-authored-by: MihailRis <mexaruc@gmail.com>
2026-08-14 21:25:42 +03:00
MihailRis
49e7f2c631 Merge branch 'main' into animation 2026-08-14 19:46:37 +03:00
MihailRis
f8e4e2759b
Merge pull request #930 from Neveix/feat-inventory-enhancements
[WIP] Inventory enhancements
2026-08-14 00:56:52 +03:00
MihailRis
e2a65412bc fix iframe.src = "" 2026-08-13 23:52:01 +03:00
neveix
365ad8497f Merge branch 'main' into feat-inventory-enhancements 2026-08-14 01:09:07 +05:00
neveix
c2f7f33bbf revert creation of clickOutside 2026-08-14 00:59:55 +05:00
MihailRis
450b32d12e
Merge pull request #925 from MihailRis/more-about-ui
more about ui
2026-08-13 22:44:45 +03:00
MihailRis
44bdd57fe5 add 'onmiddleclick' ui event 2026-08-13 22:15:50 +03:00
MihailRis
60106d4fb1 update ModelViewer 2026-08-13 21:58:54 +03:00
neveix
2a4b8b0297 delete redundant imports 2026-08-13 21:02:53 +05:00
neveix
56c4d68c84 add item dropping outside of inventory 2026-08-13 20:56:59 +05:00
MihailRis
717d41e7a5 fix 3d text render 2026-08-11 23:10:44 +03:00