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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:08:55+00:00 2026-06-06T03:08:55+00:00

I am trying to add shaders with GLFW/GLEW. I am getting an error that

  • 0

I am trying to add shaders with GLFW/GLEW.

I am getting an error that the shaders are loaded but they don’t have valid object code.

This is the code I have for loading the shaders:

class SHADER {
public:

void LoadShaders(const char *vertexFile, const char *fragmentFile);

char *vertexShader;
char *fragmentShader;

private:

int Load(const char *filename, char*&shaderSource);
fstream file;
};

int SHADER::Load(const char *filename, char *&shaderSource) {
file.open(filename, ios::in);
if(file.is_open()) {
    file.tellg();
    file.seekg(0,ios::end);
    unsigned long len = file.tellg();
    file.seekg(ios::beg);

    if(len == 0 ) {
        return -2;
    } else {
        shaderSource = new char[len + 1];
        file.read(shaderSource,len);
        file.close();
        printf("%s\n",shaderSource);
    }
} else {
    return -1;
}
return 0;
}

void SHADER::LoadShaders(const char *vertexFile, const char *fragmentFile) {
int resultVertex = this->Load(vertexFile, vertexShader);
int resultFragment = this->Load(fragmentFile, fragmentShader);
if(resultVertex ==0 && resultFragment ==0) {
    printf("Shaders loaded succesfully.\n");
}
if(resultVertex == -2) {
    printf("VertexShader is empty!\n");
}
if(resultFragment == -2) {
    printf("FragmentShader is empty!\n");
}
if(resultVertex == -1) {
    printf("Unable to load VertexShader!\n");
}
if(resultFragment == -1) {
    printf("Unable to load FragmentShader!\n");
}
}

This is the code for initializing the shaders:

SHADER Shaders;
GLhandleARB vertexShader, fragmentShader, shaderProgram;

Shaders.LoadShaders("vertexShader.vert","fragmentShader.frag");

const char* vertTemp = Shaders.vertexShader;
vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
glShaderSourceARB(vertexShader, 1, &vertTemp, NULL);
glCompileShaderARB(vertexShader);
traceShaderInfoLog(vertexShader);

const char* fragTemp = Shaders.fragmentShader;
fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
glShaderSourceARB(fragmentShader, 1, &fragTemp, NULL);
glCompileShaderARB(fragmentShader);
traceShaderInfoLog(fragmentShader);

delete[] Shaders.vertexShader;
delete[] Shaders.fragmentShader;

shaderProgram = glCreateProgramObjectARB();
glAttachObjectARB(shaderProgram,vertexShader);
glAttachObjectARB(shaderProgram,fragmentShader);
glLinkProgramARB(shaderProgram);
traceProgramInfoLog(shaderProgram);

glUseProgramObjectARB(shaderProgram);

This is vertexShader.vert and fragmentShader.frag:

void main(){
gl_Position = ftransform();
}
void main(){
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

And this is the error I get when I print the log, I get this really weird symbol at the end of the scripts which is every time I compile again another symbol:

void main(){
    //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
    gl_Position = ftransform();
}┘
void main(){
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}♣
Shaders loaded succesfully.
Vertex shader was successfully compiled to run on hardware.

Fragment shader failed to compile with the following errors:
ERROR: 0:3: error(#132) Syntax error: '<' parse error
ERROR: error(#273) 1 compilation errors.  No code generated

Fragment shader(s) were not successfully compiled before glLinkProgram() was called.
Link failed.
  • 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-06-06T03:08:56+00:00Added an answer on June 6, 2026 at 3:08 am

    Your Load function is most likely the problem: the signature should read

    int SHADER::Load(const char *filename, char *&shaderSource) // Note the &
    

    for a quick fix. You’re allocating the memory in that function and reassigning to the pointer – you only load the source to that address – but that never leaves the function.

    The compiler most likely gets an empty string due to memory being zero initialized (are you running this in debug?) and doesn’t fail because that’s sometimes okay. But the linker notices that there’s not really any code to link!

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

Sidebar

Related Questions

Im trying add roles to a drop dropdown box but im getting the error
I am trying to add some shaders to my old OpenGL program that draws
When trying to add a few items to the database I'm getting this error:
I'm trying add vertical lines to my grid. I have found some examples but
Im new to asp.net mvc. I'm trying add new model class but it got
Trying to add a blank sample app for a rails tutorial to GitHub, but
I am trying to add things to my working code, but it is returning
I am drawing one object using multi-texturing. That comes fine but when I draw
I am trying add two columns in a text file that are seperated by
im trying to add a css class in my javascript code but when i

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.