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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:25:43+00:00 2026-05-15T01:25:43+00:00

I’m having a bit of a problem with my code for compiling shaders, namely

  • 0

I’m having a bit of a problem with my code for compiling shaders, namely they both register as failed compiles and no log is received.

This is the shader compiling code:

/* Make the shader */

Uint size;
GLchar* file;

loadFileRaw(filePath, file, &size);

const char * pFile = file;
const GLint pSize = size;


newCashe.shader = glCreateShader(shaderType);
glShaderSource(newCashe.shader, 1, &pFile, &pSize); 
glCompileShader(newCashe.shader);

GLint shaderCompiled;

glGetShaderiv(newCashe.shader, GL_COMPILE_STATUS, &shaderCompiled);

if(shaderCompiled == GL_FALSE)
{
    ReportFiler->makeReport("ShaderCasher.cpp", "loadShader()", "Shader did not compile", "The shader " + filePath + " failed to compile, reporting the error - " + OpenGLServices::getShaderLog(newCashe.shader));

}

And these are the support functions:

bool loadFileRaw(string fileName, char* data, Uint* size)
{    
    if (fileName != "") 
    {
        FILE *file = fopen(fileName.c_str(), "rt");

        if (file != NULL) 
        {
            fseek(file, 0, SEEK_END);
            *size = ftell(file);
            rewind(file);

            if (*size > 0) 
            {
                data = (char*)malloc(sizeof(char) * (*size + 1));
                *size = fread(data, sizeof(char), *size, file);
                data[*size] = '\0';
            }

            fclose(file);
        }
    }

    return data;
}

string OpenGLServices::getShaderLog(GLuint obj)
{
    int infologLength = 0;

    int charsWritten  = 0;
    char *infoLog;

    glGetShaderiv(obj, GL_INFO_LOG_LENGTH,&infologLength);

    if (infologLength > 0)
    {
        infoLog = (char *)malloc(infologLength);
        glGetShaderInfoLog(obj, infologLength, &charsWritten, infoLog);

        string log = infoLog;

        free(infoLog);

        return log;
    }

    return "<Blank Log>";
}

and the shaders I’m loading:

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

void main(void)
{
    gl_Position = ftransform();
}

In short I get

From: ShaderCasher.cpp, In: loadShader(), Subject: Shader did not compile
Message: The shader Data/Shaders/Standard/standard.vs failed to compile, reporting the error - <Blank Log>

for every shader I compile.

I’ve tried replacing the file reading with just a hard coded string but I get the same error so there must be something wrong with how I’m compiling them. I have run and compiled example programs with shaders, so I doubt my drivers are the issue, but in any case I’m on a Nvidia 8600m GT.

Can anyone help?

  • 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-15T01:25:43+00:00Added an answer on May 15, 2026 at 1:25 am

    In loadFileRaw, you pass char *data by value. Then you assign to it:

    data = (char*)malloc(sizeof(char) * (*size + 1));
    

    so your call

    loadFileRaw(filePath, file, &size);
    

    does not change the value of file! To change file, pass it in by pointer:

    loadFileRaw(filePath, &file, &size);
    

    and then change your function to

    bool loadFileRaw(string fileName, char** data, Uint* size) { ... }
    

    and in it,

    *data = (char*)malloc(sizeof(char) * (*size + 1));
    

    etc. (for the remaining references to data).

    That said, since you’re using C++, look into using std::vector<char> or std::string for your memory management. To get you started,

    {
       std::vector<char> data;
       data.resize(100); // now it has 100 entries, initialized to zero
       silly_C_function_that_takes_a_char_pointer_and_a_size(&data[0], 100); // OK
    } // presto, memory freed
    

    Also, you can look into using std::ifstream for reading files, instead of using FILE *.

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

Sidebar

Ask A Question

Stats

  • Questions 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since the origin is actually not XML, but a Javabean,… May 16, 2026 at 9:55 am
  • Editorial Team
    Editorial Team added an answer If you want to know such things, add a updatedBy… May 16, 2026 at 9:55 am
  • Editorial Team
    Editorial Team added an answer Try something like this: NSLog("frame=%@ transform=%@", NSStringFromCGRect(self.frame), NSStringFromCGAffineTransform(self.transform)); I'm willing… May 16, 2026 at 9:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

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.