Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C] Some GDI routines and fun

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Jul 31, 2009 10:28 pm    Post subject: [C] Some GDI routines and fun Reply with quote

Simple wrapper for CreateDibSection and handling drawing on it. Can load any 32 bit bitmap (GIMP can save these). The functions expect the XRGB padding, so you'll probably get garbage or crash if you try anything else. Can handle alpha blending and image scaling. Also has some crap I wrote to test shit in the archive, a starfield, a Sierpinski triangle and just drawing / scaling some pictures.

If you like mind numbing, nasty code, then this may be up your alley. I commented some of it, but uhhh...


http://www.filefront.com/14169499/gdi_jamboree.rar


Maybe someone will find it useful for making a trainer with pretty effects or something, I dunno.


edit: i also noticed a mistake in the creation of the starfield.

Code:
X_RANGE = SCREEN_WIDTH << 2;
Y_RANGE = SCREEN_HEIGHT << 2 ;


Should be a division (or a right shift)

The 3d to 2d routine assumes the center of the screen as 0, 0. You want to create the stars in a range around the center, like -64 to 64...


Also, the 3d to 2d formula should read:

Code:
   float temp_x = ((stars[index].x / stars[index].z) * FOV_X_SKEW) + (SCREEN_WIDTH  >> 1);
   float temp_y = ((stars[index].y / stars[index].z) * FOV_Y_SKEW) + (SCREEN_HEIGHT >> 1);


You will probably have to crank up the FOV_..._SKEW to compensate.

The FOV_SKEW is the distance to the 45 degree mark from the center, as such, lower numbers will make it very narrow.

Half width / height (and higher) should produce a non distorted image. Maybe I should give it a more descriptive name...



edit2:
Also another stupid logic problem in the alpha blending where a value of 0 would simply function as 255... hurrr.

shoould be...
Code:
   if(alpha == 0x00)
      return;
   if(alpha == 0xFF)
      *dst = color;


while you're at it you can just add

Code:
   if(alpha == 0x00)
      return;


To the start of the bitmap routines so it can simply skip all the work as nothing is necessary. This was enough to bring my CPU usage while drawing a ton of images from 80% on one core to basically nothing.


Last edited by hcavolsdsadgadsg on Wed Aug 05, 2009 3:42 am; edited 4 times in total
Back to top
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Sun Aug 02, 2009 11:49 am    Post subject: Reply with quote

Oh lawl, I just came.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites