0

I'm experiencing issues similar to described in this question, which was never answered. Basicly when I'm calling

glVertexAttribPointer

with stride greater than this exact value: 640. OpenGL GL_INVALID_VALUE error is raised. According to documentation such an arror can be raised in one case:

GL_INVALID_VALUE is generated if stride is negative.

Which is obviously not my case.

In OpenGL 4.4 the maximum value is specified and set to GL_MAX_VERTEX_ATTRIB_STRIDE according to this site

Is there a certain magic number in older versions of OpenGL (3.3 in my case) for a maximum vertex stride? Is there any other reason that this function can raise GL_INVALID_VALUE?

Community
  • 1
  • 1
Amadeusz
  • 1,488
  • 14
  • 21
  • As an aside, why would you need such large strides to begin with? – Nicol Bolas Aug 19 '16 at 14:14
  • @Nicol Bolas I'm developing point cloud viewer and the easiest way to create some sort of thinnig out on the fly (white rotating view for example) was to set the larger stride to simply skip vertices. – Amadeusz Aug 19 '16 at 15:56
  • 1
    Wouldn't indexing vertices be a lot simpler? [Instancing](https://www.opengl.org/wiki/Vertex_Specification#Instanced_arrays) also provides a per-vertex skip mechanism. – Andon M. Coleman Aug 19 '16 at 17:06
  • @Andon M. Coleman I don't see how managing additional buffer could be simpler – Amadeusz Aug 19 '16 at 17:16
  • You are abusing vertex pulling by using ridiculous strides. Non-indexed rendering is supposed to be sequential, if you need to skip hundreds of vertices there are more appropriate ways of doing this. In theory, an explicit array of indices or attribute divisor can be more cache efficient -- in practice it does not have this size limitation you have run into; you can fetch vertex 0 followed by 65535 if you want. – Andon M. Coleman Aug 19 '16 at 17:58
  • @AndonM.Coleman: You mentioned that instancing provides per-vertex skip mechanizm but I could't find any. There is per-instance skip mechanizm instead. Did you have that in mind? – Amadeusz Aug 20 '16 at 00:03
  • @Amadeusz: Yes, I took the liberty of assuming (since you are discussing a point cloud) that each vertex represented a single primitive (point) and could stand alone as its own instance. This only holds true for one special type of primitive; per-vertex and per-instance attributes in lines and triangles always represent two different things but with point primitives you need only one vertex per-instance. – Andon M. Coleman Aug 20 '16 at 00:17

1 Answers1

1

Is there a certain magic number in older versions of OpenGL (3.3 in my case) for a maximum vertex stride?

In older versions? No. Implementations were not given leave to deny you the use of any stride. So long as it was positive or zero, the implementation had to permit it.

Is there any other reason that this function can raise GL_INVALID_VALUE?

Yes: the hardware can't handle it. If you're only getting GL 3.3, then your hardware is quite old. So it's probably going to have a lower limit than the 4.4 requirement of 2048.

Now obviously, the implementation isn't supposed to give out errors unless the spec says that it can. But adherence to the spec has never been NVIDIA's primary goal with their implementation...

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982