Creating Ring

BlitzMax Forums/BlitzMax OpenGL Programming/Creating Ring

SuperStrict
SetGraphicsDriver GLGraphicsDriver()
GLGraphics 800,600

glViewport(0,0,800,600);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(45.0,800.0/600,0.1,100.0);
glMatrixMode(GL_MODELVIEW);				
glLoadIdentity();	

Local Ring:TRing = TRing.Create(0 , 0 , 1 , .5 , 18)


Repeat
'	angle=0;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
	glLoadIdentity()
	glTranslatef(0,0.0,-6.0);
	 
	glBegin(GL_QUADS);
	glColor3f(0.0 , 0.0 , 1.0) ;
	Ring.Draw()
	glEnd();


Flip()
Until KeyDown(key_escape)

Type TQuad
	Field Points:Float[8]
	
	Function Create:TQuad(x1:Float , y1:Float , x2:Float , y2:Float , x3:Float , y3:Float , x4:Float , y4:Float)
		Local Q:TQuad = New TQuad
		
		Q.Points = [x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4]
		
		Return Q
	End Function
	
	Method Draw()
		DrawPoly(Points)
	End Method
	
	Method Render()
		glvertex2f(Points[0], Points[1])
		glvertex2f(Points[2], Points[3])
		glvertex2f(Points[4], Points[5])
		glvertex2f(Points[6] , Points[7])
	End Method
	
End Type

Type TRing
	Field Segments:TList = New TList
	
	Function Create:TRing(X:Float , Y:Float, inner:Float,thickness:Float,seg:Int = 32)
		Local R:TRing = New TRing
		Local Stepper:Float = 360.0/seg
		Local Angle:Float = 0
		Repeat 
			Local x1:Float
			Local x2:Float
			Local x3:Float
			Local x4:Float
			
			Local y1:Float
			Local y2:Float
			Local y3:Float
			Local y4:Float
			
			x1 = X + Sin(Angle) * inner
			y1 = Y - Cos(Angle) * inner
			
			x4 = X + Sin(Angle) * (inner + thickness) 
			y4 = Y - Cos(Angle) * (inner + thickness) 
			
			angle:+ Stepper
			
			x2 = X + Sin(Angle) * inner
			y2 = Y - Cos(Angle) * inner
			
			x3 = X + Sin(Angle) * (inner + thickness) 
			y3 = Y - Cos(Angle) * (inner + thickness) 
			
			R.Segments.Addlast(TQuad.Create(x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4) )

		Until Angle >= 360
		
		Return R
	End Function
	
	Method Draw()
		For Local Q:TQuad = EachIn segments
			glPolygonMode(GL_FRONT,GL_LINE)
			Q.Render()
			glPolygonMode(GL_FRONT,GL_FILL)
		Next
	End Method
End Type


something small I have put together from oyur above code.