Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

pinebanana

Member Since 28 Oct 2012
Offline Last Active May 09 2013 03:24 AM
-----

Topics I've Started

How to abstract OpenGL or DirectX specific things from classes specific to rendering

10 March 2013 - 01:12 AM

I'm not sure if this has been posted before.

 

I'm just not sure how I should abstract OpenGL or DirectX specific things from classes specific to rendering. Such as shaders, texture objects, vertex buffer objects, etc.

 

For example:

 

Let's say there is a Texture2D class, that is used to refer to textures stored on the GPU. The problem is: storing the specific GLuint (or whatever the alternative for DX is) within the Texture2D object directly, which would make my code very dependent to OpenGL. I've thought of a couple alternatives:

 

Option 1:

 

 

Store an unsigned integer inside the Texture object, (not actually the GLuint), which will resemble an index of the actual OpenGL/DX specific data. Which will most likely be present inside a TextureLoader class. Where the Renderer will have a TextureLoader, and may be accessed through a getter.

 

Here is what I mean:

 

Texture2d (this is a basic data structure)
     - width/height
     - index
Texture2dLoader (abstract)
     - loadTexture(const Image&) : Texture2d
     - destroyTexture(Texture& texture)
OglTexture2dLoader : TextureLoader
    - loadTexture(const Image&) : Texture2d // override
    - destroyTexture(Texture& texture) // override
    - vector<GLuint> textures // dynamic array, appended to when loading texture 

 

Here are the pros/cons that I've thought of from this design.

 

Pros:

  • Simple, non dependant on OpenGL or DirectX
  • Easy to make another implementation

Cons:

  • Requires manual deletion, therefore:
  • If Texture object goes out of scope, there will be no way of deleting texture manually

 

Option 2:

 

Make an abstract TextureHandler class, which will have specific OpenGL/DX in the derived class

 

Texture2dHandler (abstract)

     - virtual destructor

Texture2d (this is a basic data structure)

     - width/height

     - handler : unique_ptr<Texture2dHandler>

OglTexture2dHandler : TextureHandler

     - GLuint id

     - (destructor)

Texture2dLoader (abstract)

     - loadTexture(const Image&) : Texture2d

     - destroyTexture(Texture& texture)

OglTexture2dLoader : TextureLoader

    - loadTexture(const Image&) : Texture2d // override

    - destroyTexture(Texture& texture) // override

 

Pros:

  • Allows for RAII

Cons:

  • Handler requires to be allocated on the heap

 

The same issue is also applied to shaders, buffer objects (such as VBOs), and whatever else, and therefore this will be present all over my code. Does anyone have personal experience with this? What option should I go for?

 

This is really bugging my mind. Thanks for reading.


Losing interest in game development...

13 January 2013 - 03:17 AM

This is more of a rant, but not a rant (if you know what I mean?). Lately, well not that lately, I've been gradually losing interest in game development (specifically programming; I can't do art... so yeah), more and more. I don't know what it is! It's very frustrating.

 

Perhaps, it's the amount of work that I do that turns out to be quite useless and I have to re-do it all over again. I just keep failing. I just want to know *everything* about game-development, I want to understand how it's done from the ground up. Yet I can't do it! I mean, I can, but I always get distracted, or annoyed at myself because I just can't think of an appropriate design in order to achieve a task. For example, I'm making my own very simple renderer for my game, built in C++. I know I'm leaving half of the stuff out that I could put it in and that annoys me, e.g. texture options (whether to clamp or repeat the texture) or abstracting OpenGL specific stuff (such as Texture classes w/o GLuint directly in them, more data oriented of a design). I REALISE that I could use another engine, like Ogre3D, or whatever, but whenever I do try to use it, I just hate the way that it enforces you to do things their way (plus I find it somewhat awkward programming with someone else's code, unless I've studied it and frameworks like Ogre3d takes awhile to study). But anyway, my game is 2D so I thought why not use OpenGL by itself (probably going to use legacy code because I haven't really learnt about shaders). Another thing, I've made my own entity system, which I know I can really improve but it just gets all out of hand when I try to.

 

Now, I'm only 17 (last year of high-school this year), didn't turn that too long ago, but yet I want to make money via programming, and the only way that I can think of is: 1. Game Programming and releasing it on the Android/iOS app store (or selling it via a website, 2. being a freelancer programmer (yet most of the skills/experience I don't really have), or 3. Being the next Bill Gates (haha, I'm hilarious). I also want to be somewhat known, and I also want to know a lot, sometimes I just don't have the motivation to learn about new stuff, either that or I'm busy programming. 

 

Hopefully I'll be going to University after high-school, I want to get things done before then though, but before then I want to COMPLETE my projects that I've started, which is hard. I've made a list of what projects I'm wanting to make, but I'm not entirely sure if I'll ever them all done. I'm terrible at planning (the wanting to do everything from scratch when it comes to gamedev with C++ doesn't really help me with getting things done quicker). I've been working on my game for quite some time now, barley got anywhere near completed. (I've got a window open)...

 

