if self._buffer is not None and bool(glDeleteBuffers):
print "VBO was not properly released!"
-def DrawMachine(machineSize):
- glDisable(GL_LIGHTING)
- glDisable(GL_CULL_FACE)
- glEnable(GL_BLEND)
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-
- sx = machineSize.x
- sy = machineSize.y
- for x in xrange(-int(sx/20)-1, int(sx / 20) + 1):
- for y in xrange(-int(sx/20)-1, int(sy / 20) + 1):
- x1 = sx/2+x * 10
- x2 = x1 + 10
- y1 = sx/2+y * 10
- y2 = y1 + 10
- x1 = max(min(x1, sx), 0)
- y1 = max(min(y1, sy), 0)
- x2 = max(min(x2, sx), 0)
- y2 = max(min(y2, sy), 0)
- if (x & 1) == (y & 1):
- glColor4ub(5, 171, 231, 127)
- else:
- glColor4ub(5 * 8 / 10, 171 * 8 / 10, 231 * 8 / 10, 128)
- glBegin(GL_QUADS)
- glVertex3f(x1, y1, -0.02)
- glVertex3f(x2, y1, -0.02)
- glVertex3f(x2, y2, -0.02)
- glVertex3f(x1, y2, -0.02)
- glEnd()
-
- glEnable(GL_CULL_FACE)
-
- if profile.getPreference('machine_type') == 'ultimaker':
- glPushMatrix()
- glEnable(GL_LIGHTING)
- glTranslate(100, 200, -1)
- glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.8, 0.8, 0.8])
- glLightfv(GL_LIGHT0, GL_AMBIENT, [0.5, 0.5, 0.5])
- glEnable(GL_BLEND)
- glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR)
-
- global platformMesh
- if platformMesh is None:
- try:
- platformMesh = meshLoader.loadMesh(getPathForMesh('ultimaker_platform.stl'))
- except:
- platformMesh = False
-
- if platformMesh:
- DrawMesh(platformMesh)
- glPopMatrix()
- glDisable(GL_LIGHTING)
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
-
- glColor4ub(5, 171, 231, 64)
- glBegin(GL_QUADS)
- glVertex3f(0, 0, machineSize.z)
- glVertex3f(0, machineSize.y, machineSize.z)
- glVertex3f(machineSize.x, machineSize.y, machineSize.z)
- glVertex3f(machineSize.x, 0, machineSize.z)
- glEnd()
-
- glColor4ub(5, 171, 231, 96)
- glBegin(GL_QUADS)
- glVertex3f(0, 0, 0)
- glVertex3f(0, 0, machineSize.z)
- glVertex3f(machineSize.x, 0, machineSize.z)
- glVertex3f(machineSize.x, 0, 0)
-
- glVertex3f(0, machineSize.y, machineSize.z)
- glVertex3f(0, machineSize.y, 0)
- glVertex3f(machineSize.x, machineSize.y, 0)
- glVertex3f(machineSize.x, machineSize.y, machineSize.z)
- glEnd()
-
- glColor4ub(5, 171, 231, 128)
- glBegin(GL_QUADS)
- glVertex3f(0, 0, machineSize.z)
- glVertex3f(0, 0, 0)
- glVertex3f(0, machineSize.y, 0)
- glVertex3f(0, machineSize.y, machineSize.z)
-
- glVertex3f(machineSize.x, 0, 0)
- glVertex3f(machineSize.x, 0, machineSize.z)
- glVertex3f(machineSize.x, machineSize.y, machineSize.z)
- glVertex3f(machineSize.x, machineSize.y, 0)
- glEnd()
-
- glDisable(GL_BLEND)
-
- #Draw the X/Y/Z indicator
- glPushMatrix()
- glTranslate(5, 5, 2)
- glLineWidth(2)
- glColor3f(0.5, 0, 0)
- glBegin(GL_LINES)
- glVertex3f(0, 0, 0)
- glVertex3f(20, 0, 0)
- glEnd()
- glColor3f(0, 0.5, 0)
- glBegin(GL_LINES)
- glVertex3f(0, 0, 0)
- glVertex3f(0, 20, 0)
- glEnd()
- glColor3f(0, 0, 0.5)
- glBegin(GL_LINES)
- glVertex3f(0, 0, 0)
- glVertex3f(0, 0, 20)
- glEnd()
-
- glDisable(GL_DEPTH_TEST)
- #X
- glColor3f(1, 0, 0)
- glPushMatrix()
- glTranslate(20, 0, 0)
- noZ = ResetMatrixRotationAndScale()
- glDrawStringCenter("X")
- glPopMatrix()
-
- #Y
- glColor3f(0, 1, 0)
- glPushMatrix()
- glTranslate(0, 20, 0)
- glDrawStringCenter("Y")
- glPopMatrix()
-
- #Z
- if not noZ:
- glColor3f(0, 0, 1)
- glPushMatrix()
- glTranslate(0, 0, 20)
- glDrawStringCenter("Z")
- glPopMatrix()
-
- glPopMatrix()
- glEnable(GL_DEPTH_TEST)
-
def glDrawStringCenter(s):
glRasterPos2f(0, 0)
glBitmap(0,0,0,0, -glGetStringSize(s)[0]/2, 0, None)