| 26 | | def __cinit__( self ) : |
| 27 | | #self._axis = <gl.GLfloat *> ( 0,0,0, 1,0,0, # format XYZRGB |
| 28 | | # 1,0,0, 1,0,0 ) |
| 29 | | # # 1.,0.3,0. 1,0,0 |
| 30 | | self._axis[0] = 0 # Vertex 1 PX |
| 31 | | self._axis[1] = 0 #py |
| 32 | | self._axis[2] = 0 #pz |
| 33 | | self._axis[3] = 1 #Vertex 1 Color R |
| 34 | | self._axis[4] = 0 #G |
| 35 | | self._axis[5] = 0 #B |
| 36 | | self._axis[6] = 1 #Vertex 2 PX |
| 37 | | self._axis[7] = 0 #PY |
| 38 | | self._axis[8] = 0 #PZ |
| 39 | | self._axis[9] = 1 #R |
| 40 | | self._axis[10] = 0 #G |
| 41 | | self._axis[11] = 0 #B |
| 42 | | self._elements[0] = <char>0#Start at vertex 1 |
| 43 | | self._elements[1] = <char>1#End at vertex 2 |
| 44 | | self._vertexBuffer = 0 # BufferIDs |
| 45 | | self._elementBuffer = 0 |
| 46 | | # Generate Buffers |
| 47 | | |
| 48 | | cdef void _createBuffer(self) : |
| 49 | | gl.glGenBuffersARB(1, <gl.GLuint*> &self._vertexBuffer); |
| 50 | | gl.glBindBufferARB(gl.GL_ARRAY_BUFFER_ARB, self._vertexBuffer); |
| 51 | | gl.glBufferDataARB(gl.GL_ARRAY_BUFFER_ARB,sizeof(self._axis) , self._axis, gl.GL_STATIC_DRAW_ARB); |
| 52 | | gl.glGenBuffersARB(1, <gl.GLuint*> &self._elementBuffer); |
| 53 | | gl.glBindBufferARB(gl.GL_ARRAY_BUFFER_ARB, self._elementBuffer); |
| 54 | | gl.glBufferDataARB(gl.GL_ARRAY_BUFFER_ARB, sizeof(self._elements), self._elements, gl.GL_STATIC_DRAW_ARB); |
| 69 | | self._createBuffer() # No buffer, so create it |
| 70 | | gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY); # No Texture Coords.. |
| 71 | | gl.glDisableClientState(gl.GL_NORMAL_ARRAY); # or Normals either. |
| | 47 | # |
| | 48 | # This is the first render pass, so we need to setup the VBO |
| | 49 | # |
| | 50 | # First we'll populate _vert |
| | 51 | # |
| | 52 | self._vert[0].px = 0.00 # \ |
| | 53 | self._vert[0].py = 0.00 # } (0.0, 0.0, 0.0) |
| | 54 | self._vert[0].pz = 0.00 # / |
| | 55 | self._vert[0].cr = 1.00 # \ |
| | 56 | self._vert[0].cg = 0.00 # } Red |
| | 57 | self._vert[0].cb = 0.00 # /___________________________ |
| | 58 | self._vert[1].px = 1.00 # \ |
| | 59 | self._vert[1].py = 0.00 # } (1.0, 0.0, 0.0) |
| | 60 | self._vert[1].pz = 0.00 # / |
| | 61 | self._vert[1].cr = 1.00 # \ |
| | 62 | self._vert[1].cg = 0.00 # } Red |
| | 63 | self._vert[1].cb = 0.00 # /___________________________ |
| | 64 | # |
| | 65 | # Next populate _elmt |
| | 66 | # |
| | 67 | self._elmt[0].a = 0 # Line 0: 0-1 |
| | 68 | self._elmt[0].b = 1 # ____________________________ |
| | 69 | # |
| | 70 | # Create new vertex buffer and send _vert |
| | 71 | # |
| | 72 | gl.glGenBuffersARB(1, &self._vertBuffer) |
| | 73 | gl.glBindBufferARB(gl.GL_ARRAY_BUFFER_ARB, self._vertBuffer) |
| | 74 | gl.glBufferDataARB(gl.GL_ARRAY_BUFFER_ARB, sizeof(_vert), _vert, |
| | 75 | gl.GL_STATIC_DRAW_ARB) |
| | 76 | # |
| | 77 | # Do the same for the element buffer |
| | 78 | # |
| | 79 | gl.glGenBuffersARB(1, &self._elmtBuffer) |
| | 80 | gl.glBindBufferARB(gl.GL_ARRAY_BUFFER_ARB, self._elmtBuffer) |
| | 81 | gl.glBufferDataARB(gl.GL_ARRAY_BUFFER_ARB, sizeof(_elmt), _elmt, |
| | 82 | gl.GL_STATIC_DRAW_ARB) |
| | 83 | # |
| | 84 | # Disable unused pointers |
| | 85 | gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY) # No Texture Coords.. |
| | 86 | gl.glDisableClientState(gl.GL_NORMAL_ARRAY) # or Normals either. |
| | 87 | # |
| | 88 | # Enable color pointer |
| 73 | | gl.glVertexPointer(3, gl.GL_FLOAT, 0,<gl.GLvoid *> NULL); |
| 74 | | gl.glColorPointer(3,gl.GL_FLOAT,3*sizeof(float),<gl.GLvoid *>NULL); |
| | 90 | |
| | 91 | gl.glVertexPointer(3, gl.GL_FLOAT, 0, <gl.GLvoid *> 0) |
| | 92 | gl.glColorPointer (3, gl.GL_FLOAT, sizeof(float)*3, <gl.GLvoid *> 0) |