Exemple #1
0
Query::Query( GLuint target )
	: mTarget( target ), mId( 0 ) 
{
	CI_ASSERT_MSG( context(), "No currently valid gl context." );
	
	glGenQueries( 1, &mId );
}
void DeviceManagerXAudio::retrieveDeviceDetails()
{
	auto ctxXaudio = dynamic_cast<ContextXAudio *>( master() );
	CI_ASSERT_MSG( ctxXaudio, "DeviceManagerXAudio must be used in conjunction with ContextXaudio" );

	ctxXaudio->getMasteringVoice()->GetVoiceDetails( &mVoiceDetails );
}
Exemple #3
0
SourceFileCoreAudio::SourceFileCoreAudio( const DataSourceRef &dataSource, size_t sampleRate )
    : SourceFile( sampleRate ), mDataSource( dataSource )
{
    CI_ASSERT_MSG( mDataSource->isFilePath(), "only DataSource type supported is file" );

    initImpl();
}
Exemple #4
0
void Node::setChannelMode( ChannelMode mode )
{
	CI_ASSERT_MSG( ! mInitialized, "setting the channel mode must be done before initializing" );

	if( mChannelMode == mode )
		return;

	mChannelMode = mode;
}
ContextXAudio::~ContextXAudio()
{
	CI_ASSERT_MSG( mMasteringVoice, "Expected to have a valid mastering voice" );

	// first ensure the IXAudio2SourceVoice destroyed by uninitializing the OutputDeviceNodeXAudio
	uninitializeNode( mOutput );

	mMasteringVoice->DestroyVoice();
	mXAudio->Release();
}
void OutputDeviceNodeXAudio::initialize()
{
	CI_ASSERT_MSG( getNumChannels() <= 2, "number of channels greater than 2 is not supported." );

	auto internalBuffer = getInternalBuffer();
	size_t numSamples = internalBuffer->getSize();

	memset( &mXAudioBuffer, 0, sizeof( mXAudioBuffer ) );
	mXAudioBuffer.AudioBytes = numSamples * sizeof( float );
	if( getNumChannels() == 2 ) {
		// setup stereo, XAudio2 requires interleaved samples so point at interleaved buffer
		mBufferInterleaved = BufferInterleaved( internalBuffer->getNumFrames(), internalBuffer->getNumChannels() );
		mXAudioBuffer.pAudioData = reinterpret_cast<BYTE *>( mBufferInterleaved.getData() );
	}
	else {
		// setup mono
		mXAudioBuffer.pAudioData = reinterpret_cast<BYTE *>( internalBuffer->getData() );
	}

	initSourceVoice();
}
			View& ScrollView::addSubview( ViewRef view, bool localize )
			{
				CI_ASSERT_MSG( !mInitialized, "Can not add subview directly to ScrollView, get the content view and add to it." );
				return po::scene::View::addSubview( view );
			}
