Can I do clipping in DelphiX...

Started by
3 comments, last by AM 22 years, 7 months ago
I just recently moved from PMode DOS to DX Windows, and wondered if clipping is possible in DelphiX or just DirectX 7 with the JEDI headers. -Is there any source code avalible? AM AM TMB Productions
AMTMB Productions
Advertisement
In DirectX there''s a thing DirectClipper. You might need to look at docs for it''s usage.
However, the clipping can also be done by specifying the source and destination bitmap coordinates.

Here''s a C++ code from my previous project BCB library (u''d prolly have to convert it to pascal):

  int Blit(LPDIRECTDRAWSURFACE surf, int xpos, int ypos, int pattern){  TRect ClipRect;  DDSURFACEDESC ddsd;  RECT srcRect;  RECT dstRect;  DWORD dwFlags;  HRESULT ddrval;  int PWidth = 64;  // pattern width & height  int PHeight = 64;  int PPL = SurfaceWidth / PWidth;  // patterns per line  int StartX, StartY, LengthX, LengthY;  StartX = (pattern % PPL) * PWidth;  StartY = (pattern / PPL) * PHeight;  LengthX = PWidth;  LengthY = PHeight;  ZeroMemory(&ddsd, sizeof(ddsd));  ddsd.dwSize = sizeof(ddsd);  surf->GetSurfaceDesc(&ddsd);  ClipRect.Left = 0;  ClipRect.Right = ddsd.dwWidth;  ClipRect.Top = 0;  ClipRect.Bottom = ddsd.dwHeight;  if (xpos < ClipRect.Left)  {    StartX+= (ClipRect.Left - xpos);    LengthX-= (ClipRect.Left - xpos);    xpos = ClipRect.Left;    if (LengthX < 1)      return 0;  }  if (ypos < ClipRect.Top)  {    StartY+= (ClipRect.Top - ypos);    LengthY-= (ClipRect.Top - ypos);    ypos = ClipRect.Top;    if (LengthY < 1)      return 0;  }  if (xpos + LengthX > ClipRect.Right - 1)  {    LengthX = ClipRect.Right - xpos - 1;    if (LengthX < 1)      return 0;  }  if (ypos + LengthY > ClipRect.Bottom - 1)  {    LengthY = ClipRect.Bottom - ypos - 1;    if (LengthY < 1)      return 0;  }  srcRect.left = StartX;  srcRect.top = StartY;  srcRect.right = StartX + LengthX;  srcRect.bottom = StartY + LengthY;  dstRect.left = xpos;  dstRect.top = ypos;  dstRect.right = xpos + LengthX;  dstRect.bottom = ypos + LengthY;  dwFlags = DDBLT_WAIT;  if (FTrans)    dwFlags = dwFlags | DDBLT_KEYSRC;  ddrval = surf->Blt(&dstRect, lpDDS, &srcRect, dwFlags, NULL);  if (ddrval != DD_OK)    return -1;  return 0;}  
Thanks man, I''ll use it, but if anyone knows how to program the DirectX clipper then please post code for that also.



AM
TMB Productions
AMTMB Productions
Most of what I know about DirectX in Delphi I learned by digging around the source code for DelphiX. If you look at his TDirectDraw.Surface.Draw() you''ll get a good idea of how DDraw performs clipping...



[ Michael Wilson | turbo sys-op | turbo.gamedev.net ]
[ Michael Wilson | turbo sys-op | turbo.gamedev.net ]
Yeah, I''ve done a little of that already, but I guess I could go deeper into it. -Thanks for your reply.



AM
TMB Productions
AMTMB Productions

This topic is closed to new replies.

Advertisement