module Glu

Public Class Methods

gluBeginCurve(p1) click to toggle source
static VALUE
glu_BeginCurve(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        rb_ary_push(n_current, arg1);
        gluBeginCurve(ndata->nobj);
                
        return Qnil;
}
gluBeginPolygon(p1) click to toggle source
static VALUE
glu_BeginPolygon(obj, arg1)
VALUE obj, arg1;
{
        struct tessdata* tdata;
        GetTESS(arg1, tdata);
        rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
        rb_ary_push(t_current, arg1);
        gluBeginPolygon(tdata->tobj);
                
        return Qnil;
}
gluBeginSurface(p1) click to toggle source
static VALUE
glu_BeginSurface(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        rb_ary_push(n_current, arg1);
        gluBeginSurface(ndata->nobj);
                
        return Qnil;
}
gluBeginTrim(p1) click to toggle source
static VALUE
glu_BeginTrim(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        rb_ary_push(n_current, arg1);
        gluBeginTrim(ndata->nobj);
                
        return Qnil;
}
gluBuild1DMipmaps(p1, p2, p3, p4, p5, p6) click to toggle source
static VALUE
glu_Build1DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6)
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
{
        GLenum target;
        GLint components;
        GLint width;
        GLenum format;
        GLenum type;
        int ret;
        
        target = (GLenum)NUM2INT(arg1);
        components = (GLint)NUM2INT(arg2);
        width = (GLint)NUM2INT(arg3);
        format = (GLenum)NUM2INT(arg4);
        type = (GLenum)NUM2INT(arg5);
        Check_Type(arg6,T_STRING);
        CheckDataSize(type,format,width,arg6);

        ret = gluBuild1DMipmaps(target, components, width, format, type, RSTRING_PTR(arg6));
        check_for_gluerror(ret);
                
        return INT2NUM(ret);
}
gluBuild2DMipmaps(p1, p2, p3, p4, p5, p6, p7) click to toggle source
static VALUE
glu_Build2DMipmaps(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
{
        GLenum target;
        GLint components;
        GLint width;
        GLint height;
        GLenum format;
        GLenum type;
        int ret;
        
        target = (GLenum)NUM2INT(arg1);
        components = (GLint)NUM2INT(arg2);
        width = (GLint)NUM2INT(arg3);
        height = (GLint)NUM2INT(arg4);
        format = (GLenum)NUM2INT(arg5);
        type = (GLenum)NUM2INT(arg6);
        Check_Type(arg7,T_STRING);
        CheckDataSize(type,format,width*height,arg7);

        ret = gluBuild2DMipmaps(target, components, width, height, format, type, RSTRING_PTR(arg7));
        check_for_gluerror(ret);
                
        return INT2NUM(ret);
}
gluCylinder(p1, p2, p3, p4, p5, p6) click to toggle source
static VALUE
glu_Cylinder(obj, arg1, arg2, arg3, arg4, arg5, arg6)
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6;
{
        struct quaddata* qdata;
        GLdouble baseRadius;
        GLdouble topRadius;
        GLdouble height;
        GLint slices;
        GLint stacks;

        GetQUAD(arg1, qdata);
        baseRadius = (GLdouble)NUM2DBL(arg2);
        topRadius = (GLdouble)NUM2DBL(arg3);
        height = (GLdouble)NUM2DBL(arg4);
        slices = (GLint)NUM2INT(arg5);
        stacks = (GLint)NUM2INT(arg6);

        rb_ary_push(q_current, arg1);
        gluCylinder(qdata->qobj, baseRadius, topRadius, height, slices, stacks);
        rb_ary_pop(q_current);
                
        return Qnil;
}
gluDeleteNurbsRenderer(p1) click to toggle source
static VALUE
glu_DeleteNurbsRenderer(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        free_nurbs(ndata);
                
        return Qnil;
}
gluDeleteQuadric(p1) click to toggle source
static VALUE
glu_DeleteQuadric(obj, arg1)
VALUE obj, arg1;
{
        struct quaddata *qdata;
        GetQUAD(arg1, qdata);
        free_quad(qdata);
                
        return Qnil;
}
gluDeleteTess(p1) click to toggle source
static VALUE
glu_DeleteTess(obj, arg1)
VALUE obj, arg1;
{
        struct tessdata *tdata;
        GetTESS(arg1, tdata);
        free_tess(tdata);
                
        return Qnil;
}
gluDisk(p1, p2, p3, p4, p5) click to toggle source
static VALUE
glu_Disk(obj, arg1, arg2, arg3, arg4, arg5)
VALUE obj, arg1, arg2, arg3, arg4, arg5;
{
        struct quaddata* qdata;
        GLdouble innerRadius;
        GLdouble outerRadius;
        GLint slices;
        GLint loops;
        
        GetQUAD(arg1, qdata);
        innerRadius = (GLdouble)NUM2DBL(arg2);
        outerRadius = (GLdouble)NUM2DBL(arg3);
        slices = (GLint)NUM2INT(arg4);
        loops = (GLint)NUM2INT(arg5);

        rb_ary_push(q_current, arg1);

        gluDisk(qdata->qobj, innerRadius, outerRadius, slices, loops);
        rb_ary_pop(q_current);
                
        return Qnil;
}
gluEndCurve(p1) click to toggle source
static VALUE
glu_EndCurve(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        gluEndCurve(ndata->nobj);

        for (;gms.len>0;gms.len--)
                free(gms.ptr[gms.len-1]);
        free(gms.ptr);
        gms.ptr = NULL;

        rb_ary_pop(n_current);

                
        return Qnil;
}
gluEndPolygon(p1) click to toggle source
static VALUE
glu_EndPolygon(obj, arg1)
VALUE obj, arg1;
{
        struct tessdata* tdata;
        GetTESS(arg1, tdata);
        gluEndPolygon(tdata->tobj);
        rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
        rb_ary_pop(t_current);
                
        return Qnil;
}
gluEndSurface(p1) click to toggle source
static VALUE
glu_EndSurface(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        gluEndSurface(ndata->nobj);
        
        for(; gms.len>0; gms.len--)
                free(gms.ptr[gms.len-1]);
        free(gms.ptr);
        gms.ptr = NULL;

        rb_ary_pop(n_current);
        
                
        return Qnil;
}
gluEndTrim(p1) click to toggle source
static VALUE
glu_EndTrim(obj, arg1)
VALUE obj, arg1;
{
        struct nurbsdata *ndata;
        GetNURBS(arg1, ndata);
        gluEndTrim(ndata->nobj);
        rb_ary_pop(n_current);
                
        return Qnil;
}
gluErrorString(p1) click to toggle source
static VALUE
glu_ErrorString(obj, arg1)
VALUE obj, arg1;
{
        GLenum errorCode;
        GLubyte* error;
        errorCode = (GLenum)NUM2INT(arg1);
        error = (GLubyte*)gluErrorString(errorCode);
                
        if (error)
                return rb_str_new2((char *)error);
        else
                return Qnil;
}
gluGetNurbsProperty(p1, p2) click to toggle source
static VALUE
glu_GetNurbsProperty(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct nurbsdata *ndata;
        GLenum property;
        GLfloat value;
        GetNURBS(arg1, ndata);
        property = (GLenum)NUM2INT(arg2);
        gluGetNurbsProperty(ndata->nobj, property, &value);
                
        return cond_GLBOOL2RUBY_F(property,value);
}
gluGetString(p1) click to toggle source
static VALUE
glu_GetString(obj, arg1)
VALUE obj, arg1;
{
        GLenum name;
        GLubyte* str;
        name = (GLenum)NUM2INT(arg1);
        str = (GLubyte*)gluGetString(name);
                
        if (str)
                return rb_str_new2((char *)str);
        else
                return Qnil;
}
gluGetTessProperty(p1, p2) click to toggle source
static VALUE
glu_GetTessProperty(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct tessdata* tdata;
        GLenum property;
        GLdouble value;
        GetTESS(arg1, tdata);
        property = (GLenum)NUM2INT(arg2);
        gluGetTessProperty(tdata->tobj, property, &value);
                
        return cond_GLBOOL2RUBY_D(property,value);
}
gluLoadSamplingMatrices(p1, p2, p3, p4) click to toggle source
static VALUE glu_LoadSamplingMatrices(obj,arg1,arg2,arg3,arg4)
VALUE obj, arg1,arg2,arg3,arg4;
{
        struct nurbsdata *ndata;
        GLfloat mdl_mtx[4*4];
        GLfloat persp_mtx[4*4];
        GLint viewport[4];

        GetNURBS(arg1, ndata);
        ary2cmatfloat(arg2,mdl_mtx,4,4);
        ary2cmatfloat(arg3,persp_mtx,4,4);
        ary2cint(arg4,viewport,4);

        gluLoadSamplingMatrices(ndata->nobj,mdl_mtx,persp_mtx,viewport);

                
        return Qnil;
}
gluLookAt(p1, p2, p3, p4, p5, p6, p7, p8, p9) click to toggle source
static VALUE
glu_LookAt(obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
VALUE obj,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9;
{
        GLdouble eyex;
        GLdouble eyey;
        GLdouble eyez;
        GLdouble centerx;
        GLdouble centery;
        GLdouble centerz;
        GLdouble upx;
        GLdouble upy;
        GLdouble upz;
        eyex = (GLdouble)NUM2DBL(arg1);
        eyey = (GLdouble)NUM2DBL(arg2);
        eyez = (GLdouble)NUM2DBL(arg3);
        centerx = (GLdouble)NUM2DBL(arg4);
        centery = (GLdouble)NUM2DBL(arg5);
        centerz = (GLdouble)NUM2DBL(arg6);
        upx = (GLdouble)NUM2DBL(arg7);
        upy = (GLdouble)NUM2DBL(arg8);
        upz = (GLdouble)NUM2DBL(arg9);
        gluLookAt( eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz );
                
        return Qnil;
}
gluNewNurbsRenderer() click to toggle source
static VALUE
glu_NewNurbsRenderer(obj)
VALUE obj;
{
        VALUE ret;
        struct nurbsdata *ndata;
        ret = Data_Make_Struct(cNurbs, struct nurbsdata, mark_nurbs, free_nurbs, ndata);
        ndata->nobj = gluNewNurbsRenderer();
        ndata->n_ref = rb_ary_new2(REF_LAST);
                
        return ret;
}
gluNewQuadric() click to toggle source
static VALUE
glu_NewQuadric(obj)
VALUE obj;
{
        VALUE ret;
        struct quaddata *qdata;
        ret = Data_Make_Struct(cQuad, struct quaddata, mark_quad, free_quad, qdata);
        qdata->qobj = gluNewQuadric();
        qdata->q_ref = rb_ary_new2(REF_LAST);
                
        return ret;
}
gluNewTess() click to toggle source
static VALUE
glu_NewTess(obj)
VALUE obj;
{
        VALUE ret;
        struct tessdata *tdata;
        ret = Data_Make_Struct(cTess, struct tessdata, mark_tess, free_tess, tdata);
        tdata->tobj = gluNewTess();
        tdata->t_ref = rb_ary_new2(REF_LAST);
                
        return ret;
}
gluNextContour(p1, p2) click to toggle source
static VALUE
glu_NextContour(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct tessdata* tdata;
        GLenum type;
        GetTESS(arg1, tdata);
        type = (GLenum)NUM2INT(arg2);
        gluNextContour(tdata->tobj, type);
                
        return Qnil;
}
gluNurbsCallback(p1, p2, p3) click to toggle source
static VALUE
glu_NurbsCallback(obj, arg1, arg2, arg3)
VALUE obj, arg1, arg2, arg3;
{
        struct nurbsdata* ndata;
        GLenum type;
        GetNURBS(arg1, ndata);
        type = (GLenum)NUM2INT(arg2);
        if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
                rb_raise(rb_eTypeError, "gluNurbsCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));

        if (type!=GLU_ERROR)
                return Qnil;

        rb_ary_store(ndata->n_ref, type, arg3);
        if (NIL_P(arg3))
                gluNurbsCallback(ndata->nobj, type, NULL);
        else
                gluNurbsCallback(ndata->nobj, type, n_error);

        return Qnil;
}
gluNurbsCurve(p1, p2, p3, p4, p5, p6 = v6, p7 = v7) click to toggle source
static VALUE
glu_NurbsCurve(argc,argv,obj)
int argc;
VALUE *argv;
VALUE obj;
{
        struct nurbsdata *ndata;
        GLint uknot_count;
        GLfloat *uknot;
        GLint u_stride;
        GLint uorder;
        GLfloat *ctlarray;
        GLenum type;
        
        VALUE args[7];
        VALUE ary_ctl1;
        
        switch (rb_scan_args(argc, argv, "52", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6])) {
                case 5:
                        uknot_count = (GLint)RARRAY_LENINT(args[1]);
                        uorder = (GLenum)NUM2INT(args[3]);
                        type = (GLenum)NUM2INT(args[4]);
                        u_stride = get_curve_dim(type);
                
                        uknot = ALLOC_N(GLfloat, uknot_count);
                        ary2cflt(args[1], uknot, uknot_count);

                        ary_ctl1 = rb_funcall(args[2],rb_intern("flatten"),0);
                        break;
                case 7:
                        uknot_count = (GLint)NUM2INT(args[1]);
                        u_stride = (GLint)NUM2INT(args[3]);
                        uorder = (GLint)NUM2INT(args[5]);
                        type = (GLenum)NUM2INT(args[6]);

                        uknot = ALLOC_N(GLfloat, uknot_count);
                        ary2cflt(args[2], uknot, uknot_count);

                        ary_ctl1 = rb_funcall(args[4],rb_intern("flatten"),0);
                        break;
                default:
                        rb_raise(rb_eArgError, "gluNurbsCurve needs 5 or 7 arguments");
        }
        ctlarray = ALLOC_N(GLfloat, u_stride*(uknot_count-uorder));
        ary2cflt((VALUE)ary_ctl1, ctlarray, (uknot_count-uorder)*u_stride);

        GetNURBS(args[0], ndata);
        gluNurbsCurve(ndata->nobj, uknot_count, uknot, u_stride, ctlarray, uorder, type);

        /* store the pointers */
        gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=2);
        gms.ptr[gms.len - 2] = uknot;
        gms.ptr[gms.len - 1] = ctlarray;
                
        return Qnil;
}
gluNurbsProperty(p1, p2, p3) click to toggle source
static VALUE
glu_NurbsProperty(obj, arg1, arg2, arg3)
VALUE obj, arg1, arg2, arg3;
{
        struct nurbsdata *ndata;
        GLenum property;
        GLfloat value;
        GetNURBS(arg1, ndata);
        property = (GLenum)NUM2INT(arg2);
        value = (GLfloat)NUM2DBL(arg3);
        gluNurbsProperty(ndata->nobj, property, value);
                
        return Qnil;
}
gluNurbsSurface(p1, p2, p3, p4, p5, p6, p7, p8 = v8, p9 = v9, p10 = v10, p11 = v11) click to toggle source
static VALUE
glu_NurbsSurface(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
        struct nurbsdata *ndata;
        GLint sknot_count;
        GLfloat *sknot;
        GLint tknot_count;
        GLfloat *tknot;
        GLint s_stride;
        GLint t_stride;
        GLfloat *ctlarray;
        GLint sorder;
        GLint torder;
        GLenum type;
        
        VALUE args[11];
        VALUE ary_ctl1;
        int type_len;
        
        switch (rb_scan_args(argc, argv, "74", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5], &args[6], &args[7], &args[8], &args[9], &args[10])) {
                case 7:
                        sknot_count = (GLint)RARRAY_LENINT(args[1]);
                        sknot = ALLOC_N(GLfloat, sknot_count);
                        ary2cflt(args[1], sknot, sknot_count);

                        tknot_count = (GLint)RARRAY_LENINT(args[2]);
                        tknot = ALLOC_N(GLfloat, tknot_count);
                        ary2cflt(args[2], tknot, tknot_count);

                        sorder = (GLint)NUM2INT(args[4]);
                        torder = (GLint)NUM2INT(args[5]);
                        type = (GLenum)NUM2INT(args[6]);

                        t_stride = get_surface_dim(type);
                        s_stride = t_stride * sorder;

                        ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*t_stride);
                        ary_ctl1 = rb_funcall(args[3],rb_intern("flatten"),0);
                        ary2cflt(ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*t_stride);
                        break;
                case 11:
                        sknot_count = (GLint)NUM2INT(args[1]);
                        sknot = ALLOC_N(GLfloat, sknot_count);
                        ary2cflt(args[2], sknot, sknot_count);
                        
                        tknot_count = (GLint)NUM2INT(args[3]);
                        tknot = ALLOC_N(GLfloat, tknot_count);
                        ary2cflt(args[4], tknot, tknot_count);
                        
                        s_stride = (GLint)NUM2INT(args[5]);
                        t_stride = (GLint)NUM2INT(args[6]);
                        sorder = (GLint)NUM2INT(args[8]);
                        torder = (GLint)NUM2INT(args[9]);
                        type = (GLint)NUM2INT(args[10]);
                        type_len = get_surface_dim(type);
                        
                        ctlarray = ALLOC_N(GLfloat, (sknot_count-sorder)*(tknot_count-torder)*type_len);
                        ary_ctl1 = rb_funcall(args[7],rb_intern("flatten"),0);
                        ary2cflt(ary_ctl1, ctlarray, (sknot_count-sorder)*(tknot_count-torder)*type_len);
                        break;
                default:
                        rb_raise(rb_eArgError, "gluNurbsSurface needs 7 or 11 arguments");
                        return Qnil; /* not reached */
        }
        GetNURBS(args[0], ndata);
        gluNurbsSurface(ndata->nobj, sknot_count, sknot, tknot_count, tknot,
        s_stride, t_stride, ctlarray, sorder, torder, type);
        
        /* store the pointers */
        
        gms.ptr = REALLOC_N(gms.ptr, GLfloat*, gms.len+=3);
        gms.ptr[gms.len-3] = sknot;
        gms.ptr[gms.len-2] = tknot;
        gms.ptr[gms.len-1] = ctlarray;
        
                
        return Qnil;
}
gluOrtho2D(p1, p2, p3, p4) click to toggle source
static VALUE
glu_Ortho2D(obj,arg1,arg2,arg3,arg4)
VALUE obj,arg1,arg2,arg3,arg4;
{
        GLdouble left;
        GLdouble right;
        GLdouble bottom;
        GLdouble top;
        left = (GLdouble)NUM2DBL(arg1);
        right = (GLdouble)NUM2DBL(arg2);
        bottom = (GLdouble)NUM2DBL(arg3);
        top = (GLdouble)NUM2DBL(arg4);
        gluOrtho2D(left,right,bottom,top);
                
        return Qnil;
}
gluPartialDisk(p1, p2, p3, p4, p5, p6, p7) click to toggle source
static VALUE
glu_PartialDisk(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
{
        struct quaddata* qdata;
        GLdouble innerRadius;
        GLdouble outerRadius;
        GLint slices;
        GLint loops;
        GLdouble startAngle;
        GLdouble sweepAngle;
        
        GetQUAD(arg1, qdata);
        innerRadius = (GLdouble)NUM2DBL(arg2);
        outerRadius = (GLdouble)NUM2DBL(arg3);
        slices = (GLint)NUM2INT(arg4);
        loops = (GLint)NUM2INT(arg5);
        startAngle = (GLdouble)NUM2DBL(arg6);
        sweepAngle = (GLdouble)NUM2DBL(arg7);

        rb_ary_push(q_current, arg1);
        gluPartialDisk(qdata->qobj, innerRadius, outerRadius, slices, loops, startAngle, sweepAngle);
        rb_ary_pop(q_current);
                
        return Qnil;
}
gluPerspective(p1, p2, p3, p4) click to toggle source
static VALUE
glu_Perspective(obj,arg1,arg2,arg3,arg4)
VALUE obj,arg1,arg2,arg3,arg4;
{
        GLdouble fovy;
        GLdouble aspect;
        GLdouble zNear;
        GLdouble zFar;
        fovy = (GLdouble)NUM2DBL(arg1);
        aspect = (GLdouble)NUM2DBL(arg2);
        zNear = (GLdouble)NUM2DBL(arg3);
        zFar = (GLdouble)NUM2DBL(arg4);
        gluPerspective(fovy,aspect,zNear,zFar);
                
        return Qnil;
}
gluPickMatrix(p1, p2, p3 = v3, p4 = v4, p5 = v5) click to toggle source
static VALUE
glu_PickMatrix(argc,argv,obj)
int argc;
VALUE* argv;
VALUE obj;
{
        GLdouble x;
        GLdouble y;
        GLdouble width;
        GLdouble height;
        GLint viewport[4];
        
        VALUE args[5];
        
        switch (rb_scan_args(argc, argv, "23", &args[0], &args[1], &args[2], &args[3], &args[4])) {
                case 2:
                        width = 5.0f;
                        height = 5.0f;
                        glGetIntegerv(GL_VIEWPORT, viewport);
                        break;
                case 4:
                        width = (GLdouble)NUM2DBL(args[2]);
                        height = (GLdouble)NUM2DBL(args[3]);
                        glGetIntegerv(GL_VIEWPORT, viewport);
                        break;
                case 5:
                        width = (GLdouble)NUM2DBL(args[2]);
                        height = (GLdouble)NUM2DBL(args[3]);
                        ary2cint(args[4], viewport, 4);
                        break;
                default:
                        rb_raise(rb_eArgError, "gluPickMatrix needs 2,4 or 5 parameters");
        }
        x = (GLdouble)NUM2DBL(args[0]);
        y = (GLdouble)NUM2DBL(args[1]);
        gluPickMatrix(x, y, width, height, viewport);
                
        return Qnil;
}
gluProject(p1, p2, p3, p4 = v4, p5 = v5, p6 = v6) click to toggle source
static VALUE
glu_Project(argc,argv,obj)
int argc;
VALUE* argv;
VALUE obj;
{
        GLdouble ox;
        GLdouble oy;
        GLdouble oz;
        GLdouble mdl_mtx[4*4];
        GLdouble prj_mtx[4*4];
        GLint vport[4];
        GLdouble wx;
        GLdouble wy;
        GLdouble wz;

        VALUE args[6];
        
        switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
                case 3:
                        glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
                        glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
                        glGetIntegerv(GL_VIEWPORT, vport);
                        break;
                case 6:
                        ary2cmatdouble(args[3], mdl_mtx, 4, 4);
                        ary2cmatdouble(args[4], prj_mtx, 4, 4);
                        ary2cint(args[5], vport, 4);
                        break;
                default:
                        rb_raise(rb_eArgError, "gluProject needs 3 or 6 parameters");
        }
        ox = (GLdouble)NUM2DBL(args[0]);
        oy = (GLdouble)NUM2DBL(args[1]);
        oz = (GLdouble)NUM2DBL(args[2]);
        
        if (gluProject(ox, oy, oz, mdl_mtx, prj_mtx, vport, &wx, &wy, &wz) == GL_TRUE) {
                        
                return rb_ary_new3(3, rb_float_new(wx), rb_float_new(wy), rb_float_new(wz));
        } else {
                        
                check_for_gluerror(GLU_INVALID_VALUE);
                return Qnil; /* not reached */
        }
}
gluPwlCurve(p1, p2, p3, p4 = v4, p5 = v5) click to toggle source
static VALUE
glu_PwlCurve(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
        struct nurbsdata *ndata;
        GLint count;
        GLfloat *array;
        GLint stride;
        GLenum type;
        
        VALUE args[5];
        VALUE ary_ctl1;
        
        switch (rb_scan_args(argc, argv, "32", &args[0], &args[1], &args[2], &args[3], &args[4])) {
                case 3:
                        count = (GLint)RARRAY_LENINT(args[1]);
                        type = NUM2INT(args[2]);
                        stride = (type == GLU_MAP1_TRIM_2 ? 2 : 3);

                        array = ALLOC_N(GLfloat, count*stride);
                        ary_ctl1 = rb_funcall(args[1],rb_intern("flatten"),0);
                        ary2cflt(ary_ctl1, array, count*stride);
                        break;
                case 5:
                        count = NUM2INT(args[1]);
                        stride = NUM2INT(args[3]);
                        type = NUM2INT(args[4]);

                        array = ALLOC_N(GLfloat, count*stride);
                        ary_ctl1 = rb_funcall(args[2],rb_intern("flatten"),0);
                        ary2cflt(ary_ctl1, array, count*stride);
                        break;
                default:
                        rb_raise(rb_eArgError, "gluPwlCurve needs 3 or 5 arguments");
                        return Qnil; /* not reached */
        }

        GetNURBS(args[0], ndata);
        gluPwlCurve(ndata->nobj, count, array, stride, type);
        free(array);
                
        return Qnil;
}
gluQuadricCallback(p1, p2, p3) click to toggle source
static VALUE
glu_QuadricCallback(obj, arg1, arg2, arg3)
VALUE obj, arg1, arg2, arg3;
{
        struct quaddata* qdata;
        GLenum type;
        GetQUAD(arg1, qdata);
        type = (GLenum)NUM2INT(arg2);
        if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
                rb_raise(rb_eTypeError, "gluQuadricCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));

                
        if (type!=GLU_ERROR)
                return Qnil;

        rb_ary_store(qdata->q_ref, type, arg3);
        if (NIL_P(arg3))
                gluQuadricCallback(qdata->qobj, type, NULL);
        else
                gluQuadricCallback(qdata->qobj, type, q_error);
        
                
        return Qnil;
}
gluQuadricDrawStyle(p1, p2) click to toggle source
static VALUE
glu_QuadricDrawStyle(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct quaddata* qdata;
        GLenum drawStyle;
        GetQUAD(arg1, qdata);
        drawStyle = (GLenum)NUM2INT(arg2);
        gluQuadricDrawStyle(qdata->qobj, drawStyle);
                
        return Qnil;
}
gluQuadricNormals(p1, p2) click to toggle source
static VALUE
glu_QuadricNormals(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct quaddata* qdata;
        GLenum normals;
        GetQUAD(arg1, qdata);
        normals = (GLenum)NUM2INT(arg2);
        gluQuadricNormals(qdata->qobj, normals);
                
        return Qnil;
}
gluQuadricOrientation(p1, p2) click to toggle source
static VALUE
glu_QuadricOrientation(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct quaddata* qdata;
        GLenum orientation;
        GetQUAD(arg1, qdata);
        orientation = (GLenum)NUM2INT(arg2);
        gluQuadricOrientation(qdata->qobj, orientation);
                
        return Qnil;
}
gluQuadricTexture(p1, p2) click to toggle source
static VALUE
glu_QuadricTexture(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct quaddata* qdata;
        GLboolean textureCoords;
        GetQUAD(arg1, qdata);
        textureCoords = (GLboolean)RUBYBOOL2GL(arg2);
        gluQuadricTexture(qdata->qobj, textureCoords);
                
        return Qnil;
}
gluScaleImage(p1, p2, p3, p4, p5, p6, p7, p8) click to toggle source
static VALUE
glu_ScaleImage(obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
VALUE obj, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8;
{
        GLenum format;
        GLint widthin;
        GLint heightin;
        GLenum typein;
        void* datain;
        GLint widthout;
        GLint heightout;
        GLenum typeout;
        VALUE ret;
        GLint retcode;
        
        format = (GLenum)NUM2INT(arg1);
        widthin = (GLint)NUM2INT(arg2);
        heightin = (GLint)NUM2INT(arg3);
        typein = (GLenum)NUM2INT(arg4);
        Check_Type(arg5,T_STRING);
        CheckDataSize(typein,format,heightin*widthin,arg5);
        datain = RSTRING_PTR(arg5);
        widthout = (GLint)NUM2INT(arg6);
        heightout = (GLint)NUM2INT(arg7);
        typeout = (GLenum)NUM2INT(arg8);
        ret = allocate_buffer_with_string(GetDataSize(typeout,format,widthout*heightout));
        retcode = gluScaleImage(format, widthin, heightin, typein, datain,
                widthout, heightout, typeout, (GLvoid*)RSTRING_PTR(ret));

        check_for_gluerror(retcode);
                
        return ret;
}
gluSphere(p1, p2, p3, p4) click to toggle source
static VALUE
glu_Sphere(obj, arg1, arg2, arg3, arg4)
VALUE obj, arg1, arg2, arg3, arg4;
{
        struct quaddata* qdata;
        GLdouble radius;
        GLint slices;
        GLint stacks;

        GetQUAD(arg1, qdata);
        radius = (GLdouble)NUM2DBL(arg2);
        slices = (GLint)NUM2INT(arg3);
        stacks = (GLint)NUM2INT(arg4);

        rb_ary_push(q_current, arg1);
        gluSphere(qdata->qobj, radius, slices, stacks);
        rb_ary_pop(q_current);
                
        return Qnil;
}
gluTessBeginContour(p1) click to toggle source
static VALUE
glu_TessBeginContour(obj, arg1)
VALUE obj, arg1;
{
        struct tessdata* tdata;
        GetTESS(arg1, tdata);
        gluTessBeginContour(tdata->tobj);
                
        return Qnil;
}
gluTessBeginPolygon(p1, p2) click to toggle source
static VALUE
glu_TessBeginPolygon(obj, arg1, arg2)
VALUE obj, arg1, arg2;
{
        struct tessdata* tdata;
        GetTESS(arg1, tdata);
        rb_ary_store(tdata->t_ref, TESS_USERDATA, arg2);
        rb_ary_store(tdata->t_ref, TESS_OUTDATA, rb_ary_new());
        rb_ary_store(tdata->t_ref, TESS_DATA, rb_ary_new());
        rb_ary_push(t_current, arg1);
        gluTessBeginPolygon(tdata->tobj, (void*)arg2);
                
        return Qnil;
}
gluTessCallback(p1, p2, p3) click to toggle source
static VALUE
glu_TessCallback(obj, arg1, arg2, arg3)
VALUE obj, arg1, arg2, arg3;
{
        struct tessdata* tdata;
        GLenum type;
        GetTESS(arg1, tdata);
        type = (GLenum)NUM2INT(arg2);
        if (!rb_obj_is_kind_of(arg3,rb_cProc) && !NIL_P(arg3))
                rb_raise(rb_eTypeError, "gluTessCallback needs Proc Object:%s",rb_class2name(CLASS_OF(arg3)));
        
        switch (type) {
                TESS_CALLBACK_CASE(TESS_BEGIN,t_begin)
                TESS_CALLBACK_CASE(TESS_BEGIN_DATA,t_begin_data)
                TESS_CALLBACK_CASE(TESS_EDGE_FLAG,t_edgeFlag)
                TESS_CALLBACK_CASE(TESS_EDGE_FLAG_DATA,t_edgeFlag_data)
                TESS_CALLBACK_CASE(TESS_VERTEX,t_vertex)
                TESS_CALLBACK_CASE(TESS_VERTEX_DATA,t_vertex_data)
                TESS_CALLBACK_CASE(TESS_END,t_end)
                TESS_CALLBACK_CASE(TESS_END_DATA,t_end_data)
                TESS_CALLBACK_CASE(TESS_ERROR,t_error)
                TESS_CALLBACK_CASE(TESS_ERROR_DATA,t_error_data)
                TESS_CALLBACK_CASE(TESS_COMBINE,t_combine)
                TESS_CALLBACK_CASE(TESS_COMBINE_DATA,t_combine_data)
        }
                
        return Qnil;
}
gluTessEndContour(p1) click to toggle source
static VALUE
glu_TessEndContour(obj, arg1)
VALUE obj, arg1;
{
        struct tessdata* tdata;
        GetTESS(arg1, tdata);
        gluTessEndContour(tdata->tobj);
                
        return Qnil;
}
gluTessEndPolygon(p1) click to toggle source
static VALUE
glu_TessEndPolygon(obj, arg1)
VALUE obj, arg1;
{
        struct tessdata* tdata;
        GetTESS(arg1, tdata);
        gluTessEndPolygon(tdata->tobj);
        rb_ary_store(tdata->t_ref, TESS_USERDATA, Qnil);
        rb_ary_store(tdata->t_ref, TESS_OUTDATA, Qnil);
        rb_ary_store(tdata->t_ref, TESS_DATA, Qnil);
        rb_ary_pop(t_current);
                
        return Qnil;
}
gluTessNormal(p1, p2, p3, p4) click to toggle source
static VALUE
glu_TessNormal(obj, arg1, arg2, arg3, arg4)
VALUE obj, arg1, arg2, arg3, arg4;
{
        struct tessdata* tdata;
        GLdouble x, y, z;
        GetTESS(arg1, tdata);
        x = (GLdouble)NUM2DBL(arg2);
        y = (GLdouble)NUM2DBL(arg3);
        z = (GLdouble)NUM2DBL(arg4);
        gluTessNormal(tdata->tobj, x, y, z);
                
        return Qnil;
}
gluTessProperty(p1, p2, p3) click to toggle source
static VALUE
glu_TessProperty(obj, arg1, arg2, arg3)
VALUE obj, arg1, arg2, arg3;
{
        struct tessdata* tdata;
        GLenum property;
        GLdouble value;
        GetTESS(arg1, tdata);
        property = (GLenum)NUM2INT(arg2);
  if (property == GLU_TESS_BOUNDARY_ONLY) {
    value = (GLdouble)RUBYBOOL2GL(arg3);
  } else {
    value = (GLdouble)NUM2DBL(arg3);
  }
        gluTessProperty(tdata->tobj, property, value);
                
        return Qnil;
}
gluTessVertex(p1, p2, p3) click to toggle source
static VALUE
glu_TessVertex(obj, arg1, arg2, arg3)
VALUE obj, arg1, arg2, arg3;
{
        struct tessdata* tdata;
        GLdouble v[3] = {0.0,0.0,0.0};
        GetTESS(arg1, tdata);
        rb_ary_push(rb_ary_entry(tdata->t_ref, TESS_DATA), arg3);
        Check_Type(arg2,T_ARRAY);
        ary2cdbl(arg2, v, 3);
        gluTessVertex(tdata->tobj, v,(void *)arg3);
                
        return Qnil;
}
gluUnProject(p1, p2, p3, p4 = v4, p5 = v5, p6 = v6) click to toggle source
static VALUE
glu_UnProject(argc,argv,obj)
int argc;
VALUE* argv;
VALUE obj;
{
        GLdouble wx;
        GLdouble wy;
        GLdouble wz;
        GLdouble mdl_mtx[4*4];
        GLdouble prj_mtx[4*4];
        GLint vport[4];
        GLdouble ox;
        GLdouble oy;
        GLdouble oz;
        
        VALUE args[6];
        
        switch (rb_scan_args(argc, argv, "33", &args[0], &args[1], &args[2], &args[3], &args[4], &args[5])) {
                case 3:
                        glGetDoublev(GL_MODELVIEW_MATRIX, mdl_mtx);
                        glGetDoublev(GL_PROJECTION_MATRIX, prj_mtx);
                        glGetIntegerv(GL_VIEWPORT, vport);
                        break;
                case 6:
                        ary2cmatdouble(args[3], mdl_mtx, 4, 4);
                        ary2cmatdouble(args[4], prj_mtx, 4, 4);
                        ary2cint(args[5], vport, 4);
                        break;
                default:
                        rb_raise(rb_eArgError, "gluUnProject needs 3 or 6 parameters");
        }
        wx = (GLdouble)NUM2DBL(args[0]);
        wy = (GLdouble)NUM2DBL(args[1]);
        wz = (GLdouble)NUM2DBL(args[2]);
        
        if (gluUnProject(wx, wy, wz, mdl_mtx, prj_mtx, vport, &ox, &oy, &oz) == GL_TRUE) {
                        
                return rb_ary_new3(3, rb_float_new(ox), rb_float_new(oy), rb_float_new(oz));
        } else {
                        
                check_for_gluerror(GLU_INVALID_VALUE);
                return Qnil; /* not reached */
        }
}