[PB Cocoa] Cocoa companion library

Mac OSX specific forum
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: [PB Cocoa] Cocoa companion library

Post 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 ;)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: [PB Cocoa] Cocoa companion library

Post 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 ?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: [PB Cocoa] Cocoa companion library

Post 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() :)
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: [PB Cocoa] Cocoa companion library

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: [PB Cocoa] Cocoa companion library

Post 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 ;)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB Cocoa] Cocoa companion library

Post 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())
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: [PB Cocoa] Cocoa companion library

Post 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! ;)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: [PB Cocoa] Cocoa companion library

Post 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.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [PB Cocoa] Cocoa companion library

Post by Fred »

The pool is created at the very beginning of the program, in PureBasic init routine, before any program command.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: [PB Cocoa] Cocoa companion library

Post 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 :D

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.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: [PB Cocoa] Cocoa companion library

Post 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.
Image
Is this what you mean? If so... yes please :D
So like a warning message that fades in and fades out - semi transparent with white text.. very nice.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: [PB Cocoa] Cocoa companion library

Post 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.
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: [PB Cocoa] Cocoa companion library

Post by J. Baker »

Hey Wilbert, can you explain more on the UUID? Thanks!
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: [PB Cocoa] Cocoa companion library

Post 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 ?
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: [PB Cocoa] Cocoa companion library

Post by J. Baker »

I think that does. So basically, this unique id can then be attach to anything you need a unique id for?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply