Showing posts with label C programming language. Show all posts
Showing posts with label C programming language. Show all posts

Saturday, December 4, 2021

Vector and Matrix Math for OpenGL

draft

If you are trying to use OpenGL from C, you might want a vector and matrix math package so you dont have to write your own.  Here is one that looks pretty good to me.


And the internet being the way it is, I include the source code here: 


/****************************************************************************/
/* VECTMATH.H: include file for vector/matrix operations.                   */
/* Copyright (c) 1999 by Joshua E. Barnes, Tokyo, JAPAN.                    */
/****************************************************************************/

#ifndef _vectmath_h
#define _vectmath_h

#include "vectdefs.h"

/*
 * Vector operations.
 */

#define CLRV(v)                 /* CLeaR Vector */                      \
{                                                                       \
    int _i;                                                             \
    for (_i = 0; _i < NDIM; _i++)                                       \
        (v)[_i] = 0.0;                                                  \
}