Quote Originally Posted by WILL View Post
The 3D water is still killing me. I figured out how to have the water actually move with them map, but I'll be damned if I can figure out how to have it draw within a set confines of a viewport.

Any 3D OpenGL experts out there?
If you want to clip the water within a rectangular part of the screen (viewport), you can use code like this (origin at top left of screen):

Code:
procedure TxeGraphics.SetClippingRect_2d(x,y,w,h: Word);var
  xeMax    : Integer;
  xeMin    : Integer;
  glMax    : Integer;
  glMin    : Integer;
  scissorY : Integer;
begin
  if (x = 0) and (y = 0) and (w = FWidth) and (h = FHeight) then
  begin
    glDisable(GL_SCISSOR_TEST);
    Exit;
  end;


  glEnable(GL_SCISSOR_TEST);


  // in 2d mode, OpenGL y-coords are 0 at bottom, FHeight - 1 at top
  glMax := FHeight - 1;
  glMin := 0;
  // in 2d mode, xe y-coords are 0 at top, FHeight - 1 at bottom
  xeMax := 0;
  xeMin := FHeight - 1;


  scissorY := glMin + (glMax - glMin) * ((y - xeMin) div (xeMax - xeMin));


  glScissor(x,scissorY,w,h);
end;
If you want a non-rectangular clipping region, you need to use the stencil buffer I believe....