Ottenere le dimensioni del monitor e la sua posizione sullo schermo con le funzioni esterne del API di Allegro 5: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
| Riga 2: | Riga 2: | ||
Per poter fruire in Gambas delle risorse della libreria di ''Allegro 5'', è necessario installare e richiamare la libreria condivisa: "''liballegro.so.5.2.10''" | Per poter fruire in Gambas delle risorse della libreria di ''Allegro 5'', è necessario installare e richiamare la libreria condivisa: "''liballegro.so.5.2.10''" | ||
Mostriamo un semplice esempio: | Mostriamo un semplice esempio: | ||
Versione attuale delle 07:49, 8 ago 2025
La versione 5 della libreria Allegro consente anche di conoscere le dimensioni del monitor e la sua posizione sullo schermo.
Per poter fruire in Gambas delle risorse della libreria di Allegro 5, è necessario installare e richiamare la libreria condivisa: "liballegro.so.5.2.10"
Mostriamo un semplice esempio:
Library "liballegro:5.2.10"
Public Struct ALLEGRO_MONITOR_INFO
x1 As Integer
y1 As Integer
x2 As Integer
y2 As Integer
End Struct
' uint32_t al_get_allegro_version (void)
' Returns the (compiled) version of the Allegro library.
Private Extern al_get_allegro_version() As Integer
' bool al_install_system (int version, int (*atexit_ptr)(void (*)(void)))
' Initialize the Allegro system.
Private Extern al_install_system(version As Integer, atexit_ptr As Pointer) As Boolean
' int al_get_num_video_adapters(void)
' Get the number of video "adapters" attached to the computer.
Private Extern al_get_num_video_adapters() As Integer
' bool al_get_monitor_info(int adapter, ALLEGRO_MONITOR_INFO *info)
' Get information about a monitor's position on the desktop.
Private Extern al_get_monitor_info(adapter As Integer, info As ALLEGRO_MONITOR_INFO) As Boolean
' void al_uninstall_system (void)
' Closes down the Allegro system.
Private Extern al_uninstall_system()
Public Sub Main()
Dim monitor As New ALLEGRO_MONITOR_INFO
Dim adapters As Integer
Dim bo As Boolean
If al_install_system(al_get_allegro_version(), 0) = False Then Error.Raise("Impossibile inizializzare la libreria Allegro 5 !")
adapters = al_get_num_video_adapters()
bo = al_get_monitor_info(adapters - 1, monitor)
If bo = False Then Error.Raise("Impossibile ottenere informazioni del monitor !")
With monitor
Print .x1
Print .y1
Print .x2
Print .y2
End With
' Chiude la libreria "Allegro 5":
al_uninstall_system()
End