Sign in to follow this  

OpenGL OpenGL 4.x and OS X Mountain Lion

This topic is 1853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings,

I’m looking for a solution to load GL extensions manually on Mac OS X without the need of a library like Glew.

On Windows I use:[CODE]#include <windows.h>
#include <glcorearb.h>
LoadLibraryA("opengl32.dll");
GetProcAddress[/CODE]
…and it works beautifully.

On Linux I use:[CODE]#include <GL/glx.h>
#include <glcorearb.h>
install libX11-dev
link to X11 lib
glXGetProcAddress[/CODE]
…and the world is a wonderful place.

Now, afaik, glx doesn’t support context above version 2.1 on OS X and I’m trying to find a solution but I’m not sure which direction to take. I’m already digging into XQuartz but I can’t find any relevant example how to create a 4.x context so far.

To help me in my decision making, here is a few questions that could clear things up a bit:

1 - What is the most up to date technique to use OpenGL 4.x on Linux and OS X?
2 - Is there a common way to use OpenGL 4.x between Linux and OS X?
3 - With distribution in mind, is there a way to gather GL dependencies within the API root folder? Think of this as running a GL API on a vanilla OS without the need of installing anything.

Any help would be greatly appreciated. Edited by Neosettler

Share this post


Link to post
Share on other sites
As far as I'm aware, you only get OpenGL 3.2 in OSX.

The thing is, Apple provides the video drivers for its OS, so you get what they want to implement only. Currently, up to OpenGL 3.2.

EDIT: Ninja'd :D Edited by TheChubu

Share this post


Link to post
Share on other sites
I guess 3.2 will do just fine...

I'm confused, is there another graphic hardware-accelerated library beside OpenGL on OSX?

If my understanding is correct, all we really need from the OSes is to create function pointers to interact with the GPU. What am I missing?

What about the methodology itself, any hints on implementing the latest OpenGL capabilities? I'm asking because I'd like to avoid a GLX legacy pitfall again and stick with whatever the future of OpenGL might be on OSX. Edited by Neosettler

Share this post


Link to post
Share on other sites
[quote name='Neosettler' timestamp='1355631656' post='5011170']
I guess 3.2 will do just fine...

I'm confused, is there another graphic hardware-accelerated library beside OpenGL on OSX?

If my understanding is correct, all we really need from the OSes is to create function pointers to interact with the GPU. What am I missing?

What about the methodology itself, any hints on implementing the latest OpenGL capabilities? I'm asking because I'd like to avoid a GLX legacy pitfall again and stick with whatever the future of OpenGL might be on OSX.
[/quote]

well, imo glew is awesome, saved me from some headaches... but if you don't want to use it:
on win & linux all you need to do is get the function pointers (just like glew does)
on osx same thing, except the driver WILL NOT provide you with the function pointers beyond 3.2. Which means that there's no way you could get 4.x functionality.
The exception would be if you wrote your own graphics driver to support 4.x functionality, but I doubt you either have the skills or time or will to do so. (Neither do I)

Share this post


Link to post
Share on other sites
Alright, thank you for your inputs guys but I'm still clueless on which library to use... there seem to be several possible directions to take but the first one a picked led me to a dead end.

Any Jedi master could help clear this up? Which library is considered as prime development on OSX, OpenGL, Carbon, Cocoa, XCode, GLX, X11 or XQuartz? libraries... frameworks? Edited by Neosettler

Share this post


Link to post
Share on other sites
[quote name='Neosettler' timestamp='1355785295' post='5011846']
Alright, thank you for your inputs guys but I'm still clueless on which library to use.
[/quote]
I'm using gl3w and GLFW to get OpenGL 3.2 Core Profile contexxt.

Share this post


Link to post
Share on other sites
Well, as a matter of fact, gl3w uses GLX on OSX. I've been inspired by it in my current development and I'm trying to push it to the next level, without the need of another lib except from loading function pointers but I'm hitting a wall with OSX so far.

still digging, I'll look at GLFW Edited by Neosettler

Share this post


Link to post
Share on other sites
On OSX, you can use dlopen and dlsym to dynamically load all OpenGL API functions the drivers expose. This is the way it's done in my D binding to OpenGL. I don't know if that's the canonical or documented way to do it, but that bit was added to the binding by a Mac developer years ago.

I would recommend, however, that you not use GetProcAddress on Windows to load anything above OpenGL 1.1. According to all of the documentation I've ever read on the subject, that is not guaranteed to work. The right approach to take is to use GetProcAddress for everything up to 1.1, then after a context has been created you use wglGetProcAddress to pull in everything else. It might work just fine on recent versions of Windows, but on older versions with older drivers you're likely asking for trouble.

Share this post


Link to post
Share on other sites

I've been using XCode 4 with OGL in my projects. In XCode I just link "OpenGL.framework" then the API functions are exposed and ready to use, no need for wglGetProcAddress() like in windows.

 

