Organizing rendering code

Started by
10 comments, last by slicer4ever 8 years, 8 months ago

Still, worrying about the overhead of calling "renderer.update()" is kinda silly. I mean, how many calls of those are you even going to issue per frame? One? A dozen at most? I don't think you could even measure that kind of overhead properly.

In any case, making "pass(objects)" a method of the render manager sounds like a bad idea to me. You'll end up with a bunch of specialized methods like OGLManager->ShadowPass(objects), D3DManager->ShadowPass(objects), OGLManager->GeometryPass(objects) and so on.

IMO the pass itself should be an object, not a method. You got your render manager, it has a list of passes to run. So it iterates over each pass, executing the "render" method of each of them Pass knows what state to setup, what shaders to run, and the way you can handle the "object" list to draw can vary (make it part of the pass object, make it external managed by the render manager, etc).

Maybe that way the render manager doesn't even needs to be API specific, just the pass objects themselves.

Thats the bucketing way of drawing things. You essentially got buckets of objects that go into particular passes for drawing. Another popular way of drawing is using keys to sort and draw, each key has the state it needs to be executed packed in it. And there are probably combinations of both principles (bucketing and render-key based sorting).

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

Advertisement

So I could use an abstract class from which API specific code inherits:
But using virtual functions in rendering code could bring performance issues to something very time-critical such as the rendering.

Honestly, i think your severely overestimating the performance impact a virtual call has. yes it's a bit of indirect with looking at vtables, but I'm extremely doubtful this is going to ever be your bottleneck.
yet again it comes back to a case of pre-mature optimzations, demonstrate it is an actual issue before looking for complex patterns that results in overcomplicating your design because you think that it might be an issue.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This topic is closed to new replies.

Advertisement