If this is your first visit, be sure to check out the FAQ by clicking the link above. You have to register before you can post.

If you have recently signed up, please make sure you log in so that your activity is registered. This is required for automatic promotions to work and to ensure your account is not deleted during the registration process.

26/10/17 Didn't get anything done today. Trying to figure out best way to do chunk management.
29/10/17 Some progress on chunk management. Next need to make my OpenGL code compatible with arbitrary amount of objects. Too late in the night to start that.

Since you're not using any framework, may be it can be used with SDL or Allegro or GLScene, can it?

Also, did you plan to make it compatible with FreePascal?

It looks like that yes, but it won't be minecrafty. Gamewise, I am juggling between Dwarf fortress, Master of Magic, UFO etc. It'll definitely be a management game. I like stuff like evolution and fuzzy logic and geological evolution. I have no idea how those ingredients turns into a game Maybe it'll just be my own sandbox for weird ideas.

The engine itself should end up being relatively reusable so that I can use it for various things. Also because I do not know what I am doing, and I always forget everything so it needs to be something that is relatively easy to jump onto. I do not know what it entails to make it compatible with free pascal.

In reference to freeing all the TChunks in TDictionary<string, TChunk>, how do I do it?

I don't see a way to just do

Code:

for I = 0 to count-1 do
TDict.Items[0].Free

as it is not sorted or indexable in that way

Do I need to extract all the keys and then iterate with that list? That hardly seems like a smart way to do it.

OK this works

Code:

for Chunk in TDict.Values do Chunk.Free

Uhhh... why aren't you just using a TObjectDictionary with "doOwnsValues" set in the ownerships parameter in the constructor? That's what they're there for. That way, it works exactly like a TObjectList that has OwnsObjects set to true, and you don't need to do anything at all in your destructor as all the dictionary values will be freed automatically.

I have several dictionaries that juggle values between them, so I want to manage the lifetime of the contents myself. But when closing the program I rather empty all the dictionaries. I had a code looping the keys and then getting the values and then freeing the values. that resulted in mem leaks. But I found I can just iterate the values directly and free them. I just haven't used dictionary before. Anyway it is solved.

For graphics card I have Nvidia GFX 860M or something like that. Laptop. I didn't see any notes about maximum size in the OpenGL documentation. Will continue on this issue tonight.

I'm not sure exactly how TDictionary works but in general when you are removing items from Lists it is always better to go from last item to first instead of always removing first item in a loop. Why?
Because when you remove first item from the list all other items needs to be shifted in order to fill the hole that you caused by removing that one item. This results in lots of unneeded data moving in the list internal array.

I'm not sure exactly how TDictionary works but in general when you are removing items from Lists it is always better to go from last item to first instead of always removing first item in a loop. Why?
Because when you remove first item from the list all other items needs to be shifted in order to fill the hole that you caused by removing that one item. This results in lots of unneeded data moving in the list internal array.

I agree and would have done it 'from count-1 downto 0' but that is not possible with TDictionary. Anyway freeing the Chunks is only for the program shutdown so performance is not that important anyway.

Also I think if I do

for Chunk in TDict.Values do Chunk.Free

it still leaves the keys in, so the size of TDict size is not updated. Might be the size is not updated even if I removed the key as well, since there is some method to it called TrimExcess

Didn't work much today.

Fixed one bug, but made no progress on the case of too large VBO size causing full chunks disappear.

Line of 11x11 size chunks along X axis. If I decrease the count by few they all fill a nice solid line as supposed to. Too many like here, and something gets corrupted. Note the closest artifact, the whole chunk is not missing, only half of it (It is hollow since none of the cubes that should not be visible are not drawn)