Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Robustprogram

Pages: [1]
1
General / Re: Storing Sprites In A Vector?
« on: November 12, 2014, 11:23:21 am »
Ahhhhhh, thanks guys.

2
General / Re: Storing Sprites In A Vector?
« on: November 08, 2014, 02:14:12 pm »
Quote
Instead of doing this:
std::vector<*Sprite> sprites;
Sprite sprite1;
sprites.push_back(&sprite1);
 

So I am wondering if there is any problems with this implementation.
This does almost the same thing as above, except it leaks memory because now the vector's destructor won't be able to clean up the copy of sprite1.

The moral is: never use raw owning pointers in modern C++ without a VERY good reason.  You won't need them.  Also avoid using pointers of all kinds because you won't need any of them very often, and even smart pointers are always going to be more error prone than ordinary stack-based objects.  If your program has no pointers in it, you simply can't make most of the common memory management mistakes.

Sorry to bump this post but how come the vector's destructor won't be able to clean up the copy of sprite1? Clear me up if I am wrong but the way I see it is that the vector will store the references to the objects instead of the object itself. But since it has the reference, wouldn't it be still be able to clean it up? Sorry if I sound dumb right now.

3
General / Re: Storing Sprites In A Vector?
« on: October 26, 2014, 03:29:45 am »
1. woops :3
2. thank you

4
General / Storing Sprites In A Vector?
« on: October 26, 2014, 03:04:41 am »
I am wondering what will happen if I store the actual object into the vector instead of the reference to it. I am also worried about how the object will be handled after I am done with it.

Like doing this
std::vector<Sprite> sprites;
Sprite sprite1;
sprites.push_back(sprite1);
//What will happen to sprite1? Bad memory management?
 

Instead of doing this:
std::vector<*Sprite> sprites;
Sprite sprite1;
sprites.push_back(&sprite1);
 

So I am wondering if there is any problems with this implementation.

5
Graphics / Re: Light and Shadow Blending
« on: July 01, 2014, 04:57:02 am »
@Lee R. Holy crap, thanks for the tip as I have finally implemented a shadow system now :D
But speaking on clipping, how do we clip in sfml. One thing I was interested in was it possible to clip the area from displaying the light at all.

But still thanks for the example as it really helped me

6
Graphics / Re: Light and Shadow Blending
« on: June 30, 2014, 09:06:41 am »
I tried to use the SFML standard blendmodes by having the lights get drawn onto a rendertexture with blendmode Add for the light and Multiply for the shadow. I then applied the rendertexture to a sprite and I draw the sprite with no other blendmodes.

Also I had a look at both libraries you posted but both of them use OpenGL and that is going to open up more problems as I haven't worked with OpenGL before and just ran into problems when I ran some tests with OpenGL.

7
Graphics / Re: Light and Shadow Blending
« on: June 30, 2014, 07:11:19 am »
Btw this is the best I could do with render Textures ...

I am hopeless XD

8
Graphics / Light and Shadow Blending
« on: June 30, 2014, 06:54:30 am »
I have a poorly pieced shadow system and I am just wondering how to blend both the shadows and light together as I have absolutely no idea how to blend it together. Any help will be appreciated :D

9
General / Re: Lighting Polygon Clipping
« on: January 16, 2014, 12:02:07 pm »
I have spent hours searching on 2D dynamic lighting and I haven't being able to get the most out of it, so I'm wondering if someone can help point onto the right track. (I don't have good research skills).

10
General / Lighting Polygon Clipping
« on: January 16, 2014, 11:19:58 am »
Hello everyone,
I am currently trying to write a dynamic lighting system. Right now I am trying to perform a polygon clipping on a quad as shown in the attachment but I am not sure how to do it. If anyone can help, it will be appreciated  :D

Pages: [1]
anything