51 procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); |
51 procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); |
52 procedure DrawCircleFilled (X, Y, Radius: LongInt; r, g, b, a: Byte); |
52 procedure DrawCircleFilled (X, Y, Radius: LongInt; r, g, b, a: Byte); |
53 |
53 |
54 procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
54 procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
55 procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
55 procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
|
56 procedure DrawLineWrapped (X0, Y0, X1, Y1, Width: Single; goesLeft: boolean; Wraps: LongWord; color: LongWord); inline; |
|
57 procedure DrawLineWrapped (X0, Y0, X1, Y1, Width: Single; goesLeft: boolean; Wraps: LongWord; r, g, b, a: Byte); |
56 procedure DrawLineOnScreen (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
58 procedure DrawLineOnScreen (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
57 procedure DrawRect (rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean); |
59 procedure DrawRect (rect: TSDL_Rect; r, g, b, a: Byte; Fill: boolean); |
58 procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
60 procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
59 procedure DrawScreenWidget (widget: POnScreenWidget); |
61 procedure DrawScreenWidget (widget: POnScreenWidget); |
60 procedure DrawWater (Alpha: byte; OffsetY, OffsetX: LongInt); |
62 procedure DrawWater (Alpha: byte; OffsetY, OffsetX: LongInt); |
1335 if (not isAreaOffscreen(left, Top, Source^.w, Source^.h)) then |
1337 if (not isAreaOffscreen(left, Top, Source^.w, Source^.h)) then |
1336 DrawTexture(left, Top, Source); |
1338 DrawTexture(left, Top, Source); |
1337 end; |
1339 end; |
1338 end; |
1340 end; |
1339 |
1341 |
|
1342 // Same as below, but with color as LongWord |
1340 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
1343 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; |
1341 begin |
1344 begin |
1342 DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
1345 DrawLine(X0, Y0, X1, Y1, Width, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF) |
1343 end; |
1346 end; |
1344 |
1347 |
|
1348 // Draw line between 2 points |
|
1349 // X0, Y0: Start point |
|
1350 // X0, Y1: End point |
|
1351 // Width: Visual line width |
|
1352 // r, g, b, a: Color |
1345 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
1353 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
1346 begin |
1354 begin |
1347 openglPushMatrix(); |
1355 openglPushMatrix(); |
1348 openglTranslatef(WorldDx, WorldDy, 0); |
1356 openglTranslatef(WorldDx, WorldDy, 0); |
1349 |
1357 |
1350 UpdateModelviewProjection; |
1358 UpdateModelviewProjection; |
1351 |
1359 |
1352 DrawLineOnScreen(X0, Y0, X1, Y1, Width, r, g, b, a); |
1360 DrawLineOnScreen(X0, Y0, X1, Y1, Width, r, g, b, a); |
|
1361 |
|
1362 openglPopMatrix(); |
|
1363 |
|
1364 UpdateModelviewProjection; |
|
1365 end; |
|
1366 |
|
1367 // Same as below, but with color as a longword |
|
1368 procedure DrawLineWrapped(X0, Y0, X1, Y1, Width: Single; goesLeft: boolean; Wraps: LongWord; color: LongWord); inline; |
|
1369 begin |
|
1370 DrawLineWrapped(X0, Y0, X1, Y1, Width, goesLeft, Wraps, (color shr 24) and $FF, (color shr 16) and $FF, (color shr 8) and $FF, color and $FF); |
|
1371 end; |
|
1372 |
|
1373 // Draw a line between 2 points, but it wraps around the |
|
1374 // world edge for a given number of times. |
|
1375 // goesLeft: true if the line direction from the start point is left |
|
1376 // Wraps: Number of times the line intersects the wrapping world edge |
|
1377 // r, g, b, a: color |
|
1378 procedure DrawLineWrapped(X0, Y0, X1, Y1, Width: Single; goesLeft: boolean; Wraps: LongWord; r, g, b, a: Byte); |
|
1379 var w: LongWord; |
|
1380 startX, startY, endX, endY: Single; |
|
1381 // total X and Y distance the line travels if you would unwrap it |
|
1382 // with this we know the slope of the line. |
|
1383 totalX, totalY: Single; |
|
1384 // x variable for the line formula |
|
1385 x: Single; |
|
1386 begin |
|
1387 openglPushMatrix(); |
|
1388 openglTranslatef(WorldDx, WorldDy, 0); |
|
1389 |
|
1390 UpdateModelviewProjection; |
|
1391 |
|
1392 startX:= X0; |
|
1393 startY:= Y0; |
|
1394 if (Wraps = 0) then |
|
1395 begin |
|
1396 // Wraps=0 is trivial: Just draw one direct connection |
|
1397 endX:= X1; |
|
1398 endY:= Y1; |
|
1399 DrawLineOnScreen(startX, startY, endX, endY, Width, r, g, b, a); |
|
1400 end |
|
1401 else |
|
1402 begin |
|
1403 // A wrapping line is drawn using multiple line segments |
|
1404 // which stop at the left and right border. We |
|
1405 // calculate the points at which the line intersects with the border. |
|
1406 // Then we draws all line segments. |
|
1407 |
|
1408 // Calculate position of first wrap point |
|
1409 if goesLeft then |
|
1410 begin |
|
1411 endX:= LeftX; |
|
1412 totalX:= (RightX - X1) + (X0 - LeftX); |
|
1413 x:= X0 - LeftX; |
|
1414 end |
|
1415 else |
|
1416 begin |
|
1417 endX:= RightX; |
|
1418 totalX:= (RightX - X0) + (X1 - LeftX); |
|
1419 x:= RightX - X0; |
|
1420 end; |
|
1421 if (Wraps >= 2) then |
|
1422 totalX:= totalX + ((RightX - LeftX) * (Wraps-1)); |
|
1423 totalY:= Y1 - Y0; |
|
1424 // Calculate Y of first wrap point using the line formula |
|
1425 endY:= Y0 + (totalY / totalX) * x; |
|
1426 // Draw line segment between starting point and first wrap point |
|
1427 DrawLineOnScreen(startX, startY, endX, endY, Width, r, g, b, a); |
|
1428 |
|
1429 // Calculate and draw all remaining line segments |
|
1430 for w:=1 to Wraps do |
|
1431 begin |
|
1432 startY:= endY; |
|
1433 if goesLeft then |
|
1434 begin |
|
1435 startX:= RightX; |
|
1436 if w < Wraps then |
|
1437 endX:= LeftX |
|
1438 else |
|
1439 endX:= X1; |
|
1440 end |
|
1441 else |
|
1442 begin |
|
1443 startX:= LeftX; |
|
1444 if w < Wraps then |
|
1445 endX:= RightX |
|
1446 else |
|
1447 endX:= X1; |
|
1448 end; |
|
1449 if w < Wraps then |
|
1450 begin |
|
1451 x:= x + (RightX - LeftX); |
|
1452 endY:= Y0 + (totalY / totalX) * x; |
|
1453 end |
|
1454 else |
|
1455 endY:= Y1; |
|
1456 |
|
1457 DrawLineOnScreen(startX, startY, endX, endY, Width, r, g, b, a); |
|
1458 end; |
|
1459 |
|
1460 end; |
1353 |
1461 |
1354 openglPopMatrix(); |
1462 openglPopMatrix(); |
1355 |
1463 |
1356 UpdateModelviewProjection; |
1464 UpdateModelviewProjection; |
1357 end; |
1465 end; |