[Gambas-devel] A few comment about Tommy's changes
Benoît Minisini
gambas at ...1...
Fri Aug 5 22:33:05 CEST 2011
> Benoit,
> Did you get my project?
> It now gets through the glu.NewQuadric() and creates GluQuadric object,
> but: -It gets segfault with glu.QuadricNormals and glu.QuadricTextures
> -It doesn't crash with glu.Sphere, .Cylinder and .Disk but there's nothing
> produced on screen. The question is what exactly is passed as GluQuadric
> to the functions, as they work ok with pointer :
>
> gluQuadricTexture (GLUquadric* quad, GLboolean texture);
>
> and if the command:
>
> GLUquadric *quad = VARG(Quad);
>
> passes pointer to quad.
>
> Tomek.
>
Of course: VARG(Quad) returns the pointer to the Gambas object, not the
pointer to the 'GLUquadric *' object. You must:
1) Use GB.CheckObject() to ensure that you don't receive a NULL reference.
2) Use ((CGLUQUADRIC *)VARG(Quad))->quadric to get the 'GLUquadric *' pointer.
Now let's talk about "object oriented programming". You should centralize all
functions related to quadric inside the same source file. For example
'cgluquadric.c'. Because they are related.
Moreover, you can transform the GluQuadric class into a "true" class with
methods.
In other words, instead of doing:
glu.QuadricNormals(quadric, gl.GL_SMOOTH)
The Gambas user will do something like that:
quadric.Normals(gl.GL_SMOOTH).
To do that, you will all corresponding methods to the GluQuadric Gambas class.
Of course, this does not look like normal OpenGL GLU programming, but it is
real object oriented programming.
And you can have both. You can:
- Keep the old GLU.xxx(quadric, yyy) functions.
- Add equivalent GluQuadric.xxx(yyy) methods.
The first Gambas methods is implemented by the
DECLARE_METHOD(GLUxxx, GB_OBJECT quadric; yyy)
function. Wheread the second Gambas method will be implemented in the
GluQuadric class by:
DECLARE_METHOD(GluQuadric_xxx, yyy)
Of course, if you are a good developer, both functions will share their code.
Tell me if you want me to make an example of that.
Regards,
--
Benoît Minisini
More information about the Devel
mailing list