Skip to content
Advertisement

Unexpected behavior from glVertexAttribPointer data types using pyglet

I’ve been working on implementing a quadtree based LOD system. I’m using Pyglet as a python binding for OpenGL and I’m getting some weird behavior, I’d like to know if I’m doing something wrong.

Setting up my buffers: (input data are leaves of a quadtree to be decoded in the vertex shader)

JavaScript

Draw call:

JavaScript

source for test_shader:

JavaScript

And this doesn’t render anything for me. After some debugging I discover that if I change

JavaScript

To:

JavaScript

Then I get my expected render… despite the fact that my data is a uint, not a float. I’m fairly new to opengl, am I making some mistake here?

output with GL_FLOAT as dtype

Advertisement

Answer

If the type of the attribute is integral (e.g. uint) you must use glVertexAttribIPointer instead of glVertexAttribPointer. Focus on I and see glVertexAttribPointer:

glVertexAttribPointer(0, 1, GL_UNSIGNED_INT, GL_FALSE, 0, 0)

JavaScript

The type argument of glVertexAttribPointer just specifies the type of the source data. However, it is assumed that the type of the attribute is floating point and the data are converted to floating point values.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement