Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


2d engine design issue

This topic is 5347 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this may be just a small detail but I would like to do it right the first time Okey, I have an Engine class and a Texture class. Should the engine handle the loading and drawing of textures or should the texture be allowed to load and draw itself. Example: Texture tex = engine->loadTexture("texture.bmp"); engine->drawTexture(tex); or Texture tex; tex.load("texture.bmp"); tex.draw(); Whats the most correct way OO wise? By the way its a 2D engine using SDL. Thanks.

Share this post

Link to post
Share on other sites
na, have a texture manager. you need to be able to manage resources yourself, else it''s gonna be a nightmare to manage. You can then prioritise them, organise them in groups (menus, sprites, fonts, particles, backgrounds, ...), not downloading the same texture twice, being able to release the textures without tracking down each of the textures separately (you can count the references, if the reference count reaches zero, free the texture, if the reference count goes from zero to one, reload the texture, but watchout for memory fragmentation if you are that bothered), reusing the textures for different things (skybox and environment mapping?).

so it should really be dealt with by a global engine, that will do the dirty work for you (once you get the texture manager sorted ). Like all the other resources of the game (audio files, models, materials, animations, ect...). A resource is supposed to be shared by various things, so it''s good to keep it global and easily accessible.

well, that''s what I''d do anyway.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!