Thread: trying to return an array of floats

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    19

    trying to return an array of floats

    float& GetMatrix(IModel* model)
    {
    float matrix[4][4]; //// not my code
    model->GetMatrix( &matrix[0][0] ); // not my code

    return &matrix;

    }


    ok , im working with an engine and the float matrix[4][4] and model line are what needed to get the array .

    but how do i return it, cant figure out how..
    and how would i invoke it

    float mymatyrix[4][4] = GetMatrix(myModel);

    i cant figure this out , help please

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You can't return an array from a function. The usual method is to pass the array in and work with it that way.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    another option would be to create a class called Matrix, perhaps even a template class, with integers as template parameters to define the size of the matrix at compile time. then you could overload some operators to make it (mostly) transparent to the caller. this is what I would do in your situation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-11-2008, 07:39 AM
  2. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM