[GB.OPENGL]

* BUG: Changes in Quadrics definition code from pointer to object - needs
	some cleanup. Nurbs will follow. 


git-svn-id: svn://localhost/gambas/trunk@3969 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Tomek 2011-08-05 08:25:55 +00:00
parent ed4c392d39
commit 927bad68f3
6 changed files with 168 additions and 37 deletions

View file

@ -56,33 +56,27 @@ GB_DESC Cglu[] =
GB_STATIC_METHOD("Build2DMipmaps", "i", GLUBUILD2DMIPMAPS, "(Image)Image;"),
/* Quadratics - see GLUquadratic.h */
GB_STATIC_METHOD("NewQuadric", "p", GLUNEWQUADRIC, NULL),
GB_STATIC_METHOD("QuadricNormals", NULL, GLUQUADRICNORMALS, "(Quad)p(Normal)i"),
GB_STATIC_METHOD("QuadricTexture", NULL, GLUQUADRICTEXTURE, "(Quad)p(Texture)b"),
GB_STATIC_METHOD("DeleteQuadric", NULL, GLUDELETEQUADRIC, "(Quad)p"),
GB_STATIC_METHOD("Sphere", NULL, GLUSPHERE, "(Quad)p(Radius)f(Slices)i(Stacks)i"),
GB_STATIC_METHOD("Cylinder", NULL, GLUCYLINDER, "(Quad)p(Base)f(Top)f(Height)f(Slices)i(Stacks)i"),
GB_STATIC_METHOD("Disk", NULL, GLUDISK, "(Quad)p(Inner)f(Outer)f(Slices)i(Loops)i"),
GB_STATIC_METHOD("PartialDisk", NULL, GLUPARTIALDISK, "(Quad)p(Inner)f(Outer)f(Slices)i(Loops)i(Start)f(Sweep)f"),
GB_STATIC_METHOD("NewQuadric", "GluQuadric", GLUNEWQUADRIC, NULL),
GB_STATIC_METHOD("QuadricNormals", NULL, GluQuadricNORMALS, "(Quad)GluQuadric(Normal)i"),
GB_STATIC_METHOD("QuadricTexture", NULL, GluQuadricTEXTURE, "(Quad)GluQuadric(Texture)b"),
GB_STATIC_METHOD("Sphere", NULL, GLUSPHERE, "(Quad)GluQuadric(Radius)f(Slices)i(Stacks)i"),
GB_STATIC_METHOD("Cylinder", NULL, GLUCYLINDER, "(Quad)GluQuadric(Base)f(Top)f(Height)f(Slices)i(Stacks)i"),
GB_STATIC_METHOD("Disk", NULL, GLUDISK, "(Quad)GluQuadric(Inner)f(Outer)f(Slices)i(Loops)i"),
GB_STATIC_METHOD("PartialDisk", NULL, GLUPARTIALDISK, "(Quad)GluQuadric(Inner)f(Outer)f(Slices)i(Loops)i(Start)f(Sweep)f"),
/* NURBS - SEE GLUnurbs.h */
GB_STATIC_METHOD("BeginCurve", NULL, GLUBEGINCURVE, "(nurb)p"),
GB_STATIC_METHOD("BeginSurface", NULL, GLUBEGINSURFACE, "(nurb)p"),
GB_STATIC_METHOD("BeginTrim", NULL, GLUBEGINTRIM, "(nurb)p"),
GB_STATIC_METHOD("DeleteNurbsRenderer", NULL, GLUDELETENURBSRENDERER, "(nurb)p"),
GB_STATIC_METHOD("EndCurve", NULL, GLUENDCURVE, "(nurb)p"),
GB_STATIC_METHOD("EndSurface", NULL, GLUENDSURFACE, "(nurb)p"),
GB_STATIC_METHOD("EndTrim", NULL, GLUENDTRIM, "(nurb)p"),
/*GB_STATIC_METHOD(GLUGETNURBSPROPERTY);
GB_STATIC_METHOD(GLULOADSAMPLINGMATRICES);
GB_STATIC_METHOD(GLUNURBSCALLBACK);
GB_STATIC_METHOD(GLUNURBSCALLBACKDATA);
GB_STATIC_METHOD(GLUNURBSCALLBACKDATAEXT);*/
GB_STATIC_METHOD("NurbsCurve", NULL, GLUNURBSCURVE, "(nurb)p(knotCount)i(knots)Single[];(stride)i(control)Single[];(order)i(type)i"),
GB_STATIC_METHOD("NurbsProperty", NULL, GLUNURBSPROPERTY, "(nurb)p(property)i(value)f"),
GB_STATIC_METHOD("NurbsSurface", NULL, GLUNURBSSURFACE, "(nurb)p(sKnotCount)i(sKnots)Single[];(tKnotCount)i(tKnots)Single[];(sStride)i(tStride)i(sOrder)i(tOrder)i(type)i(control)Single[]"),
GB_STATIC_METHOD("BeginCurve", NULL, GLUBEGINCURVE, "(Nurb)p"),
GB_STATIC_METHOD("BeginSurface", NULL, GLUBEGINSURFACE, "(Nurb)p"),
GB_STATIC_METHOD("BeginTrim", NULL, GLUBEGINTRIM, "(Nurb)p"),
GB_STATIC_METHOD("DeleteNurbsRenderer", NULL, GLUDELETENURBSRENDERER, "(Nurb)p"),
GB_STATIC_METHOD("EndCurve", NULL, GLUENDCURVE, "(Nurb)p"),
GB_STATIC_METHOD("EndSurface", NULL, GLUENDSURFACE, "(Nurb)p"),
GB_STATIC_METHOD("EndTrim", NULL, GLUENDTRIM, "(Nurb)p"),
GB_STATIC_METHOD("NurbsCurve", NULL, GLUNURBSCURVE, "(Nurb)p(KnotCount)i(Knots)Single[];(Stride)i(Control)Single[];(Order)i(Type)i"),
GB_STATIC_METHOD("NurbsProperty", NULL, GLUNURBSPROPERTY, "(Nurb)p(Property)i(Value)f"),
GB_STATIC_METHOD("NurbsSurface", NULL, GLUNURBSSURFACE, "(Nurb)p(SKnotCount)i(SKnots)Single[];(TKnotCount)i(TKnots)Single[];(SStride)i(TStride)i(SOrder)i(TOrder)i(Type)i(Control)Single[]"),
GB_STATIC_METHOD("NewNurbsRenderer","p", GLUNEWNURBSRENDERER, NULL),
//GB_STATIC_METHOD("PwlCurve", NULL, GLUPWLCURVE, "(nurb)p(count)i(stride)i(type)f(data)Float[]"),
/********************/

