Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Sep 2008
Offline Last Active Sep 28 2013 03:05 PM

#5097319 potatoeses or potatoeseses

Posted by on 27 September 2013 - 04:36 PM

If you want to use any inheritance then you need to story individual pointers to objects, so the 4 bytes are required anyway (and it's not like 4 bytes per object will actually make an impact).  If you only have one object then I'd suggest just giving them a bool active variable and then just setting it to zero to show that they're 'dead' or whatever.  As to the unbearableness, it only affects maybe three lines of your code, and besides, you *are* using C++.  What did you expect?  


really though, unless there's some big reason why you're using an array like this, I'd recommend you switch to using a std::vector<SomeObject*>

#5097314 potatoeses or potatoeseses

Posted by on 27 September 2013 - 04:14 PM

Off the top of my head, try

SomeObject **so;

so = new SomeObject*[max_objects];

An array is a pointer to a block of memory, so in your case you want a pointer to a block of pointers that you can then individually allocate

#5081988 Why do I get ridiculous floating point values when I read a binary file?

Posted by on 31 July 2013 - 12:55 PM

Try using a union

union FloatInt
    int i;
    float f;

FloatInt fi;

Are you sure blender wrote a float and not a double?

#5065142 Probably a stupid question...

Posted by on 26 May 2013 - 10:17 PM

Go over the points in your grid, calculate distance from center point of circle to that point.  If it's less than the radius of the circle, then do point.z+=(1-distance_away/radius)*height_change to get a gradient

#5056192 Need advice for iOS game programming

Posted by on 23 April 2013 - 03:39 PM

Check out Unity 3D

#5049794 How do I handle lots of textures

Posted by on 03 April 2013 - 07:41 PM

256MB is a very conservative estimate.  Any recent computer is going to have at least 1GB.  Check out the Steam Hardware survey at http://store.steampowered.com/hwsurvey under VRAM.  99% of people have at least 256MB, 91% have 512MB.  I'm not sure how high resolution textures you're using, but I doubt you'd even get close to the 256.  256MB gives you space for a 8192x8192 texture.  If each tile is 16x16, that gives you enough space for 262144 tiles.  If you've got more than 1000 different tiles loaded at once, you might want to reevaluate what you're doing.    


When your video card runs out of space, the driver will just start using the regular system ram as "virtual memory", which I know causes major slowdowns, but I don't have any first hand experience there.  Don't forget though, using it as virtual memory is going to be pretty much the same as you just uploading your textures from RAM each time they're used.  I'd assume you can do a much better job of switching out the textures that are least likely to be used than the graphics card can, if by some strange turn of events that actually happens.

#5045693 Far Mesh Become Invisible

Posted by on 22 March 2013 - 01:45 PM

Numbers that big are going to be cut off. The computer can't store them. Because of depth buffer accuracy issues, you should generally never have the far distance be more than a few thousand. I'd recommend you use a smaller unit for your world

#5045052 Check video ram usage

Posted by on 20 March 2013 - 05:17 PM

If you're using GL2+, just do this:

int getFreeVideoMemory()
	int availableKB[4];
#ifdef GL234
	int temp=GLEW_ATI_meminfo;
	return availableKB[0];
	return 0;

#5038867 Is a mesh a 3d model?

Posted by on 03 March 2013 - 04:50 PM

Often I've also seen models that contain multiple meshes

#5027742 Anyone here a self-taught graphics programmer?

Posted by on 31 January 2013 - 10:43 PM

When I was fourteen I spent a year and a half writing my own software renderer from random tidbits of information I found around the internet, a lot of trial and error, and plenty of working out how different math worked on post it notes.  Once you've written a software renderer regular graphics programming is a lot easier to understand.

#5023694 Killing AI

Posted by on 20 January 2013 - 06:29 PM

Did you note the i--?

#5023637 Killing AI

Posted by on 20 January 2013 - 03:43 PM

Try using


delete zombie[i];

zombie.clear( zombie.begin() + i-- );

#5020744 Can someone mentor me?

Posted by on 12 January 2013 - 10:42 AM

If you're having problems understanding where stuff is actually used, your best bet is to actually try to program something real and see where they end up getting used.  That said, I'm up for answering some questions.  Feel free to PM/email/tweet/whatever me.

#5010734 Design a render queue

Posted by on 14 December 2012 - 02:59 PM


#5009578 unique_ptr

Posted by on 11 December 2012 - 05:03 PM

The idea is that you shouldn't have a second pointer referencing the same data. Another function could save unique_ptr.get(), just like they could just save a copy of a plain pointer, but having a unique_ptr makes it quite obvious that they shouldn't do that.

4. In this case shared_ptr would be a better bet. However, in general you should have some policy for each class regarding what 'rights' they have regarding the pointer you give them. If you're giving it to another class you should know whether that class is ever going to delete it or anything, and with any of your own classes that will be accessed by another person's code you should also make sure they know if you're going to be doing anything with their pointers. Generally I try to always have a policy regarding any place that a pointer is in my code about who 'owns' the pointer; whether it's the class that contains (say) the array the pointer is in, the function that created the pointer and added it to the array, etc.