C++, BYE BYE!! BYE BYE!!!

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-08-10 06:38:23 +03:00
parent d154db1422
commit 4e23877697
14 changed files with 2049 additions and 3901 deletions

173
src/LunarWM.h Normal file
View File

@@ -0,0 +1,173 @@
#ifndef LUNAR_WM_H
#define LUNAR_WM_H
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES3/gl3.h>
#include <GLES3/gl31.h>
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
#include <wayland-client-protocol.h>
#include <wayland-egl.h>
#include <wayland-server-core.h>
#include <wlr/backend/session.h>
#include <wlr/backend/wayland.h>
#include <wlr/render/allocator.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/log.h>
#include <raylib.h>
#include <raymath.h>
#include <rlgl.h>
#include "common.h"
struct LunarWM;
typedef struct {
struct LunarWM *server;
struct wl_list link;
struct wlr_keyboard *wlr_keyboard;
struct wl_listener modifiers;
struct wl_listener key;
struct wl_listener destroy;
} LunarWM_Keyboard;
typedef struct {
struct LunarWM *server;
struct wl_listener commit;
struct wl_listener destroy;
struct wlr_xdg_toplevel *xdg_toplevel;
struct wlr_surface *surface;
struct wlr_texture *texture;
struct wlr_buffer *locked_buffer;
struct wlr_gles2_texture_attribs attribs;
struct wlr_gles2_texture *gles_texture;
Texture2D rl_texture;
} LunarWM_Toplevel;
bool LunarWM_Toplevel_init(
LunarWM_Toplevel *tl, struct LunarWM *wm, struct wlr_xdg_toplevel *xdg);
bool LunarWM_Toplevel_destroy(LunarWM_Toplevel *this);
bool LunarWM_Toplevel_update(LunarWM_Toplevel *this);
typedef struct {
XrSwapchain swapchain;
int64_t swapchain_format;
GLuint *v_image_views;
} LunarWM_SwapchainInfo;
typedef struct {
XrSwapchain handle;
XrSwapchainImageOpenGLESKHR *a_imgs;
uint32_t a_imgs_count;
} LunarWM_SwapchainImagesEntry;
typedef struct {
XrHandJointLocationEXT joint_locations[XR_HAND_JOINT_COUNT_EXT];
XrHandTrackerEXT hand_tracker;
} LunarWM_Hand;
typedef struct {
XrTime predicted_display_time;
XrCompositionLayerProjection layer_projection;
XrCompositionLayerBaseHeader *layers[10];
uint32_t layers_count;
XrCompositionLayerProjectionView
layer_projection_views[10]; // Hopefully we dont have more than 10.
uint32_t layer_projection_views_count;
} LunarWM_RenderLayerInfo;
typedef struct LunarWM {
struct {
struct wl_display *display;
struct wl_event_loop *event_loop;
struct wlr_backend *backend;
struct wlr_renderer *renderer;
struct wlr_session *session;
struct wlr_egl *egl;
EGLDisplay egl_display;
EGLContext egl_context;
EGLConfig egl_config;
struct wlr_allocator *allocator;
struct wlr_compositor *compositor;
struct wlr_subcompositor *subcompositor;
struct wlr_data_device_manager *data_device_manager;
struct wlr_seat *seat;
struct wl_list keyboards;
struct wl_listener new_input_listener;
struct wlr_xdg_shell *xdg_shell;
struct wl_listener new_xdg_toplevel_listener;
struct wl_listener new_xdg_popup_listener;
struct wlr_cursor *cursor;
LunarWM_Toplevel **v_toplevels;
} wayland;
struct {
XrInstance instance;
XrSystemId system_id;
XrSession session;
XrSessionState session_state;
struct {
LunarWM_SwapchainInfo *v_color;
LunarWM_SwapchainInfo *v_depth;
} swapchains;
LunarWM_SwapchainImagesEntry
swapchain_images[2]; // 0 is color, 1 is depth
XrViewConfigurationView *a_view_configuration_views;
uint32_t view_configuration_views_count;
XrEnvironmentBlendMode environment_blend_mode;
XrSpace local_space, view_space;
LunarWM_Hand hands[2];
XrSystemHandTrackingPropertiesEXT hand_tracking_system_properties;
PFN_xrCreateHandTrackerEXT CreateHandTrackerEXT;
PFN_xrDestroyHandTrackerEXT DestroyHandTrackerEXT;
PFN_xrLocateHandJointsEXT LocateHandJointsEXT;
bool session_running;
} xr;
struct {
GLuint fbo;
RenderTexture2D tmp_rt;
Camera3D camera;
} renderer;
bool initialized;
bool running;
} LunarWM;
bool LunarWM_init(LunarWM *wm);
void LunarWM_destroy(LunarWM *this);
void LunarWM_terminate(LunarWM *this);
void LunarWM_run(LunarWM *this);
extern LunarWM g_wm;
#endif // LUNAR_WM_H