Saving screenshot to disk?

Started by
17 comments, last by Win Elchtest 21 years, 1 month ago
temp = Data[index];Data[index] = Data[index+2];Data[index+2] = temp;




I love it how people use temporary values to do swaps...
Try this instead sometime:



Data[index] ^= Data[index+2];Data[index+2] ^= Data[index];Data[index] ^= Data[index+2];


Voila! No temp variable. (I think I did that right)

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg."

- Bjarne Stroustrup

Realm Games Company
"I once thought I was wrong, but then I was mistaken." - A4
Advertisement
Hm. 3 assigns and an overhead-less 4-byte temp versus three XOR-assigns. You have any time-trials to show that your method is dazzlingly faster than mine?

edit : oh, and pardon me for overlooking the additional ADD and 2 pointer lookups that your method includes. Guess you really are just too clever for me. I bow down before you...

edit2 : by the way, your website link appears to be broken.

[edited by - zealouselixir on March 1, 2003 1:35:34 PM]

[twitter]warrenm[/twitter]

I''m not sure if it is faster, but if you are pressed for memory, it does beat your method there.

hmm I musta made a typo in my link...(fixing)
"I once thought I was wrong, but then I was mistaken." - A4
Pressed for memory? That''s about the shittiest excuse I''ve ever heard for someone not admitting they were wrong...

[twitter]warrenm[/twitter]

If you can''t afford and extra byte of memory(or 4, not sure how it ends up), then you''ve got bigger things to worry about!
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
Yeah, that was actually a mistake on my part. Turns out it's just one byte (though it may well wind up as 32 bits on the stack to help out the processor).

[edited by - zealouselixir on March 1, 2003 2:25:42 PM]

[twitter]warrenm[/twitter]

Yes, I may be wrong, but I did show you a neat method... :D

(do it out on pen and paper to see the bits work their swapping magic)

and I correct the link my sig

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do, it blows away your whole leg."

- Bjarne Stroustrup

Realm Games Company
"I once thought I was wrong, but then I was mistaken." - A4
interesting concept, but i think it doesn't work. it's just too late now here to think about it calm (besided i had a birthday party some hours before...)

i write on this again
[you all wanted this posting, didn't you?]


[edited by - Win Elchtest on March 1, 2003 7:12:48 PM]
http://www.quake.de
Ready4Dis: Well... glReadPixels are ALOT slower than rendering directly to the texture If you look through the slides on the link you''ll see that''s the second slowest method (they suggest 5-6 methods I think).

Then saving to a file, well you can''t get away from that now can you?

"No lies of sugar can sweeten the sournes of reality"

}+TITANIUM+{ A.K.A. DXnewbie[onMIRC]
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made chocolate covered peanuts. Pure coding pleasure. ]

This topic is closed to new replies.

Advertisement