I want to make a 3D Planet Simulation using python,pyopengl and pygame. All works fine but now I want to determine the viewers position so that he can add new planets there. I already found that post :
Using glGetFloatv to retrieve the modelview matrix in pyglet
But it doesnt works for me. Combined with some things from the internet I have this code :
x=0;
y=0;
z=0;
mdl=(GLfloat * 16)()
glGetFloatv(GL_MODELVIEW_MATRIX, mdl);
x = -(mdl[0] * mdl[12] + mdl[1] * mdl[13] + mdl[2] * mdl[14]);
y = -(mdl[4] * mdl[12] + mdl[5] * mdl[13] + mdl[6] * mdl[14]);
z = -(mdl[8] * mdl[12] + mdl[9] * mdl[13] + mdl[10] * mdl[14]);
But when I try to execute it, it gives me the following error :
Traceback (most recent call last):
File "Planets.py", line 372, in <module>
main()
File "Planets.py", line 264, in main
glGetFloatv(GL_MODELVIEW_MATRIX, mdl);
File "/usr/lib/python2.7/dist-packages/OpenGL/latebind.py", line 45, in __call__
return self._finalCall( *args, **named )
File "/usr/lib/python2.7/dist-packages/OpenGL/wrapper.py", line 570, in wrapperCall
pyArgs = tuple( calculate_pyArgs( args ))
File "/usr/lib/python2.7/dist-packages/OpenGL/wrapper.py", line 347, in calculate_pyArgs
args
ValueError: glGetFloatv requires 1 arguments (pname), received 2: (GL_MODELVIEW_MATRIX, <__main__.c_float_Array_16 object at 0x7f0d01f4e830>)
It says that glGetFloatv only takes one argument, but how else should it work ? I already tried that :
x=0;
y=0;
z=0;
mdl=(GLfloat * 16)()
glGetFloatv(mdl);
x = -(mdl[0] * mdl[12] + mdl[1] * mdl[13] + mdl[2] * mdl[14]);
y = -(mdl[4] * mdl[12] + mdl[5] * mdl[13] + mdl[6] * mdl[14]);
z = -(mdl[8] * mdl[12] + mdl[9] * mdl[13] + mdl[10] * mdl[14]);
This gives the following error :
Traceback (most recent call last):
File "Planets.py", line 372, in <module>
main()
File "Planets.py", line 264, in main
glGetFloatv(mdl);
File "/usr/lib/python2.7/dist-packages/OpenGL/latebind.py", line 45, in __call__
return self._finalCall( *args, **named )
File "/usr/lib/python2.7/dist-packages/OpenGL/wrapper.py", line 571, in wrapperCall
cArgs = tuple(calculate_cArgs( pyArgs ))
File "/usr/lib/python2.7/dist-packages/OpenGL/wrapper.py", line 374, in calculate_cArgs
yield converter( pyArgs, index, self )
File "/usr/lib/python2.7/dist-packages/OpenGL/converters.py", line 195, in __call__
return self.arrayType.zeros( self.getSize(pyArgs) )
File "/usr/lib/python2.7/dist-packages/OpenGL/converters.py", line 232, in getSize
return self.lookup( specifier )
TypeError: ('unhashable type', 'Failure in cConverter <OpenGL.converters.SizedOutput object at 0x7f91788a9380>', (<__main__.c_float_Array_16 object at 0x7f915d804830>,), 1, <ctypes.glGetFloatv object at 0x7f917890c0e0>)
It seems that another argument is expected... pname or such a thing...
Any help would be greatly appreciated !