Has anyone ever felt some-what of what I'm feeling? Does anyone have advice for me? Should I be in such a rush to get things done at my my age? Or Should I just give up, and move onto something else? Such as: programming applications with Qt, web programming, or perhaps security penetration testing (i.e. ethical hacking), or whatever else. I'm just not sure what I want to do when I'm actually a programmer, I love low-level stuff, but I'm not sure.


C++ Entity System

15 December 2012 - 12:27 AM

After many hours of confusion on how I should implement my Entity System; it has finally been completed (at like 4 in the morning) Posted Image. This framework is based of the Java Entity System, Artemis, however it's a bit different with the way it is implemented, but you will find similarities. Unfortunately it is not entirely complete, I believe the only thing left to do is the SceneDirector, however, that's not really a required class in the framework, it's more of an add-on to help you manage Scene* objects.

*If you are familiar with the Artemis framework, a Scene is a World.

Features:
- Unlimited component-types
- Fast retrieval of components
- Creation of components, entity-systems and entity-managers through a string

If you are going to try this framework out, please submit ANY bugs and feel free to add suggestions. I have put issues in my BitBucket repo available for the public, so please submit bugs/suggestions there. There are no known bugs at the moment, I have resolved them.

NOTE:
If you are unsure what an Entity System is, I recommend reading this basic tutorial and preferably a blog, such as this one, before reading the tutorial, which describes what one is.

EDIT: Moved to tutorial to the public wiki on BitBucket, here.

Questions about Events in my Entity System

08 December 2012 - 07:30 AM

EDIT:
I solved my own problem, and I am going to use an observer pattern but I am going to re-code some parts of my ES, thanks.

At the moment I'm designing an Entity System, in C++, which is some-what based off of the Java Artemis Entity System. Now I'm not 100% sure about the design of my Entity System, mostly handling events. I have multiple choices on what I should do, BUT I just don't know what to do!

Currently I have my code hosted on BitBucket, however, it's incomplete and going to most likely be redesigned.

Here is the basic classes of my Entity System:
  • Entity - An Id (and some methods to add/remove/get/etc Components)
  • Component - An empty abstract class
  • ComponentManager - Manages ALL components for ALL entities within a Scene
  • EntitySystem - Processes entities with specific components
  • Aspect - The class that is used to help determine what Components an Entity must contain so a specific EntitySystem can process it
  • EntitySystemManager - Manages all EntitySystems within a Scene
  • EntityManager - Manages entities (i.e. holds all Entities, used to determine whether an Entity has been changed, enables/disables them, etc.)
  • EntityFactory - Creates (and destroys) entities and assigns an ID to them
  • Scene - Contains an EntityManager, EntityFactory, EntitySystemManager and ComponentManager. Has functions to update and initialise the scene.
Now with the current design, here's a brief of what it does/will look like:
Scene scene;
EntityPtr entity = scene.getEntityFactory().createEntity(); // create an Entity
entity.addComponent(new VelocityComponent(1, 1, 1)); // add a component to the Entity

// add an EntitySystem to the Scene
scene.getSystemManager().addSystem(new MovementSystem());

// activate the Entity (this method wraps the method: scene.activate(EntityPtr entity)), however
// This tells the SystemManager to determine if the systems in the SystemManager object should process an Entity
entity.activate();

// init the scene
scene.initialize();

