karpatzio

Member
  • Content count

    38
  • Joined

  • Last visited

Community Reputation

143 Neutral

About karpatzio

  • Rank
    Member
  1. VBO listeners for buffer updates

    I realize that. I do keep all vertex data packed together, and can render an entire model using it. However, I now need several more models that share most of the data of the original vertex buffer, but require more data to be loaded and unloaded dynamically since I cannot realisitcally have it all loaded at the same time.
  2. VBO listeners for buffer updates

    Thanks for your answer! I do keep all vertex related data together, but I also load\unload more data such as bone animations, texture coordinates on the fly when needed which I prefer to do in separate buffers. What I would like to do is alert when there is inconsistency in the mesh due to errors whille updating such data. I was wondering what patterns or mechanisms others use to find such inconsistencies and handle them.
  3. In my game I wrapped all vertex buffers, index buffers, textures etc in separate classes which make updating, reading and activating more convenient and API independant. Now, meshes are constructed from combinations of all of these buffer objects that can be shared by more than one mesh so buffers are managed in separate containers and are not owned by the meshes.   This raises issues when buffers are changed in such a way that could break the mesh, e.g. having one buffer with position, color with N vertices and anoter buffer with texture coords that was changed to contain M vertices which is different. I was wondering how you guys are dealing with this in your  games\engines.
  4. Thank you both! I guess i'll just have to experiment with my code and walk into dead ends a couple of times until i do find some balanced scheme (for linux\windows\android\iOS at least).
  5. When designing for multiple APIs\platforms, basically there are two options for abstracting differences between the APIs: 1) Defining the low level constructs such as buffers, textures, devices/contexts. And define the basic functioins such as drawing, uploading data to buffers etc. Then have a different implementation file for these constructs per API. 2) Managing these low level details in higher level classes such as perhaps VertexBuffer and Model classes and such, and also have per API implementation files. Which option pays off more in the long run?
  6. Great! I better understand what you're saying now. The main reason i went down the path that i did was the idea that a renderable shouldn't be allowed to render itself in the context of a whole scene. But really optimizations like avoiding unnecessairy state changes, grouping for instancing and all that stuff don't really require me to centeralize my rendering code. Thanks!
  7. I read your blog post, i think thats [i]sort of [/i]what im doing now. Entities, nodes in the scenemanager and the scenemanager themselves dont actually have any API specific code other than "Entity" storing the API agnostic data needed for rendering (position, bounding volume stuff like that) but also the api specific stuff like buffers and textures in the form of say a list of "vertex elements" and "Texture" classes like youv'e talked about in your post that i extend with the information that each API, the handles, sizes and all that. So the general idea is like this: [source lang="C++"]enum ElementType { Position, Normal, TextureCoords }; class VertexElement { .... protected: ElementType m_type; Array m_data; }; typedef std::list<VertexElement, Element Type> ElemetList; class glVertexElement: public VertexElement { .... public: gluint getHandle(); private: GLuint m_handle; GLSizei m_size; .... }; class glTexture: public Texture { ... private: GLuint m_texture; }; class Entity { ... VertexElement* getElement(unsigned int index); Texture* getTexture(); private: Texture m_texture; ElementList m_elements; }; class RenderingQueue { public: std::vector<Entity> entities; } [/source] Then these Entities are attached to nodes in the scenemanager which collects them every frame to dispatch to the API specific renderer in the form of a queue of vertexelements and materials, possibly arranged, sorted and grouped for instancing. Creating an entity and rendering it might go something like this (at the lowest level): [source lang="cpp"]ElementList *elemList = ElementList::create(); elemList.push_back(VertexElement::create(Position, someBufferOfData)); elemList.push_back(VertexElement::create(Normal, someOtherBufferOfData)); elemList.push_back(VertexElement::create(TextureCoords, yetAnotherBufferOfData)); Texture *texture = Texture::create("./texture.tga"); Entity someEntity(elemList, texture); SceneManager manager(...); manager.addNode(someEntity); Renderer renderer = Renderer::create(); RenderingQueue queue = manager.getQueue(); renderer.render(queue);[/source] I guess that what i was more specifically asking is that once the renderer does recieve the entities to be rendered, how do i avoid casting the VertexElements and Textures to the glTexture and glVertexElement. But looking at your code i guess i can subclass this.
  8. Ive been spending the last couple of days making drafts of a directx+opengl abstraction layer and Ive run across some points that make me want to get input. So basically, all the drawing data is stored in an "Entity" class as an abstract VertexDecleration class and some of the data like position and orientation are stored in an EntityInstance class. Drawing data is API specific so i have a glVertexDecleration + dxDecleration etc..... I have a "mesh loader" class that reads a file, creates buffers (on system memory) along with some semantics and stuff. Then the mesh goes through an API specific class, lets call it "mesh\texture binder" that handles VBO, indexing and details like that. Then the entity is stored in a "cache" class. something like this: class Entity { public: Entity(vec3 position, box boundingVolume, .....); private: vertexDecleration m_decl; } template <class BINDER, class CACHE> class Meshloader { typedef shared_ptr<Entity> EntityPtr; public: EntityPtr loadEntity(const std::string &filename); void destroyEntity(EntityPtr); private: BINDER m_binder; CACHE m_cache; } Now, scenes are managed with a scenemanager that handles instances of Entities and is oblivious of the rest of the system, especially to the underlying VertexDecleration type and API. So FINALLY my question is: how do i elegantly collect entities to be drawn and propegate them to the API specific renderer? I know i can just cast upwards and stuff but that feels flakey to me... So, id just like input on how you handle stuff like this in your own code... THANKS!
  9. Advice on containers

    Thank you alvaro, i like that solution. About the angles what i meant is that i have a container in which i store images keyed by angles. When i want to fetch an image i request an angle and the container will retrieve the image whose angle (key) is closest to the angle i asked for. [Edited by - karpatzio on November 18, 2010 2:21:24 PM]
  10. I would like my animation class to store the frames, but also store a duration or timestamp of each frame. Then i would like to be able to fetch frames according to the elapsed time. I would love any advice on how to approach this efficiently. While at it i would also like to store animations and images at different angles using the same principles only returning the images stored in the closes matching or lower/upper bounding angles. Thanks in advance to anyone who helps.
  11. I would like my animation class to store the frames, but also store a duration or timestamp of each frame. Then i would like to be able to fetch frames according to the elapsed time. I would love any advice on how to approach this efficiently. While at it i would also like to store animations and images at different angles using the same principles only returning the images stored in the closes matching or lower/upper bounding angles. Thanks in advance to anyone who helps.
  12. Help with game engine design

    Quote:Original post by Captain P Quote:Original post by shuwo Now I've got a new problem. Where do I put all my objects? For example, if I have a lot of game objects (sprites) like Enemy, Player, Fish, etc, where do I "create" them? I usually make a Game class of some sort and put them there. It may be useful for certain game objects to have a reference back to the Game object - this would allow your characters to create Bullet objects and add them to the Game, or to ask the Game which other characters are nearby. No need to use globals here, though. If some code needs to know about the Game object, just pass it a reference or pointer to the Game object. This would create unnecessary dependencies, game logic should be handled by other classes. For example create a sprite collection class that would handle collisions, movement and creation/destruction instead!
  13. DnD rest party formula

    I played the series and also some earlier games like pool of radiance and such, and if i remember correctly the game asked the player if he wants the clerics to heal party. The clerics would use their current healing spells and gained them again after resting, it also used spare spell slots to memorize healing spells if any are available. I guess the algorithm should take into account which spells have the highest time to HP ratio but thats about as sophisticated i think it could get.
  14. C++ Newbie here, need help

    I sent you a pm with a good book that will help you get over your hurdle.
  15. C++ Newbie here, need help

    If you use a forward declaration you need not include the header file, fix that in IO.h. Include the tile header file in IO.cpp.