76 lines
2.2 KiB
PHP
76 lines
2.2 KiB
PHP
<?php
|
|
/* Test multi-window with event queue mode */
|
|
|
|
// Enable event queue mode
|
|
rgfw_setQueueEvents(true);
|
|
|
|
$win1 = rgfw_createWindow("Window 1", 100, 100, 400, 300, 0);
|
|
$win2 = rgfw_createWindow("Window 2", 550, 100, 400, 300, 0);
|
|
|
|
rsgl_init($win1);
|
|
rsgl_init($win2);
|
|
|
|
echo "Event queue mode enabled. Testing with 2 windows...\n";
|
|
echo "Try clicking in each window to test mouse events\n";
|
|
|
|
$running = true;
|
|
$frameCount = 0;
|
|
|
|
while ($running) {
|
|
// Poll events for all windows
|
|
rgfw_pollEvents();
|
|
|
|
// Check events for window 1
|
|
while ($event = rgfw_window_checkQueuedEvent($win1)) {
|
|
echo "Window 1 - Event type: {$event['type']}\n";
|
|
|
|
if ($event['type'] == RGFW_quit) {
|
|
$running = false;
|
|
} elseif ($event['type'] == RGFW_mouseButtonPressed) {
|
|
echo " Window 1 - Mouse clicked! Button: {$event['button']}\n";
|
|
} elseif ($event['type'] == RGFW_mousePosChanged) {
|
|
echo " Window 1 - Mouse moved to: {$event[0]}, {$event[1]}\n";
|
|
}
|
|
}
|
|
|
|
// Check events for window 2
|
|
while ($event = rgfw_window_checkQueuedEvent($win2)) {
|
|
echo "Window 2 - Event type: {$event['type']}\n";
|
|
|
|
if ($event['type'] == RGFW_quit) {
|
|
$running = false;
|
|
} elseif ($event['type'] == RGFW_mouseButtonPressed) {
|
|
echo " Window 2 - Mouse clicked! Button: {$event['button']}\n";
|
|
} elseif ($event['type'] == RGFW_mousePosChanged) {
|
|
echo " Window 2 - Mouse moved to: {$event[0]}, {$event[1]}\n";
|
|
}
|
|
}
|
|
|
|
// Render window 1 (red background)
|
|
rsgl_clear($win1, 255, 0, 0, 255);
|
|
rsgl_drawRectF($win1, 150, 100, 100, 100);
|
|
rgfw_window_swapBuffers($win1);
|
|
|
|
// Render window 2 (blue background)
|
|
rsgl_clear($win2, 0, 0, 255, 255);
|
|
rsgl_drawRectF($win2, 150, 100, 100, 100);
|
|
rgfw_window_swapBuffers($win2);
|
|
|
|
$frameCount++;
|
|
if ($frameCount % 100 == 0) {
|
|
echo "Frame $frameCount - Both windows running\n";
|
|
}
|
|
|
|
// Check if windows should close
|
|
if (rgfw_window_shouldClose($win1) || rgfw_window_shouldClose($win2)) {
|
|
$running = false;
|
|
}
|
|
|
|
usleep(16000); // ~60 FPS
|
|
}
|
|
|
|
echo "Test finished after $frameCount frames\n";
|
|
|
|
rgfw_window_close($win1);
|
|
rgfw_window_close($win2);
|