mdparker / Derelict3

A collection of dynamic D bindings to C libraries, useful for multimedia and game development.
169 stars 35 forks source link

OpenGL 3.2 on OS X Lion #28

Closed brendanzab closed 12 years ago

brendanzab commented 12 years ago

Lion (finally) supports OpenGL 3.2, but it doesn't seem to be working with Derelict3. I made a stack overflow question, basically stating that when I try DerelictGL3.reload() it only sets the OpenGL to version 2.1.

One of the answerers suggested I look at OpenGL Profiles (Mac OS X v10.7) for more information. I would attempt editing cgl.d to try to fix the problem, but I'm not sure where to start. Any ideas? Or would you be able to assist with this?

brendanzab commented 12 years ago

Would it help if I sent the 10.7 headers from OpenGL.framework to you? I've been digging through them, and I've found quite a few instances where things aren't defined in cgl.d, for example this, in CGLTypes.h:

/*
** OpenGL Implementation Profiles
*/
typedef enum _CGLOpenGLProfile {
    kCGLOGLPVersion_Legacy   = 0x1000,    /* choose a Legacy/Pre-OpenGL 3.0 Implementation */
    kCGLOGLPVersion_3_2_Core = 0x3200,    /* choose an OpenGL 3.2 Core Implementation      */
} CGLOpenGLProfile;

I've been having a go at changing cgl.d based on the headers, but yeah…

i have no idea what i'm doing

mdparker commented 12 years ago

Well, Derelict internally only uses one CGL function, and that's CGLGetCurrentContext, which I assume is also part of 10.7. So it doesn't matter what is in cgl.d and what isn't. The context creation is happening on the GLFW side.

This comment is puzzling: "At derelict cgl.d, the code is from OS X 10.4. If you run glfw without Derelict with the snippet you provide, you get a correct OpenGL 3.2 context" That really shouldn't matter. The CGL code is loaded dynamically just like everything else and isn't being called at all. As long as GLFW is linking with the right stuff, it should be fine.

One test to try, though, just in case dynamically pulling older function addresses into the process space really is screwing things up. Try calling DerelictGL3.load after you have finished creating your window. That way, the CGL stuff won't be loaded before GLFW creates the context. I don't see how that can change anything, but it's worth a try.

Beyond that, there' s not much I can do. I don't have access to a Mac.

brendanzab commented 12 years ago

Fixed it! All I had to do was add this:

glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

:)

mdparker commented 12 years ago

Ah, I see. I didn't notice in your original SO post that you were calling glfwOpenWindowHint after creating the window. I should have caught that.

brendanzab commented 12 years ago

Haha no worries. I learned a ton of new stuff in the process of solving it. :)

tyoc213 commented 12 years ago

Hi there, I know this isn't the exact place to ask, but haven't found much info, so I will ask anyway and hope people don't get mad at me.

Im learning OpenGL but I want to focus on 4 and above, so I found that an MBA doesn't support it, I'm following http://openglbook.com/the-book/chapter-1-getting-started/ so if you can say me how to back port 4.0 to 3.2, it use FreeGLUT (which you can't use on a mac) and there are some diferences like functionName_APPLE for some functions.

The code right now is https://gist.github.com/c6c88f5125734c16813a My gist is also working with compatibility profile but I dont know how to set it up with GLUT provided with OSX.

So I have downloaded shader builder app (comes with dev tools I guess) and shader maker (downloaded), but bot of them seem like they are working in compatibility mode, because I have downloaded an app called some like openGL extension viewer, the thing is that compatibility profile you only get up to OpenGL 2.1 and shader model 1.2 with core profile you get to OpenGL 3.2 and shading language 1.50.

mdparker commented 12 years ago

You are correct. This is not the place for this sort of thing. I recommend you take it to the forums at opengl.org, or the OpenGL forum at GameDev.net.