OO architecture for rendering in shader based games

前端 未结 2 559
难免孤独
难免孤独 2021-02-05 18:57

I keep hitting this problem when building game engines where my classes want to look like this:

interface Entity {
  draw();
}

class World {
  draw() {
    for          


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 19:15

    This is not an easy question to answer, since there are many ways to deal with the problem. A good idea is to look into some Game/Rendering engines and see how this is handled there. A good starting point would be Ogre, since its well documented and open source.

    As far as I know, it separates the vertex data from the material components (shaders) through the built-in material scripts. The renderer itself knows what mesh is to be drawn in what order and with what shader (and its passes).

    I know this answer is a bit vague, but I hope I could give you a useful hint.

提交回复
热议问题