// Example of a game loop...
while(isRunning)
{
	 // poll our input, etc, etc

	 // update the scene
	 scene.update();
}

Now here's my issue, it is to do with event, as I am not sure how to implement them. Whenever I activatean Entity, the EntitySystemManager (or EntitySystems within the manager) require to be notified when this occurs, to check if the Entity is valid for processing. The ways I am currently thinking of doing this is:

1. Having different Listener objects (or an EntityObserver class), e.g.
void Entity::activate()
{
	  getScene()->getEntityManager().activate(this);
}


void EntityManager::activate(EntityPtr entity)
{
	  // register the entity
	  register(entity); // (simply adds it to an array of entities, for storage)
	
	  // pseudo code
	  for(each entityManagerListener)
	  {
			// notify the listener object
			entityManagerListener->onActivate(entity);
	  }
}

// overridden method from an EntityManagerListener class
void EntitySystemManager::onActivate(EntityPtr entity)
{
	  // pseudo code
	  for(each system)
	  {
			// check the entity
			system.check(entity);
	  }
}
2. Calling explicitly these functions in other classes, e.g.
void Entity::activate()
{
	  getScene()->getEntityManager().activate(this);
}

void EntityManager::activate(EntityPtr entity)
{
	  // register the entity
	  register(entity); // (simply adds it to an array of entities, for storage)

	  // tell the system manager we activated an object
	  getScene()->getSystemManager().onActivate(entity);
}

void EntitySystemManager::onActivate(EntityPtr entity)
{
	  // pseudo code
	  for(each system)
	  {
			// check the entity
			system.check(entity);
	  }
}
3. Just about duplicating the Artemis framework with EntityObserver (with this I have to rewrite some code)
4. Another way of handling these events?
5. All of the above and see which one "feels" better?

Also, is it better to send out events before an update or after an Entity, i.e.
void Scene::update()
{
	 handleEvents(); // handle the events that occurred first, i.e. this will fire out methods to listener/observer objects
	 updateEverythingNecessary(); // then update everything
}
I was told that this would be better, as there are "less" loops?


NOTE:
I just realised I shouldn't really be going
EntityPtr e = scene.getEntityFactory().createEntity();
Instead.. I should be doing
EntityPtr e = scene.createEntity();
... And so on...
That way I can implement the scene in various ways, without the interface depending on those objects.

Organisation/Planning Projects...

28 October 2012 - 05:28 AM

Greetings, I am currently unsure of how to do particular things that relate to organising/planning my software projects. It seems that whenever I plan out to write software, I always get distracted by little things that occur around me, mainly the internet, such as YouTube, Facebook and so on. I feel that I am not prepared enough to tackle my programming projects that I wish to implement, my ideas just keep stacking, I feel a bit overwhelmed with all the things that I wish to do. I'm not a noob to programming, I have been programming for quite some time now, but I really feel like I'm going no where. I feel as if I was more organised/planned and concentrated on my project I would be doing something effective. I don't really wish to pay for any software that will help me organise a project; I'm cheap.

My question is simple, how can I properly organise and manage my programming projects? I have tried using UML, but frankly there is not a good range of free UML programs that are fast to work with, should I even bother with UML and if so, which UML application should I use?

Are there any free applications to "visually" see what a program's GUI (or content, for a game or something) will look like, so I know what I'm actually aiming to do.

Perhaps I'm being a little to abstract. What I really want to know is... how do people, as in people in software development teams (profesional ones) plan out their projects? What steps of organisation do they take? How do they manage their time? Etc.

For example, do they first organise their project by writing out what they wish the program to achieve and who they wish to aim their program to? If so, do they write this in a simple text file, or by hand, or... something else? Do they graphically see their progress as they are achieving their goals, as in graphs or a big TODO list made in Excel or something along those lines?

Any details such as links or a good explanation on how this is done would be really appreciated. I'm not the most organised person, but I really want to become one. I believe it will really help me, compared to just blindly coding and then realising that I could've designed it better and having to rewrite thousands of lines of code over again... Or just sitting there thinking what should I be doing right now

Thanks.


P.S.
I am sorry if there is already a thread about this, I did do a search and I didn't find any results.

PARTNERS