Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
An option to not need _GL sub
#1
I'd like to make some of my things work in GL and normal rendering without having to write individual subs/libs for each mode. 

So if the user is only working in normal QB64 screen mode and doesn't call any GL commands, having the _GL sub ENFORCED is spurious and annoying (and maybe adds extra overhead).  

Can an option be added to tell the IDE to not enforce the _GL sub? 

Thanks

John
Reply
#2
I think it's as simple as just removing it from the displayorder.

_DISPLAYORDER _HARDWARE, _SOFTWARE, _HARDWARE1      <-- No _GLRENDER, so we don't render to GL which stops the sub from processing.

I'll have to dig through some old drives and refresh my memory on exactly how the heck I completely disabled GL in the past, if that's not it. I know I've did it before, but if the above isn't the trick, I'd have to look for it, and probably won't have much time for that until after Halloween as this is one of our busy times here at the farm.  

Try _DISPLAYORDER see if it can do what you want.  If not, I'll dig when I have a chance, but don't be in any hurry.  Wink
Reply
#3
Another simple method is a global variable.

Code: (Select All)

SUB _GL
    IF glVariable = _TRUE THEN
        'do your stuff
    END IF
END SUB

Then just toggle that variable true false when you don't need that sub doing anything.
Reply
#4
(10-17-2025, 12:27 AM)SMcNeill Wrote: I think it's as simple as just removing it from the displayorder.
I think Unseen is actually talking about the fact that if you don't have a `SUB _GL` then you're not allowed to call any OpenGL functions anywhere in your code. IE. You're allowed to have a `SUB foo` that calls `_glBegin`, but the compiler will error on `_glBegin` being called if there's no `SUB _GL` elsewhere in the code. This gets messy if you're providing a library with optional OpenGL features and don't know if the code using it will have `_GL` defined.

I think the best approach would be to wrap all the OpenGL stuff in a `$IF EnableGL THEN` type of thing. That way the users can simply define `$LET EnableGL = 1` to get all the OpenGL functionality if they want it, and it will otherwise get excluded if they don't (avoiding the compilation issues).
Reply
#5
(10-17-2025, 12:09 PM)DSMan195276 Wrote:
(10-17-2025, 12:27 AM)SMcNeill Wrote: I think it's as simple as just removing it from the displayorder.
I think Unseen is actually talking about the fact that if you don't have a `SUB _GL` then you're not allowed to call any OpenGL functions anywhere in your code. IE. You're allowed to have a `SUB foo` that calls `_glBegin`, but the compiler will error on `_glBegin` being called if there's no `SUB _GL` elsewhere in the code. This gets messy if you're providing a library with optional OpenGL features and don't know if the code using it will have `_GL` defined.

I think the best approach would be to wrap all the OpenGL stuff in a `$IF EnableGL THEN` type of thing. That way the users can simply define `$LET EnableGL = 1` to get all the OpenGL functionality if they want it, and it will otherwise get excluded if they don't (avoiding the compilation issues).
Yes thats exactly it!

Thanks for the responses though guys! I'm using the method steve suggested at the moment and using a flag to allow the sub to run...

Unseen
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  option explicit Unseen Machine 20 1,367 01-26-2026, 03:09 AM
Last Post: bplus
  Found a BUG with the QB64 editor compiled with the -O3 option Coolman 2 826 06-02-2022, 06:27 PM
Last Post: Coolman
  A preview of a new QB64 option SMcNeill 12 2,682 05-04-2022, 01:11 PM
Last Post: DSMan195276

Forum Jump:


Users browsing this thread: