Browse Source

+ MorphOS support added to standard units, hope i didn't broke something else

git-svn-id: trunk@1790 -
Károly Balogh 20 years ago
parent
commit
131520c36b
3 changed files with 127 additions and 16 deletions
  1. 42 3
      packages/extra/opengl/gl.pp
  2. 49 13
      packages/extra/opengl/glu.pp
  3. 36 0
      packages/extra/opengl/glut.pp

+ 42 - 3
packages/extra/opengl/gl.pp

@@ -48,7 +48,11 @@ Abstract:
   {$DEFINE extdecl := stdcall}
 {$ELSE}
   {$DEFINE extdecl := cdecl}
-  {$LINKLIB c}
+  {$IFDEF MorphOS}
+    {$DEFINE GL_UNIT}
+  {$ELSE}
+    {$LINKLIB c}
+  {$ENDIF}
 {$ENDIF}
 
 unit GL;
@@ -60,11 +64,17 @@ uses
   {$IFDEF Win32}
   Windows
   {$ELSE Win32}
+  {$IFDEF MorphOS}
+  TinyGL
+  {$ELSE MorphOS}
   DLLFuncs
+  {$ENDIF MorphOS}
   {$ENDIF Win32};
 
+{$IFNDEF MORPHOS}
 var
   LibGL: THandle;
+{$ENDIF MORPHOS}
 
 type
   GLenum     = Cardinal;      PGLenum     = ^GLenum;
@@ -1161,6 +1171,13 @@ const
 
 {******************************************************************************}
 
