"Operation is not valid from a preview context" Error

When calling glLineWidth(2.0f), the following error is returned in the debug callback:

GL_INVALID_VALUE error generated. Operation is not valid from a preview context

I can’t find any mention of this error online, how can I fix it?

In a forward-compatibility context, line widths other than 1.0 are not allowed. glLineWidth with any value other than 1.0 will generate an invalid value error.

I assume that “preview context” is supposed to be “forward-compatibility context.”

1 Like

Note that regardless of the type of context used, the set of allowed line widths for both aliased and anti-aliased lines is implementation-dependent. All implementations are required to support a line width of 1.0; anything else is optional.

Before calling glLineWidth with any value other than 1.0, you should check that the requested width is actually supported and if necessary adjust the request. Requesting a non-supported width isn’t supposed to generate an error (the only documented error is GL_INVALID_VALUE in the case that the requested width is less than or equal to zero), but it’s unspecified whether the request is clamped to the nearest supported value, ignored, reset to 1.0, or whatever.

1 Like

This is great to know, thank you both. I’ll play around with the context settings - I recently ported my engine to Silk.NET - and see if I can get it working again.