Recent

Author Topic: Is the OpenGL version 4.6 in Lazarus as support ?  (Read 1477 times)

threedslider

  • New Member
  • *
  • Posts: 24
Is the OpenGL version 4.6 in Lazarus as support ?
« on: August 11, 2025, 04:02:32 pm »
Hi

I may ask if the OpenGL is the last version 4.6 in Lazarus ? Thanks :)


Khrys

  • Sr. Member
  • ****
  • Posts: 342
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #1 on: August 12, 2025, 07:53:26 am »
Yesn't  :)

Support for any OpenGL version depends on the graphics driver, which usually comes in the form of a dynamic library that exposes  glClear, glViewport  etc.
It doesn't matter which programming language is used when calling these functions. In theory, you could manually resolve each function you need by name (e.g.  glSpecializeShaderARB  as an example for an OpenGL 4.6 function), or you could choose the path of least resistance and rely on the language's OpenGL bindings (which do just that, but for all functions).

Now, FPC's OpenGL bindings leave much to be desired; they are incomplete. Currently the highest  Load_GL_Version_X  function is  Load_GL_Version_4_3_CORE,  but even that doesn't include all functionality for 4.3 (e.g.  glInvalidateFramebuffer  is missing).

So in essence - yes, you can use OpenGL 4.6 in Lazarus (provided your graphics driver supports it), but you'll have to manually resolve "newer" functions like this, using  wglGetProcAddress  from the  GLext  unit:

Code: Pascal  [Select][+][-]
  1. unit GL_Missing_Functions;
  2.  
  3. {$mode objfpc}{$H+}
  4. {$macro on}
  5.  
  6. interface
  7.  
  8. uses
  9.   GL, GLext;
  10.  
  11. {$ifdef WINDOWS}
  12.   {$define extdecl := stdcall}
  13. {$else}
  14.   {$define extdecl := cdecl}
  15. {$endif}
  16.  
  17. var
  18.   glInvalidateFramebuffer: procedure (target: GLenum; numAttachments: GLsizei; attachments: PGLenum); extdecl;
  19.  
  20. procedure LoadMissingFunctions();
  21.  
  22. implementation
  23.  
  24. procedure LoadMissingFunctions();
  25. begin
  26.   Pointer(glInvalidateFramebuffer) := wglGetProcAddress('glInvalidateFramebuffer');
  27. end;
  28.  
  29. end.
« Last Edit: August 12, 2025, 08:26:13 am by Khrys »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #2 on: August 12, 2025, 12:17:56 pm »
(Or if you are windows only just use dglopengl)

threedslider

  • New Member
  • *
  • Posts: 24
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #3 on: August 12, 2025, 01:37:41 pm »
Ok thanks to all !

But as other programming language, is it needed to use glew for OpenGL 4.6 ? Has Lazarus the glew lib wrapper ?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #4 on: August 12, 2025, 01:44:22 pm »
Ok thanks to all !

But as other programming language, is it needed to use glew for OpenGL 4.6 ? Has Lazarus the glew lib wrapper ?

You don't need them perse.  Most of those are just to give multiplatform abstractions for window creation and/or embedding on forms, originally made to distribute platform independent opengl examples.

I never used them, as I mainly use opengl on windows, and it is only a few calls that need abstracting anyway, not worth bothering with an additional library for.

Seenkao

  • Hero Member
  • *****
  • Posts: 717
    • New ZenGL.
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #5 on: August 12, 2025, 10:53:21 pm »
В ZenGL реализованы все последние привязки на 2022-й год (изменений вроде сильных позже не было). Можете протестировать и попробовать demo01, demo17, demo19 и demo20. Так же вы можете для себя использовать файлы со всеми привязками - "zgl_pasOpenGL.pas" и константами - "zgl_gltypeconst.pas".
Но вам понадобится файл конфигурации для них "GLdefine.cfg" - в нём я указал все необходимые определения, которые вы можете включить или выключить.

Если вы решите использовать сам ZenGL, то для включения необходимой версии смотрите demo01.
Что именно надо сделать. В проекте зайти в файл "zgl_config.cfg" и выставить там определение "USE_GL_46" (раздел "Defines for OpenGL or OpenGL ES"). Как использовать ZenGL с LCL смотрите в demo17.

------------------------------------------
Google translate:
In ZenGL all the latest bindings for 2022 have been implemented (there were no major changes later). You can test and try demo01, demo17, demo19 and demo20. You can also use files with all the bindings - "zgl_pasOpenGL.pas" and constants - "zgl_gltypeconst.pas" for yourself.
But you will need a configuration file for them "GLdefine.cfg" - in it I specified all the necessary definitions that you can enable or disable.