Exemple #8
0
void OutputNode::connect( const NodeRef &output )
{
	CI_ASSERT_MSG( 0, "OutputNode does not support connecting to other outputs" );
}
Exemple #9
0
Layer::Layer( View *view )
	: mRootView( view )
{
	CI_ASSERT_MSG( mRootView, "null pointer for root View" );
	LOG_LAYER( "root view: " << mRootView->getName() );
}
Exemple #10
0
	void MovieGlHap::Obj::newFrame( CVImageBufferRef cvImage )
	{
		::CVPixelBufferLockBaseAddress( cvImage, kCVPixelBufferLock_ReadOnly );
		// Load HAP frame
		if( ::CFGetTypeID( cvImage ) == ::CVPixelBufferGetTypeID() ) {
			GLuint width = ::CVPixelBufferGetWidth( cvImage );
			GLuint height = ::CVPixelBufferGetHeight( cvImage );
			
			CI_ASSERT( cvImage != NULL );
			
			// Check the buffer padding
			size_t extraRight, extraBottom;
			::CVPixelBufferGetExtendedPixels( cvImage, NULL, &extraRight, NULL, &extraBottom );
			GLuint roundedWidth = width + extraRight;
			GLuint roundedHeight = height + extraBottom;
			
			// Valid DXT will be a multiple of 4 wide and high
			CI_ASSERT( !(roundedWidth % 4 != 0 || roundedHeight % 4 != 0) );
			OSType newPixelFormat = ::CVPixelBufferGetPixelFormatType( cvImage );
			GLenum internalFormat;
			unsigned int bitsPerPixel;
			switch (newPixelFormat) {
				case kHapPixelFormatTypeRGB_DXT1:
					internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
					bitsPerPixel = 4;
					break;
				case kHapPixelFormatTypeRGBA_DXT5:
				case kHapPixelFormatTypeYCoCg_DXT5:
					internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
					bitsPerPixel = 8;
					break;
				default:
					CI_ASSERT_MSG( false, "We don't support non-DXT pixel buffers." );
					return;
					break;
			}
			
			// Ignore the value for CVPixelBufferGetBytesPerRow()
			size_t	bytesPerRow = (roundedWidth * bitsPerPixel) / 8;
			GLsizei	dataLength = bytesPerRow * roundedHeight; // usually not the full length of the buffer
			size_t	actualBufferSize = ::CVPixelBufferGetDataSize( cvImage );
			
			// Check the buffer is as large as we expect it to be
			CI_ASSERT( dataLength < actualBufferSize );
			
			GLvoid *baseAddress = ::CVPixelBufferGetBaseAddress( cvImage );
						
			if ( !mTexture ) {
				// On NVIDIA hardware there is a massive slowdown if DXT textures aren't POT-dimensioned, so we use POT-dimensioned backing
				GLuint backingWidth = 1;
				while (backingWidth < roundedWidth) backingWidth <<= 1;
				
				GLuint backingHeight = 1;
				while (backingHeight < roundedHeight) backingHeight <<= 1;
				
				// We allocate the texture with no pixel data, then use CompressedTexSubImage to update the content region
				gl::Texture2d::Format format;
				format.wrap( GL_CLAMP_TO_EDGE ).magFilter( GL_LINEAR ).minFilter( GL_LINEAR ).internalFormat( internalFormat ).dataType( GL_UNSIGNED_INT_8_8_8_8_REV ).immutableStorage();// .pixelDataFormat( GL_BGRA );
				mTexture = gl::Texture2d::create( backingWidth, backingHeight, format );
				mTexture->setCleanSize( width, height );
				
				CI_LOG_I( "Created texture." );
				
#if defined( CINDER_MAC )
				/// There is no default format GL_TEXTURE_STORAGE_HINT_APPLE param so we fill it manually
				gl::ScopedTextureBind bind( mTexture->getTarget(), mTexture->getId() );
				glTexParameteri( mTexture->getTarget(), GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE );
#endif
			}
			gl::ScopedTextureBind bind( mTexture );
#if defined( CINDER_MAC )
			glTextureRangeAPPLE( mTexture->getTarget(), dataLength, baseAddress );
			/* WARNING: Even though it is present here:
			 * https://github.com/Vidvox/hap-quicktime-playback-demo/blob/master/HapQuickTimePlayback/HapPixelBufferTexture.m#L186
			 * the following call does not appear necessary. Furthermore, it corrupts display
			 * when movies are loaded more than once
			 */
//			glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, 1 );
#endif
			glCompressedTexSubImage2D(mTexture->getTarget(),
									  0,
									  0,
									  0,
									  roundedWidth,
									  roundedHeight,
									  mTexture->getInternalFormat(),
									  dataLength,
									  baseAddress);
		}
		
		::CVPixelBufferUnlockBaseAddress( cvImage, kCVPixelBufferLock_ReadOnly );
		::CVPixelBufferRelease(cvImage);
	}
Exemple #11
0
void TargetFile::write( const Buffer *buffer, size_t numFrames, size_t frameOffset )
{
	CI_ASSERT_MSG( numFrames + frameOffset <= buffer->getNumFrames(), "numFrames + frameOffset out of bounds" );

	performWrite( buffer, numFrames, frameOffset );
}
Exemple #12
0
void TargetFile::write( const Buffer *buffer, size_t numFrames )
{
	CI_ASSERT_MSG( numFrames <= buffer->getNumFrames(), "numFrames out of bounds" );

	performWrite( buffer, numFrames, 0 );
}