void Renderer::initGLView()
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
    _cacheTextureListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
        /** listen the event that renderer was recreated on Android/WP8 */
        this->setupBuffer();
    });
    
    Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1);
#endif
    
    //setup index data for quads
    
    for( int i=0; i < VBO_SIZE/4; i++)
    {
        _quadIndices[i*6+0] = (GLushort) (i*4+0);
        _quadIndices[i*6+1] = (GLushort) (i*4+1);
        _quadIndices[i*6+2] = (GLushort) (i*4+2);
        _quadIndices[i*6+3] = (GLushort) (i*4+3);
        _quadIndices[i*6+4] = (GLushort) (i*4+2);
        _quadIndices[i*6+5] = (GLushort) (i*4+1);
    }
    
    setupBuffer();
    
    _glViewAssigned = true;
}
void Renderer::initGLView()
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
	_cacheTextureListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event) {
		/** listen the event that renderer was recreated on Android/WP8 */
		this->setupBuffer();
	});

	Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1);
#endif

	//setup index data for quads

	for (int i = 0; i < VBO_SIZE / 4; i++)
	{
		_quadIndices[i * 6 + 0] = (GLushort)(i * 4 + 0);
		_quadIndices[i * 6 + 1] = (GLushort)(i * 4 + 1);
		_quadIndices[i * 6 + 2] = (GLushort)(i * 4 + 2);
		_quadIndices[i * 6 + 3] = (GLushort)(i * 4 + 3);
		_quadIndices[i * 6 + 4] = (GLushort)(i * 4 + 2);
		_quadIndices[i * 6 + 5] = (GLushort)(i * 4 + 1);
	}

	QuadCommand::setStaticIndices(_quadIndices);

	setupBuffer();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM != CC_PLATFORM_WIN32)
	// only use glMapBuffer on desktop platforms as it is used with buffer orphaning, and buffer orphaning could be slow with really big data on mobile devices
	_useMapBuffer = Configuration::getInstance()->checkForGLExtension("map_buffer");
	_useMapBuffer = false;
