-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsdl_wrappers.monkey2
40 lines (32 loc) · 1.04 KB
/
sdl_wrappers.monkey2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Namespace screentools
Internal ' don't provide these lower level utility functions to the user
#Import "<sdl2>"
#Import "<std>"
Using sdl2..
Using std..
Class SDLWrap
Field displayIndex:Int
Field failed:=False
Method New( displayIndex:Int )
Self.displayIndex=displayIndex
End
Method GetDisplayDPI:Vec3f()
Local ddpi:Float, dpiX:Float, dpiY:Float
failed=SDL_GetDisplayDPI( displayIndex, Varptr ddpi, Varptr dpiX, Varptr dpiY ) < 0
Return New Vec3f( dpiX, dpiY, ddpi )
End
Method GetDisplayMode:SDL_DisplayMode()
Local displayMode:=New SDL_DisplayMode
failed=SDL_GetCurrentDisplayMode( displayIndex, Varptr displayMode ) < 0
Return displayMode
End
Method GetDisplayName:String()
failed=False ' reset failure because there is no way to detect it.
Return String.FromCString(SDL_GetDisplayName( displayIndex ))
End
Method GetDisplayBounds:Recti()
Local bounds:SDL_Rect
failed=SDL_GetDisplayBounds( displayIndex, Varptr bounds ) < 0
Return New Recti( bounds.x, bounds.y, bounds.x + bounds.w, bounds.y + bounds.h )
End
End