bool OPENGL_PBUFFER::
Create(int width, int height)
{
    if (pbuffer) {
        LOG::cerr << "Destroying old pbuffer before creating new one" << std::endl;
        Destroy();
    }

    GLint attributes[] = {AGL_RGBA,AGL_DOUBLEBUFFER,AGL_NONE};
    AGLPixelFormat format = aglChoosePixelFormat(NULL, 0, attributes);
    if(format==NULL){
        LOG::cout<<"Could not set up the pixel format"<<std::endl;return false;}
    
    AGLContext context = aglCreateContext(format, NULL);
    if(context==NULL){
        LOG::cout<<"Could not set up the pbuffer context"<<std::endl;return false;}
    aglSetCurrentContext(context);

    if(!aglCreatePBuffer(width, height, GL_TEXTURE_2D, GL_RGBA, 0, &pbuffer)){
        LOG::cout<<"Error: couldn't create pbuffer"<<std::endl;
        LOG::cout<<aglErrorString(aglGetError());
        return false;
    }

    if(!aglSetPBuffer(context, pbuffer, 0, 0, aglGetVirtualScreen(context))){
        LOG::cout<<"Error: couldn't set pbuffer"<<std::endl;
        LOG::cout<<aglErrorString(aglGetError());
        return false;
    }
       
    return true;  /* Success!! */
}
示例#2
0
bool Window::configInitAGLPBuffer()
{
    AGLContext context = getAGLContext();
    if( !context )
    {
        setError( ERROR_AGLWINDOW_NO_CONTEXT );
        return false;
    }

    // PBuffer
    const PixelViewport& pvp = getWindow()->getPixelViewport();
    AGLPbuffer pbuffer;
    if( !aglCreatePBuffer( pvp.w, pvp.h, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA,
                           0, &pbuffer ))
    {
        setError( ERROR_AGLWINDOW_CREATEPBUFFER_FAILED );
        LBWARN << getError() << ": " << AGLERROR << std::endl;
        return false;
    }

    // attach to context
    if( !aglSetPBuffer( context, pbuffer, 0, 0, aglGetVirtualScreen( context )))
    {
        setError( ERROR_AGLWINDOW_SETPBUFFER_FAILED );
        LBWARN << getError() << ": " << AGLERROR << std::endl;
        return false;
    }

    setAGLPBuffer( pbuffer );
    return true;
}
 void OSXPBuffer::createPBuffer()
 {
     LogManager::getSingleton().logMessage( "OSXPBuffer::createPBuffer()" );
     
     GLint attrib[] = { AGL_NO_RECOVERY, GL_TRUE, AGL_ACCELERATED, GL_TRUE, AGL_RGBA, AGL_NONE };
     AGLPixelFormat pixelFormat = aglChoosePixelFormat(NULL, 0, attrib);
     mAGLContext = aglCreateContext(pixelFormat, NULL);
     
     //mAGLContext = aglGetCurrentContext();
     aglCreatePBuffer( mWidth, mHeight, GL_TEXTURE_2D, GL_RGBA, 0, &mPBuffer );
     
     GLint vs = aglGetVirtualScreen( mAGLContext );
     aglSetPBuffer( mAGLContext, mPBuffer, 0, 0, vs );
     mContext = OGRE_NEW OSXCarbonContext(mAGLContext, pixelFormat);
 }
AGLPbuffer
glitz_agl_pbuffer_create (glitz_agl_thread_info_t *thread_info,
			  int                     width,
			  int                     height)
{
    AGLPbuffer pbuffer;
    glitz_gl_enum_t target;

    if (!POWER_OF_TWO (width) || !POWER_OF_TWO (height)) {
	if (thread_info->agl_feature_mask &
	    GLITZ_AGL_FEATURE_TEXTURE_RECTANGLE_MASK)
	    target = GLITZ_GL_TEXTURE_RECTANGLE;
	else
	    return (AGLPbuffer) 0;
    } else
	target = GLITZ_GL_TEXTURE_2D;

    aglCreatePBuffer (width, height, target, GLITZ_GL_RGBA, 0, &pbuffer);

    return pbuffer;
}