Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » clean to color

This thread is locked; no one can reply to it. rss feed Print
 1   2 
clean to color
a b
Member #8,092
December 2006

For example in this code should be or shouldn't be: clear_to_color(buffer,makecol(255,255,255)); ??????????????

while(index!=10)
{
index++;
clear_to_color(buffer,makecol(255,255,255));
blit(board,buffer,0,0,0,0,board->w,board->h); 
masked_blit(pawn,buffer,0,0,tab[0][index],tab[1][index],pawn->w,pawn->h);  
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
}

gnolam
Member #2,030
March 2002
avatar

What the hell do we know?

If "board" covers the entirety of "buffer", then no, you don't need to clear the buffer. Otherwise, you probably do.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

a b
Member #8,092
December 2006

yes it covers everything but is it good that all overlaps on yourself ?? without clear_to_color(buffer,makecol(255,255,255)); everything looks good but is it pretty that this overlaps without clear?

X-G
Member #856
December 2000
avatar

Don't do it, gnolam! Run while you still can!

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

a b
Member #8,092
December 2006

X-G please go away if you don't want write somothing helpful.

gnolam
Member #2,030
March 2002
avatar

Oh Bog. I forgot who I was replying to! :-X

Quote:

yes it covers everything but is it good that all overlaps on yourself ?? without clear_to_color(buffer,makecol(255,255,255)); everything looks good but is it pretty that this overlaps without clear?

If everything gets overdrawn every frame there is no reason to clear the buffer.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Kauhiz
Member #4,798
July 2004

If it looks the same without the line, remove it. It's that simple. I know it'll probably take another 180 posts to get the point through to you, but here's hoping it won't.

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

a b
Member #8,092
December 2006

ok - simply english is very important for me !! :)

Kikaru
Member #7,616
August 2006
avatar

That's what we give you though! It's like saying you want peanuts when we give you a bag of them! >:(

a b
Member #8,092
December 2006

what ? I don't understand.........

Kauhiz
Member #4,798
July 2004

Was your question answered already?

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

a b
Member #8,092
December 2006

Kikaru wrote something:
"That's what we give you though! It's like saying you want peanuts when we give you a bag of them! "
and I don't understand :)

Kauhiz
Member #4,798
July 2004

No, but was the original question answered? Do you still need help?

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

a b
Member #8,092
December 2006

I got good answer and I needn't help :)

Kikaru
Member #7,616
August 2006
avatar

You said you wanted "simply English" - and that's what we already give you! We aren't speaking French or anything! ;)

(P.S. sorry if I come across as rude, I am just rather irked with lots of incoherent new people.)

LennyLen
Member #5,313
December 2004
avatar

Quote:

P.S. sorry if I come across as rude, I am just rather irked with lots of incoherent new people.

And I seem to remember you having an irksome habit of not using google or reading the replies to your questions when you first started posting here. :P

Evert
Member #794
November 2000
avatar

Quote:

You said you wanted "simply English"

It's quite clear that he meant "simple English", or "elementary English". As I'm sure you've noticed, it's not his first language.

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

but is it good that all overlaps on yourself

You don't understand what is happening. blit actually copies the data, so "overlaps" isn't an issue at all. Now, if blit actually moved the data, this would be a concern.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Kikaru
Member #7,616
August 2006
avatar

blit() uses memcpy() on each line, doesn't it? To move the data, you would be using memmove(). Anyway, cool stuff! :)

(P.S. My frustration is also on another forum, and the fact that I have had only 20 min. of free time over the last week (mon-fri). :-/)

Evert
Member #794
November 2000
avatar

Quote:

blit() uses memcpy() on each line, doesn't it? To move the data, you would be using memmove().

blit() actually uses memmove().

Quote:

My frustration is also on another forum, and the fact that I have had only 20 min. of free time over the last week (mon-fri). :-/

Is ok. As long as it isn't personal we don't mind you taking it out on us. ;)

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

To move the data, you would be using memmove().

The difference between memcpy and memmove is that with memmove, the memory areas may overlap. memmove copies the data.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Kikaru
Member #7,616
August 2006
avatar

I thought it cleared the first area too... hmmm...

Audric
Member #907
January 2001

I've never understood what kind of useful result you would get, when blitting a bitmap on (part of) itself.
Does anybody know why blit() is implemented this way? (memmove vs memcpy)
Is it implemented this way because the overhead of checking is tiny, and the consequences would be severe (hang?) if the memory areas were overlapping ?

Evert
Member #794
November 2000
avatar

Quote:

I've never understood what kind of useful result you would get, when blitting a bitmap on (part of) itself.

You can use it for implementing scrolling maps where you only redraw the strip that is "new". Essentially, blit the back buffer to itself with some off-set and then fill in the blank spot. I've used it for this in the past (1999-ish), and it was a lot faster than redrawing the entire tilemap. It probably doesn't matter too much these days.

Quote:

Does anybody know why blit() is implemented this way? (memmove vs memcpy)

I do, because I'm the one who made it use memmove instead of the older code that was in place before. Historically, blit() has always allowed for overlapping regions, which does work with memmove and not with memcpy (more specifically, the behavior is undefined).

Quote:

Is it implemented this way because the overhead of checking is tiny, and the consequences would be severe (hang?) if the memory areas were overlapping ?

I found no measurable speed difference between memmove and memcpy.

Audric
Member #907
January 2001

Thank you Evert

Evert said:

I found no measurable speed difference between memmove and memcpy.

Good reason!

 1   2 


Go to: