C Wrapper for GLM library

Submitted by Dickens A S on Fri, 12/13/2019 - 14:46

GLM (https://glm.g-truc.net/0.9.9/index.html) is one the GL library used for 2d 3d operation 

But it is written in C++ 

This project wraps the functions using C struct and function pointers

It is still work in progress 

GitHubhttps://github.com/dickensas/glm-w

Example C code

#include <glm_w.h>
#include <stdio.h>

int main() {
    struct glmw mCGlw = Glmw();
    float a[16] = { 3.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
    float b[16] = { 1.0f, 1.0f, 2.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 1.0f, 1.0f, 1.0f};
    float *c = mCGlw.mat4x4_mul(a,b);
    mCGlw.free(c);

   for(int i=0;i<16;i++){
        printf("%2.2f ", c[i]);
        if((i+1)%4==0)printf("\n");
   }

   assert(c[12]==12);
   return 0;
}

Output - matrix multiplication

13.00 8.00 7.00 5.00 
9.00 7.00 5.00 4.00 
9.00 7.00 5.00 4.00 
12.00 11.00 6.00 5.00 

You need to have gradle for build this project as library and GLM should be pre installed

to install GLM in MSYS use the below command

pacman -S mingw-w64-x86_64-glm

 

Add new comment