Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6198417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:59:39+00:00 2026-05-24T03:59:39+00:00

Since GLSL doesn’t have an include-file option I’m trying to add this by using

  • 0

Since GLSL doesn’t have an include-file option I’m trying to add this by using a “#pragma include” parser. (I want this because I have some generic methods I’d like to implement only once but might use in many different shaders, like Ken Perlin’s smootherstep)

Parsing the shader files to get the included files works fine.
But when setting the ShaderSource with the multiple source files I always run into problems; since my main shader normally starts with “#version 330” and the #version-line always has to be the first line in the shader, I can only add my main file as the first in the array of strings passed to glShadersource, and after that all the included files.
But then my main file can’t use any functions implemented in those included files, since they’ll essentially be concatenated after my main file so the compiler complains that it doesn’t know the functions my main file is using.

The only way I can think of to get it to work is to read the main file, parse the include pragma, and then replace that pragma line with the file-contents of the file to be included (recursively applying this same method to all included files that might include other files themselves) – but that would mean the linenumbers in compilation-errors would not match the real linenumbers of the main file anymore.

Has anybody set up some sort of “include” functionality for GLSL that works AND keeps the linenumbers ? And if so – how ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:59:40+00:00Added an answer on May 24, 2026 at 3:59 am

    What about parsing for the #version tag and making this a seperate (and the first) source string? This way you may also have different version tags in the includes (depending on their functions requirements) and just reduce them to only one version tag (the one with the highest version number).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since CS3 doesn't have a web service component, as previous versions had, is there
I'm trying to figure out how to do texture mapping using GLSL version 4.10.
since they have same rendering engine, this problem shows in both. it works great
Possible Duplicate: C/C++, can you #include a file into a string literal? I have
Since I started using Fireworks CS5.1, and it doesn't matter how I write the
Since I'm using Java 1.4.2, this means that I cannot use Java's implementation of
Since this question is back to four votes to close, I'm trying again to
Since I started this new webshop for a friend to launch, which still in
Using the GLSL syntax in C++ I wrote custom vector classes such as vec2
since in GLSL the modelmatrix is not available, i was wondering if it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.