c++ - Enabling OpenGL 4.1 under OS X 10.10 with GLEW, GLFW and g++ compilation -


i have 2014 rmbp, updated latest version of os x should guarantee me compatibility opengl 4.1. have put minimal working example:

#include <iostream>  #include "gl/glew.h" #include <glfw/glfw3.h>  using namespace std;  int main(){     int windowwidth = 800;     int windowheight = 800;     string windowtitle = "title";      glfwdefaultwindowhints();     glfwwindowhint(glfw_opengl_forward_compat, gl_true);     glfwwindowhint(glfw_opengl_profile, glfw_opengl_core_profile);     glfwwindowhint(glfw_context_version_major, 4);     glfwwindowhint(glfw_context_version_minor, 1);      if( !glfwinit() )     {         cerr << "failed initialize glfw.\n";         return 1;     } else {         clog << "initialized glfw." << endl;     }      glfwwindow* pwindow = glfwcreatewindow(windowwidth, windowheight, windowtitle.c_str(), 0, null);      glfwsetwindowpos(pwindow, 700, 200);     glfwmakecontextcurrent(pwindow);     if( pwindow == null )     {         cerr << "failed open glfw window.\n";         glfwterminate();         return 1;     }      std::cout << "gl version: " << glgetstring(gl_version) << "\n";     std::cout << "glsl version: " << glgetstring(gl_shading_language_version) << "\n";     std::cout << "vendor: " << glgetstring(gl_vendor) << std::endl;     std::cout << "renderer: " << glgetstring(gl_renderer) << std::endl;      while (!glfwwindowshouldclose(pwindow))     {         glfwpollevents();     }     glfwdestroywindow(pwindow);     return 0; } 

this opens window works fine, it's outputting following: gl version: 2.1 intel-10.0.86 glsl version: 1.20 vendor: intel inc. renderer: intel iris opengl engine

which wrong! should getting 4.1 compatibility. downloaded examples @ https://github.com/tomdalling/opengl-series , under xcode, go 4.1 know computer capable of it.

this larger project; did try importing project xcode, merging tom dalling's project, won't work, gl 2.1.

i'm compiling above code

g++ main.cpp -o gltest -lglfw -framework cocoa -framework opengl -framework iokit -framework corevideo \ 

... maybe i'm missing option. thank help!

reading window creation hints at glfw site, you'll find:

these hints set default values each time library initialized glfwinit

and tom dalling's (working) code calls glfwinit before hinting version while yours afterwards.

so suspect may have it.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -