[GB.OPENGL.GLU]
* NEW: Add Glu.Project, Glu.UnProject and Glu.UnProject4 methods. These methods are returning a Float array as the result. This Float[] can be NULL in case of failure or if the Arrays passed as parameter are not of the proper size; Modelview and Projection are 16 values Arrays, Viewport is a 4 values Array. git-svn-id: svn://localhost/gambas/trunk@5355 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
225c6e0b40
commit
cfc4f1242b
5 changed files with 182 additions and 2 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "GLUtextureImage.h"
|
||||
#include "GLUquadratic.h"
|
||||
#include "GLUnurb.h"
|
||||
#include "GLUproject.h"
|
||||
|
||||
BEGIN_METHOD(GLUERRORSTRING, GB_INTEGER code)
|
||||
|
||||
|
@ -80,6 +81,11 @@ GB_DESC Cglu[] =
|
|||
GB_STATIC_METHOD("NurbsSurface", NULL, GLUNURBSSURFACE, "(Nurb)GluNurb;(SKnotCount)i(SKnots)Single[];(TKnotCount)i(TKnots)Single[];(SStride)i(TStride)i(SOrder)i(TOrder)i(Type)i(Control)Single[]"),
|
||||
GB_STATIC_METHOD("NewNurbsRenderer","GluNurb", GLUNEWNURBSRENDERER, NULL),
|
||||
|
||||
/* Projections - see GLUproject.h */
|
||||
GB_STATIC_METHOD("Project", "Float[]", GLUPROJECT, "(ObjectX)f(ObjectY)f(ObjectZ)f(Modelview)Float[];(Projection)Float[];(Viewport)Integer[];"),
|
||||
GB_STATIC_METHOD("UnProject", "Float[]", GLUUNPROJECT, "(WindowX)f(WindowY)f(WindowZ)f(Modelview)Float[];(Projection)Float[];(Viewport)Integer[];"),
|
||||
GB_STATIC_METHOD("UnProject4", "Float[]", GLUUNPROJECT4, "(WindowX)f(WindowY)f(WindowZ)f(ClipW)f(Modelview)Float[];(Projection)Float[];(Viewport)Integer[];(NearValue)f(FarValue)f"),
|
||||
|
||||
/********************/
|
||||
/* opengl constants */
|
||||
/********************/
|
||||
|
|
|
@ -89,7 +89,7 @@ BEGIN_METHOD(GLUENDTRIM, GB_OBJECT nurb)
|
|||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(GLUNURBSCURVE, GB_OBJECT nurb; GB_INTEGER knotCount; GB_OBJECT knots; GB_INTEGER stride; GB_OBJECT control; GB_INTEGER order; GB_INTEGER type)
|
||||
BEGIN_METHOD(GLUNURBSCURVE, GB_OBJECT nurb; GB_INTEGER knotCount; GB_OBJECT knots; GB_INTEGER stride; GB_OBJECT control; GB_INTEGER order; GB_INTEGER type)
|
||||
|
||||
GET_NURB();
|
||||
|
||||
|
|
138
gb.opengl/src/glu/GLUproject.c
Normal file
138
gb.opengl/src/glu/GLUproject.c
Normal file
|
@ -0,0 +1,138 @@
|
|||
/***************************************************************************
|
||||
|
||||
GLUproject.c
|
||||
|
||||
(c) 2005-2012 Laurent Carlier <lordheavy@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#define __GLUPROJECT_C
|
||||
|
||||
#include "GLU.h"
|
||||
|
||||
BEGIN_METHOD(GLUPROJECT, GB_FLOAT ObjX; GB_FLOAT ObjY; GB_FLOAT ObjZ; GB_OBJECT Model; GB_OBJECT Proj; GB_OBJECT View)
|
||||
|
||||
GLdouble model[16], proj[16], win[3];
|
||||
GLint view[4];
|
||||
int i, status;
|
||||
GB_ARRAY fArray;
|
||||
|
||||
if ((GB.Array.Count(VARG(Model)) != 16) || (GB.Array.Count(VARG(Proj)) != 16) || (GB.Array.Count(VARG(View)) != 4))
|
||||
{
|
||||
GB.ReturnNull();
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
view[i] = *((GLdouble *)GB.Array.Get(VARG(Model),i));
|
||||
for (i=0; i<16; i++)
|
||||
view[i] = *((GLdouble *)GB.Array.Get(VARG(Proj),i));
|
||||
for (i=0; i<4; i++)
|
||||
view[i] = *((GLint *)GB.Array.Get(VARG(View),i));
|
||||
|
||||
status = gluProject(VARG(ObjX), VARG(ObjY), VARG(ObjZ), model, proj, view, &win[0], &win[1], &win[2]);
|
||||
|
||||
if (status == GLU_FALSE)
|
||||
{
|
||||
GB.ReturnNull();
|
||||
return;
|
||||
}
|
||||
|
||||
GB.Array.New(&fArray , GB_T_FLOAT , 3);
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
*((GLdouble *)GB.Array.Get(fArray, i)) = win[i];
|
||||
|
||||
GB.ReturnObject(fArray);
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(GLUUNPROJECT, GB_FLOAT WinX; GB_FLOAT WinY; GB_FLOAT WinZ; GB_OBJECT Model; GB_OBJECT Proj; GB_OBJECT View)
|
||||
|
||||
|
||||
GLdouble model[16], proj[16], obj[3];
|
||||
GLint view[4];
|
||||
int i, status;
|
||||
GB_ARRAY fArray;
|
||||
|
||||
if ((GB.Array.Count(VARG(Model)) != 16) || (GB.Array.Count(VARG(Proj)) != 16) || (GB.Array.Count(VARG(View)) != 4))
|
||||
{
|
||||
GB.ReturnNull();
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
view[i] = *((GLdouble *)GB.Array.Get(VARG(Model),i));
|
||||
for (i=0; i<16; i++)
|
||||
view[i] = *((GLdouble *)GB.Array.Get(VARG(Proj),i));
|
||||
for (i=0; i<4; i++)
|
||||
view[i] = *((GLint *)GB.Array.Get(VARG(View),i));
|
||||
|
||||
status = gluUnProject(VARG(WinX), VARG(WinY), VARG(WinZ), model, proj, view, &obj[0], &obj[1], &obj[2]);
|
||||
|
||||
if (status == GLU_FALSE)
|
||||
{
|
||||
GB.ReturnNull();
|
||||
return;
|
||||
}
|
||||
|
||||
GB.Array.New(&fArray , GB_T_FLOAT , 3);
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
*((GLdouble *)GB.Array.Get(fArray, i)) = obj[i];
|
||||
|
||||
GB.ReturnObject(fArray);
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(GLUUNPROJECT4, GB_FLOAT WinX; GB_FLOAT WinY; GB_FLOAT WinZ; GB_FLOAT ClipW; GB_OBJECT Model; GB_OBJECT Proj; GB_OBJECT View; GB_FLOAT NearVal; GB_FLOAT FarVal)
|
||||
|
||||
GLdouble model[16], proj[16], obj[4];
|
||||
GLint view[4];
|
||||
int i, status;
|
||||
GB_ARRAY fArray;
|
||||
|
||||
if ((GB.Array.Count(VARG(Model)) != 16) || (GB.Array.Count(VARG(Proj)) != 16) || (GB.Array.Count(VARG(View)) != 4))
|
||||
{
|
||||
GB.ReturnNull();
|
||||
return;
|
||||
}
|
||||
|
||||
for (i=0; i<16; i++)
|
||||
view[i] = *((GLdouble *)GB.Array.Get(VARG(Model),i));
|
||||
for (i=0; i<16; i++)
|
||||
view[i] = *((GLdouble *)GB.Array.Get(VARG(Proj),i));
|
||||
for (i=0; i<4; i++)
|
||||
view[i] = *((GLint *)GB.Array.Get(VARG(View),i));
|
||||
|
||||
status = gluUnProject4(VARG(WinX), VARG(WinY), VARG(WinZ), VARG(ClipW), model, proj, view, VARG(NearVal), VARG(FarVal), &obj[0], &obj[1], &obj[2], &obj[3]);
|
||||
|
||||
if (status == GLU_FALSE)
|
||||
{
|
||||
GB.ReturnNull();
|
||||
return;
|
||||
}
|
||||
|
||||
GB.Array.New(&fArray , GB_T_FLOAT , 4);
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
*((GLdouble *)GB.Array.Get(fArray, i)) = obj[i];
|
||||
|
||||
GB.ReturnObject(fArray);
|
||||
|
||||
END_METHOD
|
34
gb.opengl/src/glu/GLUproject.h
Normal file
34
gb.opengl/src/glu/GLUproject.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/***************************************************************************
|
||||
|
||||
GLUproject.h
|
||||
|
||||
(c) 2005-2012 Laurent Carlier <lordheavy@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __GLUPROJECT_H
|
||||
#define __GLUPROJECT_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
DECLARE_METHOD(GLUPROJECT);
|
||||
DECLARE_METHOD(GLUUNPROJECT);
|
||||
DECLARE_METHOD(GLUUNPROJECT4);
|
||||
|
||||
#endif /* __GLUPROJECT_H */
|
||||
|
|
@ -15,4 +15,6 @@ gb_opengl_glu_la_SOURCES = \
|
|||
GLUquadratic.h GLUquadratic.c \
|
||||
cgluquadric.h cgluquadric.c \
|
||||
cglunurb.h cglunurb.c\
|
||||
GLUnurb.h GLUnurb.c
|
||||
GLUnurb.h GLUnurb.c \
|
||||
GLUproject.h GLUproject.c
|
||||
|
||||
|
|
Loading…
Reference in a new issue