samedi 28 mai 2016

Design for Graphic Rendering in Java with Unspecified update reasons (Hierarchical)

I'm working for graphic rendering part of my program, and got into several severe problems with my previous design.

So, I want to ask how to design structures of renderers and models. Or is there specific design pattern to handle this case?

Currently I have hierarchical implementations of

  • Renderers (Graphics)
  • Models (Data to Render, Receive Updates)

I accepted hierarchy since rendered contents can be classified, and should be managed separately.

There are several limiting conditions:

  1. Rendering is done on rendering loop.
  2. There could be many types of renderers and models, and the design should not be aware of them.
  3. There could be various reasons to update models.
    1. Update reasons should not be specified in the design itself, since various reasons can be added.
    2. Models are aware of possible update reasons for itself.
  4. Renderers have Render Passes and Render Helpers.
    1. Types of Render Passes are dependent to the Classes(groups) of renderers.
    2. Render Helpers should be provided, and each renderer should be able to use different version of it.

EDIT: Source to explain current situation.

Renderer:

public interface IRenderer<Settings, Pass, Model, Helper> {
    public void initialize(Settings settings);
    public void preRender(Settings settings, Helper info);
    public void renderPass(Model model, Pass pass, Helper info);
    public void postRender(Settings settings, Helper info);
}

Model:

public interface IModel<Settings, UpdateInfo> {
    public void initialize(Settings settings);
    public void update(Settings settings, UpdateInfo update);
}

Aucun commentaire:

Enregistrer un commentaire