[squeak-dev] Need your opinion: What is most appealing form for GL function bindings?

Igor Stasenko siguctua at gmail.com
Thu May 20 15:47:46 UTC 2010


There are multiple GL bindings exists by now
- one that used by Croquet (FFI)
- another one that using Alien

and i doing one more, which using NativeBoost for callouts.

And the question, what form of selectors you like most,
pros/cons .. i need to know, because i can pick any of them,
but i hope, that i will not be only one who using this stuff, so i
need your opinion.

Lets take a usual OpenGL function:

void glVertex3f(GLfloat x, GLfloat y, GLfloat z)

A Croquet/FFI bindings translates it to a following selector:

1. glVertex3f: x with: y with: z

An Alien bindings using following form:

2. glVertex3fX: x y: y z: z

Since my bindings will definitely use underscores, its not a problem
to use a following one:

3. glVertex3f_x: x y: y z: z

Currently i using this one:

4. glVertex3f: x y: y z: z

In private mail with Andreas, he proposed a following:
---
The one thing I'd consider is to use #comma: as the 'standard' keyword
instead of #with: for example:

5. glVertex3f: x comma: y comma: z

The reason should be obvious; you're replacing the comma so it should
be a little more clear than using #with:.
---

6. this option actually not about positional arguments, but about
omitting the 'gl' prefix for each function name.
It is because, you already typing gl at each invocation:

gl glVertex3f: x with: y with: z

so, maybe it worth to omit gl prefix, so, a code will look like:

gl Vertex3f: x with: y with: z

(sure thing, one may use different name for api interface object, not
'gl'.. but i think that in 99.9%
cases, 'gl' is a natural choice).

---

My own choice is [3].
As to me, it helps greatly when you coding,
so, once you autocomplete the selector, you know what parameter you
need at each position,
unlike anonymous keywords, like with: or comma: , which don't telling
you anything about arguments you end up browsing docs each time.
Oh, and btw, each time you need to change something, you again may
need to refer to docs,
since it still may be not clear, what argument types a function
expects even if you look at already working code.

The pro for picking [1] is mainly be compatible with lots of Croquet
code which using GL.
Except that, in NB bindings, i taking a constant names as is , i.e.
GL_LINES, while croquet
uses GLLines. So, its still will require porting.


P.S. i'm already having some stuff working (see attachment).. But i
little bit hesistant to do more, because then , if i reconsider
about selector names, it will require a lot of fixes all around places.
It generating all these methods automatically, so i can change a form
at any moment.
NBOpenGL methodDict size 2063
NBWgl methodDict size  132
NBGlx methodDict size 121

-- 
Best regards,
Igor Stasenko AKA sig.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GL viewport.png
Type: image/png
Size: 34632 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100520/8ea7f7be/GLviewport.png


More information about the Squeak-dev mailing list