If you decide to use ZenGL itself, then see demo01 to enable the required version.
What exactly needs to be done. In the project, go to the "zgl_config.cfg" file and set the definition "USE_GL_46" there (section "Defines for OpenGL or OpenGL ES"). How to use ZenGL with LCL see demo17.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

threedslider

  • New Member
  • *
  • Posts: 24
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #6 on: August 13, 2025, 09:07:51 pm »
В ZenGL реализованы все последние привязки на 2022-й год (изменений вроде сильных позже не было). Можете протестировать и попробовать demo01, demo17, demo19 и demo20. Так же вы можете для себя использовать файлы со всеми привязками - "zgl_pasOpenGL.pas" и константами - "zgl_gltypeconst.pas".
Но вам понадобится файл конфигурации для них "GLdefine.cfg" - в нём я указал все необходимые определения, которые вы можете включить или выключить.

Если вы решите использовать сам ZenGL, то для включения необходимой версии смотрите demo01.
Что именно надо сделать. В проекте зайти в файл "zgl_config.cfg" и выставить там определение "USE_GL_46" (раздел "Defines for OpenGL or OpenGL ES"). Как использовать ZenGL с LCL смотрите в demo17.

------------------------------------------
Google translate:
In ZenGL all the latest bindings for 2022 have been implemented (there were no major changes later). You can test and try demo01, demo17, demo19 and demo20. You can also use files with all the bindings - "zgl_pasOpenGL.pas" and constants - "zgl_gltypeconst.pas" for yourself.
But you will need a configuration file for them "GLdefine.cfg" - in it I specified all the necessary definitions that you can enable or disable.

If you decide to use ZenGL itself, then see demo01 to enable the required version.
What exactly needs to be done. In the project, go to the "zgl_config.cfg" file and set the definition "USE_GL_46" there (section "Defines for OpenGL or OpenGL ES"). How to use ZenGL with LCL see demo17.

Wow ! Very cool thanks a lot for sharing !  :)

Mathias

  • Full Member
  • ***
  • Posts: 101
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #7 on: September 05, 2025, 05:17:57 pm »
I've created a few bindings for OpenGL, including the glew lib. The advantage of glew is that the Lazarus EXE remains very lean, since everything is in glew.so or glew.dll. It's very up-to-date; in addition to the entire OpenGL 4.6, almost all extensions are supported. The disadvantage for Window users is that it requires the glw.dll. Linux already has it anyway.

glad and dglopengl compile everything into the EXE, which bloats the EXE and only supports a small portion of the extensions. The advantage is that you don't need a DLL.

The packages can be found here: https://github.com/sechshelme/Lazarus-OpenGL-3.3-Tutorial/tree/master/clib_packages

By the way, I also have many OpenGL examples for Lazarus here, although the 4.6 ones are a bit hidden.
https://github.com/sechshelme/Lazarus-OpenGL-3.3-Tutorial
https://github.com/sechshelme/Lazarus-OpenGL-3.3-Tutorial/tree/master/Versuche/80_-_OpenGL_4.x
« Last Edit: September 05, 2025, 05:22:48 pm by Mathias »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #8 on: September 05, 2025, 05:33:16 pm »
glad and dglopengl compile everything into the EXE, which bloats the EXE and only supports a small portion of the extensions. The advantage is that you don't need a DLL.

And what magnitude is that "bloat"?   Hardly care about a few hundred bytes on a multimegabyte GUI app.

440bx

  • Hero Member
  • *****
  • Posts: 5805
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #9 on: September 05, 2025, 06:35:39 pm »
I've created a few bindings for OpenGL, including the glew lib.
Thank you for sharing your work.
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Mathias

  • Full Member
  • ***
  • Posts: 101
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #10 on: September 05, 2025, 07:17:31 pm »
glad and dglopengl compile everything into the EXE, which bloats the EXE and only supports a small portion of the extensions. The advantage is that you don't need a DLL.

And what magnitude is that "bloat"?   Hardly care about a few hundred bytes on a multimegabyte GUI app.
GLEW:
Linux = 445B
Win = 58KB

GLAD:
Linux = 1200KB
Win = 330KB

It should be noted that GLAD or dglopengl only provide the basic functions of OpenGL 4.6, while glew provides almost all of the new extensions.
Okay, you can also have GLAD built that supports these functions, but then the EXE will be at least twice as large if you include everything.
I find an EXE of over 1.2MB quite large for a simple triangle.









marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12523
  • FPC developer.
Re: Is the OpenGL version 4.6 in Lazarus as support ?
« Reply #11 on: September 05, 2025, 09:42:51 pm »
I don't care about GLAD, I use DGLOPENGL, which FPC can partially smartlink. My applications are not a simple triangle (and are LCL based to begin with). In that context 250k IMHO is not worth distributing and managing version of a DLL for.

I assume Linux has some smartlinking problem, otherwise the problems wouldn't be this big.

 

TinyPortal © 2005-2018