I have an SDL2 application in which I want to create an OpenGL 3.2 context. I googled a bit and started following this tutorial: http://open.gl/context#SDL
Everything seems to work except for the last step. When I had to implement this piece of code:
GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
printf("%u\n", vertexBuffer);
My application doesn't seem to have a reference to the functor that should be there. I know there are some people here who had the same problem but I didn't find a solution there. When I output the GL_VERSION it says it's 1.1.0 although I say it should be 3.2.0. Here's my code:
// START SDL
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
logSDLError(std::cout, "SDL_Init");
return 1;
}
// SETUP OPENGL SETTINGS
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
// OPENING WINDOW
m_pWindow = SDL_CreateWindow("SDL/OpenGL Game Client - With Networking Library", 100, 100, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL);
if (m_pWindow == nullptr)
{
logSDLError(std::cout, "CreateWindow");
return 2;
}
// CREATE AN OPENGL CONTEXT ASSOCIATED WITH THE WINDOW.
m_GlContext = SDL_GL_CreateContext(m_pWindow);
if( m_GlContext == NULL )
{
printf( "OpenGL context could not be created! SDL Error: %s\n", SDL_GetError() );
}
//Initialize GLEW
glewExperimental = GL_TRUE;
GLenum glewError = glewInit();
if( glewError != GLEW_OK )
{
printf( "Error initializing GLEW! %s\n", glewGetErrorString( glewError ) );
}
printf((char*)glGetString(GL_VERSION));
I have a FirePro graphics card that should be able to run OpenGL 4.0. I checked my driver updates and everything should be fine + I get no compile warnings saying that something might be wrong with OpenGL or Glew or SDL.
One thing I had to do to make glGetString() working was to include GL\\freeglut.h. I don't really know why that is because it doesn't say so in the tutorial I followed.
I found the problem. I forgot to mention that I'm using MSTSC to remote from my desktop to my laptop (which is easier to work) and apparently this changes the graphics device.
I tried opening my application from the actual laptop and suddenly it worked, giving the right OpenGL version and everything.
Stupid mistake, I should've found this earlier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.