Author Topic: Question about DrawLine  (Read 5965 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Question about DrawLine
« on: December 31, 2010, 09:47:15 AM »
Is there an easy way to get it to display Behind asteroids, instead of On top of them?

It seems like it displays behind asteroid owner icons, but in front of the asteroids themselves.  Any way to change this, or is it time for more crazy mathematics? :>

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Question about DrawLine
« Reply #1 on: December 31, 2010, 09:54:32 AM »
Also the context of the command seems slightly mislabelled.
It's not
Code: [Select]
DrawLine(linex1[i],liney1[i],linex2[i],liney2[i],red,green,blue,alpha,red,green,blue,alpha,thickness)
...but rather:
Code: [Select]
DrawLine(linex1[i],liney1[i],linex2[i],liney2[i],red,blue,green,alpha,red,blue,green,alpha,thickness)

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Question about DrawLine
« Reply #2 on: January 01, 2011, 01:20:15 AM »
The colour order should be RGB, but I may have cocked it up. I'll just leave it as-is and update the docs I guess? Maybe

Anyway, there's no way to change when the draw line will render at the moment - even stuff in the game can't really choose when it draws as it's all mandated from the game class. man i'm such a great coder

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Question about DrawLine
« Reply #3 on: January 01, 2011, 01:34:53 AM »
It's all good, don't worry about it.  :>  I can just run some checks to see if the line overlaps with the asteroids at all, and not draw it if it does.  I'm rendering stars at the moment which are composed of 2 very small lines, so I don't think it'll be necessary to calculate visible line parts.  They'll just wink out of existence when they go behind a roid.  :>

The asteroid coordinates are known, as is the radius, so it shouldn't be too bad really.  Might be computationally expensive though...  will have to see..

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Question about DrawLine
« Reply #4 on: January 01, 2011, 03:56:52 AM »
I have sorted it, and it is indeed computationally expensive.  Having more than about 40 stars means that when a lot of asteroids are onscreen, the FPS drops greatly.
I'm working on ways to optimise it.. :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Question about DrawLine
« Reply #5 on: January 01, 2011, 05:09:12 AM »
How about only drawing a certain number of stars an any one time, sort of like a twinkling effect. I know stars don't twinkle when seen from outside the atmosphere, but it could save on drawing, though deciding which ones to draw could be even worse...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Question about DrawLine
« Reply #6 on: January 01, 2011, 06:41:10 AM »
The method I seem to have settled on is to decrease the alpha as you zoom further out, and then ultimately to stop rendering them altogether.

This means there are 5 different "steps".  Full stars, 3 layers, 2 layers, 1 layer, and no stars.

The layers are at different "depths" so the furthest-away stars disappear first.

It looks pretty slick, but I wish there was a way to have millions of stars onscreen at once without FPS slowdown.  It would look so beautiful.


One idea I'm toying with is to draw each star with a tiny sprite, instead of 2 lines.  That would mean only 1 draw operation is required per star, instead of 2.  I don't suppose anyone has a list of all the different sprites, do they..? :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Question about DrawLine
« Reply #7 on: January 01, 2011, 05:28:23 PM »
Sprites glow, too, I think. That could look good.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Question about DrawLine
« Reply #8 on: January 02, 2011, 07:56:44 AM »
0            Point,
1            Spot,
2            Wing,
3            Background,
4            Noise,
5            CircleFill,
6            Ring,
7            ThickRing,
8            Atmosphere,
9            UIWindow,
10            UIButton,
11            UIButtonPressed,
12            UIButtonHighlight,
13            Pixel,

Most are pretty self-explanatory :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Question about DrawLine
« Reply #9 on: January 02, 2011, 01:26:28 PM »
Point for the win!!

They make great stars.  :>
It also means we are now able to draw stars in one command, rather than requiring 2 DrawLine commands to form the cross that I was using for stars previously.  This yielded substantial performance improvements.


Thanks for this.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Question about DrawLine
« Reply #10 on: January 02, 2011, 09:59:22 PM »
Point is the best texture I reckon :)

I think it's an inverse distance field (rather than inverse square) so not quite representative for a point of light but still great :)

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Question about DrawLine
« Reply #11 on: January 03, 2011, 01:17:45 AM »
UIWindow? UIBUtton? Do they do anything special, like block clicks behind them?

TELL ME!!!!

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Question about DrawLine
« Reply #12 on: January 03, 2011, 05:03:01 AM »
They're just textures used to draw the UI. Sorry!