PDA

View Full Version : glDrawArrays access violation (Python/PyOpenGL)



ChrisAWFUL
06-28-2010, 06:58 PM
I can't figure out how to solve this intermittent error, and I've failed to find a solution. I just ignored it; thinking I could solve it later, but now I've created another object that uses vertex arrays and so this error is occurring more often.



Traceback (most recent call last):
File "Z:\Goon\Goon.py", line 589, in <module>
main()
File "Z:\Goon\Goon.py", line 581, in main
DrawGLScene()
File "Z:\Goon\Goon.py", line 321, in DrawGLScene
glDrawArrays(GL_QUADS, 4, 8)
WindowsError: exception: access violation reading 0x01AC5000


This happens most often when I run Goon.py from a batch file, but can happen when executing Goon.py normally. I'm thinking that the problem lies with the compiled python files that are created each time Goon.py is ran or executed, because the problem will temporarily go away after deleting the PYC files. Sprites on the screen will often flash and glitch(blending) proceeding this error.

Here is heavily omitted code showing how I use Vertex Arrays. I'll post the vertex array lists if necessary.


glEnableClientState(GL_VERTEX_ARRAY)
glEnableClientState(GL_NORMAL_ARRAY)
glEnableClientState(GL_TEXTURE_COORD_ARRAY)

glNormalPointer(GL_FLOAT, 0, normals)
glTexCoordPointer(2, GL_FLOAT, 0, texCoords)
glVertexPointer(3, GL_FLOAT, 0, vertices)

glLightfv(GL_LIGHT1, GL_POSITION,LightPosition)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

for z in map
for y map[z]
for x map[z][y]
glPushMatrix()
glLoadIdentity()
glTranslatef(x,y,z)

if foo:
glBindTexture(GL_TEXTURE_2D, texture[t])
glDrawArrays(GL_QUADS, 4, 8)

else:
glBindTexture(GL_TEXTURE_2D, texture[t])
glDrawArrays(GL_QUADS, 0, 4)

glPopMatrix()

glDisableClientState(GL_TEXTURE_COORD_ARRAY)
glDisableClientState(GL_NORMAL_ARRAY)
glDisableClientState(GL_VERTEX_ARRAY)

ChrisAWFUL
06-30-2010, 04:54 PM
Resolved:. I misunderstood the index and count arguments to mean range. glDrawArrays(GL_QUADS, 4, 8) should have been glDrawArrays(GL_QUADS, 4, 4).