| 1 |
module test; |
|---|
| 2 |
|
|---|
| 3 |
import minid.minid; |
|---|
| 4 |
import minid.types; |
|---|
| 5 |
import minid.bind; |
|---|
| 6 |
import tango.io.Stdout; |
|---|
| 7 |
|
|---|
| 8 |
//version = Arc; |
|---|
| 9 |
|
|---|
| 10 |
void main() |
|---|
| 11 |
{ |
|---|
| 12 |
MDContext ctx; |
|---|
| 13 |
|
|---|
| 14 |
try |
|---|
| 15 |
{ |
|---|
| 16 |
ctx = NewContext(); |
|---|
| 17 |
|
|---|
| 18 |
version(Arc) |
|---|
| 19 |
LoadArc(ctx); |
|---|
| 20 |
|
|---|
| 21 |
ctx.addImportPath(`samples`); |
|---|
| 22 |
ctx.importModule("simple"); |
|---|
| 23 |
} |
|---|
| 24 |
catch(MDException e) |
|---|
| 25 |
{ |
|---|
| 26 |
Stdout.formatln("Error: {}", e.toString()); |
|---|
| 27 |
Stdout.formatln("{}", ctx.getTracebackString()); |
|---|
| 28 |
} |
|---|
| 29 |
catch(Exception e) |
|---|
| 30 |
{ |
|---|
| 31 |
Stdout.formatln("Bad error ({}, {}): {}", e.file, e.line, e.toString()); |
|---|
| 32 |
Stdout.formatln("{}", ctx.getTracebackString()); |
|---|
| 33 |
} |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
version(Arc) |
|---|
| 37 |
{ |
|---|
| 38 |
|
|---|
| 39 |
import arc.draw.color; |
|---|
| 40 |
import arc.draw.image; |
|---|
| 41 |
import arc.draw.shape; |
|---|
| 42 |
import arc.font; |
|---|
| 43 |
import arc.input; |
|---|
| 44 |
import arc.math.point; |
|---|
| 45 |
import arc.math.rect; |
|---|
| 46 |
import arc.math.size; |
|---|
| 47 |
import arc.sound; |
|---|
| 48 |
import arc.texture; |
|---|
| 49 |
import arc.time; |
|---|
| 50 |
import arc.window; |
|---|
| 51 |
|
|---|
| 52 |
void LoadArc(MDContext ctx) |
|---|
| 53 |
{ |
|---|
| 54 |
static class MyTexture |
|---|
| 55 |
{ |
|---|
| 56 |
private arc.texture.Texture mTex; |
|---|
| 57 |
|
|---|
| 58 |
public this(char[] filename) |
|---|
| 59 |
{ |
|---|
| 60 |
mTex = Texture(filename); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
public this(Size size, Color color) |
|---|
| 64 |
{ |
|---|
| 65 |
mTex = Texture(size, color); |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
public Size getSize() |
|---|
| 69 |
{ |
|---|
| 70 |
return mTex.getSize(); |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
public Size getTextureSize() |
|---|
| 74 |
{ |
|---|
| 75 |
return mTex.getTextureSize(); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
uint getID() |
|---|
| 79 |
{ |
|---|
| 80 |
return mTex.getID(); |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
char[] getFile() |
|---|
| 84 |
{ |
|---|
| 85 |
return mTex.getFile(); |
|---|
| 86 |
} |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
static void myEnableTexturing(MyTexture t) |
|---|
| 90 |
{ |
|---|
| 91 |
arc.texture.enableTexturing(t.mTex); |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
static void myDrawImage(MyTexture t, Point pos, Size size = Size(float.nan, float.nan), Point piv = Point(0, 0), float angle = 0, Color color = Color.White) |
|---|
| 95 |
{ |
|---|
| 96 |
arc.draw.image.drawImage(t.mTex, pos, size, piv, angle, color); |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
static void myDrawImageTopLeft(MyTexture t, Point pos, Size size = Size(float.nan, float.nan), Color color = Color.White) |
|---|
| 100 |
{ |
|---|
| 101 |
arc.draw.image.drawImageTopLeft(t.mTex, pos, size, color); |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
static void myDrawImageSubsection(MyTexture t, Point pos, Point rightBottom, Color color = Color.White) |
|---|
| 105 |
{ |
|---|
| 106 |
arc.draw.image.drawImageSubsection(t.mTex, pos, rightBottom, color); |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
WrapModule("arc.draw.color", ctx) |
|---|
| 110 |
.type(WrapClass!(Color, |
|---|
| 111 |
void function(int, int, int), |
|---|
| 112 |
void function(int, int, int, int), |
|---|
| 113 |
void function(float, float, float), |
|---|
| 114 |
void function(float, float, float, float))() |
|---|
| 115 |
.method!(Color.setR)() |
|---|
| 116 |
.method!(Color.setG)() |
|---|
| 117 |
.method!(Color.setB)() |
|---|
| 118 |
.method!(Color.setA)() |
|---|
| 119 |
.method!(Color.getR)() |
|---|
| 120 |
.method!(Color.getG)() |
|---|
| 121 |
.method!(Color.getB)() |
|---|
| 122 |
.method!(Color.getA)() |
|---|
| 123 |
.method!(Color.setGLColor)()); |
|---|
| 124 |
|
|---|
| 125 |
WrapModule("arc.draw.image", ctx) |
|---|
| 126 |
.func!(myDrawImage, "drawImage")() |
|---|
| 127 |
.func!(myDrawImageTopLeft, "drawImageTopLeft")() |
|---|
| 128 |
.func!(myDrawImageSubsection, "drawImageSubsection")(); |
|---|
| 129 |
|
|---|
| 130 |
WrapModule("arc.draw.shape", ctx) |
|---|
| 131 |
.func!(arc.draw.shape.drawPixel)() |
|---|
| 132 |
.func!(arc.draw.shape.drawLine)() |
|---|
| 133 |
.func!(arc.draw.shape.drawCircle)() |
|---|
| 134 |
.func!(arc.draw.shape.drawRectangle)(); |
|---|
| 135 |
//.func!(arc.draw.shape.drawPolygon)(); |
|---|
| 136 |
|
|---|
| 137 |
WrapModule("arc.font", ctx) |
|---|
| 138 |
.func!(arc.font.open)() |
|---|
| 139 |
.func!(arc.font.close)() |
|---|
| 140 |
.type(WrapClass!(Font, void function(char[], int))() |
|---|
| 141 |
.method!(Font.getWidth!(dchar))() |
|---|
| 142 |
.method!(Font.getWidthLastLine!(dchar))() |
|---|
| 143 |
.method!(Font.getHeight)() |
|---|
| 144 |
.method!(Font.getLineSkip)() |
|---|
| 145 |
.method!(Font.setLineGap)() |
|---|
| 146 |
.method!(Font.draw, void function(dchar[], Point, Color))() |
|---|
| 147 |
.method!(Font.calculateIndex!(dchar))()); |
|---|
| 148 |
|
|---|
| 149 |
WrapModule("arc.input", ctx) |
|---|
| 150 |
.func!(arc.input.open)() |
|---|
| 151 |
.func!(arc.input.close)() |
|---|
| 152 |
.func!(arc.input.process)() |
|---|
| 153 |
.func!(arc.input.setKeyboardRepeat)() |
|---|
| 154 |
.func!(arc.input.keyPressed)() |
|---|
| 155 |
.func!(arc.input.keyReleased)() |
|---|
| 156 |
.func!(arc.input.keyDown)() |
|---|
| 157 |
.func!(arc.input.keyUp)() |
|---|
| 158 |
.func!(arc.input.charHit)() |
|---|
| 159 |
.func!(arc.input.lastChars)() |
|---|
| 160 |
.func!(arc.input.mouseButtonPressed)() |
|---|
| 161 |
.func!(arc.input.mouseButtonReleased)() |
|---|
| 162 |
.func!(arc.input.mouseButtonDown)() |
|---|
| 163 |
.func!(arc.input.mouseButtonUp)() |
|---|
| 164 |
.func!(arc.input.mouseX)() |
|---|
| 165 |
.func!(arc.input.mouseY)() |
|---|
| 166 |
.func!(arc.input.mousePos)() |
|---|
| 167 |
.func!(arc.input.mouseOldX)() |
|---|
| 168 |
.func!(arc.input.mouseOldY)() |
|---|
| 169 |
.func!(arc.input.mouseOldPos)() |
|---|
| 170 |
.func!(arc.input.mouseMotion)() |
|---|
| 171 |
.func!(arc.input.defaultCursorVisible)() |
|---|
| 172 |
.func!(arc.input.wheelUp)() |
|---|
| 173 |
.func!(arc.input.wheelDown)() |
|---|
| 174 |
.type(WrapClass!(JoystickException, void function(char[]))()) |
|---|
| 175 |
.func!(arc.input.numJoysticks)() |
|---|
| 176 |
.func!(arc.input.openJoysticks)() |
|---|
| 177 |
.func!(arc.input.closeJoysticks)() |
|---|
| 178 |
.func!(arc.input.joyButtonDown)() |
|---|
| 179 |
.func!(arc.input.joyButtonUp)() |
|---|
| 180 |
.func!(arc.input.joyButtonPressed)() |
|---|
| 181 |
.func!(arc.input.joyButtonReleased)() |
|---|
| 182 |
.func!(arc.input.joyAxisMoved)() |
|---|
| 183 |
.func!(arc.input.numJoystickButtons)() |
|---|
| 184 |
.func!(arc.input.numJoystickAxes)() |
|---|
| 185 |
.func!(arc.input.joystickName)() |
|---|
| 186 |
.func!(arc.input.isJoystickOpen)() |
|---|
| 187 |
.func!(arc.input.setAxisThreshold)() |
|---|
| 188 |
.func!(arc.input.lostFocus)() |
|---|
| 189 |
.func!(arc.input.quit)() |
|---|
| 190 |
.func!(arc.input.isQuit)() |
|---|
| 191 |
.custom("key", MDTable.create |
|---|
| 192 |
( |
|---|
| 193 |
"Quit", ARC_QUIT, |
|---|
| 194 |
"Up", ARC_UP, |
|---|
| 195 |
"Down", ARC_DOWN, |
|---|
| 196 |
"Left", ARC_LEFT, |
|---|
| 197 |
"Right", ARC_RIGHT, |
|---|
| 198 |
"Esc", ARC_ESCAPE |
|---|
| 199 |
)) |
|---|
| 200 |
.custom("mouse", MDTable.create |
|---|
| 201 |
( |
|---|
| 202 |
"Any", ANYBUTTON, |
|---|
| 203 |
"Left", LEFT, |
|---|
| 204 |
"Middle", MIDDLE, |
|---|
| 205 |
"Right", RIGHT, |
|---|
| 206 |
"WheelUp", WHEELUP, |
|---|
| 207 |
"WheelDown", WHEELDOWN |
|---|
| 208 |
)); |
|---|
| 209 |
|
|---|
| 210 |
WrapModule("arc.math.point", ctx) |
|---|
| 211 |
.type(WrapClass!(Point, void function(float, float))() |
|---|
| 212 |
.method!(Point.set)() |
|---|
| 213 |
.method!(Point.angle)() |
|---|
| 214 |
.method!(Point.length)() |
|---|
| 215 |
.method!(Point.toString, "toString")() |
|---|
| 216 |
.method!(Point.maxComponent)() |
|---|
| 217 |
.method!(Point.minComponent)() |
|---|
| 218 |
.method!(Point.opNeg)() |
|---|
| 219 |
.method!(Point.cross)() |
|---|
| 220 |
.method!(Point.dot)() |
|---|
| 221 |
.method!(Point.scale)() |
|---|
| 222 |
// apply |
|---|
| 223 |
.method!(Point.lengthSquared)() |
|---|
| 224 |
.method!(Point.normalise, "normalize")() |
|---|
| 225 |
.method!(Point.normaliseCopy, "normalizeCopy")() |
|---|
| 226 |
.method!(Point.rotate)() |
|---|
| 227 |
.method!(Point.rotateCopy)() |
|---|
| 228 |
.method!(Point.abs)() |
|---|
| 229 |
.method!(Point.absCopy)() |
|---|
| 230 |
.method!(Point.clamp)() |
|---|
| 231 |
.method!(Point.randomise, "randomize")() |
|---|
| 232 |
.method!(Point.distance)() |
|---|
| 233 |
.method!(Point.distanceSquared)() |
|---|
| 234 |
.method!(Point.getX)() |
|---|
| 235 |
.method!(Point.getY)() |
|---|
| 236 |
.method!(Point.setX)() |
|---|
| 237 |
.method!(Point.setY)() |
|---|
| 238 |
.method!(Point.addX)() |
|---|
| 239 |
.method!(Point.addY)() |
|---|
| 240 |
.method!(Point.above)() |
|---|
| 241 |
.method!(Point.below)() |
|---|
| 242 |
.method!(Point.left)() |
|---|
| 243 |
.method!(Point.right)()); |
|---|
| 244 |
|
|---|
| 245 |
WrapModule("arc.math.rect", ctx) |
|---|
| 246 |
.type(WrapClass!(Rect, |
|---|
| 247 |
void function(float, float, float, float), |
|---|
| 248 |
void function(Point, Size), |
|---|
| 249 |
void function(Size), |
|---|
| 250 |
void function(float, float))() |
|---|
| 251 |
.method!(Rect.getBottomRight)() |
|---|
| 252 |
.method!(Rect.getTop)() |
|---|
| 253 |
.method!(Rect.getLeft)() |
|---|
| 254 |
.method!(Rect.getBottom)() |
|---|
| 255 |
.method!(Rect.getRight)() |
|---|
| 256 |
.method!(Rect.getPosition)() |
|---|
| 257 |
.method!(Rect.getSize)() |
|---|
| 258 |
.method!(Rect.move)() |
|---|
| 259 |
.method!(Rect.contains)() |
|---|
| 260 |
.method!(Rect.intersects)()); |
|---|
| 261 |
|
|---|
| 262 |
WrapModule("arc.math.size", ctx) |
|---|
| 263 |
.type(WrapClass!(Size, void function(float, float))() |
|---|
| 264 |
.method!(Size.set)() |
|---|
| 265 |
.method!(Size.toString, "toString")() |
|---|
| 266 |
.method!(Size.maxComponent)() |
|---|
| 267 |
.method!(Size.minComponent)() |
|---|
| 268 |
.method!(Size.opNeg)() |
|---|
| 269 |
.method!(Size.scale)() |
|---|
| 270 |
.method!(Size.abs)() |
|---|
| 271 |
.method!(Size.absCopy)() |
|---|
| 272 |
.method!(Size.clamp)() |
|---|
| 273 |
.method!(Size.randomise, "randomize")() |
|---|
| 274 |
.method!(Size.getWidth)() |
|---|
| 275 |
.method!(Size.getHeight)() |
|---|
| 276 |
.method!(Size.setWidth)() |
|---|
| 277 |
.method!(Size.setHeight)() |
|---|
| 278 |
.method!(Size.addW)() |
|---|
| 279 |
.method!(Size.addH)()); |
|---|
| 280 |
|
|---|
| 281 |
WrapModule("arc.sound", ctx) |
|---|
| 282 |
.func!(arc.sound.open)() |
|---|
| 283 |
.func!(arc.sound.close)() |
|---|
| 284 |
.func!(arc.sound.process)() |
|---|
| 285 |
.func!(arc.sound.on)() |
|---|
| 286 |
.func!(arc.sound.off)() |
|---|
| 287 |
.func!(arc.sound.isSoundOn)() |
|---|
| 288 |
.type(WrapClass!(Sound, void function(SoundFile))() |
|---|
| 289 |
.method!(Sound.getSound)() |
|---|
| 290 |
.method!(Sound.setSound)() |
|---|
| 291 |
.method!(Sound.setGain)() |
|---|
| 292 |
.method!(Sound.getPitch)() |
|---|
| 293 |
.method!(Sound.setPitch)() |
|---|
| 294 |
.method!(Sound.getVolume)() |
|---|
| 295 |
.method!(Sound.setVolume)() |
|---|
| 296 |
.method!(Sound.getLooping)() |
|---|
| 297 |
.method!(Sound.setLoop)() |
|---|
| 298 |
.method!(Sound.getPaused)() |
|---|
| 299 |
.method!(Sound.setPaused)() |
|---|
| 300 |
.method!(Sound.play)() |
|---|
| 301 |
.method!(Sound.pause)() |
|---|
| 302 |
.method!(Sound.seek)() |
|---|
| 303 |
.method!(Sound.tell)() |
|---|
| 304 |
.method!(Sound.stop)() |
|---|
| 305 |
.method!(Sound.updateBuffers)() |
|---|
| 306 |
.method!(Sound.process)()) |
|---|
| 307 |
.type(WrapClass!(SoundFile, void function(char[]))() |
|---|
| 308 |
.method!(SoundFile.getFrequency)() |
|---|
| 309 |
.method!(SoundFile.getBuffers, "getBuffersList", uint[] function())() |
|---|
| 310 |
.method!(SoundFile.getBuffersLength)() |
|---|
| 311 |
.method!(SoundFile.getBuffersPerSecond)() |
|---|
| 312 |
.method!(SoundFile.getLength)() |
|---|
| 313 |
.method!(SoundFile.getSize)() |
|---|
| 314 |
.method!(SoundFile.getSource)() |
|---|
| 315 |
.method!(SoundFile.getBuffers, uint[] function(int, int))() |
|---|
| 316 |
.method!(SoundFile.allocBuffers)() |
|---|
| 317 |
.method!(SoundFile.freeBuffers)() |
|---|
| 318 |
.method!(SoundFile.print)()); |
|---|
| 319 |
|
|---|
| 320 |
WrapModule("arc.texture", ctx) |
|---|
| 321 |
.func!(arc.texture.incrementTextureCount)() |
|---|
| 322 |
.func!(arc.texture.assignTextureID)() |
|---|
| 323 |
.func!(arc.texture.load)() |
|---|
| 324 |
.func!(myEnableTexturing, "enableTexturing")() |
|---|
| 325 |
.type("Texture", WrapClass!(MyTexture, |
|---|
| 326 |
void function(char[]), |
|---|
| 327 |
void function(Size, Color))() |
|---|
| 328 |
.method!(MyTexture.getID)() |
|---|
| 329 |
.method!(MyTexture.getFile)() |
|---|
| 330 |
.method!(MyTexture.getSize)() |
|---|
| 331 |
.method!(MyTexture.getTextureSize)()); |
|---|
| 332 |
|
|---|
| 333 |
WrapModule("arc.time", ctx) |
|---|
| 334 |
.func!(arc.time.open)() |
|---|
| 335 |
.func!(arc.time.close)() |
|---|
| 336 |
.func!(arc.time.process)() |
|---|
| 337 |
.func!(arc.time.sleep)() |
|---|
| 338 |
.func!(arc.time.elapsedMilliseconds)() |
|---|
| 339 |
.func!(arc.time.elapsedSeconds)() |
|---|
| 340 |
.func!(arc.time.fps)() |
|---|
| 341 |
.func!(arc.time.limitFPS)() |
|---|
| 342 |
.func!(arc.time.getTime)(); |
|---|
| 343 |
|
|---|
| 344 |
MDNamespace coordinates = new MDNamespace("coordinates"); |
|---|
| 345 |
|
|---|
| 346 |
with(arc.window.coordinates) |
|---|
| 347 |
{ |
|---|
| 348 |
WrapFunc!(setSize)(coordinates); |
|---|
| 349 |
WrapFunc!(setOrigin)(coordinates); |
|---|
| 350 |
WrapFunc!(getSize)(coordinates); |
|---|
| 351 |
WrapFunc!(getWidth)(coordinates); |
|---|
| 352 |
WrapFunc!(getHeight)(coordinates); |
|---|
| 353 |
WrapFunc!(getOrigin)(coordinates); |
|---|
| 354 |
} |
|---|
| 355 |
|
|---|
| 356 |
WrapModule("arc.window", ctx) |
|---|
| 357 |
.func!(arc.window.open)() |
|---|
| 358 |
.func!(arc.window.close)() |
|---|
| 359 |
.func!(arc.window.getWidth)() |
|---|
| 360 |
.func!(arc.window.getHeight)() |
|---|
| 361 |
.func!(arc.window.getSize)() |
|---|
| 362 |
.func!(arc.window.isFullScreen)() |
|---|
| 363 |
.func!(arc.window.resize)() |
|---|
| 364 |
.func!(arc.window.toggleFullScreen)() |
|---|
| 365 |
.func!(arc.window.clear)() |
|---|
| 366 |
.func!(arc.window.swap)() |
|---|
| 367 |
.func!(arc.window.swapClear)() |
|---|
| 368 |
.func!(arc.window.screenshot)() |
|---|
| 369 |
.custom("coordinates", coordinates); |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
} |
|---|