Using OpgnGL modelview matrix into Direct Sound listener

Started by
5 comments, last by tolaris 18 years, 10 months ago
Hi; I dont know if its the right place to put this thread, but its more acceptable than posting in Directx forum (since there they should use Direct3d for graphics...). Im trying to set the listeners parameters using the modelview of OpenGL, but as the Z axis is inverted in DirectX, the sound get inverted...Im testing in a 5.1 system, so i can hear clearly when something is wrong...i tried setting every sound position and velocity as the -position.z and -velocity.z, as well as the -camera.position.z..but now the problem is that the modelview seems to be wrong when my X angle is not 0 ...i set up the camera like this glRotatef(ang_x,1,0,0); glRotatef(ang_y,0,1,0); glTranslatef(-position.x,-position.y,-position.z); Now i did this way: cMATRIX matx, maty,mat; matx.RotateX(ang_x); maty.RotateY(ang_y); mat = maty*matx; and im using this matrix to set up the UP and FRONT vectors of my listener, and continue using the inverted Z axis everywhere....but its a bit confusing. Is there another way to setup the listener? Thanks
Advertisement
What you have to keep in mind is that DX's matrix is row major where as OpenGL's matrix is column major, so if you need to feed an OpenGL matrix into a DX function you'll need to transpose it from one form to the other (or, iirc there is a function which allows you to readback a transposed matrix from OpenGL)
i have a question why some people use thier own Matrix's calculating and the don't use the stander functios like (glRotate*(),glTranslate*(),glScale*(),gluLookAt(),....etc)
i think because the readback from the current modelview matrix is slow. and if you have your own matrix manipulation you don't have to read back!
is it too slow ???!
it can be, however it is still faster to perform alot of the maths yourself and onlu upload the matrix when done as you'll need the matrix for many other operations.
Quote:Original post by Anonymous Poster
i have a question why some people use thier own Matrix's calculating and the don't use the stander functios like (glRotate*(),glTranslate*(),glScale*(),gluLookAt(),....etc)

If you have local copy of the calculated matrix, it can be used to quickly extract things like position and local forward/right/up vectors from it, to convert object orientation between local and world spaces, and do other things which are also quite useful. (you avoid having to pull the current matrix out of openGL which from what i understand, can be rather slow)

Also, IIRC openGL functions always post-multiply current matrix, effectively doing transformations in local space, which might not be something you want.

This topic is closed to new replies.

Advertisement