LaundroMat wrote: > Hi, > > When running the following code from within Gutsy, the results are > unpredictable: one time I see a gradient-filled triangle, other times > what seems to me is just random gfx memory is being displayed. > > > glColorPointer (3, GL_FLOAT, 6 * sizeof(GLfloat), (GLfloat * > len(intertwined))(*intertwined)) > glVertexPointer (3, GL_FLOAT, 6 * sizeof(GLfloat), (GLfloat * > len(intertwined[3:]))(*intertwined[3:])) > > glBegin(GL_TRIANGLES) > glArrayElement (2) > glArrayElement (3) > glArrayElement (5) > glEnd() >
The arrays of vertex and color data are being garbage collected as soon as the glColorPointer and glVertexPointer functions return. Differences in the implementation of malloc on Windows and Linux are causing the data to be overwritten before glArrayElement is being called. The solution is to hold the arrays in free variables so that they are not released until the function is left. e.g.: color_data = (GLfloat * len(intertwined))(*intertwined) glColorPointer(3, GL_FLOAT, 6 * sizeof(GLfloat), color_data) [Side note: the data will not actually be intertwined in your example, as the slice [3:] creates a copy of the list. You can achieve the effect I believe you are after with some ctypes trickery to mangle a pointer into the color array (but it's almost certainly easier to use glInterleavedArrays with GL_C3F_V3F). Apologies if you knew this already and were just trying something different :-) ] Alex. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
