Recent

Author Topic: SIGSEGV when calling glGenBuffers  (Read 5034 times)

LemonParty

  • Sr. Member
  • ****
  • Posts: 393
SIGSEGV when calling glGenBuffers
« on: December 18, 2024, 07:29:11 pm »
Hello.
I trying to use glGenBuffers function from unit GLext this way:
Code: Pascal  [Select][+][-]
  1. var
  2.   VBO: GLuint;
  3. {...}
  4. glGenBuffers(1, @VBO);
And I getting SIGSEGV on glGenBuffers(1, @VBO); line. What I missing?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

zamtmn

  • Hero Member
  • *****
  • Posts: 679
Re: SIGSEGV when calling glGenBuffers
« Reply #1 on: December 18, 2024, 07:47:22 pm »
If you use GLext.pp? you need run
Code: Pascal  [Select][+][-]
  1. Load_GL_version_1_5
or later GL version init function, and it need return true

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: SIGSEGV when calling glGenBuffers
« Reply #2 on: December 18, 2024, 08:15:45 pm »
Hello.
I trying to use glGenBuffers function from unit GLext this way:
Code: Pascal  [Select][+][-]
  1. var
  2.   VBO: GLuint;
  3. {...}
  4. glGenBuffers(1, @VBO);
And I getting SIGSEGV on glGenBuffers(1, @VBO); line. What I missing?
Memory allocation... Basic mistake.
VBO needs memory... Allocmem, Getmem, New...
« Last Edit: December 18, 2024, 08:17:55 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

zamtmn

  • Hero Member
  • *****
  • Posts: 679
Re: SIGSEGV when calling glGenBuffers
« Reply #3 on: December 18, 2024, 08:28:02 pm »
Thaddy
The first principle is to read the documentation. And you often don't do that in a hurry to answer the question

Khrys

  • Sr. Member
  • ****
  • Posts: 390
Re: SIGSEGV when calling glGenBuffers
« Reply #4 on: December 19, 2024, 07:26:53 am »
Memory allocation... Basic mistake.
VBO needs memory... Allocmem, Getmem, New...

Have you ever used OpenGL?



Like @zamtmn said, you'll have to call one of the  Load_GL_***  functions to initialize OpenGL before using it.
Because graphics drivers are very hardware-specific, they're loaded as dynamic libraries and can vary from host to host. FPC's OpenGL units declare all API functions as function pointers (initialized to  Nil) and resolves their actual values only when calling one of the aforementioned  Load_GL_***  functions, with each variant only resolving the functions that are required by that version of the OpenGL specification.

Looking at the OpenGL documentation for  glGenBuffers and scrolling to the bottom of the page, we can see that it is only supported from version 2.0 and onwards, so you'll have to call at least  Load_GL_Version_2_0.

So in essence, the segfault you're getting has nothing to do with  @VBO, but with the fact that you're calling a function pointer whose value is  Nil  (if you hover over  glGenBuffers  in Lazarus you'll see that it is declared as a  var).

LemonParty

  • Sr. Member
  • ****
  • Posts: 393
Re: SIGSEGV when calling glGenBuffers
« Reply #5 on: December 19, 2024, 12:39:15 pm »
I see. Where can I download a proper DLL?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

zamtmn

  • Hero Member
  • *****
  • Posts: 679
Re: SIGSEGV when calling glGenBuffers
« Reply #6 on: December 19, 2024, 01:12:44 pm »
>>I see. Where can I download a proper DLL?
No need download dll. You need install drivers from your video card manuacturer site, not use default ms video driver. and run Load_GL_version_1_5 (or later if you yse features from later version) once, before call glGenBuffers

LemonParty

  • Sr. Member
  • ****
  • Posts: 393
Re: SIGSEGV when calling glGenBuffers
« Reply #7 on: December 19, 2024, 01:44:19 pm »
I have installed drivers and Load_GL_version_2_0 return false. I see from source code of GLext that opengl32.dll is used when Load_GL_version_* called.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

zamtmn

  • Hero Member
  • *****
  • Posts: 679
Re: SIGSEGV when calling glGenBuffers
« Reply #8 on: December 19, 2024, 02:22:24 pm »
You must call Load_GL_versionХХХ after create OpenGL context. What GL control you use? TOpenglControl?

LemonParty

  • Sr. Member
  • ****
  • Posts: 393
Re: SIGSEGV when calling glGenBuffers
« Reply #9 on: December 19, 2024, 02:55:27 pm »
I using glfw. I moved Load_GL_version_2_0 after glfwMakeContextCurrent(window); and now it works. Thank you.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Mathias

  • Full Member
  • ***
  • Posts: 101
Re: SIGSEGV when calling glGenBuffers
« Reply #10 on: January 09, 2025, 06:04:12 pm »
I using glfw. I moved Load_GL_version_2_0 after glfwMakeContextCurrent(window); and now it works. Thank you.
The order is very important.

 

TinyPortal © 2005-2018