Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Alpha blended cursors?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 krum   Members   -  Reputation: 255

Like
0Likes
Like

Posted 26 October 2006 - 08:39 AM

I've been working on trying to get alpha blended cursors working. In this time, I've pretty much convinced myself that the Direct3D cursor stuff really doesn't work very well at all (e.g. SetCursorProperties(), etc). According to the documentation, SetCursorProperties() doesn't support alpha blended cursors. Now I have been able to get them to work, but only by creating using the Win32 API CreateIconIndirect using a 32bpp HBITMAP with alpha info to create the cursor. Shouldn't there be a more correct way? Here's some code I just threw together to demonstrate what I'm doing (it's in C# with MDX, but you'll get the point). The only reason I'm using a DX surface is because its the easiest way to load the 32bpp bitmap, since Image.Load doesn't load the alpha channel.
            Bitmap mono = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);

            Bitmap bm = new Bitmap(32, 32, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using ( Stream s = new FileStream("..\\..\\data\\cursor.bmp", FileMode.Open, FileAccess.Read) )
            {
                using ( Surface surf = Surface.FromStream(_device, s, Pool.Scratch) )
                {

                    using (GraphicsStream gs = surf.LockRectangle(LockFlags.None))
                    {
                        uint* data = (uint*)gs.InternalDataPointer;
                        for (int x = 0; x < 32; ++x)
                        {
                            for (int y = 0; y < 32; ++y)
                            {
                                uint z = *data++;
                                if (z == 0xffffffff)
                                    z = 0;
                                bm.SetPixel(x, y, Color.FromArgb((int)z));
                            }
                        }
                    }

                }

            }



            ICONINFO ii;
            ii.fIcon = false;
            ii.xHotspot = 16;
            ii.yHotspot = 16;
            ii.hbmColor = bm.GetHbitmap();
            ii.hbmMask = mono.GetHbitmap();

            IntPtr hIcon = CreateIconIndirect( ref ii);

            Cursor c = new Cursor(hIcon);

            _window.Cursor = c;



Sponsor:

#2 Evil Steve   Members   -  Reputation: 1986

Like
0Likes
Like

Posted 26 October 2006 - 08:47 AM

Is there any reason you don't just render a textured quad at the current cursor location?

#3 krum   Members   -  Reputation: 255

Like
0Likes
Like

Posted 26 October 2006 - 08:57 AM

Quote:
Original post by Evil Steve
Is there any reason you don't just render a textured quad at the current cursor location?


If you do this, you're limited by framerate.

While I was working at SOE on this particular MMO, I'm not going to name names... but if you've played any big sci-fi MMOs you've probably played it, there were some cases where the frame rate could drop into the sub 10 FPS range (of course this could be expected with any MMO). At that point, it becomes extremely annoying when your cursor is running at the frame rate.

Fortunately, in that game it was possible to switch to a hardware cursor.

The difference is that game does not have an alpha blended cursor requirement.








Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS