()
| 296 | } |
| 297 | |
| 298 | function debugRender() |
| 299 | { |
| 300 | if (debugVideoCaptureIsActive()) |
| 301 | return; // don't show debug info when capturing video |
| 302 | |
| 303 | // flush any gl sprites before drawing debug info |
| 304 | glFlush(); |
| 305 | |
| 306 | if (debugTakeScreenshot) |
| 307 | { |
| 308 | // combine canvases, remove alpha and save |
| 309 | combineCanvases(); |
| 310 | saveCanvas(mainCanvas); |
| 311 | debugTakeScreenshot = 0; |
| 312 | } |
| 313 | |
| 314 | const debugContext = mainContext; |
| 315 | if (debugGamepads && gamepadsEnable) |
| 316 | { |
| 317 | // draw gamepads |
| 318 | const maxGamepads = 8; |
| 319 | let gamepadConnectedCount = 0; |
| 320 | for (let i = 0; i < maxGamepads; i++) |
| 321 | gamepadConnected(i) && gamepadConnectedCount++; |
| 322 | |
| 323 | for (let i = 0; i < maxGamepads; i++) |
| 324 | { |
| 325 | if (!gamepadConnected(i)) |
| 326 | continue; |
| 327 | |
| 328 | const stickScale = 1; |
| 329 | const buttonScale = .2; |
| 330 | const cornerPos = cameraPos.add(vec2(-stickScale*2, ((gamepadConnectedCount-1)/2-i)*stickScale*3)); |
| 331 | debugText(i, cornerPos.add(vec2(-stickScale, stickScale)), 1); |
| 332 | if (i === gamepadPrimary) |
| 333 | debugText('Main', cornerPos.add(vec2(-stickScale*2, 0)),1, '#0f0'); |
| 334 | |
| 335 | // read analog sticks |
| 336 | const stickCount = gamepadStickData[i].length; |
| 337 | for (let j = 0; j < stickCount; j++) |
| 338 | { |
| 339 | const stick = gamepadStick(j, i); |
| 340 | const drawPos = cornerPos.add(vec2(j*stickScale*2, 0)); |
| 341 | const stickPos = drawPos.add(stick.scale(stickScale)); |
| 342 | debugCircle(drawPos, stickScale*2, '#fff7',0,true); |
| 343 | debugLine(drawPos, stickPos, '#f00'); |
| 344 | debugText(j, drawPos, .3); |
| 345 | debugPoint(stickPos, '#f00'); |
| 346 | } |
| 347 | |
| 348 | const buttonCount = inputData[i+1].length; |
| 349 | for (let j = 0; j < buttonCount; j++) |
| 350 | { |
| 351 | const drawPos = cornerPos.add(vec2(j*buttonScale*2, -stickScale-buttonScale*2)); |
| 352 | const pressed = gamepadIsDown(j, i); |
| 353 | debugCircle(drawPos, buttonScale*2, pressed ? '#f00' : '#fff7', 0, true); |
| 354 | debugText(j, drawPos, .3); |
| 355 | } |
no test coverage detected