Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

results are different from the DirectX math library (DirectXMath.h) #48

Open
badasahog opened this issue Apr 24, 2023 · 1 comment
Open

Comments

@badasahog
Copy link

badasahog commented Apr 24, 2023

Hi!

I'm trying to find a C alternative to the DirectXMath.h header (which requires C++)

I'm brand new to this repo, so please excuse me if I'm missing something obvious, but it appears that DirectXMath.h gives different results from this library.

example:

int Width = 800;
int Height = 600;

XMMATRIX tmpMat = XMMatrixPerspectiveFovLH(
			45.0f * (3.14f / 180.0f),
			(float)Width / (float)Height,
			0.1f,
			1000.0f);
	
for (int i = 0; i < 4; i++)
{

	for(int j = 0; j < 4; j++)
		std::cout << tmpMat.r[i].m128_f32[j] << '\t' << '\t';
	std::cout << '\n';
}

std::cout << '\n';

mat4_perspective(
tmpMat.r[0].m128_f32,
45.0f * (3.14f / 180.0f),
(float)Width / (float)Height,
0.1f,
1000.0f);

for (int i = 0; i < 4; i++)
{

	for (int j = 0; j < 4; j++)
		std::cout << tmpMat.r[i].m128_f32[j] << '\t' << '\t';
	std::cout << '\n';
}
std::cout << '\n';

output:

1.81168 0 0 0
0 2.41557 0 0
0 0 1.0001 1
0 0 -0.10001 0

1.81168 0 0 0
0 0.41398 0 0
0 0 -1.0001 -1
0 0 -0.10001 0

@Rickodesea
Copy link

This is true. I am having the same experience comparing this library with the C++ GLM.
There seem to be minor differences in the calculations. I assume the one in MathC is incorrect and needs to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants