mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 22:34:41 +01:00
openglcontrol: fixed compilation for fpc 2.4.4, bug #20645
git-svn-id: trunk@33463 -
This commit is contained in:
parent
e509d48543
commit
0a718ef6e5
@ -19,10 +19,19 @@ unit GLGtkGlxContext;
|
|||||||
{$LinkLib GL}
|
{$LinkLib GL}
|
||||||
{$PACKRECORDS C}
|
{$PACKRECORDS C}
|
||||||
|
|
||||||
|
{$IFNDEF VER2_4}
|
||||||
|
{$Define UseFPGLX}
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, LCLType, glx, X, XUtil, XLib, gl, InterfaceBase,
|
Classes, SysUtils, LCLProc, LCLType, X, XUtil, XLib, gl, InterfaceBase,
|
||||||
|
{$IFDEF UseFPGLX}
|
||||||
|
glx,
|
||||||
|
{$ELSE}
|
||||||
|
ctypes,
|
||||||
|
{$ENDIF}
|
||||||
WSLCLClasses,
|
WSLCLClasses,
|
||||||
{$IFDEF LCLGTK2}
|
{$IFDEF LCLGTK2}
|
||||||
LMessages, Gtk2Def, gdk2x, glib2, gdk2, gtk2, Gtk2Int,
|
LMessages, Gtk2Def, gdk2x, glib2, gdk2, gtk2, Gtk2Int,
|
||||||
@ -32,8 +41,20 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Controls;
|
Controls;
|
||||||
|
|
||||||
|
{$IFDEF UseFPGLX}
|
||||||
|
type
|
||||||
|
TGLBool = longbool;
|
||||||
|
const
|
||||||
|
GLXTrue:longbool = true;
|
||||||
|
GLXFalse:longbool = false;
|
||||||
|
{$ELSE}
|
||||||
|
type
|
||||||
|
TGLBool = cint;
|
||||||
|
const
|
||||||
|
GLXTrue = 1;
|
||||||
|
GLXFalse = 0;
|
||||||
|
{$ENDIF}
|
||||||
// gdkgl
|
// gdkgl
|
||||||
|
|
||||||
const
|
const
|
||||||
// enum _GDK_GL_CONFIGS
|
// enum _GDK_GL_CONFIGS
|
||||||
GDK_GL_NONE = 0;
|
GDK_GL_NONE = 0;
|
||||||
@ -76,9 +97,9 @@ function gdk_gl_choose_visual(attrlist: Plongint): PGdkVisual;
|
|||||||
function gdk_gl_get_config(visual: PGdkVisual; attrib: longint): longint;
|
function gdk_gl_get_config(visual: PGdkVisual; attrib: longint): longint;
|
||||||
function gdk_gl_context_new(visual: PGdkVisual; attrlist: PlongInt): PGdkGLContext;
|
function gdk_gl_context_new(visual: PGdkVisual; attrlist: PlongInt): PGdkGLContext;
|
||||||
function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
|
function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
|
||||||
direct: boolean; attrlist: plongint): PGdkGLContext;
|
direct: TGLBool; attrlist: plongint): PGdkGLContext;
|
||||||
function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
|
function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
|
||||||
sharelist: PGdkGLContext; direct: boolean): PGdkGLContext;
|
sharelist: PGdkGLContext; direct: TGLBool): PGdkGLContext;
|
||||||
function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext;
|
function gdk_gl_context_ref(context: PGdkGLContext): PGdkGLContext;
|
||||||
procedure gdk_gl_context_unref(context:PGdkGLContext);
|
procedure gdk_gl_context_unref(context:PGdkGLContext);
|
||||||
function gdk_gl_make_current(drawable: PGdkDrawable;
|
function gdk_gl_make_current(drawable: PGdkDrawable;
|
||||||
@ -158,6 +179,28 @@ type
|
|||||||
//PGLXDrawable = ^GLXDrawable;
|
//PGLXDrawable = ^GLXDrawable;
|
||||||
GLXDrawable = TXID;
|
GLXDrawable = TXID;
|
||||||
|
|
||||||
|
{$IFNDEF UseFPGLX}
|
||||||
|
{ GLX 1.0 functions. }
|
||||||
|
|
||||||
|
function glXChooseVisual(dpy:PDisplay; screen:longint; attrib_list:Plongint):PXVisualInfo;cdecl;external;
|
||||||
|
procedure glXCopyContext(dpy:PDisplay; src:TGLXContext; dst:TGLXContext; mask: cardinal);cdecl;external;
|
||||||
|
function glXCreateContext(dpy:PDisplay; vis:PXVisualInfo; share_list:TGLXContext; direct:TGLBool):TGLXContext;cdecl;external;
|
||||||
|
function glXCreateGLXPixmap(dpy:PDisplay; vis:PXVisualInfo; pixmap:TPixmap):GLXPixmap;cdecl;external;
|
||||||
|
procedure glXDestroyContext(dpy:PDisplay; ctx:TGLXContext);cdecl;external;
|
||||||
|
procedure glXDestroyGLXPixmap(dpy:PDisplay; pix:GLXPixmap);cdecl;external;
|
||||||
|
function glXGetConfig(dpy:PDisplay; vis:PXVisualInfo; attrib:longint; var value:longint):longint;cdecl;external;
|
||||||
|
function glXGetCurrentContext:TGLXContext;cdecl;external;
|
||||||
|
function glXGetCurrentDrawable:GLXDrawable;cdecl;external;
|
||||||
|
function glXIsDirect(dpy:PDisplay; ctx:TGLXContext):TGLBool;cdecl;external;
|
||||||
|
function glXMakeCurrent(dpy:PDisplay; drawable:GLXDrawable; ctx:TGLXContext):TGLBool;cdecl;external;
|
||||||
|
function glXQueryExtension(dpy:PDisplay; var error_base:longint; var event_base:longint):TGLBool;cdecl;external;
|
||||||
|
function glXQueryVersion(dpy:PDisplay; major:Plongint; minor:Plongint):TGLBool;cdecl;external;
|
||||||
|
procedure glXSwapBuffers(dpy:PDisplay; drawable:GLXDrawable);cdecl;external;
|
||||||
|
procedure glXUseXFont(font:TFont; first:longint; count:longint; list_base:longint);cdecl;external;
|
||||||
|
procedure glXWaitGL;cdecl;external;
|
||||||
|
procedure glXWaitX;cdecl;external;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
procedure g_return_if_fail(b: boolean; const Msg: string);
|
procedure g_return_if_fail(b: boolean; const Msg: string);
|
||||||
begin
|
begin
|
||||||
if not b then raise Exception.Create(Msg);
|
if not b then raise Exception.Create(Msg);
|
||||||
@ -313,7 +356,7 @@ var
|
|||||||
errorb: Integer = 0;
|
errorb: Integer = 0;
|
||||||
event: Integer = 0;
|
event: Integer = 0;
|
||||||
begin
|
begin
|
||||||
Result:=boolean(glXQueryExtension(GetDefaultXDisplay, errorb, event){$IFDEF VER2_2}=true{$ENDIF});
|
Result:=boolean(glXQueryExtension(GetDefaultXDisplay, errorb, event));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function gdk_gl_choose_visual(attrlist: Plongint): PGdkVisual;
|
function gdk_gl_choose_visual(attrlist: Plongint): PGdkVisual;
|
||||||
@ -357,6 +400,7 @@ begin
|
|||||||
|
|
||||||
vi := get_xvisualinfo(visual);
|
vi := get_xvisualinfo(visual);
|
||||||
|
|
||||||
|
value:=0;
|
||||||
if (glXGetConfig(dpy, vi, attrib, value) = 0) then begin
|
if (glXGetConfig(dpy, vi, attrib, value) = 0) then begin
|
||||||
XFree(vi);
|
XFree(vi);
|
||||||
Result:=value;
|
Result:=value;
|
||||||
@ -366,18 +410,18 @@ end;
|
|||||||
|
|
||||||
function gdk_gl_context_new(visual: PGdkVisual; attrlist: PlongInt): PGdkGLContext;
|
function gdk_gl_context_new(visual: PGdkVisual; attrlist: PlongInt): PGdkGLContext;
|
||||||
begin
|
begin
|
||||||
Result := gdk_gl_context_share_new(visual, nil, false, attrlist);
|
Result := gdk_gl_context_share_new(visual, nil, GLXFalse, attrlist);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
|
function gdk_gl_context_share_new(visual: PGdkVisual; sharelist: PGdkGLContext;
|
||||||
direct: boolean; attrlist: plongint): PGdkGLContext;
|
direct: TGLBool; attrlist: plongint): PGdkGLContext;
|
||||||
var
|
var
|
||||||
dpy: PDisplay;
|
dpy: PDisplay;
|
||||||
vi: PXVisualInfo;
|
vi: PXVisualInfo;
|
||||||
PrivateShareList: PGdkGLContextPrivate;
|
PrivateShareList: PGdkGLContextPrivate;
|
||||||
PrivateContext: PGdkGLContextPrivate;
|
PrivateContext: PGdkGLContextPrivate;
|
||||||
glxcontext: TGLXContext;
|
glxcontext: TGLXContext;
|
||||||
|
{$IFDEF UseFPGLX}
|
||||||
FBConfig: TGLXFBConfig;
|
FBConfig: TGLXFBConfig;
|
||||||
FBConfigs: PGLXFBConfig;
|
FBConfigs: PGLXFBConfig;
|
||||||
FBConfigsCount: Integer;
|
FBConfigsCount: Integer;
|
||||||
@ -391,6 +435,7 @@ var
|
|||||||
GLX_BLUE_SIZE, 1,
|
GLX_BLUE_SIZE, 1,
|
||||||
GLX_DOUBLEBUFFER, 1 { true },
|
GLX_DOUBLEBUFFER, 1 { true },
|
||||||
none);
|
none);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
@ -399,8 +444,10 @@ begin
|
|||||||
|
|
||||||
{$IFDEF lclgtk2}
|
{$IFDEF lclgtk2}
|
||||||
if visual=nil then ;
|
if visual=nil then ;
|
||||||
|
{$IFDEF UseFPGLX}
|
||||||
if GLX_version_1_3(dpy) then begin
|
if GLX_version_1_3(dpy) then begin
|
||||||
{ use approach recommended since glX 1.3 }
|
{ use approach recommended since glX 1.3 }
|
||||||
|
FBConfigsCount:=0;
|
||||||
FBConfigs:=glXChooseFBConfig(dpy, DefaultScreen(dpy), AttrFB, FBConfigsCount);
|
FBConfigs:=glXChooseFBConfig(dpy, DefaultScreen(dpy), AttrFB, FBConfigsCount);
|
||||||
if FBConfigsCount = 0 then
|
if FBConfigsCount = 0 then
|
||||||
raise Exception.Create('Could not find FB config');
|
raise Exception.Create('Could not find FB config');
|
||||||
@ -412,6 +459,9 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
vi:=glXChooseVisual(dpy, DefaultScreen(dpy), @attrList[0]);
|
vi:=glXChooseVisual(dpy, DefaultScreen(dpy), @attrList[0]);
|
||||||
end;
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
vi:=glXChooseVisual(dpy, DefaultScreen(dpy), @attrList[0]);
|
||||||
|
{$ENDIF}
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
if visual=nil then exit;
|
if visual=nil then exit;
|
||||||
vi := get_xvisualinfo(visual);
|
vi := get_xvisualinfo(visual);
|
||||||
@ -421,6 +471,7 @@ begin
|
|||||||
|
|
||||||
PrivateShareList:=PGdkGLContextPrivate(sharelist);
|
PrivateShareList:=PGdkGLContextPrivate(sharelist);
|
||||||
|
|
||||||
|
{$IFDEF UseFPGLX}
|
||||||
if GLX_version_1_3(dpy) then begin
|
if GLX_version_1_3(dpy) then begin
|
||||||
//DebugLn('GLX Version 1.3 context creation');
|
//DebugLn('GLX Version 1.3 context creation');
|
||||||
if (sharelist<>nil) then
|
if (sharelist<>nil) then
|
||||||
@ -435,6 +486,13 @@ begin
|
|||||||
else
|
else
|
||||||
glxcontext := glXCreateContext(dpy, vi, nil, direct);
|
glxcontext := glXCreateContext(dpy, vi, nil, direct);
|
||||||
end;
|
end;
|
||||||
|
{$ELSE}
|
||||||
|
if (sharelist<>nil) then
|
||||||
|
glxcontext := glXCreateContext(dpy, vi, PrivateShareList^.glxcontext,
|
||||||
|
direct)
|
||||||
|
else
|
||||||
|
glxcontext := glXCreateContext(dpy, vi, nil, direct);
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
XFree(vi);
|
XFree(vi);
|
||||||
if (glxcontext = nil) then exit;
|
if (glxcontext = nil) then exit;
|
||||||
@ -448,7 +506,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
|
function gdk_gl_context_attrlist_share_new(attrlist: Plongint;
|
||||||
sharelist: PGdkGLContext; direct: boolean): PGdkGLContext;
|
sharelist: PGdkGLContext; direct: TGLBool): PGdkGLContext;
|
||||||
var
|
var
|
||||||
visual: PGdkVisual;
|
visual: PGdkVisual;
|
||||||
begin
|
begin
|
||||||
@ -653,7 +711,7 @@ begin
|
|||||||
|
|
||||||
sharelist := nil;
|
sharelist := nil;
|
||||||
if share <> nil then sharelist := share^.glcontext;
|
if share <> nil then sharelist := share^.glcontext;
|
||||||
glcontext := gdk_gl_context_share_new(visual, sharelist, true, attrlist);
|
glcontext := gdk_gl_context_share_new(visual, sharelist, GLXTrue, attrlist);
|
||||||
if (glcontext = nil) then exit;
|
if (glcontext = nil) then exit;
|
||||||
|
|
||||||
{$IFNDEF MSWindows}
|
{$IFNDEF MSWindows}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user