Page 1 of 1

Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Thu Feb 28, 2013 5:14 pm
by gekkonier
Hi!

I just figured out how to create a Window with OpenGL context on OSX Lion with PB 5.11 beta 1 (x64) as AGL doesn't work anymore on cocoa apps.

Code: Select all

InitSprite()
 
ImportC "/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h"
   glClear(color.l)
   glClearColor(r.f,g.f,b.f,a.f)
EndImport

#GL_COLOR_BUFFER_BIT = $00004000
#GL_DEPTH_BUFFER_BIT = $00000100

OpenWindow (0, 100, 100, 256, 256, "OpenGL Window")
OpenWindowedScreen(WindowID(0), 0, 0, 256, 256, 0, 0, 0)

Repeat
   Select WaitWindowEvent(10)
      Case #PB_Event_CloseWindow
         Break
      Default
         glClearColor(1, 0.5, 0, 0)
         glClear(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
         FlipBuffers()
   EndSelect
ForEver
Have a nice day!

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Sun Mar 03, 2013 10:49 am
by Shardik
gekkonier wrote:I just figured out how to create a Window with OpenGL context on OSX Lion with PB 5.11 beta 1 (x64) as AGL doesn't work anymore on cocoa apps.
Thank you for your example but I demonstrated this already last year in a cross-platform example for Windows, Linux and MacOS X (Cocoa and Carbon framework). In that thread you even posted yourself: :wink:
gekkonier wrote:very nice!
thank you!

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Mon Mar 04, 2013 10:03 am
by gekkonier
Whoa, my brain!
I've forgotten where I lost it…

Thank you for the reminder :mrgreen:

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Mon Mar 04, 2013 10:51 am
by eesau

Code: Select all

ImportC "/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h"
   glClear(color.l)
   glClearColor(r.f,g.f,b.f,a.f)
EndImport
Huh, is it possible to import from a header file?

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Mon Mar 04, 2013 11:18 am
by gekkonier
That should answer another guy, I don't know exactly whats going on here - except that it works on my box here.

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Mon Mar 04, 2013 11:30 am
by Fred
No, this is a wrong. It is probably ignored by GCC, better don't put anything in import, as the screen lib does it for you.

Code: Select all

ImportC ""
   glClear(color.l)
   glClearColor(r.f,g.f,b.f,a.f)
EndImport

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Mon Mar 04, 2013 11:41 am
by gekkonier
Thank you for the info, fred.
This is gonna be straight forward then!

Re: Open GL Window on Lion with PB 5.11 beta 1 (x64)

Posted: Mon Mar 04, 2013 11:51 am
by eesau
Fred wrote:No, this is a wrong. It is probably ignored by GCC, better don't put anything in import, as the screen lib does it for you.

Code: Select all

ImportC ""
   glClear(color.l)
   glClearColor(r.f,g.f,b.f,a.f)
EndImport
I thought as much, though it's interesting that it doesn't result in an error message.