Video cards and power of 2

Video cards and power of 2

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Video cards and power of 2

Post by Forboding Angel »

I'm actually curious about this and dunno what forum to post it in, but I assume this is prolly more or less the appropriate place.

My question is this: In another thread a user mentioned that using the OS drivers for his vid card (gentoo), he saw non-transparent mouse cursors (caused because the image used for the cursor was not power of w).

In my opinion, this is a failing with the drivers themselves. The reason we don't use power of 2 for mouse cursors is because for precise clicking, you need the odd pixel.

Imagine a box of 4 pixels. Which box is the center? Well, obviously none of them are. Now extrapolate that into the next logical box which would be 9 pixels. This box does have an exact center because it is non-even.

All that to say that there are very excellent reasons to use odd sizes for mouse cursors.

But regardless, that is irrelevant due to the fact that any self respecting video card should be able to render a transparent image properly, regardless of what size it is.

Am I incorrect? If not can you explain why (3rd grader language please!)?
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Video cards and power of 2

Post by Das Bruce »

Is anyone going to notice one pixel in (how many pixels in your cursor?) sixteen? That's about six percent error.
dansan
Server Owner & Developer
Posts: 1203
Joined: 29 May 2010, 23:40

Re: Video cards and power of 2

Post by dansan »

power != multiplication
3^2 = 9
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Video cards and power of 2

Post by Kloot »

The reason we don't use power of 2 for mouse cursors is because for precise clicking, you need the odd pixel.
Clicks are registered underneath a cursor's "hotspot" pixel which can be either its center (int(xsize/2), int(zsize/2)) giving an absolute error of sqrt(1+1)~=1.4 pixels for square power-of-two cursors or its top-left corner causing a screen-space error of zero, so your premise is shaky / false. Did you calculate how many elmos difference that center error makes in world-coordinates for a click at "normal" zoom level? Can you prove this is really significant enough to hamper gameplay in practice? Keep in mind that:
  • old/crappy GPU's not handling PO2 textures is a real issue for some players
  • mouseclicks not being precisely registered is an imagined issue for most players
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Video cards and power of 2

Post by AF »

It's also a question of semantics. Should the top left cursor be pointing at the target, or on top of the target?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Video cards and power of 2

Post by knorke »

Imagine a box of 4 pixels. Which box is the center? Well, obviously none of them are.
you mean like "cursorjump"?
Some cursors are animated so they have a clear center "center pixel" in 1 out of 15 frames or something (attack) and some never have. (reclaim)
Does not matter though because error is negligible.
google has lots of stuff on non pow2 textures.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Video cards and power of 2

Post by Forboding Angel »

Good point Bruce. I should have used a real world example, like a cursor that is 29x29 but I was trying to keep it simple. (I was thinking multiples of 2, not powers, silly me)

But Kloot basically answered my question. Old/Cold vid cards not performing right.

The reason I questioned it was because knorke referred to it as a "mod error". I didn't agree but before dismissing it entirely I wanted to make sure that I wasn't completely off base.

Thanks :-)

Edit: @bruce's second part -- When I did EE's cursor set (it's currently in zk and evo as an option), I originally made the first one at 40x40 and had to go back and redo it as 39x39 (this is before ye olde png cursors, so I literally had to redraw them) because the hotspot didn't "feel" right.
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Video cards and power of 2

Post by Das Bruce »

Do you get to define the hot spot or is it hard coded?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Video cards and power of 2

Post by jK »

Das Bruce wrote:Do you get to define the hot spot or is it hard coded?
http://springrts.com/wiki/MouseCursors
Post Reply

Return to “Engine”