 |
 |
Loopy
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
In GLUT, you can make a draw loop pretty easily...
How can I make an infinite loop in Cocoa, while keeping the functionality of the buttons and UI?
I want a continuous rotational display, but to have sliders & buttons control the rotation. I can pretty much only trigger my drawing function in response to buttons.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2000
Status:
Offline
|
|
You just need a thread. Try looking at the documentation on NSThread. I'm still learning C/Obj-C so someone else may be able to help you more. It's a start though.
If nothing else it moves your question to the top for a few. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
No not NSThread! Use + (void)detachDrawingThread  SEL)selector toTarget  id)target withObject  id)argument in NSApplication or your program will probably crash when you try to update the interface from another thread.
[This message has been edited by Dalgo (edited 01-23-2001).]
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
I'll try that. Can I use POSIX threads, just out of curiousity?
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
I'll try that. Can I use POSIX threads, just out of curiousity?
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
The rason for using that method in NSApplication to update the interface vs. just using NSThread is because it creates some locks so that your second thread isn't trying to update the interface at the same time that another thread is. If you can figure out some way to make the locks required to update the interface from a POSIX thread then there is no reason why you can't.
However, if you can't figure out how to make those locks (I have no idea how to do that, I think they are private anyway) then there is another possibility. It is possible, and also very likely, that by default, none of the methods in appkit are safe to update the interface but when you make a thread from that method in NSApp they all become thread safe in that respect and stay that way. In order to test that you could spin off a drawing thread in order to do some menial task and then use your POSIX threads to do whatever you want in your program to play with the interface. If you don't have any probelms then it's pretty safe to assume that the interface stays thread safe after the first drawing thread is spun off.
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
Hmmm... Apple's documentation on detachDrawingThread: is non-Existant, as far as I can tell. How do I use it? Or, if there are any example applications, that would be awsome.
Thanks.
|
|
"Against stupidity, the gods themselves contend in vain" (Schiller)
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
Just use it in the same way that you'd use the NSThread method to make a new thread. One thing to keep in mind, if you don't already know, the method is in NSApplication but you might have to use NSApp as the object (as is true with many things in NSApplication). I don't remember offhand; I'm not at my computer now so I don't know. If using NSApplication as the object doesn't work then use NSApp or vice versa.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|