+{$IFDEF MORPHOS}
+
+{ MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
+{ systems, so its headers are included here. }
+{$INCLUDE tinyglh.inc}
+
+{$ELSE MORPHOS}
 var
   glAccum: procedure(op: GLenum; value: GLfloat); extdecl;
   glAlphaFunc: procedure(func: GLenum; ref: GLclampf); extdecl;
@@ -1501,6 +1518,7 @@ var
   {$IFDEF Win32}
   ChoosePixelFormat: function(DC: HDC; p2: PPixelFormatDescriptor): Integer; extdecl;
   {$ENDIF}
+{$ENDIF MORPHOS}
 
 type
   // EXT_vertex_array
@@ -1543,9 +1561,21 @@ implementation
 function WinChoosePixelFormat(DC: HDC; p2: PPixelFormatDescriptor): Integer; extdecl; external 'gdi32' name 'ChoosePixelFormat';
 {$endif}
 
+{$IFDEF MORPHOS}
+
+{ MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
+{ systems, so its functions are included here. }
+{$INCLUDE tinygl.inc}
+
+{$ENDIF MORPHOS}
+
 procedure FreeOpenGL;
 begin
+{$IFDEF MORPHOS}
 
+  // MorphOS's GL will closed down by TinyGL unit, nothing is needed here.
+
+{$ELSE MORPHOS}
   @glAccum := nil;
   @glAlphaFunc := nil;
   @glAreTexturesResident := nil;
@@ -1887,10 +1917,15 @@ begin
   {$ENDIF}
 
   FreeLibrary(LibGL);
-
+{$ENDIF MORPHOS}
 end;
 
 procedure LoadOpenGL(const dll: String);
+{$IFDEF MORPHOS}
+begin
+  // MorphOS's GL has own initialization in TinyGL unit, nothing is needed here.
+end;
+{$ELSE MORPHOS}
 var
   MethodName: string = '';
 
@@ -2256,8 +2291,8 @@ begin
     raise Exception.Create('Unable to select pixel format');
   end;
   {$ENDIF}
-
 end;
+{$ENDIF MORPHOS}
 
 initialization
 
@@ -2271,7 +2306,11 @@ initialization
   {$ifdef darwin}
   LoadOpenGL('/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib');
   {$ELSE}
+  {$IFDEF MorphOS}
+  InitTinyGLLibrary;
+  {$ELSE}
   LoadOpenGL('libGL.so.1');
+  {$ENDIF}
   {$endif}
   {$ENDIF}
 

+ 49 - 13
packages/extra/opengl/glu.pp

@@ -60,6 +60,10 @@ Abstract:
   {$DEFINE extdecl := cdecl}
 {$ENDIF}
 
+{$IFDEF MORPHOS}
+{$DEFINE GLU_UNIT}
+{$ENDIF}
+
 unit GLu;
 
 interface
@@ -69,8 +73,12 @@ uses
   {$IFDEF Win32}
   Windows,
   {$ELSE}
+  {$IFDEF MORPHOS}
+  TinyGL,
+  {$ELSE}
   DLLFuncs,
   {$ENDIF}
+  {$ENDIF}
   GL;
 
 type
@@ -82,6 +90,24 @@ type
   T4fArray = array [0..3] of GLfloat;
   PPointer = ^Pointer;
 
+type
+  GLUnurbs = record end;                PGLUnurbs = ^GLUnurbs;
+  GLUquadric = record end;              PGLUquadric = ^GLUquadric;
+  GLUtesselator = record end;           PGLUtesselator = ^GLUtesselator;
+
+  // backwards compatibility:
+  GLUnurbsObj = GLUnurbs;               PGLUnurbsObj = PGLUnurbs;
+  GLUquadricObj = GLUquadric;           PGLUquadricObj = PGLUquadric;
+  GLUtesselatorObj = GLUtesselator;     PGLUtesselatorObj = PGLUtesselator;
+  GLUtriangulatorObj = GLUtesselator;   PGLUtriangulatorObj = PGLUtesselator;
+
+{$IFDEF MORPHOS}
+
+{ MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
+{ systems, so its headers are included here. }
+{$INCLUDE tinyglh.inc}
+
+{$ELSE MORPHOS}
 var
   gluErrorString: function(errCode: GLenum): PChar; extdecl;
   gluErrorUnicodeStringEXT: function(errCode: GLenum): PWideChar; extdecl;
@@ -96,17 +122,6 @@ var
   gluBuild1DMipmaps: function(target: GLenum; components, width: GLint; format, atype: GLenum; const data: Pointer): Integer; extdecl;
   gluBuild2DMipmaps: function(target: GLenum; components, width, height: GLint; format, atype: GLenum; const data: Pointer): Integer; extdecl;
 
-type
-  GLUnurbs = record end;                PGLUnurbs = ^GLUnurbs;
-  GLUquadric = record end;              PGLUquadric = ^GLUquadric;
-  GLUtesselator = record end;           PGLUtesselator = ^GLUtesselator;
-
-  // backwards compatibility:
-  GLUnurbsObj = GLUnurbs;               PGLUnurbsObj = PGLUnurbs;
-  GLUquadricObj = GLUquadric;           PGLUquadricObj = PGLUquadric;
-  GLUtesselatorObj = GLUtesselator;     PGLUtesselatorObj = PGLUtesselator;
-  GLUtriangulatorObj = GLUtesselator;   PGLUtriangulatorObj = PGLUtesselator;
-
 var
   gluNewQuadric: function: PGLUquadric; extdecl;
   gluDeleteQuadric: procedure(state: PGLUquadric); extdecl;
@@ -145,6 +160,7 @@ var
   gluNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: GLenum; value: GLfloat); extdecl;
   gluGetNurbsProperty: procedure(nobj: PGLUnurbs; aproperty: GLenum; value: PGLfloat); extdecl;
   gluNurbsCallback: procedure(nobj: PGLUnurbs; which: GLenum; fn: TCallBack); extdecl;
+{$ENDIF MORPHOS}
 
 (**** Callback function prototypes ****)
 
@@ -368,12 +384,24 @@ procedure FreeGLu;
 
 implementation
 
+{$IFDEF MORPHOS}
+
+{ MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
+{ systems, so its functions are included here. }
+{$INCLUDE tinygl.inc}
+
+{$ELSE MORPHOS}
+
 var
   hDLL: THandle;
 
+{$ENDIF MORPHOS}
+
 procedure FreeGLu;
 begin
-
+{$IFDEF MORPHOS}
+  // MorphOS's GL will closed down by TinyGL unit, nothing is needed here.
+{$ELSE MORPHOS}
   @gluErrorString := nil;
   @gluErrorUnicodeStringEXT := nil;
   @gluGetString := nil;
@@ -428,10 +456,15 @@ begin
   @gluEndPolygon := nil;
 
   FreeLibrary(hDLL);
-
+{$ENDIF MORPHOS}
 end;
 
 procedure LoadGLu(const dll: String);
+{$IFDEF MORPHOS}
+begin
+  // MorphOS's GL has own initialization in TinyGL unit, nothing is needed here.
+end;
+{$ELSE MORPHOS}
 var
   MethodName: string = '';
   
@@ -505,6 +538,7 @@ begin
     raise Exception.Create('Could not load ' + MethodName + ' from ' + dll);
   end;
 end;
+{$ENDIF MORPHOS}
 
 initialization
 
@@ -514,7 +548,9 @@ initialization
   {$ifdef darwin}
   LoadGLu('/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib');
   {$else}
+  {$ifndef MorphOS}
   LoadGLu('libGLU.so.1');
+  {$endif}
   {$ENDIF}
   {$endif}
 

+ 36 - 0
packages/extra/opengl/glut.pp

@@ -13,6 +13,10 @@
   {$DEFINE extdecl := cdecl}
 {$ENDIF}
 
+{$IFDEF MORPHOS}
+{$DEFINE GLUT_UNIT}
+{$ENDIF}
+
 unit Glut;
 
 // Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */
@@ -34,8 +38,12 @@ uses
   {$IFDEF Win32}
   Windows,
   {$ELSE}
+  {$IFDEF MORPHOS}
+  TinyGL,
+  {$ELSE}
   DLLFuncs,
   {$ENDIF}
+  {$ENDIF}
   GL;
 
 type
@@ -276,6 +284,13 @@ const
   GLUT_GAME_MODE_REFRESH_RATE     = 5;
   GLUT_GAME_MODE_DISPLAY_CHANGED  = 6;
 
+{$IFDEF MORPHOS}
+
+{ MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
+{ systems, so its headers are included here. }
+{$INCLUDE tinyglh.inc}
+
+{$ELSE MORPHOS}
 var
 // GLUT initialization sub-API.
   glutInit: procedure(argcp: PInteger; argv: PPChar); extdecl;
@@ -421,17 +436,29 @@ var
   glutEnterGameMode : function : integer; extdecl;
   glutLeaveGameMode : procedure; extdecl;
   glutGameModeGet : function (mode : GLenum) : integer; extdecl;
+{$ENDIF MORPHOS}
 
 procedure LoadGlut(const dll: String);
 procedure FreeGlut;
 
 implementation
 
+{$IFDEF MORPHOS}
+
+{ MorphOS GL works differently due to different dynamic-library handling on Amiga-like }
+{ systems, so its functions are included here. }
+{$INCLUDE tinygl.inc}
+
+{$ELSE MORPHOS}
 var
   hDLL: THandle;
+{$ENDIF MORPHOS}
 
 procedure FreeGlut;
 begin
+{$IFDEF MORPHOS}
+  // MorphOS's GL will closed down by TinyGL unit, nothing is needed here.
+{$ELSE MORPHOS}
 
   FreeLibrary(hDLL);
 
@@ -549,9 +576,15 @@ begin
   @glutEnterGameMode := nil;
   @glutLeaveGameMode := nil;
   @glutGameModeGet := nil;
+{$ENDIF MORPHOS}
 end;
 
 procedure LoadGlut(const dll: String);
+{$IFDEF MORPHOS}
+begin
+  // MorphOS's GL has own initialization in TinyGL unit, nothing is needed here.
+end;
+{$ELSE MORPHOS}
 var
   MethodName: string = '';
 
@@ -686,6 +719,7 @@ begin
     raise Exception.Create('Could not load ' + MethodName + ' from ' + dll);
   end;
 end;
+{$ENDIF MORPHOS}
 
 initialization
 
@@ -695,7 +729,9 @@ initialization
   {$ifdef darwin}
   LoadGlut('/System/Library/Frameworks/GLUT.framework/GLUT');
   {$else}
+  {$IFNDEF MORPHOS}
   LoadGlut('libglut.so.3');
+  {$ENDIF}
   {$endif}
   {$ENDIF}