Beware that using OGL from scratch (without GLEW etc...) on the mac can be a little trick and frustrating to do as there are only a few examples to find. The mac developer library is a good place to start. Here's the link is you want to go down that route.

 

And as others have stated previously, OSX only supports 3.2. And I don't think apple have plans to change that anytime soon unfortunately. This version on the mac will probably do most things you want though, if there was not a core function I was after, there was normally an ARB functions there that did the job.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Similar Content

    • By _OskaR
      Hi,
      I have an OpenGL application but without possibility to wite own shaders.
      I need to perform small VS modification - is possible to do it in an alternative way? Do we have apps or driver modifictions which will catch the shader sent to GPU and override it?
    • By xhcao
      Does sync be needed to read texture content after access texture image in compute shader?
      My simple code is as below,
      glUseProgram(program.get());
      glBindImageTexture(0, texture[0], 0, GL_FALSE, 3, GL_READ_ONLY, GL_R32UI);
      glBindImageTexture(1, texture[1], 0, GL_FALSE, 4, GL_WRITE_ONLY, GL_R32UI);
      glDispatchCompute(1, 1, 1);
      // Does sync be needed here?
      glUseProgram(0);
      glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer);
      glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                     GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, texture[1], 0);
      glReadPixels(0, 0, kWidth, kHeight, GL_RED_INTEGER, GL_UNSIGNED_INT, outputValues);
       
      Compute shader is very simple, imageLoad content from texture[0], and imageStore content to texture[1]. Does need to sync after dispatchCompute?
    • By Jonathan2006
      My question: is it possible to transform multiple angular velocities so that they can be reinserted as one? My research is below:
      // This works quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); quat quaternion2 = GEMultiplyQuaternions(quaternion1, GEQuaternionFromAngleRadians(angleRadiansVector2)); quat quaternion3 = GEMultiplyQuaternions(quaternion2, GEQuaternionFromAngleRadians(angleRadiansVector3)); glMultMatrixf(GEMat4FromQuaternion(quaternion3).array); // The first two work fine but not the third. Why? quat quaternion1 = GEQuaternionFromAngleRadians(angleRadiansVector1); vec3 vector1 = GETransformQuaternionAndVector(quaternion1, angularVelocity1); quat quaternion2 = GEQuaternionFromAngleRadians(angleRadiansVector2); vec3 vector2 = GETransformQuaternionAndVector(quaternion2, angularVelocity2); // This doesn't work //quat quaternion3 = GEQuaternionFromAngleRadians(angleRadiansVector3); //vec3 vector3 = GETransformQuaternionAndVector(quaternion3, angularVelocity3); vec3 angleVelocity = GEAddVectors(vector1, vector2); // Does not work: vec3 angleVelocity = GEAddVectors(vector1, GEAddVectors(vector2, vector3)); static vec3 angleRadiansVector; vec3 angularAcceleration = GESetVector(0.0, 0.0, 0.0); // Sending it through one angular velocity later in my motion engine angleVelocity = GEAddVectors(angleVelocity, GEMultiplyVectorAndScalar(angularAcceleration, timeStep)); angleRadiansVector = GEAddVectors(angleRadiansVector, GEMultiplyVectorAndScalar(angleVelocity, timeStep)); glMultMatrixf(GEMat4FromEulerAngle(angleRadiansVector).array); Also how do I combine multiple angularAcceleration variables? Is there an easier way to transform the angular values?
    • By dpadam450
      I have this code below in both my vertex and fragment shader, however when I request glGetUniformLocation("Lights[0].diffuse") or "Lights[0].attenuation", it returns -1. It will only give me a valid uniform location if I actually use the diffuse/attenuation variables in the VERTEX shader. Because I use position in the vertex shader, it always returns a valid uniform location. I've read that I can share uniforms across both vertex and fragment, but I'm confused what this is even compiling to if this is the case.
       
      #define NUM_LIGHTS 2
      struct Light
      {
          vec3 position;
          vec3 diffuse;
          float attenuation;
      };
      uniform Light Lights[NUM_LIGHTS];
       
       
    • By pr033r
      Hello,
      I have a Bachelor project on topic "Implenet 3D Boid's algorithm in OpenGL". All OpenGL issues works fine for me, all rendering etc. But when I started implement the boid's algorithm it was getting worse and worse. I read article (http://natureofcode.com/book/chapter-6-autonomous-agents/) inspirate from another code (here: https://github.com/jyanar/Boids/tree/master/src) but it still doesn't work like in tutorials and videos. For example the main problem: when I apply Cohesion (one of three main laws of boids) it makes some "cycling knot". Second, when some flock touch to another it scary change the coordination or respawn in origin (x: 0, y:0. z:0). Just some streng things. 
      I followed many tutorials, change a try everything but it isn't so smooth, without lags like in another videos. I really need your help. 
      My code (optimalizing branch): https://github.com/pr033r/BachelorProject/tree/Optimalizing
      Exe file (if you want to look) and models folder (for those who will download the sources):
      http://leteckaposta.cz/367190436
      Thanks for any help...

  • Popular Now