[r5]: blitz / irrlicht.bmx Maximize Restore History

Download this file

irrlicht.bmx    148 lines (134 with data), 4.6 kB

  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
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
; BlitzMax Irrlicht functions
; original idea made wrapper for Blitz3D was by Atulos, many thanks him
; programming Maxim Kolosov
Include "constant.bb"
Type D3D8
Field D3D8
Field D3DDev8
Field HWnd
End Type
Type D3D9
Field D3D9
Field D3DDev9
Field HWnd
End Type
Type OpenGLWin32
Field HDc
Field HRc
Field HWnd
End Type
Type OpenGLLinux
Field X11Display
Field X11Context
Field X11Window
End Type
Type SExposedVideoData
Field c_pointer
Field d3d8.D3D8
Field d3d9.D3D9
Field openglwin32.OpenGLWin32
Field opengllinux.OpenGLLinux
Method New (Window)
Self.c_pointer = SExposedVideoData_ctor2(Window)
End Method
End Type
Type SIrrlichtCreationParameters
Field DeviceType
Field DriverType
Field WindowSize
Field Bits
Field ZBufferBits
Field Fullscreen
Field Stencilbuffer
Field Vsync
Field AntiAlias
Field WithAlphaChannel
Field Doublebuffer
Field IgnoreInput
Field Stereobuffer
Field HighPrecisionFPU
Field EventReceiver
Field WindowId
Field LoggingLevel
Field SDK_version_do_not_use$
End Type
Type dimension2du
Field c_pointer
Method New (w = 320, h = 240)
Self.c_pointer = dimension2du_ctor2(w, h)
End Method
End Type
Type IrrlichtDevice
Field c_pointer
Method New (deviceType = 0, windowSize* = 0, bits = 16, fullscreen = False, stencilbuffer = False, vsync = False, receiver* = 0)
Self.c_pointer = IrrlichtDevice_createDevice(deviceType, windowSize.c_pointer, bits, fullscreen, stencilbuffer, vsync, receiver)
End Method
Method New (deviceType = 0, windowSize = 0, bits = 16, fullscreen = False, stencilbuffer = False, vsync = False, create_receiver = False)
Self.c_pointer = IrrlichtDevice_createDevice2(deviceType, windowSize.c_pointer, bits, fullscreen, stencilbuffer, vsync, create_receiver)
End Method
Function run()
Return IrrlichtDevice_run(Self.c_pointer)
End Function
Function getVersion$()
Return IrrlichtDevice_getVersion(Self.c_pointer)
End Function
Sub closeDevice()
IrrlichtDevice_closeDevice(Self.c_pointer)
End Sub
End Type
Type RECT
Field leftRect
Field topRect
Field rightRect
Field bottomRect
End Type
Global irrlicht_device%, global_font%, irrlicht_creation_parameters% = SIrrlichtCreationParameters_ctor()
Function WBuffer (enable%)
SIrrlichtCreationParameters_set_Doublebuffer irrlicht_creation_parameters, enable
End Function
Function AntiAlias (enable%)
SIrrlichtCreationParameters_set_AntiAlias irrlicht_creation_parameters, enable
End Function
Function Graphics (x%, y%, depth%, mode%, driver_type% = EDT_DIRECT3D9)
;window_handle% = SystemProperty("AppHWND")
window_handle% = GetActiveWindow()
rect.RECT = New RECT
GetWindowRect GetDesktopWindow(), rect
posx% = rect\rightRect/2-x/2
If posx < 0
posx = 0
EndIf
posy% = rect\bottomRect/2-y/2
If posy < 0
posy = 0
EndIf
MoveWindow window_handle, posx, posy, x, y, False
;window_size% = dimension2du_ctor2(x, y)
;irrlicht_creation_parameters = SIrrlichtCreationParameters_ctor()
SIrrlichtCreationParameters_set_DriverType irrlicht_creation_parameters, driver_type
SIrrlichtCreationParameters_set_WindowId irrlicht_creation_parameters, window_handle
;SIrrlichtCreationParameters_set_WindowSize irrlicht_creation_parameters, window_size
SIrrlichtCreationParameters_set_Bits irrlicht_creation_parameters, depth
SIrrlichtCreationParameters_set_ZBufferBits irrlicht_creation_parameters, depth
If mode <> 1
SIrrlichtCreationParameters_set_Fullscreen irrlicht_creation_parameters, False
Else
SIrrlichtCreationParameters_set_Fullscreen irrlicht_creation_parameters, True
EndIf
SIrrlichtCreationParameters_set_Stencilbuffer irrlicht_creation_parameters, True
SIrrlichtCreationParameters_set_Vsync irrlicht_creation_parameters, True
SIrrlichtCreationParameters_set_IgnoreInput irrlicht_creation_parameters, True
irrlicht_device = IrrlichtDevice_createDeviceEx(irrlicht_creation_parameters)
global_font = IGUIEnvironment_getBuiltInFont(IrrlichtDevice_getGUIEnvironment(irrlicht_device))
End Function
Function Graphics3D (x%, y%, depth%, mode%, driver_type% = EDT_DIRECT3D9)
Graphics x, y, depth, mode, driver_type
End Function
Function End ()
IrrlichtDevice_closeDevice irrlicht_device
End Function
Function Text (x%, y%, string_value$, center_x% = False, center_y% = False)
If global_font
IGUIFont_draw global_font, tool_char_to_wchar(string_value), recti_ctor2(x, y, 100, 20), SColor_ctor2(255, 255, 255, 255), center_x, center_y, 0
EndIf
End Function