#endif

	_glViewAssigned = true;
}
Exemple #3
0
bool ILBMLoader::callback(Common::IFFChunk &chunk) {
	switch (chunk._type) {
	case ID_BMHD:
		_decoder.loadHeader(chunk._stream);
		break;

	case ID_CMAP:
		if (_palette) {
			chunk._stream->read(_palette, chunk._size);
		}
		break;

	case ID_CRNG:
		if (_crng) {
			PaletteFxRange *ptr = &_crng[_numCRNG];
			chunk._stream->read((byte*)ptr, chunk._size);
			ptr->_timer = FROM_BE_16(ptr->_timer);
			ptr->_step = FROM_BE_16(ptr->_step);
			ptr->_flags = FROM_BE_16(ptr->_flags);
			++_numCRNG;
		}
		break;

	case ID_BODY:
		setupBuffer(_decoder._header.width, _decoder._header.height);
		assert(_intBuffer);
		_decoder.loadBitmap(_mode, _intBuffer, chunk._stream);
		return true;	// stop the parser
	}

	return false;
}
Exemple #4
0
Drawboard::Drawboard(QWidget* parent, tool::Tool initialTool)
    : QWidget(parent), buffer(NULL), painter(NULL),
      currentTool(initialTool), toolVisible(false)
{
    setAttribute(Qt::WA_OpaquePaintEvent);

    setupBuffer();
}
Exemple #5
0
void DrawEngine::changeScreenSize( int w , int h )
{
	getWindow().resize( w , h );
	if ( mBufferDC->getWidth() != w || mBufferDC->getHeight() != h )
	{
		setupBuffer( w , h );
		mGLGraphics->init( w , h );
	}
}
Exemple #6
0
void DrawEngine::stopOpenGL()
{
	if ( !mbGLEnable )
		return;

	mbGLEnable = false;

	RenderUtility::stopOpenGL();
	setupBuffer( getScreenWidth() , getScreenHeight() );
	mGLContext.cleanup();
}
Exemple #7
0
// flip the image either vertically or horizontally based on the rotation flag in the images EXIF
void flip_image (vImage_Buffer *vImage_source, img_prop o, args flags) {
	
	// Return error value for vImage functions
	vImage_Error error;

	// Create a buffer for processing
	vImage_Buffer *vImage_processed = (vImage_Buffer*) malloc (sizeof (vImage_Buffer));

	// Check for null
	if (vImage_processed->data == NULL) {
		printf ("Could not malloc the memory for vImage_processed->data.\n");
		exit (0);
	}	

	// setup the vimage buffers
	setupBuffer (vImage_processed, o->image_h, o->image_w, o->bytes_row);
	
	// mallocing blank data are for the processed image buffer
	vImage_processed->data = (void *) malloc (vImage_processed->rowBytes * vImage_processed->height);
	
	// Check for null
	if (vImage_processed->data == NULL) 
		printf ("Unable to get the vimage.data pointer\n");
	
	// Flipping the image.
	if (o->image_rot == 4 || o->image_rot == 7 || o->image_rot == 5) {
		printf ("Flip vertical.\n");
		error = vImageVerticalReflect_ARGB8888 (vImage_source, 
											   vImage_processed, 
											   kvImageNoFlags);	
		if (error) { 
			printf ("Flip vertical error: %d\n", (int)error);
		}
	} 
	
	// Flipping the image.
	if (o->image_rot == 2) {
		printf ("Flip Horizontal.\n");
		error = vImageHorizontalReflect_ARGB8888 (vImage_source, 
												 vImage_processed, 
												 kvImageNoFlags);	
		if (error) {
			printf ("Flip Horizontal error: %d\n", (int)error);
		}
	}

	// return the processed data to the sourcebuffer
	reset_vImage (vImage_source, vImage_processed, o);
	
	// free the processing buffer
	free (vImage_processed);
	vImage_processed = NULL;

} // flip_image ()
Exemple #8
0
void Renderer::initGLView()
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
    _cacheTextureListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
        /** listen the event that renderer was recreated on Android/WP8 */
        this->setupBuffer();
    });
    
    Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1);
#endif

    setupBuffer();
    
    _glViewAssigned = true;
}
void SWDecoder::operator()()
{
	int res = 0;
	std::cout << "SWDecoder thread started" << std::endl;
	setupBuffer();
	setupCodec();

	while(!mFinish)
	{
		decodeStream();
		boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(5));
	}

	releaseCodec();
	std::cout << "SWDecoder thread stopped" << std::endl;
}
Exemple #10
0
void Renderer::initGLView()
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
    _cacheTextureListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
        /** listen the event that coming to foreground on Android */
        this->setupBuffer();
    });
    
    Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_cacheTextureListener, -1);
