View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1ZomeonE  Members

Posted 11 January 2000 - 04:21 AM

I've been thinking and thinking what could be wrong, but I'm too tired to figure that out so maybe you can help me. It looks like this:
quote:
int Blt_Clipped(int x, int y, int width, int height, LPDIRECTDRAWSURFACE7 surface) { RECT src; if((x >= SCREEN_WIDTH) // (y >= SCREEN_HEIGHT) // ((x + width) <= 0) // ((y + height) <= 0)) //Check if surface is totally off the screen return 0; int x1 = x; // Compute bounding box of surface int y1 = y; int x2 = x1 + width; int y2 = y1 + height; if (x1 < 0) // Check if surface is off the left edge x1 = 0; if (y1 < 0) // Check if surface is off the top y1 = 0; if (x2 >= SCREEN_WIDTH) //Check if the surface has gone off the screen to the right x2 = SCREEN_WIDTH; if (y2 >= SCREEN_HEIGHT) // Check if the surface har gone off the bottom of the screen y2 = SCREEN_HEIGHT; src.top = y1 - y; // Calculate which part of src.left = x1 - x; // the surface to use src.bottom = y2 - y1; // when blitting src.right = x2 - x1; backsurf->BltFast(x1, y1, surface, &src, DDBLTFAST_WAIT); // Blit surface to backbuffer return 0; // Return function }
The problem is that the bitmap is clipped on all sides when partially outside the screen on the left or top side. This doesn't happen on the right or bottom side of the screen. What could i do to make it work? Edited by - ZomeonE on 1/11/00 11:32:39 AM Edited by - ZomeonE on 1/11/00 11:47:03 AM

### #2ZomeonE  Members

Posted 11 January 2000 - 05:33 AM

I really need some help, isn''t there anyone who can help me?

### #3MikeD  Members

Posted 11 January 2000 - 05:42 AM

ZomeonE, a good practice, if you want to understand your code or if you want anyone else to understand it (which is a mild pre-requisite for them helping you) is to comment it.

It might look obvious to you what it does but it adds a factor of ten to the difficulty of anyone else trying to understand it. Yes, even for the simplest code.

Besides, if you make this effort for others, they may be more inclined to return the gesture and help you.

Mike

### #4ZomeonE  Members

Posted 11 January 2000 - 06:10 AM

There''s no need to answer, I figured it out by my self.

Thankz anyway!

Correction:

src.bottom = y2 - y;
src.right = x2 - x;

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.