I tried using a core OpenGL context on my old MacBook (2010) and got a crash 
from glGetString from the Pascal bindings (a legacy 2.x context doesn’t crash).

I pulled out the related functions from glext.pp where it crashes in 
Load_GL_ARB_blend_func_extended from Load_GL_VERSION_3_3. It looks like the 
function pointer for glGetString wasn’t loaded but how could that be? I’m using 
SDL to load the context and I need to use glGetString in order to even return 
what the highest OpenGL version is on the system.

* thread #1: tid = 0x750fc, 0x00007fff9362ffc8 libGL.dylib`glGetString + 15, 
queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x0)
    frame #0: 0x00007fff9362ffc8 libGL.dylib`glGetString + 15
libGL.dylib`glGetString + 15:
-> 0x7fff9362ffc8:  movq   (%rcx), %rdi
   0x7fff9362ffcb:  movq   0x3b0(%rcx), %rcx
   0x7fff9362ffd2:  movl   %eax, %esi
   0x7fff9362ffd4:  popq   %rbp
(lldb) bt
* thread #1: tid = 0x750fc, 0x00007fff9362ffc8 libGL.dylib`glGetString + 15, 
queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x0)
  * frame #0: 0x00007fff9362ffc8 libGL.dylib`glGetString + 15
    frame #1: 0x00000001000a78fc 
OpenGL-Tests`GLEXT_$$_LOAD_GL_ARB_BLEND_FUNC_EXTENDED$BOOLEAN$$BOOLEAN + 76
    frame #2: 0x000000010004b6b1 
OpenGL-Tests`TEST_1_VERTATTRIBS_$$_TESTVERTATTRIBS + 201
    frame #3: 0x0000000100000ae5 OpenGL-Tests`PASCALMAIN + 69
    frame #4: 0x00000001000205d4 OpenGL-Tests`FPC_SysEntry + 12
    frame #5: 0x0000000100000a4e OpenGL-Tests`FPC_SYSTEMMAIN + 54
    frame #6: 0x00000001000009f4 OpenGL-Tests`start + 52
(lldb)

procedure Load_GL_VERSION_3_3x(var allOK: boolean; out isVersion: Boolean);
var
   dummy: boolean;
begin
  isVersion := Load_GL_ARB_blend_func_extended(true);
  if not isVersion then allOK := false;
  if not Load_GL_ARB_sampler_objects(true) then allOK := false;
  if not Load_GL_ARB_timer_query(true) then allOK := false;
  if not Load_GL_ARB_vertex_type_2_10_10_10_rev(true) then allOK := false;
  Load_GL_VERSION_3_2x(allOK, dummy);
end;


function Load_GL_ARB_blend_func_extended(LoadAsCore: boolean): Boolean;
var
  extstring: String;
begin
  Result := False;
  extstring := String(PChar(glGetString(GL_EXTENSIONS)));

  if LoadAsCore or glext_ExtensionSupported('GL_ARB_blend_func_extended', 
extstring) then
  begin
    glBindFragDataLocationIndexed := 
wglGetProcAddress('glBindFragDataLocationIndexed');
    if not Assigned(glBindFragDataLocationIndexed) then Exit;
    glGetFragDataIndex := wglGetProcAddress('glGetFragDataIndex');
    if not Assigned(glGetFragDataIndex) then Exit;
    Result := True;
  end;
end;


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to