Apr-01-2017, 07:14 AM
class cube(): def __init__(self,vertexcount,VAOid): self.vertexcount=vertexcount self.VAOid=VAOid def draw(self): GL.glBindVertexArray(self.VAOid) GL.glEnableVertexAttributeArray(0) GL.glDrawArrays(GL_TRIANGLES,0,self.vertexcount) GL.glDisableVertexAttribArray(0) GL.glBindVertexArray(0) ######################################################################################################### class VAO(): def __init__(self,VAOid,VBOid,attributenum,positions=[],VAOS=[],VBOS=[]): self.VAOid,self.VBOid=VAOid,VBOid self.positions=positions self.attributenum=attributenum self.VAOS,self.VBOS=VAOS,VBOS def create(self): self.VAOid=GL.glGenVertexArrays() self.VAOS.append(self.VAOid) GL.glBindVertexArray(self.VAOid) return self.VAOid def store(self,attributenum,data): self.VBOid=GL.glGenBuffers() self.VBOS.append(self.VBOid) GL.glBindBuffer(GL.GL_ARRAY_BUFFER,self.VBOid) GL.glBufferData(GL.GL_ARRAY_BUFFER,data,GL.GL_STATIC_DRAW) GL.glVertexAttribPointer(attributenum,3,GL.GL_FLOAT,False,0,0) GL.glBindBuffer(GL.GL_ARRAY_BUFFER,0) def clean(self): for VAO in self.VAOS: GL.glDeleteVertexArrays(VAO) for VBO in self.VBOS: GL.glDeleteBuffers(VBO) def unbind(self): GL.glBindVertexArray(0) def loadtoVAO(self): self.VAOid=self.create() self.store(self.attributenum,self.positions) self.unbind() return cube(self.VAOid,len(self.positions)/3)Note:This is not the full code just the VAO and VBO part, the part of code that calls this method is also not included.The reason i did not post the full code is because the question asking guideline from this forum says to extract the part that i thinks causes the error only,so here it is.
Error:Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package
s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\latebind.py", line 41, in __call__
return self._finalCall( *args, **named )
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "game.py", line 172, in <module>
game=game(True,'loading','mainmenu',False)
File "game.py", line 25, in __init__
square1=VAOcreator.loadtoVAO()
File "game.py", line 154, in loadtoVAO
self.VAOid=self.create()
File "game.py", line 132, in create
self.VAOid=GL.glGenVertexArrays()
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package
s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\latebind.py", line 45, in __call__
return self._finalCall( *args, **named )
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package
s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\wrapper.py", line 655, in wrapperCall
pyArgs = tuple( calculate_pyArgs( args ))
File "C:\Users\User\AppData\Local\Programs\Python\Python35-32\lib\site-package
s\pyopengl-3.1.1a1-py3.5.egg\OpenGL\wrapper.py", line 430, in calculate_pyArgs
args
ValueError: glGenVertexArrays requires 1 arguments (n, arrays), received 0: ()
This code shouldnt give a error,because i copied it(changed a bit) from a youtube tutorial(https://www.youtube.com/watch?v=WMiggUPst-Q&t=687s)
the few things that i change are:
1)changing the class the method should be in
-the draw method should be in the renderer class(according to the video),but i put it in the cube class.
2)translating from java to python
-the tutorial is in java,so i dont know how to translate it properly,especially the bufferutil part,so i skip that part.(which i think will also work,because it is just used to convert from array\list to buffer)
3)adding constructor
-using the __init__() method in every class
any help will be appreciated.
