OpenGL via library linking

Post your Gambas programming questions here.
Post Reply
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

OpenGL via library linking

Post by Technopeasant »

Hello all,

I have been working on a 3D game for the current LibreJam, and while I am managing to keep performance up using the OpenGL 2.x immediate mode supported by the Gambas component (mostly through the use of tight distance culling and fog), I am well aware that using that is no longer best practice and has not been for a long time now. Alas, the component really has not been updated much since its inception fifteen years ago and is more and more out of date with each passing year, though I still have not tried out the GLSL component that much yet.

Which is why this thread on the Spanish forum caught my eye.

https://h6ctdsfmvw4rqzto4rgorow3du-jj2c ... d97#p48521

They are implementing calls to OpenGL directly via a C library, which I assume would allow me to access OpenGL 3.x features and onward. I would still probably maintain my fixed-function pipeline renderer for compatibility sake, but it would be nice to be able to start looking into using vertex buffer objects. Mind you, a part of me wonders if I would be better off just trying to learn Vulkan once I get hardware that can readily handle it...
Technical director,
Piga Software
http://icculus.org/piga/
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: OpenGL via library linking

Post by stevedee »

Technopeasant wrote: Sunday 4th April 2021 6:51am ...Which is why this thread on the Spanish forum caught my eye.

https://h6ctdsfmvw4rqzto4rgorow3du-jj2c ... d97#p48521

They are implementing calls to OpenGL directly via a C library....

I got this code example to run after installing:-
- libopengl0
- freeglut3
- freeglut3-dev

Note: some of these packages may not be necessary, but I haven't back-tracked to check.

openglCube.png
openglCube.png (51.09 KiB) Viewed 4450 times

I'm not sure how you are supposed to stop this program (only the IDE 'stop' button seemed to shut it down) but will take another look maybe later today.
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: OpenGL via library linking

Post by Technopeasant »

Some more background on this topic:

https://rqesua32mznbxhbhbz7toivwgi-jj2c ... 40&start=0

Your issue is mentioned:
Because it closes a window, by clicking with the mouse pointer on its X in the upper right corner, (in this case in which the window is created using the OpenGL functions directly ) it is an event that must be managed at the code level.
Admittedly I would much prefer it if this could somehow be used from within a Gambas GUI component, as I have re-written my engine in Qt to explicitly avoid using OpenGL for anything other than 3D rendering exactly because of this version incompatibility mess (I still fancy writing a software rendering option at some point, or at least a basic raycaster).

I do find it a little amusing that all the examples posted of this are still using immediate mode, which frankly makes loading it in externally rather pointless.
Well, your approach to the problem became necessary: apparently the Gambas component is incomplete, since the Vertex Array and the Vertex Buffer Objects (VBO) essential to operate with OpenGL indirect mode are not supported.
As the indirect mode is among the basic concepts of OpenGL, it seems essential that they are implemented in Gambas, therefore I asked for them on the mailing list. Benoit asked for a volunteer to complete the complement and sign me up. It doesn't seem to be that complicated, so I'm on it. This tutorial has to continue with the VBOs, so when the complement is complete, which I hope will be soon, I will continue. I wish you all a great start to the year.
Sadly nothing appears to have come of it since 2015, unless it was undocumented.

The lighting tutorial tercoIDE posted should come in useful though.
Technical director,
Piga Software
http://icculus.org/piga/
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: OpenGL via library linking

Post by Technopeasant »

So I got the example to work on my machine, and interestingly I was able to swap between calling library functions (glBegin) and component functions (gb.Begin) from within the same program. This makes me suspect that I can try and implement this only using the library calls where necessary. Next up is trying to get this rendering from within Qt, and then after that attempting to load a VBO.
Technical director,
Piga Software
http://icculus.org/piga/
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: OpenGL via library linking

Post by Technopeasant »

Just tested this from within a Qt GLArea and it worked fine, and since we have Qt handling the windowing we don't need to call libglut (I imagine you can do the same with SDL).

Next to look into a VBO I suppose.
Technical director,
Piga Software
http://icculus.org/piga/
tercoIDE
Posts: 9
Joined: Monday 27th April 2020 2:32pm

Re: OpenGL via library linking

Post by tercoIDE »

Hi there.
I believe the newest Qt5 allows the use of Vertex Array Objects, and therefore, going in Programed mode is available. When I wrote that tutorial only immediate mode was possible with Qt4. Now, if the OpenGL component is updated, we may (or better, should) use programmed mode. AFAIK that is not done yet, and I don't know how to do it.

If you need help, I can guide you , time permitting.

King regards.
Post Reply