View file

@ -23,21 +23,21 @@
#define __GLUQUADRATIC_C
#include "GLU.h"
#include "cgluquadric.h"
/**************************************************************************/
BEGIN_METHOD_VOID(GLUNEWQUADRIC)
GLUquadricObj *quad;
quad = gluNewQuadric();
GB.ReturnPointer(quad);
CGLUQUADRIC *ob = CGLUQUADRIC_create(gluNewQuadric());
GB.ReturnObject(ob);
END_METHOD
BEGIN_METHOD(GLUQUADRICNORMALS, GB_OBJECT Quad; GB_INTEGER Normal)
GLUquadricObj *quad;
//Hope this will work
GLUquadric *quad;
quad = VARG(Quad);
gluQuadricNormals (quad, VARG(Normal));
@ -45,7 +45,7 @@ END_METHOD
BEGIN_METHOD(GLUQUADRICTEXTURE, GB_OBJECT Quad; GB_BOOLEAN Texture)
GLUquadricObj *quad;
GLUquadric *quad;
quad = VARG(Quad);
gluQuadricTexture (quad, VARG(Texture));
@ -53,7 +53,7 @@ END_METHOD
BEGIN_METHOD(GLUDELETEQUADRIC, GB_OBJECT Quad)
GLUquadricObj *quad;
GLUquadric *quad;
quad = VARG(Quad);
gluDeleteQuadric(quad);
@ -61,7 +61,7 @@ END_METHOD
BEGIN_METHOD(GLUSPHERE, GB_OBJECT Quad; GB_FLOAT Radius; GB_INTEGER Slices; GB_INTEGER Stacks)
GLUquadricObj *quad;
GLUquadric *quad;
quad = VARG(Quad);
gluSphere (quad, VARG(Radius), VARG(Slices), VARG(Stacks));
@ -70,7 +70,7 @@ END_METHOD
BEGIN_METHOD(GLUCYLINDER, GB_OBJECT Quad; GB_FLOAT Base; GB_FLOAT Top; GB_FLOAT Height; \
GB_INTEGER Slices; GB_INTEGER Stacks)
GLUquadricObj *quad;
GLUquadric *quad;
quad = VARG(Quad);
gluCylinder (quad, VARG(Base), VARG(Top), VARG(Height), VARG(Slices), VARG(Stacks));
@ -80,7 +80,7 @@ END_METHOD
BEGIN_METHOD(GLUDISK, GB_OBJECT Quad; GB_FLOAT Inner; GB_FLOAT Outer; \
GB_INTEGER Slices; GB_INTEGER Loops)
GLUquadricObj *quad;
GLUquadric *quad;
quad = VARG(Quad);
gluDisk (quad, VARG(Inner), VARG(Outer), VARG(Slices), VARG(Loops));
@ -89,7 +89,7 @@ END_METHOD
BEGIN_METHOD(GLUPARTIALDISK, GB_OBJECT Quad; GB_FLOAT Inner; GB_FLOAT Outer; \
GB_INTEGER Slices; GB_INTEGER Loops; GB_FLOAT Start; GB_FLOAT Sweep)
GLUquadricObj *quad;
GLUquadric *quad;
quad = VARG(Quad);
gluPartialDisk (quad, VARG(Inner), VARG(Outer), VARG(Slices), VARG(Loops), VARG(Start), VARG(Sweep));