#endif

    setupIndices();
    
    setupBuffer();
    
    _glViewAssigned = true;
}
Exemple #11
0
bool DrawEngine::startOpenGL( bool useGLEW )
{
	if ( mbGLEnable )
		return true;

	setupBuffer( getScreenWidth() , getScreenHeight() );
	if ( !mGLContext.init( getWindow().getHDC() , WGLContext::InitSetting() ) )
		return false;

	if ( glewInit() != GLEW_OK )
		return false;

	RenderUtility::startOpenGL();
	mbGLEnable = true;

	return true;
}
Exemple #12
0
void Drawboard::resizeEvent(QResizeEvent*)
{
    setupBuffer();
}
bool Direct3D11ConstantBuffer::updateBuffer(const void* Buffer, u32 Size)
{
    setupBuffer(Buffer);
    return true;
}
Exemple #14
0
// resize the image to the desired output size (DEFAULT = 800px[max x or y length])
void resize_image (vImage_Buffer *vImage_source, img_prop o, args flags) {

	// create the output buffer for processing too
	vImage_Buffer *vImage_processed = (vImage_Buffer*) malloc (sizeof (vImage_Buffer));

	// Check for null
	if (NULL == vImage_processed) {
		printf ("Cannot malloc vImage_processed buffer\n");
		exit (0);
	}
	
	// Return error value for vImage functions
	vImage_Error error;
	
	// if both the width and height have been set
	if (flags->image_h != -1 && flags->image_w != -1) {
		o->image_h = flags->image_h;
		o->image_w = flags->image_w;
	}
	
	// If the output width has been set
	if (flags->image_w != -1 && flags->image_h == -1) {

		// calculate the required length or width to scale the image and apply them to the image destination attributes
		if (vImage_source->width < vImage_source->height) {
			o->image_w = flags->image_w;
			o->image_h = calcImageLongSide (flags->image_w, 
											 vImage_source->height, 
											 vImage_source->width);
		} else {
			o->image_w = flags->image_w;
			o->image_h = calcImageShortSide (flags->image_w, 
											  vImage_source->width, 
											  vImage_source->height);
		}
	}

	// If the output height has been set
	if (flags->image_h != -1 && flags->image_w == -1) {

		// calculate the required length or width to scale the image and apply them to the image destination attributes
		if (vImage_source->width < vImage_source->height) {
			o->image_h = flags->image_h;
			o->image_w = calcImageShortSide (flags->image_h, 
											  vImage_source->height, 
											  vImage_source->width);
		} else {
			o->image_h = flags->image_h;
			o->image_w = calcImageLongSide (flags->image_h, 
											 vImage_source->width, 
											 vImage_source->height);
		}
	}

	// if the max length has been set ** overides the width or height settings
	if (flags->image_l != -1) {
		
		// calculate the required length or width to scale the image and apply them to the image destination attributes
		if (vImage_source->width < vImage_source->height) {
			o->image_h = flags->image_l;
			o->image_w = calcImageShortSide (flags->image_l, 
											  vImage_source->height, 
											  vImage_source->width);
		} else {
			o->image_w = flags->image_l;
			o->image_h = calcImageShortSide (flags->image_l, 
											  vImage_source->width, 
											  vImage_source->height);
		}
	}
	
	// setup the vimage buffers
	setupBuffer (vImage_processed, o->image_h, o->image_w, o->image_w * 4);
	
	//	printf ("mallocing blank data are for the processed image buffer\n");
	vImage_processed->data = malloc (vImage_processed->rowBytes * vImage_processed->height);
	
	// Check for null
	if (NULL == vImage_processed->data) 
		printf ("Unable to get the vimage.data pointer\n");
	
	// Scale the image
	error = vImageScale_ARGB8888 (vImage_source, 
								 vImage_processed, 
								 NULL, 
								 kvImageHighQualityResampling);
	if (error) {
		printf ("Resize error: %d\n", (int) error);
	}

	// return the processed data to the sourcebuffer
	reset_vImage (vImage_source, vImage_processed, o);

	// free the processing buffer
	free (vImage_processed);
	vImage_processed = NULL;

} // resize_image
Exemple #15
0
void process_1_image (args cli_flags, char *files) {
	
	char *out_file_name = get_out_filename (files, cli_flags);
	
	if (file_exists (out_file_name)) {
		printf ("| Output file %s already exists. skipping... ", out_file_name);
		return;
	}
	
	// Origional Image Properties struct
	img_prop o = (img_prop) malloc (sizeof (image_properties));
	
	// set all the vales in the imapg properties struct to -1
	null_ip (o);
	
	// Create a data provider
	CGDataProviderRef source_image_provider = CGDataProviderCreateWithFilename (files);
	
	// Check for a null returned value
	if (source_image_provider == NULL) {
		
		// something went wrong 
		printf ("error: Couldn't create CGDataProvider from URL.\n"); 
		exit (0);
	}
	
	// get the information from the image exif here
	o->image_rot = get_exif_rot (source_image_provider);
	

	// Create the image in memory from the JPEG data
	CGImageRef source_image = CGImageCreateWithJPEGDataProvider (source_image_provider, NULL, no, kCGRenderingIntentDefault);
	
  /********************************************/
  /* Getting the colour space **/
  
  o->colorSpace = CGImageGetColorSpace(source_image);
  
  /********************************************/
  
	// populate the image info struct
	pop_img_props (source_image, o);
	
	// create a data provider from the decoded JPEG data
	CGDataProviderRef image_data_provider = CGImageGetDataProvider (source_image);
	
	// Create a pointer to the data section of the image in memory
	CFDataRef source_data_ptr = CGDataProviderCopyData (image_data_provider);

	// The vImage_Buffers we will use
	vImage_Buffer *vImage_source = (vImage_Buffer*) malloc (sizeof (vImage_Buffer));
	
	// Check for NULL
	if (NULL == vImage_source) {
		printf ("Cannot malloc vImage_source buffer\n");
		exit (0);
	}
	
	if (o->bits_ppixel == 24) {
		
		// convert from 24bit to 32bit by adding the alpha channel.
		source_data_ptr = convert24_32bit (source_data_ptr, o);
		
	}
	
	// Setup the vImage Buffer for the image
	setupBuffer (vImage_source, o->image_h, o->image_w, o->bytes_row);

	// Assign the data to the vImage Buffer for the source
	vImage_source->data = (void *) CFDataGetBytePtr (source_data_ptr);
	
	// Check for NULL
	if (vImage_source->data == NULL) 
		printf ("Unable to get the vimage.data pointer\n");

	if (o->image_rot != 1 && o->image_rot != 4 && o->image_rot != 2) // rotate the image
		rotate_image (vImage_source, o, NULL);
	
	// flip the image
	if (o->image_rot == 2  || o->image_rot == 4 || o->image_rot == 7 || o->image_rot == 5)
		flip_image (vImage_source, o, NULL);
	
  
	// Resize the images
	resize_image (vImage_source, o, cli_flags);

    // Create a colour space to be compared against
    CGColorSpaceRef rgb = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
    if (NULL == rgb) {
        fprintf(stderr, "Unable to create the reference colourspace.\n");
        exit(0);
    }
    
    // Convert the colourspace to RGB
    if (!CFEqual(rgb, o->colorSpace) && !cli_flags->disableCC) {
        vImage_source->data = convert_space(vImage_source->data, o->image_w, o->image_h);
        if (NULL == vImage_source->data) exit(0);
    }
    
    // release the reference colour space
    CGColorSpaceRelease(rgb);
    
	// save the image
	save_image (vImage_source, o, cli_flags->quality, out_file_name);
	
	// Release the source provider
	CGDataProviderRelease (source_image_provider);
	source_image_provider = NULL;
	
	// Release the source image
	CGImageRelease (source_image);
	source_image = NULL;
	
	free(source_data_ptr);
    
	// Free the filename created by get_out_filename ()
	free (out_file_name);
	out_file_name = NULL;
	
	// free the image properties
	free (o);
	o = NULL;
	
	// if there is info in the buffer
	if (vImage_source->data != NULL) {
		free (vImage_source->data);
		vImage_source->data = NULL;
	}
	
	// free the buffer
	free (vImage_source);
	vImage_source = NULL;

} // Process 1 image
extern "C" AudioHardwareInterface* createAudioHardware(void) {
	ALOGI("Creating Audio Hardware");
	setupBuffer();
	setupInBuffer(); // fake microphone
    return new AudioFakeHardware();
}
void dx11ShaderProgram::setData(int index, DataType type, int mult,
		const void *ptr, unsigned int count, bool modified,
		ShaderBufferCache **cache, int stride, int offset) {
	activate();
	setupBuffer(index, type, mult, ptr, count, modified, cache,stride,offset);
}