What do you think of this proposal ?

What do you think of this proposal ?

instead of writing this

https://github.com/tothpaul/Delphi/blob/master/CubeMan3D/Execute.CrossGL.pas#L365

we could write this

type
OpenGL = library
procedure glClear(mask: GLbitfield);
procedure glClearColor(red, green, blue, alpha: GLclampf);
procedure glDrawArrays(mode: GLenum; first: GLint; count: GLsizei);
procedure glEnable(cap: GLenum);
procedure glEnableClientState(array_: GLenum);
procedure glFlush;
procedure glHint(target, mode: GLenum);
procedure glLightfv(light, pname: GLenum; params: PGLfloat);
procedure glLoadIdentity;
procedure glNormalPointer(type_: GLenum; stride: GLsizei; pointer: Pointer);
procedure glMatrixMode (mode: GLenum);
procedure glMultMatrixf (m: PGLfloat);
procedure glPopMatrix;
procedure glPushMatrix;
procedure glRotatef(angle, x, y, z: GLfloat);
procedure glShadeModel(mode: GLenum);
procedure glTranslatef(x, y, z: GLfloat);
procedure glVertexPointer(size: GLint; type_: GLenum; stride: GLsizei; pointer: Pointer);
procedure glViewport (x,y: GLint; width, height: GLsizei);
end
{$IFDEF MSWINDOWS}stdcall external 'OpenGL.DLL' {$ENDIF}
{$IFDEF ANDROID}cdecl external '/usr/lib/libGLESv1_CM.so'{$ENDIF}
{$IFDEF MACOS}cdecl external '/System/Library/Frameworks/OpenGL.framework/OpenGL' prefix '_'{$ENDIF}
{$IFDEF LINUX}cdecl external 'libGL.so'{$ENDIF};

and if the "external" keyword is omitted, you could write OpenGL.Load(FileName) that will load the library and all the methods and return 0 on error (or an exception) and the library handle on success
https://github.com/tothpaul/Delphi/blob/master/CubeMan3D/Execute.CrossGL.pas#L365

Comments

  1. Yes, that would be nice. I have done that manually for a few DLLs, but it's a lot of work.

    ReplyDelete

Post a Comment