View file

@ -24,10 +24,11 @@
#define __GLUQUADRATIC_H
#include "main.h"
#include "cgluquadric.h"
DECLARE_METHOD(GLUNEWQUADRIC);
DECLARE_METHOD(GLUQUADRICNORMALS);
DECLARE_METHOD(GLUQUADRICTEXTURE);
DECLARE_METHOD(GLUDELETEQUADRIC);
DECLARE_METHOD(GLUSPHERE);
DECLARE_METHOD(GLUCYLINDER);
DECLARE_METHOD(GLUDISK);

View file

@ -13,4 +13,5 @@ gb_opengl_glu_la_SOURCES = \
GLUcoordTransf.h GLUcoordTransf.c \
GLUtextureImage.h GLUtextureImage.c \
GLUquadratics.h GLUquadratic.c \
cgluquadric.h cgluquadric.c \
GLUnurb.h GLUnurb.c

View file

@ -0,0 +1,74 @@
/***************************************************************************
cgluquadric.c
(c) 2000-2011 Benoît Minisini <gambas@users.sourceforge.net>
(and Tomek Kolodziejczyk)
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., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#define __CGLUQUADRATIC_C
#include "gb_common.h"
#include "cgluquadric.h"
CGLUQUADRIC *CGLUQUADRIC_create(GLUquadric *quadric)
{
CGLUQUADRIC *ob = GB.New(GB.FindClass("GluQuadric"), NULL, NULL);
ob->quadric = quadric;
return ob;
};
/* This is source of glu.h procedure of gluNewQuadric()
GLUquadric * GLAPIENTRY
gluNewQuadric(void)
{
GLUquadric *newstate;
newstate = (GLUquadric *) malloc(sizeof(CGLUQUADRIC));
if (newstate == NULL) {
Can't report an error at this point...
return NULL;
}
newstate->normals = GLU_SMOOTH;
newstate->textureCoords = GL_FALSE;
newstate->orientation = GLU_OUTSIDE;
newstate->drawStyle = GLU_FILL;
newstate->errorCallback = NULL;
return newstate;
}*/
GB_DESC GluQuadricDesc[] =
{
GB_DECLARE("GluQuadric", sizeof(CGLUQUADRIC)),
GB_NOT_CREATABLE(),
GB_END_DECLARE
};
/* If this is ok, then uncomment it please.
BEGIN_METHOD(CGLUQUADRIC_free, GB_OBJECT quadric)
if (!quadric)
return;
gluDeleteNurbsRenderer (quadric);
END_METHOD*/

View file

@ -0,0 +1,61 @@
/***************************************************************************
cgluquadric.h
(c) 2000-2011 Benoît Minisini <gambas@users.sourceforge.net>
(and Tomek Kolodziejczyk)
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., 675 Mass Ave, Cambridge, MA 02139, USA.
***************************************************************************/
#ifndef __CGLUQUADRIC_H
#define __CGLUQUADRIC_H
#include "gambas.h"
#include "main.h"
#include "GLU.h"
#ifndef __CGLUQUADRIC_C
extern GB_DESC GLUquadricDesc[];
#else
#define THIS OBJECT(CGLUQUADRIC)
#endif
typedef
struct {
GB_BASE ob;
GLUquadric *quadric;
}
CGLUQUADRIC;
CGLUQUADRIC *CGLUQUADRIC_create(GLUquadric *quadric);
/* Gluquadric structure as described in glu.h source
struct GLUquadric
{
GLint normals;
GLboolean textureCoords;
GLint orientation;
GLint drawStyle;
void (GLAPIENTRY *errorCallback)( GLint );
};
*/
#endif