Handmade Hero » Forums » Code » Day 368 - GL improvements
mmozeiko
Mārtiņš Možeiko
1568 posts
1 project
#11053 Day 368 - GL improvements
12 months ago

Couldn't catch the stream live, but here are couple comments on today's code.

Instead of checking validation on program you should use check compile and link status. Compile/link status is exactly what it says - if compilation of shader, or linking of program succeeded or failed. Validate does a bit more. For example, for core context it checks if currently there is non zero VAO bound. Basically anything that might make glDrawArrays/glDrawElements to fail at place where the glValidateProgram is called. This is probably not what you want, because I assume you won't be bounding buffers, setting attribute pointers & friends at shader compilation place.

Visual Studio 2013 supports C++11 raw string literals that can be multiline. So instead of this:
1
2
3
4
5
6
char *HeaderCode =
    "// Header Code"
    "int foo() {"
    "  return 1;"
    "}"
    ;
you can write
1
2
3
4
5
6
char *HeaderCode = R"(
    // Header Code
    int foo() {
      return 1;
    }
    )";

which is maybe a bit nicer to use. And it will put \n symbols automatically in the string for better error reporting so. GCC and clang supports this C++11 feature for many years already.