/usr/src/castle-game-engine-5.0.0/window/unix/castleglx.pas is in castle-game-engine-src 5.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | { FPC GLX unit with my patch to bring it to 1.4 level:
http://bugs.freepascal.org/view.php?id=19953
Also modified to work in objfpc mode, to ease compilation along
with the rest of the engine. }
{
Translation of the Mesa GLX headers for FreePascal
Copyright (C) 1999 Sebastian Guenther
Mesa 3-D graphics library
Version: 3.0
Copyright (C) 1995-1998 Brian Paul
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}
{You have to enable Macros (compiler switch "-Sm") for compiling this unit!
This is necessary for supporting different platforms with different calling
conventions via a single unit.}
{ @exclude (This is only a C header translation --- no nice PasDoc docs.) }
unit CastleGlx;
interface
{$MACRO ON}
{$IFDEF Unix}
uses
X, XLib, XUtil;
{$DEFINE HasGLX} // Activate GLX stuff
{$ELSE}
{$MESSAGE Unsupported platform.}
{$ENDIF}
{$IFNDEF HasGLX}
{$MESSAGE GLX not present on this platform.}
{$ENDIF}
// =======================================================
// Unit specific extensions
// =======================================================
// Note: Requires that the GL library has already been initialized
function InitGLX: Boolean;
var
GLXDumpUnresolvedFunctions,
GLXInitialized: Boolean;
// =======================================================
// GLX consts, types and functions
// =======================================================
// Tokens for glXChooseVisual and glXGetConfig:
const
GLX_USE_GL = 1;
GLX_BUFFER_SIZE = 2;
GLX_LEVEL = 3;
GLX_RGBA = 4;
GLX_DOUBLEBUFFER = 5;
GLX_STEREO = 6;
GLX_AUX_BUFFERS = 7;
GLX_RED_SIZE = 8;
GLX_GREEN_SIZE = 9;
GLX_BLUE_SIZE = 10;
GLX_ALPHA_SIZE = 11;
GLX_DEPTH_SIZE = 12;
GLX_STENCIL_SIZE = 13;
GLX_ACCUM_RED_SIZE = 14;
GLX_ACCUM_GREEN_SIZE = 15;
GLX_ACCUM_BLUE_SIZE = 16;
GLX_ACCUM_ALPHA_SIZE = 17;
// Error codes returned by glXGetConfig:
GLX_BAD_SCREEN = 1;
GLX_BAD_ATTRIBUTE = 2;
GLX_NO_EXTENSION = 3;
GLX_BAD_VISUAL = 4;
GLX_BAD_CONTEXT = 5;
GLX_BAD_VALUE = 6;
GLX_BAD_ENUM = 7;
// GLX 1.1 and later:
GLX_VENDOR = 1;
GLX_VERSION = 2;
GLX_EXTENSIONS = 3;
// GLX 1.3 and later:
GLX_CONFIG_CAVEAT = $20;
GLX_DONT_CARE = $FFFFFFFF;
GLX_X_VISUAL_TYPE = $22;
GLX_TRANSPARENT_TYPE = $23;
GLX_TRANSPARENT_INDEX_VALUE = $24;
GLX_TRANSPARENT_RED_VALUE = $25;
GLX_TRANSPARENT_GREEN_VALUE = $26;
GLX_TRANSPARENT_BLUE_VALUE = $27;
GLX_TRANSPARENT_ALPHA_VALUE = $28;
GLX_WINDOW_BIT = $00000001;
GLX_PIXMAP_BIT = $00000002;
GLX_PBUFFER_BIT = $00000004;
GLX_AUX_BUFFERS_BIT = $00000010;
GLX_FRONT_LEFT_BUFFER_BIT = $00000001;
GLX_FRONT_RIGHT_BUFFER_BIT = $00000002;
GLX_BACK_LEFT_BUFFER_BIT = $00000004;
GLX_BACK_RIGHT_BUFFER_BIT = $00000008;
GLX_DEPTH_BUFFER_BIT = $00000020;
GLX_STENCIL_BUFFER_BIT = $00000040;
GLX_ACCUM_BUFFER_BIT = $00000080;
GLX_NONE = $8000;
GLX_SLOW_CONFIG = $8001;
GLX_TRUE_COLOR = $8002;
GLX_DIRECT_COLOR = $8003;
GLX_PSEUDO_COLOR = $8004;
GLX_STATIC_COLOR = $8005;
GLX_GRAY_SCALE = $8006;
GLX_STATIC_GRAY = $8007;
GLX_TRANSPARENT_RGB = $8008;
GLX_TRANSPARENT_INDEX = $8009;
GLX_VISUAL_ID = $800B;
GLX_SCREEN = $800C;
GLX_NON_CONFORMANT_CONFIG = $800D;
GLX_DRAWABLE_TYPE = $8010;
GLX_RENDER_TYPE = $8011;
GLX_X_RENDERABLE = $8012;
GLX_FBCONFIG_ID = $8013;
GLX_RGBA_TYPE = $8014;
GLX_COLOR_INDEX_TYPE = $8015;
GLX_MAX_PBUFFER_WIDTH = $8016;
GLX_MAX_PBUFFER_HEIGHT = $8017;
GLX_MAX_PBUFFER_PIXELS = $8018;
GLX_PRESERVED_CONTENTS = $801B;
GLX_LARGEST_PBUFFER = $801C;
GLX_WIDTH = $801D;
GLX_HEIGHT = $801E;
GLX_EVENT_MASK = $801F;
GLX_DAMAGED = $8020;
GLX_SAVED = $8021;
GLX_WINDOW = $8022;
GLX_PBUFFER = $8023;
GLX_PBUFFER_HEIGHT = $8040;
GLX_PBUFFER_WIDTH = $8041;
GLX_RGBA_BIT = $00000001;
GLX_COLOR_INDEX_BIT = $00000002;
GLX_PBUFFER_CLOBBER_MASK = $08000000;
// GLX 1.4 and later:
GLX_SAMPLE_BUFFERS = $186a0; // 100000
GLX_SAMPLES = $186a1; // 100001
// Extensions:
// GLX_ARB_multisample
GLX_SAMPLE_BUFFERS_ARB = 100000;
GLX_SAMPLES_ARB = 100001;
// GLX_ARB_create_context (http://www.opengl.org/registry/specs/ARB/glx_create_context.txt)
GLX_CONTEXT_DEBUG_BIT_ARB = $00000001;
GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = $00000002;
GLX_CONTEXT_MAJOR_VERSION_ARB = $2091;
GLX_CONTEXT_MINOR_VERSION_ARB = $2092;
GLX_CONTEXT_FLAGS_ARB = $2094;
// GLX_ARB_create_context_profile
GLX_CONTEXT_CORE_PROFILE_BIT_ARB = $00000001;
GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = $00000002;
GLX_CONTEXT_PROFILE_MASK_ARB = $9126;
// GLX_ARB_create_context_robustness
GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB = $00000004;
GLX_LOSE_CONTEXT_ON_RESET_ARB = $8252;
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = $8256;
GLX_NO_RESET_NOTIFICATION_ARB = $8261;
// GLX_SGIS_multisample
GLX_SAMPLE_BUFFERS_SGIS = 100000;
GLX_SAMPLES_SGIS = 100001;
// GLX_EXT_visual_info
GLX_X_VISUAL_TYPE_EXT = $22;
GLX_TRANSPARENT_TYPE_EXT = $23;
GLX_TRANSPARENT_INDEX_VALUE_EXT = $24;
GLX_TRANSPARENT_RED_VALUE_EXT = $25;
GLX_TRANSPARENT_GREEN_VALUE_EXT = $26;
GLX_TRANSPARENT_BLUE_VALUE_EXT = $27;
GLX_TRANSPARENT_ALPHA_VALUE_EXT = $28;
GLX_TRUE_COLOR_EXT = $8002;
GLX_DIRECT_COLOR_EXT = $8003;
GLX_PSEUDO_COLOR_EXT = $8004;
GLX_STATIC_COLOR_EXT = $8005;
GLX_GRAY_SCALE_EXT = $8006;
GLX_STATIC_GRAY_EXT = $8007;
GLX_NONE_EXT = $8000;
GLX_TRANSPARENT_RGB_EXT = $8008;
GLX_TRANSPARENT_INDEX_EXT = $8009;
type
// From XLib:
XPixmap = TXID;
XFont = TXID;
XColormap = TXID;
GLXContext = Pointer;
GLXPixmap = TXID;
GLXDrawable = TXID;
GLXContextID = TXID;
TXPixmap = XPixmap;
TXFont = XFont;
TXColormap = XColormap;
TGLXContext = GLXContext;
TGLXPixmap = GLXPixmap;
TGLXDrawable = GLXDrawable;
// GLX 1.3 and later
TGLXFBConfigRec = record { internal, use only a pointer to this } end;
TGLXFBConfig = ^TGLXFBConfigRec;
{ PGLXFBConfig is a pointer to TGLXFBConfig (which is also a pointer).
glX uses this to represent an array of FB configs. }
PGLXFBConfig = ^TGLXFBConfig;
TGLXFBConfigID = TXID;
TGLXContextID = GLXContextID;
TGLXWindow = TXID;
TGLXPbuffer = TXID;
var
glXChooseVisual: function(dpy: PDisplay; screen: Integer; attribList: PInteger): PXVisualInfo; cdecl;
glXCreateContext: function(dpy: PDisplay; vis: PXVisualInfo; shareList: GLXContext; direct: Boolean): GLXContext; cdecl;
glXDestroyContext: procedure(dpy: PDisplay; ctx: GLXContext); cdecl;
glXMakeCurrent: function(dpy: PDisplay; drawable: GLXDrawable; ctx: GLXContext): Boolean; cdecl;
glXCopyContext: procedure(dpy: PDisplay; src, dst: GLXContext; mask: LongWord); cdecl;
glXSwapBuffers: procedure(dpy: PDisplay; drawable: GLXDrawable); cdecl;
glXCreateGLXPixmap: function(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap): GLXPixmap; cdecl;
glXDestroyGLXPixmap: procedure(dpy: PDisplay; pixmap: GLXPixmap); cdecl;
glXQueryExtension: function(dpy: PDisplay; var errorb, event: Integer): Boolean; cdecl;
glXQueryVersion: function(dpy: PDisplay; var maj, min: Integer): Boolean; cdecl;
glXIsDirect: function(dpy: PDisplay; ctx: GLXContext): Boolean; cdecl;
glXGetConfig: function(dpy: PDisplay; visual: PXVisualInfo; attrib: Integer; var value: Integer): Integer; cdecl;
glXGetCurrentContext: function: GLXContext; cdecl;
glXGetCurrentDrawable: function: GLXDrawable; cdecl;
glXWaitGL: procedure; cdecl;
glXWaitX: procedure; cdecl;
glXUseXFont: procedure(font: XFont; first, count, list: Integer); cdecl;
// GLX 1.1 and later
glXQueryExtensionsString: function(dpy: PDisplay; screen: Integer): PChar; cdecl;
glXQueryServerString: function(dpy: PDisplay; screen, name: Integer): PChar; cdecl;
glXGetClientString: function(dpy: PDisplay; name: Integer): PChar; cdecl;
// GLX 1.2 and later
glXGetCurrentDisplay: function: PDisplay; cdecl;
// GLX 1.3 and later
glXChooseFBConfig: function(dpy: PDisplay; screen: Integer; attribList: PInteger; var nitems: Integer): PGLXFBConfig; cdecl;
glXGetFBConfigAttrib: function(dpy: PDisplay; config: TGLXFBConfig; attribute: Integer; var value: Integer): Integer; cdecl;
glXGetFBConfigs: function(dpy: PDisplay; screen: Integer; var nelements: Integer): PGLXFBConfig; cdecl;
glXGetVisualFromFBConfig: function(dpy: PDisplay; config: TGLXFBConfig): PXVisualInfo; cdecl;
glXCreateWindow: function(dpy: PDisplay; config: TGLXFBConfig; win: X.TWindow; attribList: PInteger): TGLXWindow; cdecl;
glXDestroyWindow: procedure (dpy: PDisplay; window: TGLXWindow); cdecl;
glXCreatePixmap: function(dpy: PDisplay; config: TGLXFBConfig; pixmap: TXPixmap; attribList: PInteger): TGLXPixmap; cdecl;
glXDestroyPixmap: procedure (dpy: PDisplay; pixmap: TGLXPixmap); cdecl;
glXCreatePbuffer: function(dpy: PDisplay; config: TGLXFBConfig; attribList: PInteger): TGLXPbuffer; cdecl;
glXDestroyPbuffer: procedure (dpy: PDisplay; pbuf: TGLXPbuffer); cdecl;
glXQueryDrawable: procedure (dpy: PDisplay; draw: TGLXDrawable; attribute: Integer; value: PLongWord); cdecl;
glXCreateNewContext: function(dpy: PDisplay; config: TGLXFBConfig; renderType: Integer; shareList: TGLXContext; direct: boolean): TGLXContext; cdecl;
glXMakeContextCurrent: function(dpy: PDisplay; draw: TGLXDrawable; read: GLXDrawable; ctx: TGLXContext): boolean; cdecl;
glXGetCurrentReadDrawable: function: TGLXDrawable; cdecl;
glXQueryContext: function(dpy: PDisplay; ctx: TGLXContext; attribute: Integer; var value: Integer): Integer; cdecl;
glXSelectEvent: procedure (dpy: PDisplay; drawable: TGLXDrawable; mask: LongWord); cdecl;
glXGetSelectedEvent: procedure (dpy: PDisplay; drawable: TGLXDrawable; mask: PLongWord); cdecl;
// GLX 1.4 and later
glXGetProcAddress: function(procname: PChar): Pointer; cdecl;
// Extensions:
// GLX_ARB_get_proc_address
glXGetProcAddressARB: function(procname: PChar): Pointer; cdecl;
// GLX_ARB_create_context
glXCreateContextAttribsARB: function (dpy: PDisplay; config: TGLXFBConfig; share_context: TGLXContext; direct: boolean; attrib_list: PInteger): TGLXContext; cdecl;
// GLX_MESA_pixmap_colormap
glXCreateGLXPixmapMESA: function(dpy: PDisplay; visual: PXVisualInfo; pixmap: XPixmap; cmap: XColormap): GLXPixmap; cdecl;
// Unknown Mesa GLX extension (undocumented in current GLX C headers?)
glXReleaseBufferMESA: function(dpy: PDisplay; d: GLXDrawable): Boolean; cdecl;
glXCopySubBufferMESA: procedure(dpy: PDisplay; drawbale: GLXDrawable; x, y, width, height: Integer); cdecl;
// GLX_SGI_video_sync
glXGetVideoSyncSGI: function(var counter: LongWord): Integer; cdecl;
glXWaitVideoSyncSGI: function(divisor, remainder: Integer; var count: LongWord): Integer; cdecl;
// =======================================================
//
// =======================================================
{
Safe checking of glX version and extension presence.
For each glX version, these functions check that
- glXQueryExtension indicates that glX extension is present at all on this display.
- glXQueryVersion indicates that (at least) this version is supported.
- all the entry points defined for this glX version were
successfully loaded from the library.
For now, all glX versions are fully backward-compatible,
so e.g. if GLX_version_1_3 is true, you know that also GLX_version_1_2
and GLX_version_1_1 etc. are true,
and all entry points up to glX 1.3 are assigned.
For each extension, these functions check that
- it is declared within glXQueryExtensionsString (which in turn means
that glXQueryExtensionsString must be available, which requires glX 1.1)
- all it's entry points were successfully loaded from library
As such, these functions are the safest way to check if given
extension/glX version is available.
Note that the availability of glX version and extension may depend
on the X display and (in case of extension) even screen number.
}
function GLX_version_1_0(Display: PDisplay): boolean;
function GLX_version_1_1(Display: PDisplay): boolean;
function GLX_version_1_2(Display: PDisplay): boolean;
function GLX_version_1_3(Display: PDisplay): boolean;
function GLX_version_1_4(Display: PDisplay): boolean;
function GLX_ARB_get_proc_address(Display: PDisplay; Screen: Integer): boolean;
function GLX_ARB_create_context(Display: PDisplay; Screen: Integer): boolean;
function GLX_ARB_create_context_profile(Display: PDisplay; Screen: Integer): boolean;
function GLX_ARB_create_context_robustness(Display: PDisplay; Screen: Integer): boolean;
function GLX_ARB_multisample(Display: PDisplay; Screen: Integer): boolean;
function GLX_EXT_visual_info(Display: PDisplay; Screen: Integer): boolean;
function GLX_MESA_pixmap_colormap(Display: PDisplay; Screen: Integer): boolean;
function GLX_SGI_video_sync(Display: PDisplay; Screen: Integer): boolean;
function GLX_SGIS_multisample(Display: PDisplay; Screen: Integer): boolean;
implementation
uses GL, dynlibs, GLExt { for glext_ExtensionSupported utility }, CastleWarnings;
{$LINKLIB m}
function GLX_version_1_0(Display: PDisplay): boolean;
var
IgnoredErrorb, IgnoredEvent, Major, Minor: Integer;
begin
Result :=
{ check is glX present at all for this display }
Assigned(glXQueryExtension) and
glXQueryExtension(Display, IgnoredErrorb, IgnoredEvent) and
{ check glXQueryVersion, although there is no glX with version < 1 }
Assigned(glXQueryVersion) and
glXQueryVersion(Display, Major, Minor) and
(Major >= 1) and
{ check entry points assigned }
Assigned(glXChooseVisual) and
Assigned(glXCreateContext) and
Assigned(glXDestroyContext) and
Assigned(glXMakeCurrent) and
Assigned(glXCopyContext) and
Assigned(glXSwapBuffers) and
Assigned(glXCreateGLXPixmap) and
Assigned(glXDestroyGLXPixmap) and
{ Assigned(glXQueryExtension) and } { (already checked) }
{ Assigned(glXQueryVersion) and } { (already checked) }
Assigned(glXIsDirect) and
Assigned(glXGetConfig) and
Assigned(glXGetCurrentContext) and
Assigned(glXGetCurrentDrawable) and
Assigned(glXWaitGL) and
Assigned(glXWaitX) and
Assigned(glXUseXFont)
end;
function GLX_version_1_1(Display: PDisplay): boolean;
var
Major, Minor: Integer;
begin
Result :=
{ check previous version Ok }
GLX_version_1_0(Display) and
{ check glXQueryVersion }
glXQueryVersion(Display, Major, Minor) and
( (Major > 1) or ((Major = 1) and (Minor >= 1)) ) and
{ check entry points assigned }
Assigned(glXQueryExtensionsString) and
Assigned(glXQueryServerString) and
Assigned(glXGetClientString);
end;
function GLX_version_1_2(Display: PDisplay): boolean;
var
Major, Minor: Integer;
begin
Result :=
{ check previous version Ok }
GLX_version_1_1(Display) and
{ check glXQueryVersion }
glXQueryVersion(Display, Major, Minor) and
( (Major > 1) or ((Major = 1) and (Minor >= 2)) ) and
{ check entry points assigned }
Assigned(glXGetCurrentDisplay);
end;
function GLX_version_1_3(Display: PDisplay): boolean;
var
Major, Minor: Integer;
begin
Result :=
{ check previous version Ok }
GLX_version_1_2(Display) and
{ check glXQueryVersion }
glXQueryVersion(Display, Major, Minor) and
( (Major > 1) or ((Major = 1) and (Minor >= 3)) ) and
{ check entry points assigned }
Assigned(glXChooseFBConfig) and
Assigned(glXGetFBConfigAttrib) and
Assigned(glXGetFBConfigs) and
Assigned(glXGetVisualFromFBConfig) and
Assigned(glXCreateWindow) and
Assigned(glXDestroyWindow) and
Assigned(glXCreatePixmap) and
Assigned(glXDestroyPixmap) and
Assigned(glXCreatePbuffer) and
Assigned(glXDestroyPbuffer) and
Assigned(glXQueryDrawable) and
Assigned(glXCreateNewContext) and
Assigned(glXMakeContextCurrent) and
Assigned(glXGetCurrentReadDrawable) and
Assigned(glXQueryContext) and
Assigned(glXSelectEvent) and
Assigned(glXGetSelectedEvent);
end;
function GLX_version_1_4(Display: PDisplay): boolean;
var
Major, Minor: Integer;
begin
Result :=
{ check previous version Ok }
GLX_version_1_3(Display) and
{ check glXQueryVersion }
glXQueryVersion(Display, Major, Minor) and
( (Major > 1) or ((Major = 1) and (Minor >= 4)) ) and
{ check entry points assigned }
Assigned(glXGetProcAddress);
end;
function GLX_ARB_get_proc_address(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_ARB_get_proc_address', GlxExtensions) and
Assigned(glXGetProcAddressARB);
end;
end;
function GLX_ARB_create_context(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_ARB_create_context', GlxExtensions) and
Assigned(glXCreateContextAttribsARB);
end;
end;
function GLX_ARB_create_context_profile(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_ARB_create_context_profile', GlxExtensions);
end;
end;
function GLX_ARB_create_context_robustness(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_ARB_create_context_robustness', GlxExtensions);
end;
end;
function GLX_ARB_multisample(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_ARB_multisample', GlxExtensions);
end;
end;
function GLX_EXT_visual_info(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_EXT_visual_info', GlxExtensions);
end;
end;
function GLX_MESA_pixmap_colormap(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_MESA_pixmap_colormap', GlxExtensions) and
Assigned(glXCreateGLXPixmapMESA);
end;
end;
function GLX_SGI_video_sync(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_SGI_video_sync', GlxExtensions) and
Assigned(glXGetVideoSyncSGI) and
Assigned(glXWaitVideoSyncSGI);
end;
end;
function GLX_SGIS_multisample(Display: PDisplay; Screen: Integer): boolean;
var
GlxExtensions: PChar;
begin
Result := GLX_version_1_1(Display);
if Result then
begin
GlxExtensions := glXQueryExtensionsString(Display, Screen);
Result := glext_ExtensionSupported('GLX_SGIS_multisample', GlxExtensions);
end;
end;
function GetProc(handle: PtrInt; name: PChar): Pointer;
begin
Result := GetProcAddress(handle, name);
if (Result = nil) and GLXDumpUnresolvedFunctions then
OnWarning(wtMajor, 'GLX', 'Unresolved: ' + name);
end;
function InitGLX: Boolean;
var
OurLibGL: TLibHandle;
begin
Result := False;
{$ifndef darwin}
OurLibGL := libGl;
{$else darwin}
OurLibGL := LoadLibrary('/usr/X11R6/lib/libGL.dylib');
{$endif darwin}
if OurLibGL = 0 then
exit;
Pointer(glXChooseVisual) := GetProc(OurLibGL, 'glXChooseVisual');
Pointer(glXCreateContext) := GetProc(OurLibGL, 'glXCreateContext');
Pointer(glXDestroyContext) := GetProc(OurLibGL, 'glXDestroyContext');
Pointer(glXMakeCurrent) := GetProc(OurLibGL, 'glXMakeCurrent');
Pointer(glXCopyContext) := GetProc(OurLibGL, 'glXCopyContext');
Pointer(glXSwapBuffers) := GetProc(OurLibGL, 'glXSwapBuffers');
Pointer(glXCreateGLXPixmap) := GetProc(OurLibGL, 'glXCreateGLXPixmap');
Pointer(glXDestroyGLXPixmap) := GetProc(OurLibGL, 'glXDestroyGLXPixmap');
Pointer(glXQueryExtension) := GetProc(OurLibGL, 'glXQueryExtension');
Pointer(glXQueryVersion) := GetProc(OurLibGL, 'glXQueryVersion');
Pointer(glXIsDirect) := GetProc(OurLibGL, 'glXIsDirect');
Pointer(glXGetConfig) := GetProc(OurLibGL, 'glXGetConfig');
Pointer(glXGetCurrentContext) := GetProc(OurLibGL, 'glXGetCurrentContext');
Pointer(glXGetCurrentDrawable) := GetProc(OurLibGL, 'glXGetCurrentDrawable');
Pointer(glXWaitGL) := GetProc(OurLibGL, 'glXWaitGL');
Pointer(glXWaitX) := GetProc(OurLibGL, 'glXWaitX');
Pointer(glXUseXFont) := GetProc(OurLibGL, 'glXUseXFont');
// GLX 1.1 and later
Pointer(glXQueryExtensionsString) := GetProc(OurLibGL, 'glXQueryExtensionsString');
Pointer(glXQueryServerString) := GetProc(OurLibGL, 'glXQueryServerString');
Pointer(glXGetClientString) := GetProc(OurLibGL, 'glXGetClientString');
// GLX 1.2 and later
Pointer(glXGetCurrentDisplay) := GetProc(OurLibGL, 'glXGetCurrentDisplay');
// GLX 1.3 and later
Pointer(glXChooseFBConfig) := GetProc(OurLibGL, 'glXChooseFBConfig');
Pointer(glXGetFBConfigAttrib) := GetProc(OurLibGL, 'glXGetFBConfigAttrib');
Pointer(glXGetFBConfigs) := GetProc(OurLibGL, 'glXGetFBConfigs');
Pointer(glXGetVisualFromFBConfig) := GetProc(OurLibGL, 'glXGetVisualFromFBConfig');
Pointer(glXCreateWindow) := GetProc(OurLibGL, 'glXCreateWindow');
Pointer(glXDestroyWindow) := GetProc(OurLibGL, 'glXDestroyWindow');
Pointer(glXCreatePixmap) := GetProc(OurLibGL, 'glXCreatePixmap');
Pointer(glXDestroyPixmap) := GetProc(OurLibGL, 'glXDestroyPixmap');
Pointer(glXCreatePbuffer) := GetProc(OurLibGL, 'glXCreatePbuffer');
Pointer(glXDestroyPbuffer) := GetProc(OurLibGL, 'glXDestroyPbuffer');
Pointer(glXQueryDrawable) := GetProc(OurLibGL, 'glXQueryDrawable');
Pointer(glXCreateNewContext) := GetProc(OurLibGL, 'glXCreateNewContext');
Pointer(glXMakeContextCurrent) := GetProc(OurLibGL, 'glXMakeContextCurrent');
Pointer(glXGetCurrentReadDrawable) := GetProc(OurLibGL, 'glXGetCurrentReadDrawable');
Pointer(glXQueryContext) := GetProc(OurLibGL, 'glXQueryContext');
Pointer(glXSelectEvent) := GetProc(OurLibGL, 'glXSelectEvent');
Pointer(glXGetSelectedEvent) := GetProc(OurLibGL, 'glXGetSelectedEvent');
// GLX 1.4 and later
Pointer(glXGetProcAddress) := GetProc(OurLibGL, 'glXGetProcAddress');
// Extensions
// GLX_ARB_get_proc_address
Pointer(glXGetProcAddressARB) := GetProc(OurLibGL, 'glXGetProcAddressARB');
// GLX_ARB_create_context
Pointer(glXCreateContextAttribsARB) := GetProc(OurLibGL, 'glXCreateContextAttribsARB');
// GLX_MESA_pixmap_colormap
Pointer(glXCreateGLXPixmapMESA) := GetProc(OurLibGL, 'glXCreateGLXPixmapMESA');
// Unknown Mesa GLX extension
Pointer(glXReleaseBufferMESA) := GetProc(OurLibGL, 'glXReleaseBufferMESA');
Pointer(glXCopySubBufferMESA) := GetProc(OurLibGL, 'glXCopySubBufferMESA');
// GLX_SGI_video_sync
Pointer(glXGetVideoSyncSGI) := GetProc(OurLibGL, 'glXGetVideoSyncSGI');
Pointer(glXWaitVideoSyncSGI) := GetProc(OurLibGL, 'glXWaitVideoSyncSGI');
GLXInitialized := True;
Result := True;
end;
initialization
InitGLX;
end.
|