| 132 | } |
| 133 | |
| 134 | bool |
| 135 | GLWindow::initGL (int bits) |
| 136 | { |
| 137 | #ifdef __APPLE__ |
| 138 | SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 2); |
| 139 | SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 1); |
| 140 | #endif |
| 141 | SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); |
| 142 | SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, 16); |
| 143 | SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8); |
| 144 | SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE, 8); |
| 145 | SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE, 8); |
| 146 | SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE, 8); |
| 147 | |
| 148 | glContext = SDL_GL_CreateContext (window); |
| 149 | if (!glContext) |
| 150 | { |
| 151 | std::cerr << "Failed to create OpenGL context: " << SDL_GetError () |
| 152 | << std::endl; |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | if (SDL_GL_MakeCurrent (window, glContext) < 0) |
| 157 | { |
| 158 | std::cerr << "Failed to make OpenGL context current: " << SDL_GetError () |
| 159 | << std::endl; |
| 160 | return false; |
| 161 | } |
| 162 | |
| 163 | // Initialize GLEW with experimental flag |
| 164 | glewExperimental = GL_TRUE; |
| 165 | GLenum err = glewInit (); |
| 166 | if (err != GLEW_OK) |
| 167 | { |
| 168 | std::cerr << "Failed to initialize GLEW: " << glewGetErrorString (err) |
| 169 | << std::endl; |
| 170 | return false; |
| 171 | } |
| 172 | |
| 173 | return true; |
| 174 | } |
| 175 | |
| 176 | bool |
| 177 | GLWindow::createGLWindow (const char *title) |
nothing calls this directly
no outgoing calls
no test coverage detected