Merge remote-tracking branch 'glBitmap.delphigl.com/unstable'
[LazOpenGLCore.git] / dglOpenGL.pas
index 6601c87..5d2a5ed 100644 (file)
@@ -1,10 +1,10 @@
 { ============================================================================
 
        OpenGL 4.5 - Headertranslation
-       Version 4.5
+       Version 4.5a
 
        Supported environments and targets :
-        - (Win32) Delphi 4 and up
+        - (Win32) Delphi 6 and up
         - (Win32, Win64) Delphi XE2
         - (Win32, Win64, Linux, MacOSX) FreePascal (1.9.3 and up)
 
@@ -134,6 +134,17 @@ interface
   {$A4}
 {$ENDIF}
 
+// 64 BIT architecture
+// Free pascal
+{$IFDEF CPU64}
+  {$DEFINE DGL_64BIT}
+{$ENDIF}
+// Delphi
+{$IFDEF WIN64}
+  {$DEFINE DGL_64BIT}
+{$ENDIF}
+
+
 // generell options
 {$H+,O+,X+}
 
@@ -161,25 +172,20 @@ interface
 {$ENDIF}
 {$ENDIF}
 
-
-// detecting 64 Bit CPU
-{$IFDEF CPU64}          // fpc on 64 bit cpus
-  {$DEFINE DGL_64BIT}   // dgl define for 64 bit
-{$ENDIF}
-
-
-
 uses
   {$IFDEF FPC}{$IFDEF DARWIN}dynlibs,{$ENDIF}{$ENDIF}  // LoadLibrary functions
   SysUtils
   {$IFDEF DGL_WIN}, Windows{$ENDIF}
+  {$IFDEF DGL_64BIT} ,math {$ENDIF}
   {$IFDEF DGL_LINUX}, X, XLib, XUtil{$ENDIF}
   ;
 
 type
-  // Needed for Delphi 6 and less (defined in system.pas for Delphi 7)
-  PPointer = ^Pointer;
-  PCardinal = ^Cardinal;
+  {$IFDEF DELPHI6_AND_DOWN}
+    // Delphi 6 compatibility
+    PPointer = ^Pointer;
+    PCardinal = ^Cardinal;
+  {$ENDIF}
 
   GLenum = Cardinal;
   GLboolean = BYTEBOOL;
@@ -376,6 +382,7 @@ type
   TGLVector3f = TGLVectorf3;
 
   // Datatypes corresponding to OpenGL12.pas for easy porting
+  TVector3f = TGLVectorf3;
   TVector3d = TGLVectord3;
 
   TVector4i = TGLVectori4;
@@ -1026,8 +1033,8 @@ const
   GL_STENCIL_BUFFER_BIT = $00000400;
   GL_COLOR_BUFFER_BIT = $00004000;
   { Boolean }
-  GL_TRUE = 1;
-  GL_FALSE = 0;
+  GL_TRUE: ByteBool = True;
+  GL_FALSE: ByteBool = False;
   { BeginMode }
   GL_POINTS = $0000;
   GL_LINES = $0001;
@@ -3011,6 +3018,7 @@ const
 
   // GL_ARB_imaging
   GL_CONSTANT_COLOR_ARB = $8001;
+  GL_CONSTANT_COLOR = $8001;
   GL_ONE_MINUS_CONSTANT_COLOR = $8002;
   GL_CONSTANT_ALPHA = $8003;
   GL_ONE_MINUS_CONSTANT_ALPHA = $8004;
@@ -7636,8 +7644,8 @@ const
   GLU_INCOMPATIBLE_GL_VERSION = 100903;
   GLU_VERSION = 100800;
   GLU_EXTENSIONS = 100801;
-  GLU_TRUE = GL_TRUE;
-  GLU_FALSE = GL_FALSE;
+  GLU_TRUE: ByteBool = True;
+  GLU_FALSE: ByteBool = False;
   GLU_SMOOTH = 100000;
   GLU_FLAT = 100001;
   GLU_NONE = 100002;
@@ -14886,7 +14894,7 @@ const
 function dglLoadLibrary(Name: PChar): Pointer;
 begin
   {$IFDEF DGL_WIN}
-  Result := Pointer(LoadLibrary(Name));
+  Result := {%H-}Pointer(LoadLibrary(Name));
   {$ENDIF}
 
   {$IFDEF DGL_LINUX}
@@ -14909,7 +14917,7 @@ begin
     Result := False
   else
     {$IFDEF DGL_WIN}
-    Result := FreeLibrary(HMODULE(LibHandle));
+    Result := FreeLibrary({%H-}HMODULE(LibHandle));
     {$ENDIF}
 
     {$IFDEF DGL_LINUX}
@@ -14933,7 +14941,7 @@ begin
 
 
   {$IFDEF DGL_WIN}
-    Result := GetProcAddress(HMODULE(LibHandle), ProcName);
+    Result := GetProcAddress({%H-}HMODULE(LibHandle), ProcName);
 
     if result <> nil then
       exit;
@@ -14968,7 +14976,7 @@ end;
 
 function Int_GetExtensionString: AnsiString;
 var
-       ExtensionCount : GLuint;
+       ExtensionCount : GLint;
   i : Integer;
 begin
   if GL_VERSION_3_0
@@ -19275,7 +19283,7 @@ var
   Buffer: String;
   MajorVersion, MinorVersion: Integer;
 
-  procedure TrimAndSplitVersionString(Buffer: String; var Max, Min: Integer);
+  procedure TrimAndSplitVersionString(Buffer: String; out Max, Min: Integer);
     // Peels out the X.Y form from the given Buffer which must contain a version string like "text Minor.Major.Build text"
     // at least however "Major.Minor".
   var
@@ -20070,7 +20078,7 @@ begin
   if GL_LibHandle = nil then
     InitOpenGL;
 
-  FillChar(PFDescriptor, SizeOf(PFDescriptor), 0);
+  FillChar(PFDescriptor{%H-}, SizeOf(PFDescriptor), 0);
 
   with PFDescriptor do
   begin
@@ -20168,7 +20176,7 @@ begin
   if not Assigned(GL_LibHandle) then
        raise Exception.Create('GL_LibHandle is NIL. Could not load OpenGL library!');
 
-  FillChar(PFDescriptor, SizeOf(PFDescriptor), 0);
+  FillChar(PFDescriptor{%H-}, SizeOf(PFDescriptor), 0);
 
   with PFDescriptor do
     begin
@@ -20321,6 +20329,10 @@ initialization
 {$IFDEF CPU386}
   Set8087CW($133F);
 {$ENDIF}
+{$IFDEF DGL_64BIT}
+  SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,exOverflow, exUnderflow, exPrecision]);
+{$ENDIF}
+
 
 finalization