Browse Source

* fixed some bugs to compile with Delphi7

master
Bergmann89 9 years ago
parent
commit
67d613411d
2 changed files with 28 additions and 9 deletions
  1. +25
    -6
      uglcContext.pas
  2. +3
    -3
      uglcContextWGL.pas

+ 25
- 6
uglcContext.pas View File

@@ -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.


+ 3
- 3
uglcContextWGL.pas View File

@@ -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;


Loading…
Cancel
Save