ENTRY | DOWNLOAD | MANUAL | ONGOING | |
vertices.py"""Draw opengl, vertex-based shapes. This is just a small selection of what can be drawn with the opengl api. by stephan) """ from slut import * class Atlantis(World): def onSetup(self): self.width = 400 self.height = 300 self.name = "By Vertex" def onDraw(self): # points glPointSize(3) glColor4f(1.0, 1.0, 1.0, 1.0) glBegin(GL_POINTS) glVertex3f(0.2, 1.5, 0) glVertex3f(0.1, 1.5, 0) glVertex3f(0, 1.5, 0) glEnd() #a zig-zag line glLineWidth(1) glColor4f(1.0, 1.0, 1.0, 1.0) glBegin(GL_LINE_STRIP) glVertex3f(-2, 0, 0.2) glVertex3f(-2, 1, 0.2) glVertex3f(-1, 0, 0.2) glVertex3f(-1, 1, 0.2) glVertex3f(-0.1, 0, 0.2) glVertex3f(-0.1, 1, 0.2) glEnd() #line segments glLineWidth(3) glColor4f(1.0, 0.5, 0.5, 1.0) glBegin(GL_LINES) glVertex3f(2, 0, 0.0) glVertex3f(2, 1, 0.0) glVertex3f(1, 0, 0.2) glVertex3f(1, 1, 0.2) glVertex3f(0.1, 0, 0.0) glVertex3f(0.1, 1, 0.0) glEnd() #single colored polygon glLineWidth(1) glColor4f(1.0, 0.3, 0.3, 1.0) glBegin(GL_POLYGON) glVertex3f(-1, -1, 0) glVertex3f(-2, -1.5, 0) glVertex3f(-2, 0, 0) glVertex3f(-1.3, 1, 0) glVertex3f(-1, -1, 0) glEnd() #multi-colored polygon glLineWidth(3) glBegin(GL_POLYGON) glColor4f(0.5, 0.5, 0.5, 1.0) glVertex3f(0, -1, 0) glVertex3f(2, -1, 0) glVertex3f(2, 1, 0) glColor4f(1.0, 0.5, 0.5, 1.0) glVertex3f(1.2, 1.5, 0) glVertex3f(0, -1, 0) glEnd() def onDrawOrtho(self): glLineWidth(1) glColor4f(0.5, 0.5, 0.8, 1.0) glBegin(GL_LINE_STRIP) glVertex2f(0, 250) glVertex2f(110, 220) glVertex2f(210, 250) glVertex2f(400, 220) glEnd() atlantis = Atlantis() atlantis.run() |
|
Initiated by Stephan Hechenberger Thanks to CADRE's 103 |