我正在使用PyOpenGL为蟒蛇和PyQt5编写一个3D图形工具包。我正在编写自己的着色器来配合它,如果这有帮助的话。我试图做的是从使用glBegin到使用顶点缓冲区数组。我在使用VBO时发现了以下内容:
http://www.songho.ca/opengl/gl_vbo.html - 我只能从中抓取一些信息,因为它是在C / C++中。
如何让 VBO 与蟒蛇和 PyOpenGL 一起工作 - 这是在 Python2 中,因此是相当有限的。
但是,我无法将每个形状对象的顶点编译为场景VBO所需的内容拼凑在一起。我也不知道数组中的数据是如何布局的。我的初始化和绘制GL函数如下,我的顶点和片段着色器的GLSL代码也是如此。
def initGL(self):
self.vertProg = open(self.vertPath, 'r')
self.fragProg = open(self.fragPath, 'r')
self.vertCode = self.vertProg.read()
self.fragCode = self.fragProg.read()
self.vertShader = shaders.compileShader(self.vertCode, GL_VERTEX_SHADER)
self.fragShader = shaders.compileShader(self.fragCode, GL_FRAGMENT_SHADER)
self.shader = shaders.compileProgram(self.vertShader, self.fragShader)
#paintGL uses shape objects, such as cube() or mesh(). Shape objects require the following:
#a list named 'vertices' - This list is a list of points, from which edges and faces are drawn.
#a list named 'wires' - This list is a list of tuples which refer to vertices, dictating where to draw wires.
#a list named 'facets' - This list is a list of tuples which refer to vertices, ditating where to draw facets.
#a bool named 'render' - This bool is used to dictate whether or not to draw the shape.
#a bool named 'drawWires' - This bool is used to dictate whether wires should be drawn.
#a bool named 'drawFaces' - This bool is used to dictate whether facets should be drawn.
在这个项目的最终形式中,我想在我的缓冲区中包含顶点位置,颜色甚至发光的信息。(当我最终把它放到光线行军中时,这将实现。我还需要一种方法来指定我是否应该绘制电线和面。
如何设置和配置一个或多个虚拟操作系统,以将所有这些信息传输到 GPU 和 OpenGL?
慕标琳琳
相关分类