OpenGL Imports

Mac OSX specific forum
User avatar
grabiller
Enthusiast
Enthusiast
Posts: 309
Joined: Wed Jun 01, 2011 9:38 am
Location: France - 89220 Rogny-Les-Septs-Ecluses
Contact:

OpenGL Imports

Post by grabiller »

Hello,

Not sure if I'm doing something wrong or what but with this simple code:

Code: Select all

ImportC "/System/Library/Frameworks/OpenGL.framework/OpenGL"
  glCullFace( mode.l )
EndImport

Debug "@glCullFace(): "+ Hex(@glCullFace())
I get the following error:
PureBasic - Assembler error
purebasic.asm:119:error: macho: sorry, cannot apply 32 bit absolute relocations in 64 bit mode, consider "[_symbol wrt rip]" for mem access, "qword" and "dq_foo" for pointers.

If I try to directly use glCullFace() then I get an "Invalid memory access."

I'm using PB x64 bit compiler on Mac OS X Yosemite v10.10.4.

Any idea what's going wrong ? (Or what I'm doing wrong ?)

(the same code works correctly on Windows & Linux with proper library path)

Cheers,
Guy.
guy rabiller | radfac founder / ceo | raafal.org
User avatar
Shardik
Addict
Addict
Posts: 2076
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: OpenGL Imports

Post by Shardik »

grabiller wrote:Any idea what's going wrong ? (Or what I'm doing wrong ?)
You should take care of these 3 hints:
- On MacOS you have to open at least a window and create a WindowedScreen or an OpenGLGadget
- The ImportC block isn't necessary anymore when using PB 5.3x
- glCullFace() needs a parameter like #GL_BACK, #GL_FRONT or #GL_FRONT_AND_BACK

The following two example codes are working on my OS X 10.9.5 (Mavericks) without problems when compiling for x86 and x64 with PB 5.31. They also work without a change on Kubuntu 14.04 x64 and PB 5.31 and Windows 7 SP1 x64 with PB 5.31 x86 and x64:

Code: Select all

OpenWindow(0, 270, 100, 640, 480, "OpenGL window", #PB_Window_Invisible)
OpenGLGadget(0, 0, 0, WindowWidth(0), WindowHeight(0))
Debug "glCullFace(#GL_BACK): $"+ Hex(glCullFace_(#GL_BACK))

Code: Select all

If InitSprite()
  OpenWindow(0, 270, 100, 640, 480, "OpenGL window", #PB_Window_Invisible)
  OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0))
  Debug "glCullFace(#GL_BACK): $"+ Hex(glCullFace_(#GL_BACK))
EndIf
Post Reply