void GLWindow::queryDrawableConfig( DrawableConfig& dc ) { dc = DrawableConfig(); // GL version const char* glVersion = (const char*)glGetString( GL_VERSION ); if( !glVersion ) // most likely no context { LBWARN << "glGetString(GL_VERSION) returned 0, assuming GL version 1.1" << std::endl; dc.glVersion = 1.1f; } else dc.glVersion = static_cast<float>( std::atof( glVersion )); if( dc.glVersion >= 3.2f ) { GLint mask; EQ_GL_CALL( glGetIntegerv( GL_CONTEXT_PROFILE_MASK, &mask )); dc.coreProfile = mask & GL_CONTEXT_CORE_PROFILE_BIT; } TEST_GLEW_VERSION( 1, 1 ); TEST_GLEW_VERSION( 1, 2 ); TEST_GLEW_VERSION( 1, 3 ); TEST_GLEW_VERSION( 1, 4 ); TEST_GLEW_VERSION( 1, 5 ); TEST_GLEW_VERSION( 2, 0 ); TEST_GLEW_VERSION( 2, 1 ); TEST_GLEW_VERSION( 3, 0 ); TEST_GLEW_VERSION( 3, 1 ); TEST_GLEW_VERSION( 3, 2 ); TEST_GLEW_VERSION( 3, 3 ); TEST_GLEW_VERSION( 4, 0 ); TEST_GLEW_VERSION( 4, 1 ); TEST_GLEW_VERSION( 4, 2 ); TEST_GLEW_VERSION( 4, 3 ); #ifdef GLEW_VERSION_4_5 TEST_GLEW_VERSION( 4, 4 ); TEST_GLEW_VERSION( 4, 5 ); #endif // Framebuffer capabilities GLboolean result; EQ_GL_CALL( glGetBooleanv( GL_STEREO, &result )); dc.stereo = result; EQ_GL_CALL( glGetBooleanv( GL_DOUBLEBUFFER, &result )); dc.doublebuffered = result; if( dc.coreProfile ) { if( getFrameBufferObject( )) { glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &dc.stencilBits ); // eat GL error if no stencil attachment; should return '0' bits // according to spec, but gives GL_INVALID_OPERATION glGetError(); EQ_GL_CALL( glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &dc.colorBits )); EQ_GL_CALL( glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &dc.alphaBits )); } else { EQ_GL_CALL( glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &dc.stencilBits )); EQ_GL_CALL( glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &dc.colorBits )); EQ_GL_CALL( glGetFramebufferAttachmentParameteriv( GL_FRAMEBUFFER, GL_FRONT_LEFT, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, &dc.alphaBits )); } } else { EQ_GL_CALL( glGetIntegerv( GL_STENCIL_BITS, &dc.stencilBits )); EQ_GL_CALL( glGetIntegerv( GL_RED_BITS, &dc.colorBits )); EQ_GL_CALL( glGetIntegerv( GL_ALPHA_BITS, &dc.alphaBits )); EQ_GL_CALL( glGetIntegerv( GL_ACCUM_RED_BITS, &dc.accumBits )); } dc.accumBits *= 4; LBDEBUG << "Window drawable config: " << dc << std::endl; }
bool FrameData::addImage( const co::ObjectVersion& frameDataVersion, const PixelViewport& pvp, const Zoom& zoom, const uint32_t buffers_, const bool useAlpha, uint8_t* data ) { LBASSERT( _impl->readyVersion < frameDataVersion.version.low( )); if( _impl->readyVersion >= frameDataVersion.version.low( )) return false; Image* image = _allocImage( Frame::TYPE_MEMORY, DrawableConfig(), false /* set quality */ ); image->setPixelViewport( pvp ); image->setAlphaUsage( useAlpha ); Frame::Buffer buffers[] = { Frame::BUFFER_COLOR, Frame::BUFFER_DEPTH }; for( unsigned i = 0; i < 2; ++i ) { const Frame::Buffer buffer = buffers[i]; if( buffers_ & buffer ) { PixelData pixelData; const ImageHeader* header = reinterpret_cast<ImageHeader*>( data ); data += sizeof( ImageHeader ); pixelData.internalFormat = header->internalFormat; pixelData.externalFormat = header->externalFormat; pixelData.pixelSize = header->pixelSize; pixelData.pvp = header->pvp; pixelData.compressorFlags = header->compressorFlags; const uint32_t compressor = header->compressorName; if( compressor > EQ_COMPRESSOR_NONE ) { lunchbox::CompressorChunks chunks; const uint32_t nChunks = header->nChunks; chunks.reserve( nChunks ); for( uint32_t j = 0; j < nChunks; ++j ) { const uint64_t size = *reinterpret_cast< uint64_t*>( data ); data += sizeof( uint64_t ); chunks.push_back( lunchbox::CompressorChunk( data, size )); data += size; } pixelData.compressedData = lunchbox::CompressorResult( compressor, chunks ); } else { const uint64_t size = *reinterpret_cast< uint64_t*>( data ); data += sizeof( uint64_t ); pixelData.pixels = data; data += size; LBASSERT( size == pixelData.pvp.getArea()*pixelData.pixelSize ); } image->setZoom( zoom ); image->setQuality( buffer, header->quality ); image->setPixelData( buffer, pixelData ); } } _impl->pendingImages.push_back( image ); return true; }