DrawOval, with less filling

BlitzMax Forums/BlitzMax Beginners Area/DrawOval, with less filling

Or no fill, to be exact.

I don't want my ovals filled. Do I have to write a function to
make this happen, or am I missing something?

In OpenGL you can tweak the settings (using GL functions not found in BlitzMax's docs, but which can be found via third-party docs online and in the BlitzWiki here and here):

SetGraphicsDriver GLMax2DDriver()
Graphics 800, 600

glPolygonMode GL_FRONT_AND_BACK, GL_LINE
DrawOval 100, 100, 200, 50
DrawRect 200, 200, 200, 50
glPolygonMode GL_FRONT_AND_BACK, GL_FILL

Flip
WaitKey
But I don't know of a way to do it in DirectX.

Have a look in the blitzmax code archives at the code I posted to draw filled or unfilled ovals.

For example;

http://www.blitzbasic.com/codearcs/codearcs.php?code=1479

Maybe you can use it.

Graphics 400,400,0

Const PixSize=1
Const RadiusX=100
Const RadiusY=70
Const PosX=200 'center
Const PosY=200 'center
Local Rad:Float

'draw the circle----------------------------
For Rad = 0 To 360 Step .1 'step is the definition of the circle
DrawRect PosX + (Sin(Rad) * RadiusX)-PixSize/2, PosY + (Cos(Rad) * RadiusY)-PixSize/2,PixSize,PixSize; Next
'-------------------------------------------

SetColor 0,255,0
DrawLine PosX-10,PosY,PosX+10,PosY
DrawLine PosX,PosY-10,PosX,PosY+10
Flip
WaitKey()


Thanks all, but for now I'll just include this handy little graphics module I wrote.
Const NORMAL = 0
Const DOTTED = 1
Function drawEllipse(x,y,xSize,ySize,StepSize = 20, width=1, style = NORMAL)
	Local oldlinewidth = GetLineWidth(), dot = 1
	SetLineWidth width
	Local a = stepSize
	Repeat
		If dot DrawLine x+xSize*Sin(a), y+ySize*Cos(a),x+xSize*Sin(a-stepSize), y+ySize*Cos(a-stepSize)
		a:+stepSize
		If DOTTED dot = 1-dot
	Until a> 360
	SetLineWidth oldlinewidth
EndFunction


Const FILL = 3
Const LINE = 2
Const CORNERS = 1
Const BOX = 0

Function drawl(x1,y1,x2,y2,width=1,style = BOX)
	Local oldlinewidth = GetLineWidth()
	SetLineWidth width
	Select style
	Case 3
		DrawRect x1,y1,x2,y2
	Case 2
		x2:+x1
		y2:+y1
		DrawLine x1,y1,x2,y2
	Case 1
		x2:+x1
		y2:+y1
		DrawLine (x1,y1,x1+(x2-x1)*.1,y1)
		DrawLine (x1,y1,x1,y1+(y2-y1)*.1)
		DrawLine (x1,y2-(y2-y1)*.1,x1,y2)
		DrawLine (x1,y2,x1+(x2-x1)*.1,y2)
		
		DrawLine (x2,y1,x2-(x2-x1)*.1,y1)
		DrawLine (x2,y1,x2,y1+(y2-y1)*.1)
		DrawLine (x2,y2-(y2-y1)*.1,x2,y2)
		DrawLine (x2,y2,x2-(x2-x1)*.1,y2)
	Default
		x2:+x1
		y2:+y1
		DrawLine (x1,y1,x2,y1)
		DrawLine (x1,y1,x1,y2)
		DrawLine (x1,y2,x2,y2)
		DrawLine (x2,y1,x2,y2)
	EndSelect
	SetLineWidth oldlinewidth
End Function




It isn't a module unless you specify it as such. It's also probably quite slow using Cos() and Sin().

Yeah, whoops, I guess it's just an included function.
And about the Sin and Cos, I'd like to have them
pre-calculated. How might I do this in an included file?
Can I just define them as Const at the top?

They aren't a constant. They are based on an angle each time, so you'd need an array of them.

AngelDaniel. On a modern CPU, FP instructions (like Sin and Cos) are likely faster than a memory fetch.

I didn't know those were built in FPU instructions these days. They used to have to require a software routine.


so you'd need an array of them.


Well I thought that was obvious. I guess I should have said it anyway. ;)

I have also heard that doing realtime sin and cos is no
problem for modern processors. But if you take a look, I've
included a step parameter so that on average, only 10 or
less calculations are done per circle.