Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to get a list of errors and their line numbers so I can display the error information differently from how it's formatted in the error string and also to show the line in the output.

It looks easy enough to just parse the result of glGetShaderInfoLog(), look for ERROR:, then read the next number up to :, and then the next, and finally the error description up to the next newline.

However, the OpenGL docs say:

Application developers should not expect different OpenGL implementations to produce identical information logs.

This makes me worry that my code may behave incorrectly on different systems. I don't need them to be identical, I just need them to follow the same format.

So is there a better way to get a list of errors with the line number separate, is it safe to assume that they'll always follow the "ERROR: 0:123:" format, or is there simply no reliable way to do this?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

This is too long for a comment, so i have to put it in an answer. Here are error codes i got when developing an engine in OpenGL 3.3 GLSL 330 about 3 months back. Latest drivers on both platforms.

Sample Vertex Shader error on my friend's laptop (NVIDIA). It wouldn't recognize a matrix layout specified locally in an UBO structure:

0(35) : error C3008: unknown layout specifier 'row_major'
0(36) : error C3008: unknown layout specifier 'row_major'

Sample Fragment Shader error on my own PC (ATI):

Fragment shader failed to compile with the following errors:
ERROR: 0:83: error(#143) Undeclared identifier blinn_phong
ERROR: 0:83: error(#132) Syntax error: 'term' parse error
ERROR: error(#273) 2 compilation errors.  No code generated

You can't expect the same format for all drivers, but the values you're looking for should be distinguishable enough to let you rely on regular expressions to get the information without the need to detect which drivers the user has installed.

share|improve this answer
    
Thanks for the answer, kinda disappointing that it's not standardized, but I really should get around to learning regular expressions anyway.. –  m4ttbush Oct 11 '12 at 11:52

It has different formats in different graphics card drivers, however it should be possible to detect common things and retrieve them. There are things that should be common between various drivers:

  • First word should specify error type.

  • First two integers will be File ID and line number.

  • The rest of the text will most probably be error text.*

There are things to look out for:

  • Symbols separating items may differ. Order may differ too.

  • Error text can contain almost anything.

  • Any of these rules can be broken at any time so if you start using something like this, be prepared to enable driver version detection and driver-specific hacks, at least if you plan to make the feature available to users.

*- According to images found in Google with queries "glsl compile error"/"glsl error", in one case, before reading text, the colon should be skipped while apostrophe shouldn't. More info inside these images: image 1; image 2; image 3

share|improve this answer
    
Thanks for the advice, Should be able to come up with something to handle known cases with this strategy, and if I come across a case that fails, I can update it. –  m4ttbush Oct 11 '12 at 11:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.