Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More Mac Issues? _MOUSEHIDE & DESKTOPWIDTH
#1
Well I encountered a couple other issues (on my Mac mini) that should probably be sniffed at to see if I'm crazy or what. Yesterday I was flummoxed by _MOUSEMOVEMENTX not reporting data beyond the edges of the desktop, and while I was messing with that I encountered another apparent bug. 

While polling for mouse feedback (DO WHILE MOUSEINPUT: cx = cx + _MOUSEMOVEMENTX: LOOP), I discovered that, if I wiggled my mouse around hard, the mouse pointer would reappear even though I had already used _MOUSEHIDE in the beginning of the program. I thought it must be the OS butting in, so I turned off "Wiggle Mouse to Show Pointer," but that didn't fix it, nor did sprinkling around a few more _MOUSEHIDEs. Not until I added 
_MOUSESHOW: _MOUSEHIDE into the relevant sub did the issue go away.  

One more. In trying to create a little onscreen gauge to show where the MouseMovementX position was within its limited range on my machine, I wrote one line that made my game grind to a halt - from ~450 FPS to 27 FPS. After plenty of head scratching, I found this wee formula was causing the problem:  g = INT((cx / _DESKTOPWIDTH) * _WIDTH). Specifically, dividing by _DESKTOPWIDTH killed the performance. When I replaced that command with 1920 (my desktop width) the problem went away. Now I'm thinking of making a CONST out of _DESKTOPWIDTH to fix it...

Weird stuff. I'm happy to provide the code that caused the wackiness. Thanks, Ted
Reply
#2
_DESKTOPWIDTH is one of those GLUT library calls on Mac, and as such it's all wrapped up in the whole display queue lineup.  (Screen has to be initialized, draw, set, reported to the OS, and then polled to return the value.)   

I definitely wouldn't want to rely on calling it inside a loop of any sort, or else that loop is going to take a rather large performace hit, as you've noticed for yourself.

My recommendation?  At the start of a program:

DIM SHARED DTW AS LONG: DTW = _DESKTOPWIDTH

Unless you expect the user of resizing their desktop on you while the program is running, I'd ust get that information once, store it, and then go with that stored value throughout my program for Linux and Mac.
Reply
#3
(02-14-2024, 05:41 PM)SMcNeill Wrote: _DESKTOPWIDTH is one of those GLUT library calls on Mac, and as such it's all wrapped up in the whole display queue lineup.  (Screen has to be initialized, draw, set, reported to the OS, and then polled to return the value.)   

I definitely wouldn't want to rely on calling it inside a loop of any sort, or else that loop is going to take a rather large performace hit, as you've noticed for yourself.

My recommendation?  At the start of a program:

DIM SHARED DTW AS LONG: DTW = _DESKTOPWIDTH

Unless you expect the user of resizing their desktop on you while the program is running, I'd ust get that information once, store it, and then go with that stored value throughout my program for Linux and Mac.

Gotcha, that makes sense. I had already set it up as a shared integer and it works just fine. Thanks again, Mr. Steve.
Reply




Users browsing this thread: 1 Guest(s)