Last active
August 29, 2015 14:05
-
-
Save Yoplitein/c04237c74101f3395c98 to your computer and use it in GitHub Desktop.
gl3n to gfm conversion functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gl3n.util: is_matrix, is_vector; | |
auto to_gfm(MatrixType)(MatrixType matrix) | |
if(is_matrix!MatrixType) | |
{ | |
static import gfm.math; | |
enum matrixSize = matrix.cols * matrix.rows; | |
matrix.mt[matrixSize] data; | |
matrix.mt *ptr = matrix.value_ptr; | |
foreach(index; 0 .. matrixSize) | |
data[index] = *ptr++; | |
return gfm.math.Matrix!(matrix.mt, matrix.rows, matrix.cols)(data); | |
} | |
auto to_gfm(VectorType)(VectorType vector) | |
if(is_vector!VectorType) | |
{ | |
static import gfm.math; | |
return gfm.math.Vector!(vector.vt, vector.dimension)(vector.vector); | |
} | |
//no way to prefer these over GLUniform.set. :( | |
/*void set(MatrixType)(GLUniform uniform, MatrixType matrix) | |
if(is_matrix!MatrixType) | |
{ | |
uniform.set(matrix.to_gfm); | |
} | |
void set(MatrixType)(GLUniform uniform, VectorType vector) | |
if(is_vector!VectorType) | |
{ | |
uniform.set(vector.to_gfm); | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment