I am using a Macbook air with OS X 10.9.2. My graphics card (Intel HD Graphics 4000 1024 MB) Apple declares that you can read the Macbook sound with the technical specifications supported by me up to Opengl 4.1 here → http://support.apple.com/kb/HT5942 . however, when I use SDL2 and force the system to use opengl 3.2, and when I request the version of OpenGL using glGetString () , I get the following line:
2.1 INTEL-8.24.11
my code is:
#include <iostream>
#include <SDL2/SDL.h>
#include <opengL/gl3.h>
using namespace std;
void sdldie(const char *msg)
{
printf("%s: %s\n", msg, SDL_GetError());
SDL_Quit();
exit(1);
}
void checkSDLError(int line = -1)
{
#ifndef NDEBUG
const char *error = SDL_GetError();
if (*error != '\0')
{
printf("SDL Error: %s\n", error);
if (line != -1)
printf(" + line: %i\n", line);
SDL_ClearError();
}
#endif
}
int main(int argc, const char * argv[])
{
SDL_Window *mainwindow;
SDL_GLContext maincontext;
if (SDL_Init(SDL_INIT_VIDEO) < 0)
sdldie("Unable to initialize SDL");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
mainwindow = SDL_CreateWindow("Hello", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!mainwindow)
sdldie("Unable to create window");
checkSDLError(__LINE__);
maincontext = SDL_GL_CreateContext(mainwindow);
checkSDLError(__LINE__);
cout << glGetString(GL_VERSION);
SDL_GL_SetSwapInterval(1);
glClearColor ( 1.0, 0.0, 0.0, 1.0 );
glClear ( GL_COLOR_BUFFER_BIT );
SDL_GL_SwapWindow(mainwindow);
SDL_Delay(2000);
glClearColor ( 0.0, 1.0, 0.0, 1.0 );
glClear ( GL_COLOR_BUFFER_BIT );
SDL_GL_SwapWindow(mainwindow);
SDL_Delay(2000);
glClearColor ( 0.0, 0.0, 1.0, 1.0 );
glClear ( GL_COLOR_BUFFER_BIT );
SDL_GL_SwapWindow(mainwindow);
SDL_Delay(2000);
SDL_GL_DeleteContext(maincontext);
SDL_DestroyWindow(mainwindow);
SDL_Quit();
return 0;
}
source
share