Loading shader firom file: GL_error 'illigal counting'

Hi all,
I’m using a shader that on and off generates an error.

//std::ifstream::pos_type mSize;
int mSize;
std::ifstream ctFile ("F:/Projekter/GLFW3_2/vertShader6.txt", std::ios::in|std::ios::binary|std::ios::ate);
    if (ctFile.is_open())
        printf("ctFile is_open
        mSize = ctFile.tellg();
        printf("ctFile mSize : %i 
", mSize ) ;
        checkErrors() ;

        char *buffer = new char [mSize];
        ctFile.seekg (0, std::ios::beg);
        ctFile.read (buffer, mSize);
        buffer[mSize] = '\0';

        const GLchar *vertexShaderChars[] = { buffer };

I detect the error at checkErrors(). It’s printed in my local language and translates to something like ‘illigal counting’
The error sometimes generates a faul status:
glGetShaderiv(vertShader, GL_COMPILE_STATUS, &status);

I make a printf() of ‘buffer’ and it provides a correct visual impression of the shader-code/text.

It ‘did’ bypass GL_COMPILE_STATUS earlier without the error spawning a faul status, and I would have a functioning program …

It probably takes a newbie to produce the code above … any suggestion of a more straightforward code is welcome.

I changed my approach to a very elegant way presented at

… and I get the same error.
It would belong to something about ‘vec4 coll’ …?

#version 330 core
precision mediump float;
precision mediump int;
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 normal;
uniform mat4 modelM;
uniform mat4 cameraM;
uniform mat4 projectionM;
uniform vec3 normal;
uniform vec3 camPosition;
uniform vec3 lightPos;
out vec4 coll;
void main()
coll = vec4(1.0f,1.0f,1.0f,1.0f);
mat4 tmp1 = cameraM*modelM;
mat4 tmp2 = projectionM * tmp1;
gl_Position = tmp2 * position;

… ups, noticed the doubly named variable ‘normal’. Changing it has made an immediate change to the better …

hi again,
the error ‘illegal counting’ persists, but it does not knock the program out right away. It runs a good handful of seconds and displays what it’s supposed to display, then pops a fatal error 1 (?) and says that too many errors has occurred. The errors are not caught in the application.
I counted the chars of the shader and it matches the right size. I display the shader-source in printf() and it’s not garbled … it adds a couple of blank lines in the console though.
I’ve changed a simple draw-triangle program (working perfectly with the same shader [and error?]) to display a height-field of 1201*1201 vertices (bitbanging to little-endian). I should go look for errors in that load and associated changes.

alas …
Index and Vertex MAX_COUNT exceeded ;o/

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.