Passing a reference to a function?

I'm trying to put all my device configuration in a separate class from my GameEngine class, but I'm not sure the best way to get the created device back.
Currently I have a function that does the capatilities checking, creates the device and returns it.
Is there a way to pass a device variable reference to the function instead of creating a whole new one in the function As opposed to creating a device, returning it from the function then disposing it when function call is done..
I'm not sure if I'm making sense here...



Answer this question

Passing a reference to a function?

  • Rick Qually

    Yes, that is quite helpful.

    Do you have any code snippets, of how you organize your components (Or mabye a design doc) I would be very interested to see how you structure your engine. I find the web sorely lacking on this type of information.



  • AFTIadmin

    What are the incx and incz members for
    That's specific to some sample I was working on.
    Are Effects just HLSL files
    That's it. I just store a string to all the resources. This saves the duplication of resources and in turn memory usage.
    What is the boundingRectangle for I would have thought it would be for a bounding box, but it is only 2d..
    You can have bounding rectangles for 2d collision detection. Bounding Boxes is what you
    normally use for 3D. I just use the width and height in the bounding rectangles for each entity and their positions for collision tests.

    I hope this helps.
    Take care.


  • mtm_king

    Take a look at the ref keyword. The ref keyword on a method parameter causes a method to refer to the same variable that was passed as an input parameter for the same method.

    What I usually do is have a device manager. There are 2 objects that really use the device. My renderer which handles the rendering and the resource manager which handles the creation of resources. You don't really need to expose the device to any other objects.

    I hope this helps.
    Take care.


  • Dandan8752

    You can take a look at the following code snippits that I prototyped to show off the basic idea.
    Entity
    RenderableEntity
    Renderer
    ResourceManager

    Objects like the RenderableEntity can be greatly improved by adding an array of textures to support multiple textures per entity and alot more.

    I hope this helps.
    Take care.


  • Dan Green

    Yes, thanks, that helps immensely!

    What are the incx and incz members for

    Are Effects just HLSL files

    What is the boundingRectangle for I would have thought it would be for a bounding box, but it is only 2d..



  • Passing a reference to a function?