- sx = self._machineSize[0]
- sy = self._machineSize[1]
- 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 = x * 10
- x2 = x1 + 10
- y1 = y * 10
- y2 = y1 + 10
- x1 = max(min(x1, sx/2), -sx/2)
- y1 = max(min(y1, sy/2), -sy/2)
- x2 = max(min(x2, sx/2), -sx/2)
- y2 = max(min(y2, sy/2), -sy/2)
- #Black or "white" checker
- 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) #Draw bit below z0 to prevent zfighting.
- glVertex3f(x2, y1, -0.02)
- glVertex3f(x2, y2, -0.02)
- glVertex3f(x1, y2, -0.02)
- glEnd()
-
- if machine == 'ultimaker2':
-
- glColor4ub(127, 127, 127, 200)
- #if UM2, draw bat-area zone for head. THe head can't stop there, because its bat-area.
- #UpperRight
- clipWidth = 50
- clipHeight = 10
- posX = sx / 2 - clipWidth
- posY = sy / 2 - clipHeight
- glBegin(GL_QUADS)
- glVertex3f(posX, posY, 0.1)
- glVertex3f(posX+clipWidth, posY, 0.1)
- glVertex3f(posX+clipWidth, posY+clipHeight, 0.1)
- glVertex3f(posX, posY+clipHeight, 0.1)
- glEnd()
- #UpperLeft
- clipWidth = 55
- clipHeight = 10
- posX = -sx / 2
- posY = sy / 2 - clipHeight
- glBegin(GL_QUADS)
- glVertex3f(posX, posY, 0.1)
- glVertex3f(posX+clipWidth, posY, 0.1)
- glVertex3f(posX+clipWidth, posY+clipHeight, 0.1)
- glVertex3f(posX, posY+clipHeight, 0.1)
+ if self._platformTexture is None:
+ self._platformTexture = opengl.loadGLTexture('checkerboard.png')
+ glBindTexture(GL_TEXTURE_2D, self._platformTexture)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
+ glColor4f(1,1,1,0.5)
+ glBindTexture(GL_TEXTURE_2D, self._platformTexture)
+ glEnable(GL_TEXTURE_2D)
+ glBegin(GL_TRIANGLE_FAN)
+ for p in polys[0]:
+ glTexCoord2f(p[0]/20, p[1]/20)
+ glVertex3f(p[0], p[1], 0)
+ glEnd()
+ glDisable(GL_TEXTURE_2D)
+ glColor4ub(127, 127, 127, 200)
+ for poly in polys[1:]:
+ glBegin(GL_TRIANGLE_FAN)
+ for p in poly:
+ glTexCoord2f(p[0]/20, p[1]/20)
+ glVertex3f(p[0], p[1], 0)