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 7031661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:49:58+00:00 2026-05-28T00:49:58+00:00

What is a good way to load a GLSL shader using C/C++ without using

  • 0

What is a good way to load a GLSL shader using C/C++ without using Objective-C or any Apple APIs?

I am currently using the following method, which is from the iPhone 3D Programming book, but it says that it is not recommended for production code:

Simple.vsh

const char* SimpleVertexShader = STRINGIFY
(

// Shader code...

);

RenderingEngine.cpp

#define STRINGIFY(A) #A
#include "Simple.vsh"

// ...

glShaderSource( shaderHandle, 1, &SimpleVertexShader, 0 );
  • 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-28T00:49:59+00:00Added an answer on May 28, 2026 at 12:49 am

    If you want to load your shaders from files in your app bundle, you can get the file paths using the NSBundle object (in Objective-C), or using the CoreFoundation CFBundle object (in pure C).

    Either way, you are using Apple-specific APIs. The only thing you’re getting by using CFBundle instead of NSBundle is more boilerplate code.

    If you don’t want to use any Apple APIs, then your options are to embed your shaders as literal strings, or connect to a server on the Internet and download them (using the Unix socket API).

    What you really need to do is define an interface by which your RenderingEngine gets the source code for its shaders, and implement that interface using the appropriate platform-specific API on each platform to which your port the RenderingEngine. The interface can be something super simple like this:

    RenderingEngineShaderSourceInterface.h

    #ifdef __cplusplus
    extern "C" {
    #endif
    
    // You are responsible for freeing the C string that this function returns.
    extern char const *RenderingEngine_shaderSourceForName(char const *name);
    
    #ifdef __cplusplus
    }
    #endif
    

    Then you create RenderingEngineShaderSource_Windows.cpp, RenderingEngineShaderSource_iOS.m, RenderingEngineShaderSource_Linux.cpp, etc. Each one implements RenderingEngine_shaderSourceForName using the appropriate API for that platform.

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

Sidebar

Related Questions

I'm currently trying to find a good way to load my javascript files only
Is there any good way to deal with the class renaming refactor from Resharper
Does anyone have a good way to build MSI (vdproj) projects using MsBuild or
What is a good way to perform animation using .NET? I would prefer not
Is there a good way to see what format an image is, without having
Is there a good way to find out which exceptions a procedure/function can raise
Is there a good way to time SQL queries when using Linq to SQL?
Any thoughts on a good way to accomplish something along the lines of var
What would be a good way to attempt to load the hosted jQuery at
What would be a good way to pre-load a bunch of commonly used R

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.