Home > OS >  OpenGL Version not Supported for IntelliJ on Mac
OpenGL Version not Supported for IntelliJ on Mac

Time:09-10

I've been trying to learn glsl with OpenGL on IntelliJ and have been running into a few problems. First of my issues is with the #version.

#type vertex
#version 460

layout (location=0) in vec3 aPos;
layout (location=1) in vec4 aColor;

out vec4 fColor;

void main(){
    fColor = aColor;
    gl_Position = vec4(aPos, 1.0);
}

when I try to run this with my java in my java program I get an error message:

"ERROR: 0:1: '' :  version '460' is not supported"\

Even though when I looked up my graphics chip (Intel Iris Graphics 550) it says it supports the openGL 4.60 API.

I put:

System.out.println(glGetString(GL_SHADING_LANGUAGE_VERSION));

which returns 1.20, and I'm not sure if I can get that to change to my needed 4.6 some how.

I believe that is also why I am receive my other error message which is:

"ERROR: 0:3: 'layout' : syntax error: syntax error"

I've tried a few things like having the extensions:

#extension GL_ARB_explicit_attribute_location : require
#extension GL_ARB_explicit_uniform_location : require

but then I just get "not supported" errors for those as well.

Any suggestions are appreciated!

If you need more info about the code I'm working on I've just been trying to follow a YouTube tutorial at
around 1:36:00-1:46:00

EDIT:

Here is where I initialized the OpenGL context:

//initialize GLFW
if(!glfwInit()){
   throw new IllegalStateException("Unable to initialize GLFW.");
}

//configure GLFW
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);

//create the window
glfwWindow = glfwCreateWindow(this.width, this.height, this.title, NULL, NULL);
if(glfwWindow == NULL) {
    throw new IllegalStateException("Failed to create the window.");
}

glfwSetCursorPosCallback(glfwWindow, MouseListener::mousePosCallback);
glfwSetMouseButtonCallback(glfwWindow, MouseListener::mouseButtonCallback);
glfwSetScrollCallback(glfwWindow, MouseListener::mouseScrollCallback);
glfwSetKeyCallback(glfwWindow, KeyListener::keyCallback);
//make the OpenGl context current
glfwMakeContextCurrent(glfwWindow);
//Enable v-sync (buffer swapping)
glfwSwapInterval(1);

//Make window Visible
glfwShowWindow(glfwWindow);

GL.createCapabilities();

CodePudding user response:

I got it to work by adding

GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 3);

after my other window hints when I am initializing my context for my OpenGL window. then I changed the version in my .glsl file back to

#version 330 core

this also fixed my issue I had with the layout().

  • Related