abstraction or detail...

Started by
2 comments, last by Thaligar 18 years, 7 months ago
hi, i thought now for couple of days if i should really make a renderer-interface class and derive my renderer from it, but, i'm not sure because if i implement the interface class i can 1.) try to catch every single detail from my api into the renderer (i'm using OGL, and if i do this i can stay at ogl without interface) or 2.) or make it so abstract that i can also easily implement a dx renderer but why (i mean at the moment i can't think of an dx implementation) should i lost all the details of ogl or completly copy the api interface and make a single interface class of it?? please post your opinion and help me with my decision, (well i think often, yeah it would be good to make it so abstract so i can easily change every module) thx in advance for your time (to think about it and to read this fat post) and also for your attandance and your help, greets tgar
Advertisement
I think your abstraction is too fine grain, low-level if all you are going to do is wrap the API functions its going to be a pain. Abstract to a higher level like dealing with scene objects/entities. There will be instances of different types of objects/entities in a scene, a renderer would render those different types in different ways. A renderer could quite easily be an instance of the visitor pattern.
Reduce the dependencies from the API (GL). Write your own (hyper simplified) renderer then it's more simple to reimplement it in two different 'flavours'.

In other words: it's impossible to keep each aspect of GL and DX in a unique virtual renderer unless you take the union of each set of functions (!!!).

The first tip is that I prefer! Try to create classes independent from the Graphic API (ie use your matrices, your viewport, your transform).

However in my experience a decent engine to do something is >90% API indepedent
thanks for your replies,

so the renderer is only needed for let's say, render a model with given matrices and textures, prob. a spec. shader...

it seems to get a little bit clearer but i have to do some more research on that (and on the visitor pattern),

thanks for your time, and your opinions,
but be sure, i'll coming to ask again,
greets
tgar

This topic is closed to new replies.

Advertisement