Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AM

Can I do clipping in DelphiX...

This topic is 6085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 ]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!