Sie sind auf Seite 1von 3

// Setup a 2D projection

const XSize = 640, YSize = 480


glMatrixMode (GL_PROJECTION)
glLoadIdentity ()
glOrtho (0, XSize, YSize, 0, 0, 1)
glDisable(GL_DEPTH_TEST)
glMatrixMode (GL_MODELVIEW)
glLoadIdentity()
//Displacement trick for exact pixelization
glTranslatef(0.375, 0.375, 0)

//Variables
dim angle#, x1, y1, x2, y2, radius#
dim i

//Draw a scene
glClearColor(.3, .3, .3, 0)
glClear(GL_COLOR_BUFFER_BIT)

x1 = 20: y1 = 20: x2 = 620: y2 = 460: gosub HollowRectangle


x1 = 20: y1 = 40: x2 = 620: y2 = 40: gosub Line
x1 = 602: y1 = 22: x2 = 618: y2 = 37: gosub Rectangle
x1 = 580: y1 = 460: x2 = 620: y2 = 420: gosub Line

for i = 1 to 5000
x1 = rnd() % 600 + 20
y1 = rnd() % 420 + 40
gosub Point
next

x1 = 320: y1 = 240: radius# = 20: gosub Circle


x1 = 320: y1 = 240: radius# = 40: gosub HollowCircle
x1 = 320: y1 = 240: radius# = 60: gosub HollowCircle
x1 = 320: y1 = 240: radius# = 80: gosub HollowCircle

SwapBuffers()
End

Point:
glBegin(GL_POINTS)
glVertex2f(x1 + 0.5, y1 + 0.5)
glEnd()
return

Line:
glBegin(GL_LINES)
glVertex2f(x1, y1): glVertex2f(x2, y2)
glEnd()
return

Rectangle:
glBegin(GL_QUADS)
glVertex2f(x1, y1): glVertex2f(x2, y1): glVertex2f(x2, y2): glVertex2f(x1,
y2)
glEnd()
return

HollowRectangle:

glBegin(GL_LINE_LOOP)
glVertex2f(x1, y1): glVertex2f(x2, y1): glVertex2f(x2, y2): glVertex2f(x1,
y2)
glEnd()
return

Circle:
glBegin(GL_TRIANGLE_FAN)
glVertex2f(x1, y1)
for angle# = 0 to 360 step 5
glVertex2f(x1 + sind(angle#) * radius#, y1 + cosd(angle#) * radius#)
next
glEnd()
return

HollowCircle:
glBegin(GL_LINE_LOOP)
for angle# = 0 to 360 step 5
glVertex2f(x1 + sind(angle#) * radius#, y1 + cosd(angle#) * radius#)
next
glEnd()
return
{

Das könnte Ihnen auch gefallen