PDA

View Full Version : Using OpenGL Core Profile with OpenGL 3.0



robinfaury
03-03-2016, 01:36 AM
Hi,

I want to use OpenGL 3.0 in a core profile context.
I use GLFW with this code :

#include <iostream>

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>

void main() {
if (!glfwInit())
{
return;
}

glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

GLFWwindow* window;
window = glfwCreateWindow(1024, 768, "testGL", NULL, NULL);
if (window == NULL) {
fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
glfwTerminate();
return;

}
glfwMakeContextCurrent(window);
glewExperimental = true; // Needed in core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEW\n");
return;
}
}


If my minor version is lether than 2 the code dosen't works.
My question is : wath is the minimum OpenGL version to use Core Profile. (I think is 3.0 but it seem 3.2).

Regards,
Robin

mhagain
03-03-2016, 02:29 AM
All outlined here: https://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts

Aleksandar
03-03-2016, 02:30 AM
Ptofiles were introduced in GL 3.2.

robinfaury
03-03-2016, 05:31 AM
"The 3.0 form of context creation allows the user to ask for a profile. Initially, only one profile was available: core" (wiki)
If I understand, OpenGL 3.0 must be used in core profile.
But with GLFW, why I can't create an OpenGL 3.0 context ?

Aleksandar
03-03-2016, 08:23 AM
"The 3.0 form of context creation allows the user to ask for a profile. Initially, only one profile was available: core" (wiki)
If I understand, OpenGL 3.0 must be used in core profile.
No. There is on profiles in OpenGL 3.0. Alfonse noticed the error and changed it today.

By the way, wikis should never be used as references.


But with GLFW, why I can't create an OpenGL 3.0 context ?
I don't know the answer since I've never used GLFW. The full control is the main reason I like to do everything by myself.
Why do you need GL 3.0 exactly?

robinfaury
03-03-2016, 08:45 AM
Ok so using OpenGL 3.0 in Core Profile is a mistake.
If I want to use OpenGL context in Core Profile I have to use OpenGL 3.2.
Thant for your answer :)