Professional Documents
Culture Documents
Setup A 2D Projection
Setup A 2D Projection
Setup A 2D Projection
//Variables
dim angle#, x1, y1, x2, y2, radius#
dim i
//Draw a scene
glClearColor(.3, .3, .3, 0)
glClear(GL_COLOR_BUFFER_BIT)
for i = 1 to 5000
x1 = rnd() % 600 + 20
y1 = rnd() % 420 + 40
gosub Point
next
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
{