Jump to content

ArBuZ

Members
  • Posts

    164
  • Joined

  • Last visited

Blog Comments posted by ArBuZ

  1. I can not even try to argue with you because you are by a lot of heads taller than me in programming :)

    I just thought that Shader is a base class. And OpenGLShader and maybe DirectXShader are derived classes.

    But as I understand

    Shader* shader=new Shader();
    

    allays returns Shader object and it can not return any other derived type. That what I meant.

  2. I think static methods is a good way to go. I think constructor doesn't control memory allocation of the object itself. The compiler with the "new" command does it.

    All, that work with pointers must work with objects. I mean both:

    Mesh* meshObj=new Mesh("mesh.gmf");
    Mesh meshObj("mesh.gmf");
    

    must work. But with the exceptions you can not use second line, right?

     

    It will be similar with what Roland suggested

    KittenFactory fact;
    Kitten* k = fact.CreateFluffy()
    

    But factory will be encapsulated in the class.

    Kitten* k=Kitten::CreateFluffy();
    

     

    That is only my thoughts. I'm not as good in programing as you guys. :)

     

    [Edit] Damn I type too slow. Two more posts are made :D

  3. Maybe you should place all Create/Load methods in classes as static methods.

     

    For example:

     

    Model* myModel=Model::LoadModel("myModel.gmf");
    Shader* myShader=Shader::LoadShader();
    

     

    And this static functions could return NULL or object itself.

    And in LoadShader() function you can decide what exactly type of shader to return

×
×
  • Create New...