mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-23 10:59:45 +00:00
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.
This commit is contained in:
parent
b934e033b3
commit
3b337241f5
11 changed files with 890 additions and 1187 deletions
|
|
@ -37,24 +37,10 @@ static inline bool resizeLogging = getenv("VOXEL_LOG_RESIZE") != nullptr;
|
|||
bool barEnabled = false;
|
||||
bool fullscreen = false;
|
||||
std::string title = "VoxelCore";
|
||||
std::vector<uint8_t> iconPixels;
|
||||
int iconWidth = 0;
|
||||
int iconHeight = 0;
|
||||
int hoveredButton = -1;
|
||||
double lastBarPress = 0.0;
|
||||
double pointerX = 0.0;
|
||||
double pointerY = 0.0;
|
||||
GLuint barProgram = 0;
|
||||
GLuint barVao = 0;
|
||||
GLuint barVbo = 0;
|
||||
GLuint barFontTexture = 0;
|
||||
GLuint barIconTexture = 0;
|
||||
GLint barViewportLoc = -1;
|
||||
GLint barTextureLoc = -1;
|
||||
GLint barModeLoc = -1;
|
||||
std::vector<float> barRects;
|
||||
std::vector<float> barText;
|
||||
std::vector<float> barIcons;
|
||||
bool frameOnCallback = false;
|
||||
double frameInterval = 0.0;
|
||||
double nextFrameTime = 0.0;
|
||||
|
|
@ -111,10 +97,18 @@ glm::vec4 scissorArea {};
|
|||
WindowMode getMode() const override;
|
||||
void focus() override;
|
||||
void setTitle(const std::string& title) override;
|
||||
const std::string& getTitle() const override;
|
||||
int getDecorationHeight() const override;
|
||||
int getDecorationHoveredButton() const override;
|
||||
|
||||
bool isIconSupported() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void setIcon(const ImageData*) override {
|
||||
}
|
||||
void setFullscreen(bool enabled);
|
||||
void setMaximized(bool enabled);
|
||||
bool isIconSupported() const override;
|
||||
void setIcon(const ImageData* image) override;
|
||||
void resize(int width, int height);
|
||||
void onConfigure(int32_t width, int32_t height, wl_array* states);
|
||||
void applyConfigure();
|
||||
|
|
@ -129,13 +123,7 @@ glm::vec4 scissorArea {};
|
|||
void drawStretched();
|
||||
void enableOwnDecorations();
|
||||
bool barVisible() const;
|
||||
void initBarRenderer();
|
||||
void initBarIconTexture();
|
||||
void barDrawText( float x, float y, const std::vector<uint32_t>& codepoints, int maxChars, const glm::vec4& color );
|
||||
void barDrawBatch(const std::vector<float>& data, int mode, GLuint texture);
|
||||
void barFlush();
|
||||
void drawBar();
|
||||
int barButtonAt(double x, double y) const;
|
||||
int barButtonAt(double x, double y) const;
|
||||
uint32_t barEdgeAt(double x, double y) const;
|
||||
static CursorShape edgeCursor(uint32_t edges);
|
||||
bool handleBarMotion(double x, double y);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue