VB and gluUnproject

Here is my problem with the follow I get a byref error because the glGetXXXXX functions don’t understand the VB array.

Dim MatrixModel(16) As GLdouble
Dim MatrixProject(16) As GLdouble
Dim MatrixView(4) As GLint
glGetIntegerv glgViewport, MatrixView
glGetDoublev glgModelViewMatrix, MatrixModel
glGetDoublev glgProjectionMatrix, MatrixProject

gluUnProject x, y, 0, MatrixModel, MatrixProject, MatrixView, MCoordX, MCoordY, MCoordZ
txtScrCoords.Text = "(" & MCoordX & "," & MCoordX & "," & MCoordX & ")"

If I remove the array and make them single like:
Dim MatrixModel As GLdouble
Dim MatrixProject As GLdouble
Dim MatrixView As GLint

It blows the VB editor away when it gets to either glGetdoublev calls.

Does this have to be done inside a pushmatrix?

Try this…

Dim MatrixModel(0 To 15) As GLdouble
Dim MatrixProject(0 To 15) As GLdouble
Dim MatrixView(0 To 3) As GLint

glGetIntegerv glgViewport, MatrixView(0)
glGetDoublev glgModelViewMatrix, MatrixModel(0)
glGetDoublev glgProjectionMatrix, MatrixProject(0)

gluUnProject x, y, 0, MatrixModel(0), MatrixProject(0), MatrixView(0), MCoordX, MCoordY, MCoordZ

That should do it.

[This message has been edited by Pat (edited 03-22-2002).]

Thanks, that works great Pat. I just couldn’t figure out how to get around the errors.