Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [GDK] Rain effect using STD::List library

Author
Message
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 16th Dec 2010 23:19 Edited at: 30th Dec 2010 03:42
After including <list> in your code make sure you add:
using namespace std

This effect took me some time to debug as each time I was erasing an item within the list the program would crash. I fixed this after reading up the MSDN docs and found that list::erase returns a pointer for the iterator to the next available item.




Main.cpp


rain.h


camcontrol.h


I do hope this helps people out understanding the use of lists in C++...

EDIT:
To get this to compile and build you will need to set the Options:
Properties/Configuration properties/C C++/Code Generation
and set it to /MT (not /MTd)

Warning! May contain Nuts!
thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 24th Dec 2010 20:57
Could you post an exe? My compiler is messed up, and isn't letting me run this.

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 27th Dec 2010 03:31 Edited at: 27th Dec 2010 03:44
The project and .exe is attached.

Please note:

To get this to compile and build you will need to set the Options:
Properties/Configuration properties/C C++/Code Generation
and set it to /MT (not /MTd)

EDIT:

Since I wrote this to test the <list> library I have found that there is a big overhead with this. I'm going to re-write it using the <vector> library instead because it use contiguous memory allocation unlike the <list> library which allocates memory per item added.

Because I am removing items from the list and also adding new ones using the <vector> class would be more speed efficient.

Either way I still think it's a good example to show how to use the library with GDK.

(How do you post an image?)

Warning! May contain Nuts!

Attachments

Login to view attachments
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 27th Dec 2010 12:19
to post a picture add to the next post you make, view it, copy the address, edit the above post, then click on image button, then paste the address in.

Dark Physics makes any hot drink go cold.
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 27th Dec 2010 14:27 Edited at: 30th Dec 2010 03:39
The image posting requires an URL where as my image is stored locally. I probably sound daft asking this, is there somewhere I can throw up an image then show it on here?[img]null[/img]

Warning! May contain Nuts!

Attachments

Login to view attachments
thenerd
15
Years of Service
User Offline
Joined: 9th Mar 2009
Location: Boston, USA
Posted: 28th Dec 2010 18:29
Like HowDo said, you can attach the image to your post, and then after posting click the "view" icon and copy that link to use for the URL.

Login to post a reply

Server time is: 2024-04-23 16:01:08
Your offset time is: 2024-04-23 16:01:08