VAO and VBO not working. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: VAO and VBO not working. (/thread-2664.html) |
VAO and VBO not working. - hsunteik - Apr-01-2017 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. 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. RE: VAO and VBO not working. - Ofnuts - Apr-01-2017 So, it complains it's missing an argument, and your code indeed doesn't provide it (and your code extract doesn't include the problem code...)
RE: VAO and VBO not working. - hsunteik - Apr-01-2017 But i copied it from a youtube tutorial,and it works when he run it. he doesnt provide the argument for that function,but his code work,why? RE: VAO and VBO not working. - Ofnuts - Apr-01-2017 1) when some code doesn't work, the best person to ask is the author... 2) check software versions. I see two different signatures for that function (and none of them is the same as the one you use), here and there. RE: VAO and VBO not working. - hsunteik - Apr-02-2017 After fixing this error ,another error occur. the error name is NullFunctionError,it says glGenVertexArrays method is undefined,so i checked by doing print(bool(GL.glGenVertexArrays)) and it returns false,so i just downloaded GPU caps viewer to check my system supported version. software pyopengl version:3.1 gpu/hardware gpu opengl version:4.0 glsl version:4.0 renderer:Intel® HD Graphic 4400 GPU opengl extension GL_ARB_VAO version:2.1 GPU opengl extension GL_ARB_VBO version:1.5 etc should i uninstall pyopengl and download a lower version one? what should i do now? |