0

I am looking for a way in c++ to do something like this OpenGL GLSL 3.30 in Ubuntu 14.10 mesa 10.1.3

Tobi
  • 45
  • 1
  • 8
  • The [documentation for the lwjgl ContextAttribs](http://legacy.lwjgl.org/javadoc/org/lwjgl/opengl/ContextAttribs.html) says it is equivalent to the openGL feature 'ARB_create_context', the [documentation for which](https://www.khronos.org/registry/OpenGL/extensions/ARB/GLX_ARB_create_context.txt) says it is accessed using the function 'glXCreateContextAttribsARB'. Have you tried using that? You can even find some example code [here](https://www.khronos.org/opengl/wiki/Tutorial:_OpenGL_3.0_Context_Creation_(GLX)). – Sean Burton Mar 12 '18 at 17:01

1 Answers1

8

Take a look at this code snippet (See https://learnopengl.com/code_viewer_gh.php?code=src/1.getting_started/1.2.hello_window_clear/hello_window_clear.cpp) for the rest of the code:

int main()
{
 // glfw: initialize and configure
 // ------------------------------
 glfwInit();
 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

 #ifdef __APPLE__
   glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif

" In the main function we first initialize GLFW with glfwInit, after which we can configure GLFW using glfwWindowHint. The first argument of glfwWindowHint tells us what option we want to configure, where we can select the option from a large enum of possible options prefixed with GLFW_. The second argument is an integer that sets the value of our option. A list of all the possible options and its corresponding values can be found at GLFW's window handling documentation. If you try to run the application now and it gives a lot of undefined reference errors it means you didn't successfully link the GLFW library.

Since the focus of this website is on OpenGL version 3.3 we'd like to tell GLFW that 3.3 is the OpenGL version we want to use. This way GLFW can make the proper arrangements when creating the OpenGL context. This ensures that when a user does not have the proper OpenGL version GLFW fails to run. We set the major and minor version both to 3. We also tell GLFW we want to explicitly use the core-profile. Telling GLFW explicitly that we want to use the core-profile means we'll get access to a smaller subset of OpenGL features (without backwards-compatible features we no longer need). Note that on Mac OS X you need to add glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); to your initialization code for it to work. " From: https://learnopengl.com/Getting-started/Hello-Window

Hope this helps.

Shades
  • 667
  • 1
  • 7
  • 22