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

Expose MultMatrix #384

Merged
merged 6 commits into from May 22, 2024
Merged

Expose MultMatrix #384

merged 6 commits into from May 22, 2024

Conversation

rocktavious
Copy link
Contributor

This adds the MultMatrix with is in raylib core so you can easily setup rendering matrix instead of having to make several calls to Translatef and Rotatef and Scalef.

@rocktavious
Copy link
Contributor Author

I have tested this in my project and it works properly.

@gen2brain
Copy link
Owner

Can you please also add that function to rlgl_purego.go

raylib/rlgl_purego.go Outdated Show resolved Hide resolved
@JupiterRider
Copy link
Contributor

@gen2brain
Is our MatrixToFloat implementation correct?
There is also MatrixToFloatV.

// MatrixToFloatV - Get float array of matrix data
func MatrixToFloatV(mat Matrix) [16]float32 {
	var result [16]float32

	result[0] = mat.M0
	result[1] = mat.M1
	result[2] = mat.M2
	result[3] = mat.M3
	result[4] = mat.M4
	result[5] = mat.M5
	result[6] = mat.M6
	result[7] = mat.M7
	result[8] = mat.M8
	result[9] = mat.M9
	result[10] = mat.M10
	result[11] = mat.M11
	result[12] = mat.M12
	result[13] = mat.M13
	result[14] = mat.M14
	result[15] = mat.M15

	return result
}
// MatrixToFloat - Converts Matrix to float32 slice
func MatrixToFloat(mat Matrix) []float32 {
	data := make([]float32, 16)

	data[0] = mat.M0
	data[1] = mat.M4
	data[2] = mat.M8
	data[3] = mat.M12
	data[4] = mat.M1
	data[5] = mat.M5
	data[6] = mat.M9
	data[7] = mat.M13
	data[8] = mat.M2
	data[9] = mat.M6
	data[10] = mat.M10
	data[11] = mat.M14
	data[12] = mat.M3
	data[13] = mat.M7
	data[14] = mat.M11
	data[15] = mat.M15

	return data
}

C-raylib:

#ifndef MatrixToFloat
    #define MatrixToFloat(mat) (MatrixToFloatV(mat).v)
#endif

RMAPI float16 MatrixToFloatV(Matrix mat)
{
    float16 result = { 0 };

    result.v[0] = mat.m0;
    result.v[1] = mat.m1;
    result.v[2] = mat.m2;
    result.v[3] = mat.m3;
    result.v[4] = mat.m4;
    result.v[5] = mat.m5;
    result.v[6] = mat.m6;
    result.v[7] = mat.m7;
    result.v[8] = mat.m8;
    result.v[9] = mat.m9;
    result.v[10] = mat.m10;
    result.v[11] = mat.m11;
    result.v[12] = mat.m12;
    result.v[13] = mat.m13;
    result.v[14] = mat.m14;
    result.v[15] = mat.m15;

    return result;
}

@gen2brain
Copy link
Owner

@JupiterRider Sorry, I don't remember what happened there.

@JupiterRider
Copy link
Contributor

I fixed it in #390 as well

@rocktavious
Copy link
Contributor Author

Thanks @JupiterRider and @gen2brain - should be good now.

@gen2brain gen2brain merged commit b1a49c2 into gen2brain:master May 22, 2024
9 checks passed
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

Successfully merging this pull request may close these issues.

None yet

3 participants