277 {$ELSE} // pas2c part |
277 {$ELSE} // pas2c part |
278 glLoadExtension:= false; |
278 glLoadExtension:= false; |
279 {$ENDIF} |
279 {$ENDIF} |
280 end; |
280 end; |
281 |
281 |
282 {$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)} |
282 {$IFDEF USE_S3D_RENDERING OR USE_VIDEO_RECORDING} |
283 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
283 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
284 begin |
284 begin |
285 glGenFramebuffersEXT(1, @frame); |
285 glGenFramebuffersEXT(1, @frame); |
286 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
286 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
287 glGenRenderbuffersEXT(1, @depth); |
287 glGenRenderbuffersEXT(1, @depth); |
415 |
415 |
416 Tint(255, 255, 255, 255); |
416 Tint(255, 255, 255, 255); |
417 UpdateModelviewProjection; |
417 UpdateModelviewProjection; |
418 {$ENDIF} |
418 {$ENDIF} |
419 |
419 |
420 {$IFNDEF USE_S3D_RENDERING} |
420 {$IFDEF USE_S3D_RENDERING} |
421 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then |
421 if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then |
422 begin |
422 begin |
423 // prepare left and right frame buffers and associated textures |
423 // prepare left and right frame buffers and associated textures |
424 if glLoadExtension('GL_EXT_framebuffer_object') then |
424 if glLoadExtension('GL_EXT_framebuffer_object') then |
425 begin |
425 begin |
426 CreateFramebuffer(framel, depthl, texl); |
426 CreateFramebuffer(framel, depthl, texl); |
846 |
846 |
847 procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
847 procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
848 var ft, fb, fl, fr: GLfloat; |
848 var ft, fb, fl, fr: GLfloat; |
849 hw, hh, nx, ny: LongInt; |
849 hw, hh, nx, ny: LongInt; |
850 begin |
850 begin |
851 |
851 // visibility check only under trivial conditions |
852 // note: not taking scale into account |
852 if (Scale <= 1) then |
853 if isAreaOffscreen(X, Y, w, h) then |
853 begin |
854 exit; |
854 if Angle <> 0 then |
|
855 begin |
|
856 if (OffsetX = 0) and (OffsetY = 0) then |
|
857 begin |
|
858 // sized doubled because the sprite might occupy up to 1.4 * of it's |
|
859 // original size in each dimension, because it is rotated |
|
860 if isDxAreaOffscreen(X - w, 2 * w) <> 0 then |
|
861 exit; |
|
862 if isDYAreaOffscreen(Y - h, 2 * h) <> 0 then |
|
863 exit; |
|
864 end; |
|
865 end |
|
866 else |
|
867 begin |
|
868 if isDxAreaOffscreen(X + dir * trunc(OffsetX) - w div 2, w) <> 0 then |
|
869 exit; |
|
870 if isDYAreaOffscreen(Y + trunc(OffsetY) - h div 2, h) <> 0 then |
|
871 exit; |
|
872 end; |
|
873 end; |
855 |
874 |
856 { |
875 { |
857 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
876 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
858 if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * 2 > ViewWidth) then |
877 if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * 2 > ViewWidth) then |
859 exit; |
878 exit; |
1460 ViewBottomY, |
1479 ViewBottomY, |
1461 first, count) |
1480 first, count) |
1462 else |
1481 else |
1463 PrepareVbForWater(true, |
1482 PrepareVbForWater(true, |
1464 OffsetY + WorldDy + cWaterLine, ViewTopY, |
1483 OffsetY + WorldDy + cWaterLine, ViewTopY, |
1465 LeftX + WorldDx - OffsetX, ViewLeftX, |
1484 LongInt(LeftX) + WorldDx - OffsetX, ViewLeftX, |
1466 RightX + WorldDx + OffsetX, ViewRightX, |
1485 LongInt(RightX) + WorldDx + OffsetX, ViewRightX, |
1467 ViewBottomY, |
1486 ViewBottomY, |
1468 first, count); |
1487 first, count); |
1469 |
1488 |
1470 // quit if there's nothing to draw (nothing in view) |
1489 // quit if there's nothing to draw (nothing in view) |
1471 if count < 1 then |
1490 if count < 1 then |
1539 // ( ox and dy are used to create different horizontal and vertical offsets |
1558 // ( ox and dy are used to create different horizontal and vertical offsets |
1540 // between wave layers ) |
1559 // between wave layers ) |
1541 dY:= -cWaveHeight + dy; |
1560 dY:= -cWaveHeight + dy; |
1542 ox:= -cWaveHeight + ox; |
1561 ox:= -cWaveHeight + ox; |
1543 |
1562 |
1544 lx:= LeftX + WorldDx - ox; |
1563 lx:= LongInt(LeftX) + WorldDx - ox; |
1545 rx:= RightX + WorldDx + ox; |
1564 rx:= LongInt(RightX) + WorldDx + ox; |
1546 |
1565 |
1547 topy:= cWaterLine + WorldDy + dY; |
1566 topy:= cWaterLine + WorldDy + dY; |
1548 |
1567 |
1549 |
1568 |
1550 if (WorldEdge <> weSea) then |
1569 if (WorldEdge <> weSea) then |