I have this app running on both my Windows and Linux boxes just fine. I’m trying this simple/stupid shader that sets the color of the “quads” (triangle strips with two triangles), and it appears my mac quietly decides to go fixed-function or something. Everything is black or white. Here’s the shader:
All of the uniform locations are -1 when I check them. Mind you, this works on Linux and Windows just fine… but not on my mac. Now, something to be said, I’m in the middle of porting a lot of old OpenGL 2 code to OpenGL 3+, so I’ve not set a core profile. Might this be the cause?
It’s more likely the case that you either didn’t post your actual shader code or your code doesn’t work on any platform.
I say that because your shader has a suspicious lack of "
", outside of the first one. Now technically you don’t need them in most cases, but since your fragment shader uses “//” comments…
[QUOTE=Alfonse Reinheart;1264220]It’s more likely the case that you either didn’t post your actual shader code or your code doesn’t work on any platform.
I say that because your shader has a suspicious lack of "
", outside of the first one. Now technically you don’t need them in most cases, but since your fragment shader uses “//” comments…[/QUOTE]
The // is outside the quotes, so they’re not really in the shader. Note each line is separately quoted.
That is my actual shader code; I’m working on upgrading an old in-game windowing system which used the fixed-function pipeline to produce simple user interface… in the future I intend to make it more fancy, but for now, a flat color windowing system is my target.
Well, I tried using a core profile and whatnot in my application, and now GLFW doesn’t open the window; returning NULL for the context (on Mac and Linux). So I deferred to a simpler approach, rather than work with my application which still intermingles a lot of legacy/deprecated OpenGL (working on upgrading…) I decided to attack it from a much simpler angle, and try the single triangle tutorial (tutorial #2) from opengl-tutorial.org. I got the same results; it refused to open the window and present anything but a NULL pointer. I am wondering if this may be because:
I am building this with g++ rather than OS/X’s Clang compiler (why would that make any difference?)
My video card + OS/X Maverick is no longer supported (doubt it)
I’m not linking in the right library? (I see a libGL.dylib and libGL.1.dylib… nothing else)
After reviewing the code in the tutorial, I found that this (required by mac) line was missing:
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
And once added, the triangle tutorial was happy.
So this brings up the question… If I link deprecated OpenGL code into my application and I try to use a 3.2+ profile, does the system recognize this and refuse to open a context? It appears to be so… on both Mac and Linux. I’m asking because hopefully there’s somebody with more insight into this than I.
I had been programming OpenGL for years, but my work (microcontrollers and Linux kernels; no graphics) took me away promptly after GLSL appeared, which was before OpenGL 3 ever saw the light of day. Now I’m getting back into it and … whoa. What a change.
Learn about profiles. See also platform documentation about profiles.
TLDR: On OSX, GL3.2 and later contexts are always core and forward-compatible; all deprecated features are removed.
If you look at glfw you can see how it enforces OSX’s requirement for forward-compatible contexts.
If I link deprecated OpenGL code into my application and I try to use a 3.2+ profile, does the system recognize this and refuse to open a context?
Context creation is one thing, linking API is another, calling API is another.
[QUOTE=robstoddard;1264219]All of the uniform locations are -1 when I check them. Mind you, this works on Linux and Windows just fine… but not on my mac. Now, something to be said, I’m in the middle of porting a lot of old OpenGL 2 code to OpenGL 3+, so I’ve not set a core profile. Might this be the cause?
[/QUOTE]
IIRC, MacOSX offers a choice of 2.1 compatibility profile or 3.x core profile. Unlike Windows or Linux, there is no 3.x compatibility profile, so if you use a mix of 3.x features and legacy features, something is going to fail.
As a start, I’d suggest checking that the shaders compiled successfully, the program linked successfully, and that glGetError() isn’t reporting any errors.