Reputation: 1484
I am unable to create GLFW windows with versions past 2.1 after install glfw through brew using the command brew install glfw
.
basically my problem is that this code works:
import qualified Graphics.UI.GLFW as GLFW
configAndCreateWindow :: IO (Maybe GLFW.Window)
configAndCreateWindow = do
GLFW.windowHint (GLFW.WindowHint'ContextVersionMajor 2)
GLFW.windowHint (GLFW.WindowHint'ContextVersionMinor 1)
GLFW.createWindow 100 100 "test" Nothing Nothing
main :: IO ()
main = do
GLFW.init
maybeWindow <- configAndCreateWindow
case maybeWindow of
Nothing -> putStrLn "Failure :("
Just _ -> putStrLn "Success!"
but if I change
GLFW.windowHint (GLFW.WindowHint'ContextVersionMajor 2)
GLFW.windowHint (GLFW.WindowHint'ContextVersionMinor 1)
to
GLFW.windowHint (GLFW.WindowHint'ContextVersionMajor 3)
GLFW.windowHint (GLFW.WindowHint'ContextVersionMinor 3)
it breaks.
Just to make sure it didn't have to do with GLFW-b I also wrote a c program:
#define GLFW_INCLUDE_GL_3
#include <GLFW/glfw3.h>
#include <stdio.h>
int main ()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
GLFWwindow* window = glfwCreateWindow(800, 600, "GLFW test", NULL, NULL);
if (window == NULL) {
printf("Success!");
} else {
printf("Failure :(");
}
}
and if I change context version number it works just like with the Haskell example.
Upvotes: 2
Views: 1548
Reputation: 22167
When requesting an OpenGL context on MacOS, two additional flags have to be set:
glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
Upvotes: 5