View Full Version : glLineWidth gives GL_INVALID_VALUE for widths > 1?

12-18-2012, 07:53 AM

On a mac I am getting GL_INVALID_VALUE when I call glLineWidth with any value over 1. Why would I get that? The documentation seems to indicate that widths greater than 1 are supported.


12-18-2012, 09:45 AM
Hi Bob,

You say "on a mac"; do you mean you are programming for Mac OS X or simulating your mobile application on a Mac? Based on your previous questions I'm going to guess the latter.

Given that you seem to be programming in OpenGL ES 2.0, my best guess is that it's your emulator that doesn't like the line width; glLineWidth's valid values depend on the hardware, and only a width of 1.0f is guaranteed to be supported. Try using this code (from here (http://stackoverflow.com/a/7788811/1839806)) to find out what is supported on your device/emulator.

GLint range[2];
glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range);
glGetIntegerv(GL_SMOOTH_LINE_WIDTH_RANGE, range);

As you might guess from the code, the valid range can be different for anti-aliased vs aliased lines. Generally speaking, aliased lines will have a larger valid range. As far as I know, though, most modern devices can handle at least 2.0f width...

12-18-2012, 01:21 PM
actually, this problem is for Mac OS X. And it appears that the range is actually just 1-1. From reading up, it seems like the latest versions of OpenGL are abandoning line-width support. Is that true? Something about future-compatibility.

12-18-2012, 04:22 PM
glLineWidth is in the 4.2 core and restriction "Wide lines - LineWidth values greater than 1.0 will generate an INVALID_VALUE error." is listed as depreciated but I am not sure Mac OS supports 4.2.