Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

1335 Excellent

About CableGuy

  • Rank
    Advanced Member

Personal Information

  • Role
  • Interests
  1. CableGuy

    Personal Update

    Glad you are feeling better and hope to read your posts sooner than later
  2. I have a question regarding the implementation of AbstractDelegate. AbstractDelegate has a member called v which is a vector of events but to me it seems the vector would always be of size 1 (or 0) because for each new connection the Delegate class creates a new instance of ConcreteDelegate. So is there actually a reason to store a vector of events in AbstractDelegate or am I missing something?   Thanks.   BTW, Great article.
  3. CableGuy

    Memory management of resources

    @haegarr I think your concept of a resource pool is too much for my needs. It seems to me that the resource pool purpose is to reduce the dynamic allocations using new / delete but for now that isn't an issue. And besides, even when using the resource pool I'll still have to manage the memory manually but instead of calling delete on the pointer, I will need to tell the resource pool that the memory is not used anymore.   I'm considering going with an intrusive reference counting approach. It seems to me to have the most convenient usage with not too much overhead...
  4. CableGuy

    Memory management of resources

    Thank you guys for the responses   @imoogiBG - If I understand you correctly, you are basically using intrusive reference counting inside your resource classes?   @haegarr: I agree with the sole responsibility principle but I still can't see how you would solve the problem I described. Given a resource that wasn't loaded using the resource loader but was manually created how would you go about and manage its memory? or are you saying that every memory allocation would go through the resource pool?
  5. Hi,   I know this question had probably been asked a few times and I did search the forums but couldn't find what I'm after.   My question concerns memory allocation (of resources in a game) and how to avoid having to manage them manually.   At first, my little game framework had (almost) everything wrapped in std::shared_ptr.  I think this has impacted performance (AFAIR I did profile it) and also leads to bad design. Recently I removed every use of std::shared_ptr in favor of raw pointers and started to actually think about ownership of memory to define who has the responsibility to free the resources. I have a class called ResourcePool which given a type of a resource, it allocated it and is the owner of the resource and therefore responsible to free its memory. But what if for instance, I would like to clone a resource (because I'm going to change it and don't want everything which uses this resource to be affected).  The cloned resource wasn't created using the ResourcePool (The resource pool can create resource only from files) and therefore won't be freed by it which leaves the responsibility to the user. I can think of three solutions to the problem: 1. Use shared_ptr (or probably my own intrusive reference counting) but that's what I was try to avoid in the first place. 2. Leave it to the user, but in the long run is cumbersome and would cause memory leaks if not carefully taken care of 3. Add the resource to the ResourcePool (or other class) which will become the owner of the resource and therefore will free it.   I hope I was clear enough and would like to hear what other designs have you guys used to avoid having to manually manage memory in your game   Thanks
  6. Can't you initialize your Lua states before hand and store them in an array, one for each thread? Also you might want to look here, some of the libraries allow concurrent execution of Lua code
  7. I would suggest to parametrize the plane using two orthogonal vectors that lie inside. Then every point on the plane would have the form: P0 + a*V0 + b*V1 where P0 is the origin V0,V1 are the orthogonal vectors and a,b are scalars (this is basically an affine 2d space defined in 3d space)   Hope this helps
  8. CableGuy

    How to create a level editor

    Are you seeking to create a tilemap based level editor or polygonal one? (Also I assume you are aiming at a 2d game) Both cases usually have different representation of the game world. With a tilemap, a 2D matrix specifying which tile to use at each (X,Y) is the most logical. A polygonal map representation, at it's most naive form, will store an array of polygons. The representation of the game world greatly affects how you would implement the level editing area in your editor
  9. I guess you can use glGetTexImage to get the texture data and then create an appropriate OpenCV matrix and point it to the data retrieved from OpenGL.
  10. CableGuy

    OpenGL QuadTree Issue

    I used the same approach for the my quad tree implementation. Faces only have x and y coordinates, but the bounding boxes for each node is 3d. For culling there is not need to convert each face. The bounding boxes are already 3d and you just perform culling on them. Once you have found a leaf node which is visible you add it's indices. Same goes for picking  until you reach a leaf node, where you will have to check each triangle with the picking ray.   Hope this helps.
  11. CableGuy

    Dealing with bind-to-edit in OpenGL

    I have most of my resources pointed to as shared_ptr's. I know it is not the best solution but it works for now. Also why do you need to cache the rendering state? In my code, a list is prepared containing all things to be rendered this frame. Then it is sorted to reduce state changes and then rendered in a single function removing the need to store a global cache.
  12. You need to go to Linker->Input->Additional Dependencies and add the lib files there (only write their name, no need for full path ie. sdl.lib) SDL.dll should reside in a place where your exectuable can find it as with any dll: in the application directory, Windows directory, etc... EDIT: reread you post Additional Dependencies should contain the name of the libraries as I wrote, the libraries path should be entered in Linker->General->Additional Library Directories
  13. CableGuy

    SDL collision detection!

    I didn't quite get exactly what type of game you are creating and what exactly you are trying to achieve... If you can answer those question I might be able to help you rethink your problem
  14. CableGuy

    SDL collision detection!

    What do you mean by strange? What are the exact problems you are facing? Tile collision is pretty easy. Usually you have a 2d array representing the map, checking for collison simply invovlves getting the player position in the tile map and indexing the array to check if this tile is passable. Your code looks a bit overly complicated. Why do you have a for loop when checking for collisions?
  15. A global function and a member function are not the same. even if they appear to have the same signature, a non-static member function always has a hidden "this" parameter. May I suggest using boost::function?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!