|
| 1 | +// Test for SetWindowTitle and SetSubWindowTitle functions |
| 2 | + |
| 3 | +#include <raygpu.h> |
| 4 | +#include <stdio.h> |
| 5 | + |
| 6 | +void DrawToWindow(SubWindow window, const char* text, int windowWidth, Color bgColor, Color textColor) { |
| 7 | + if (window == NULL) { |
| 8 | + BeginDrawing(); |
| 9 | + } else { |
| 10 | + BeginWindowMode(window); |
| 11 | + } |
| 12 | + |
| 13 | + ClearBackground(bgColor); |
| 14 | + int textWidth = MeasureText(text, 30); |
| 15 | + DrawText(text, (windowWidth - textWidth) / 2, 180, 30, textColor); |
| 16 | + |
| 17 | + if (window == NULL) { |
| 18 | + EndDrawing(); |
| 19 | + } else { |
| 20 | + EndWindowMode(); |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +void UpdateWindowTitle(SubWindow window, const char* libraryName, int seconds) { |
| 25 | + char titleBuffer[256]; |
| 26 | + snprintf(titleBuffer, sizeof(titleBuffer), "%s - %d", libraryName, seconds); |
| 27 | + |
| 28 | + if (window == NULL) { |
| 29 | + SetWindowTitle(titleBuffer); |
| 30 | + } else { |
| 31 | + SetSubWindowTitle(window, titleBuffer); |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +int main(void) { |
| 36 | + // Initialize main window with resizable flag |
| 37 | + SetConfigFlags(FLAG_WINDOW_RESIZABLE); |
| 38 | + InitWindow(800, 600, "Main Window"); |
| 39 | + |
| 40 | + // Create platform-specific sub-windows |
| 41 | + SubWindow glfwWindow = OpenSubWindow_GLFW(600, 400, "GLFW"); |
| 42 | + SubWindow rgfwWindow = OpenSubWindow_RGFW(600, 400, "RGFW"); |
| 43 | + SubWindow sdl3Window = OpenSubWindow_SDL3(600, 400, "SDL3"); |
| 44 | + |
| 45 | + double lastUpdateTime = 0.0; |
| 46 | + |
| 47 | + while (!WindowShouldClose()) { |
| 48 | + double currentTime = GetTime(); |
| 49 | + |
| 50 | + // Update titles every second |
| 51 | + if (currentTime - lastUpdateTime >= 1.0) { |
| 52 | + lastUpdateTime = currentTime; |
| 53 | + int seconds = (int)currentTime; |
| 54 | + |
| 55 | + // Update all window titles |
| 56 | + UpdateWindowTitle(NULL, "Main", seconds); |
| 57 | + UpdateWindowTitle(glfwWindow, "GLFW", seconds); |
| 58 | + UpdateWindowTitle(rgfwWindow, "RGFW", seconds); |
| 59 | + UpdateWindowTitle(sdl3Window, "SDL3", seconds); |
| 60 | + } |
| 61 | + |
| 62 | + // Draw on all windows |
| 63 | + DrawToWindow(NULL, "Main Window", 800, RAYWHITE, DARKGRAY); |
| 64 | + DrawToWindow(glfwWindow, "GLFW Window", 600, SKYBLUE, DARKBLUE); |
| 65 | + DrawToWindow(rgfwWindow, "RGFW Window", 600, LIME, DARKGREEN); |
| 66 | + DrawToWindow(sdl3Window, "SDL3 Window", 600, ORANGE, RED); |
| 67 | + } |
| 68 | + |
| 69 | + return 0; |
| 70 | +} |
0 commit comments