From 67d613411dc51250ef002b692e4634e66d4bea94 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Wed, 10 Dec 2014 18:13:15 +0100 Subject: [PATCH] * fixed some bugs to compile with Delphi7 --- uglcContext.pas | 31 +++++++++++++++++++++++++------ uglcContextWGL.pas | 6 +++--- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/uglcContext.pas b/uglcContext.pas index 6255396..73f419a 100644 --- a/uglcContext.pas +++ b/uglcContext.pas @@ -44,6 +44,10 @@ const GLC_CONTEXT_VERSION_UNKNOWN = -1; type +{$IFNDEF fpc} + TThreadID = Cardinal; +{$ENDIF} + TMultiSample = 1..high(byte); TglcContextPixelFormatSettings = packed record DoubleBuffered: boolean; @@ -93,8 +97,8 @@ type property PixelFormatSettings: TglcContextPixelFormatSettings read fPixelFormatSettings; property VersionSettings: TglcContextVersionSettings read fVersionSettings; - constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings); virtual; overload; - constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings; const aVersionSettings: TglcContextVersionSettings); virtual; overload; + constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings); overload; virtual; + constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings; const aVersionSettings: TglcContextVersionSettings); overload; virtual; destructor Destroy; override; property ThreadID: TThreadID read fThreadID; @@ -111,11 +115,13 @@ type procedure SetSwapInterval(const aInterval: GLint); virtual; abstract; function GetSwapInterval: GLint; virtual; abstract; procedure Share(const aContext: TglcContext); virtual; abstract; - +{$IFDEF fpc} private class var fMainContextThreadID: TThreadID; public class property MainContextThreadID: TThreadID read fMainContextThreadID; +{$ENDIF} + public class function MakePF(DoubleBuffered: boolean = true; Stereo: boolean=false; MultiSampling: TMultiSample=1; @@ -137,12 +143,20 @@ implementation uses {$IFDEF WINDOWS} uglcContextWGL - {$ENDIF} + {$ELSE}{$IFDEF WIN32} + uglcContextWGL{$IFNDEF fpc}, Windows{$ENDIF} + {$ENDIF}{$ENDIF} + {$IFDEF LINUX} uglcContextGtk2GLX {$ENDIF} ; +{$IFNDEF fpc} +var + fMainContextThreadID: TThreadID; +{$ENDIF} + procedure GlDebugCallbackARB(source: GLenum; type_: GLenum; id: GLuint; severity: GLenum; {%H-}length: GLsizei; const message_: PGLchar; {%H-}userParam: PGLvoid); {$IFDEF WINDOWS}stdcall; {$ELSE}cdecl; {$ENDIF} var src, typ: String; @@ -274,12 +288,17 @@ end; class function TglcContext.GetPlatformClass: TglcContextClass; begin + Result := nil; {$IFDEF WINDOWS} Result:= TglcContextWGL; - {$ENDIF} + {$ELSE}{$IFDEF WIN32} + Result:= TglcContextWGL; + {$ENDIF}{$ENDIF} {$IFDEF LINUX} Result:= TglcContextGtk2GLX; {$ENDIF} + if not Assigned(result) then + raise EGLError.Create('unable to find suitabe context class'); end; class function TglcContext.IsAnyContextActive: boolean; @@ -340,7 +359,7 @@ begin end; initialization - TglcContext.fMainContextThreadID := 0; + {$IFDEF fpc}TglcContext.{$ENDIF}fMainContextThreadID := 0; end. diff --git a/uglcContextWGL.pas b/uglcContextWGL.pas index 76e0614..16fc885 100644 --- a/uglcContextWGL.pas +++ b/uglcContextWGL.pas @@ -21,7 +21,7 @@ type FRC: HGLRC; fHandle: THandle; fPixelFormat: Integer; - {%H-}constructor Create(const aControl: TWinControl); + {%H-}constructor Create(const aControl: TWinControl); overload; protected procedure UpdatePixelFormat; procedure OpenContext; override; @@ -29,8 +29,8 @@ type function FindPixelFormatNoAA: Integer; procedure OpenFromPF(PixelFormat: Integer); public - constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings); override; overload; - constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings; const aVersionSettings: TglcContextVersionSettings); override; overload; + constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings); overload; override; + constructor Create(const aControl: TWinControl; const aPixelFormatSettings: TglcContextPixelFormatSettings; const aVersionSettings: TglcContextVersionSettings); overload; override; procedure CloseContext; override; procedure Activate; override; -- 2.1.4