Page 2 of 7
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Aug 10, 2012 12:31 pm
by Polo
You're doing a nice work here!!
Any chances you'd be able to create an OpenGL context on a PB window? There's code for this on the forum for all platforms, but obviously not for Cocoa

Re: [PB Cocoa] Cocoa companion library
Posted: Fri Aug 10, 2012 1:21 pm
by wilbert
Polo wrote:Any chances you'd be able to create an OpenGL context on a PB window? There's code for this on the forum for all platforms, but obviously not for Cocoa

Yes, there's NSOpenGLView.
Basically it's a bit like a gadget. You can define a rectangle and add it to a window.
The problem is that I know nothing about OpenGL. Can you point me to some short code that would be useful to test if it works ?
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Aug 10, 2012 1:23 pm
by Polo
I haven't got any code unfortunately, I don't know Cocoa too much!
Actually it'd be great to have a cross platform OpenGLGadget()

Re: [PB Cocoa] Cocoa companion library
Posted: Fri Aug 10, 2012 2:01 pm
by J. Baker
@Polo
Not sure what you are trying to do exactly but there is already OpenGL in PB. If you are looking for some king of scrolling text effect or something, it can be done.
Re: [PB Cocoa] Cocoa companion library
Posted: Fri Aug 10, 2012 2:41 pm
by Polo
J. Baker wrote:@Polo
Not sure what you are trying to do exactly but there is already OpenGL in PB. If you are looking for some king of scrolling text effect or something, it can be done.
I know, though there is not OpenGL Gadget, ie just a part of a window ready to use with the opengl API

Re: [PB Cocoa] Cocoa companion library
Posted: Sat Aug 11, 2012 1:42 pm
by Fred
You can use a WindowedScreen(), and use glcommand in it (indeed you need to use opengl subsystem on windows). Should work on all OS
@wilbert: i looked at your source, and you don't need to create the autorelease pool for each command, as PB already have one (which is flushed in Wait/WindowEvent())
Re: [PB Cocoa] Cocoa companion library
Posted: Sat Aug 11, 2012 1:44 pm
by Polo
Fred wrote:You can use a WindowedScreen(), and use glcommand in it (indeed you need to use opengl subsystem on windows). Should work on all OS
@wilbert: i looked at your source, and you don't need to create the autorelease pool for each command, as PB already have one (which is flushed in Wait/WindowEvent())
Thanks for the tip, will try that!

Re: [PB Cocoa] Cocoa companion library
Posted: Sat Aug 11, 2012 6:26 pm
by wilbert
Fred wrote:@wilbert: i looked at your source, and you don't need to create the autorelease pool for each command, as PB already have one (which is flushed in Wait/WindowEvent())
Thanks for the info Fred.
Is the pool already allocated in the beginning ?
I was wondering what happens to objects created before the repeat loop that handles events.
Some commands to extend the capability of the gadgets would probably be called after the creation of the gadget but before the first event loop.
Re: [PB Cocoa] Cocoa companion library
Posted: Sat Aug 11, 2012 6:29 pm
by Fred
The pool is created at the very beginning of the program, in PureBasic init routine, before any program command.
Re: [PB Cocoa] Cocoa companion library
Posted: Sun Aug 12, 2012 6:18 am
by wilbert
Fred wrote:The pool is created at the very beginning of the program, in PureBasic init routine, before any program command.
That's great
Added a few more commands
The sound commands support all sound formats that are supported by either Core Audio or QuickTime.
Sound_Catch (*MemoryAddress, Size) - Catch sound from memory.
Sound_IsPlaying (SoundObject) - Returns #True is the sound object is playing.
Sound_Load (FileName.s) - Load sound.
Sound_Play (SoundObject [, Loop]) - Starts playing the sound object.
Sound_Release (SoundObject) - Releases the sound object.
Sound_SetVolume (SoundObject, Volume.d) - Sets the volume of the sound object.
Sound_Stop (SoundObject) - Stops playing the sound object.
UUID_Create() - Returns a universally unique identifier.
Window_SetAlpha (WindowID, Alpha.d)- Sets the alpha value of the window.
Re: [PB Cocoa] Cocoa companion library
Posted: Sun Aug 12, 2012 7:24 am
by jesperbrannmark
When you are talking about "opengl" text in a normal window.
I dont really understand that. I have seen this in multiple Mac OS X applications that look great.

Is this what you mean? If so... yes please
So like a warning message that fades in and fades out - semi transparent with white text.. very nice.
Re: [PB Cocoa] Cocoa companion library
Posted: Sun Aug 12, 2012 8:23 am
by wilbert
@Jesper, I don't know what you mean.
If all you want is some flashing message on top of a window, OpenGL is a lot of overkill.
Re: [PB Cocoa] Cocoa companion library
Posted: Sun Aug 12, 2012 8:33 am
by J. Baker
Hey Wilbert, can you explain more on the UUID? Thanks!
Re: [PB Cocoa] Cocoa companion library
Posted: Sun Aug 12, 2012 9:22 am
by wilbert
J. Baker wrote:Hey Wilbert, can you explain more on the UUID? Thanks!
It's just a small command that internally creates a CFUUID and outputs it as a PureBasic string.
It looked useful enough to me to put it in.
According to the Apple docs
Apple docs wrote:UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values guaranteed to be unique. A UUID is made unique over both space and time by combining a value unique to the computer on which it was generated—usually the Ethernet hardware address—and a value representing the number of 100-nanosecond intervals since October 15, 1582 at 00:00:00.
The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067.
Does that help ?
Re: [PB Cocoa] Cocoa companion library
Posted: Sun Aug 12, 2012 9:46 am
by J. Baker
I think that does. So basically, this unique id can then be attach to anything you need a unique id for?