Esempio n. 1
0
void GLGraphicsImpl::initOpenGL( GLContext& context ) {
    //Is this the first time we've called this function?
    //If m_initialized is "false", set it to "true" and continue.
    //Otherwise, stop here.
    bool expect = false;
    if( !m_initialized.compare_exchange_strong( expect, true ) )
        return;

    //Activate our context temporarily
    context.begin();

    //Now that a context is loaded we can load extensions
    loadOpenGLExtensions();

    //Get the version of OpenGL we're using and log it
    GLint major, minor;
    glGetIntegerv( GL_MAJOR_VERSION, &major );
    glGetIntegerv( GL_MINOR_VERSION, &minor );

    logInfo( ( boost::format( "OpenGL version is %d.%d." ) % major % minor ).str() );

    //Log supported extensions
    GLint extensions;
    glGetIntegerv( GL_NUM_EXTENSIONS, &extensions );
    logInfo( "Supported extensions:" );
    for( GLuint i = 0; i < (GLuint)extensions; ++i )
        logInfo( (
            boost::format( "%4d:    %s" ) %
            (i+1) %
            glGetStringi( GL_EXTENSIONS, i )
        ).str() );

    //Done using it
    context.end();
}
Esempio n. 2
0
SDL_GLContext WindowService::createSDLGLContext() {
	SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
	SDL_GLContext context = SDL_GL_CreateContext(m_sdlWindow);

	if (context == NULL)
		throw new IWindowService::FailedToInitializeWindow();

	SDL_GL_SetSwapInterval(1);
	loadOpenGLExtensions();

	return context;
}