DrawOval improvement
BlitzMax Forums/BlitzMax Module Tweaks/DrawOval improvement
| ||
Hi, A small fix to make DrawOval work with a width+height less than 5. Ie. DrawOval(x,y,2,2) Replace the original DrawOval method in: '\mod\brl.mod\glmax2d.mod\glmax2d.bmx'With this: Method DrawOval( x0#,y0#,x1#,y1#,tx#,ty# ) DisableTex Local i,x#,y#,w#,h#,c glBegin GL_POLYGON w=(x1-x0)*.5 h=(y1-y0)*.5 x0:+w y0:+h c=(Abs(w)+Abs(h)) If c<3 c=3 ' <- My genius fix c=360/c If c<1 c=1 i=0 While i<360 x=x0+Cos(i)*w y=y0-Sin(i)*h glVertex2f x*ix+y*iy+tx,x*jx+y*jy+ty i:+c Wend glEnd End Method(As I'm the first to post here, I don't know if this is what this board is intended to be used for...so feel free to remove this topic elsewhere, if it isn't) |
| ||
Cheer Fredborg! Yep, this is the right place for that sort of thing. |
| ||
Actually, this isn't correct. The 'front end' bit in max2d converts the x,y,w,h to x0,y0,x1,y1 Here's a little test that seems to indicate everything's OK 'as-is': Strict Graphics 640,480 Type TPixie Field x#=Rnd(640),y#=Rnd(480) Field width#=Rnd(32),height#=Rnd(32) Field scale_x#=Rnd(1,3),scale_y#=Rnd(1,3) Field rot#,rot_speed#=Rnd(3,6) Method Render() rot:+rot_speed SetRotation rot SetScale scale_x,scale_y SetHandle width/2,height/2 SetColor 255,255,255 DrawRect x,y,width,height SetColor 0,0,255 DrawOval x,y,width,height End Method End Type Local list:TList=New TList For Local i=0 Until 100 list.Addlast New TPixie Next While Not KeyHit(KEY_ESCAPE) Cls For Local p:TPixie=EachIn list p.Render() Next Flip FlushMem Wend |
| ||
Hi Mark, Any ideas why my other Oval probelm is happening? The Oval is a different, rough, non-oval shape depending on where I draw it on my window. http://www.blitzbasic.com/Community/posts.php?topic=41393 Very strange |
| ||
Try substituting this code in Mark's example. Take a screen shot using Apple+Shift+3 and then load that into a paint program and zoom in.Field width#=5,height#=5 Field scale_x#= 1,scale_y#= 1 |
| ||
Well, there you go...Just me being silly again :D I guess I'll have to wait for the Windows version to try it out for real. So I'll just keep quiet now :) |
| ||
Ok, in my strive to make this topic less pointless, I've changed the code at the top, to handle ovals with a width+ height less than 5. This should be a real fix, and not just some mumbo jumbo I invented in my wait for BMax for PC :) |
| ||
Are you coding blind or have you actually tried your code on BMX? |
| ||
Well, I have to admit I'm coding more or less in blind. But this one should be correct. Here's a quick explanation: When width+height is less than 5, then (width*0.5)+(height*0.5) <= 2 which is what is used to calculate how many points/vertices are needed to form a visually correct circle of a given size. And since two points/vertices doesn't render in OpenGL unless you have it set to 'Point (or Wire) Rendering Mode' instead of 'Solid Rendering Mode' you will end up with no visual output. So my fix is that if the number of points/vertices created is less than 3 then set it to 3, so the circle will at least render as a triangle if it's very small. I sure hope that's correct, or I'll now officially be known as 'The Stupidest BMax User'...So please confirm :) |
| ||
you were wrong then huh? :) |
| ||
Can't you tell from his username????? Sheesh! :p |