Пример #1
0
Scene::~Scene() {
  // Deletes all scene data
  delete m_settings;

  for(size_t i=0; i<m_lights->size(); ++i)
    delete m_lights->at(i);
  delete m_lights;

  for(size_t i=0; i<m_textures.size(); ++i)
    delete m_textures[i];

  for(size_t i=0; i<m_materials.size(); ++i)
    delete m_materials[i];

  for(size_t i=0; i<m_triangles.size(); ++i)
    delete m_triangles[i];

  delete m_acc_data_struct;

  if (m_drawable!=NULL)
    delete m_drawable;

  if (environment_map!=NULL)
    delete environment_map;

  ilShutDown();
}
Пример #2
0
EditorUI::~EditorUI()
{
	SAFE_DELETE(uiMapping);
	SAFE_DELETE(uiIK);
	SAFE_DELETE(uiTimeline);
	SAFE_DELETE(uiTexBuilder);
	SAFE_DELETE(uiAnimTrackEditor);
	SAFE_DELETE(uiRotator);
	SAFE_DELETE(uiBackupViewer);

	if (textureGroupHandler) {
		textureGroupHandler->Save((applicationPath+TextureGroupConfig).c_str());
		delete textureGroupHandler;
		textureGroupHandler=0;
	}

	SAFE_DELETE(textureHandler);

	SAFE_DELETE(objectViewer);
	SAFE_DELETE(modelDrawer);
	SAFE_DELETE(model);

	delete &BackupManager::Get();

	ilShutDown ();
}
Пример #3
0
CBitmap::~CBitmap()
{
	if(mem!=0)
		delete[] mem;
	if(ddsimage)
		delete ddsimage;
	ilShutDown();
}
Пример #4
0
ImageWriter::~ImageWriter()
{
  if (!lstrcmpi(ext, "ebmp"))
  {
  }
  else {
    ilShutDown();
  }
}
Пример #5
0
//================================================================================================//
Engine::~Engine(void)
{
	gLog.OutPut("\n[Engine Shutdown]\n");
	ilShutDown();
	FSOUND_Close();  
	SDL_Quit();
	SaveScores();
	gLog.OutPut("Complete...\n\n");
}
Пример #6
0
bool CGuildMarkUploader::__LoadSymbol(const char* c_szFileName, UINT* peError)
{
	//	For Check Image
	ILuint uImg;
	ilGenImages(1, &uImg);
	ilBindImage(uImg);
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
	if (!ilLoad(IL_TYPE_UNKNOWN, (const ILstring)c_szFileName))
	{
		*peError=ERROR_LOAD;
		return false;
	}
	if (ilGetInteger(IL_IMAGE_WIDTH) != 64)
	{
		*peError=ERROR_WIDTH;
		return false;
	}
	if (ilGetInteger(IL_IMAGE_HEIGHT) != 128)
	{
		*peError=ERROR_HEIGHT;
		return false;
	}
	ilDeleteImages(1, &uImg);
	ilShutDown();

	/////

	FILE * file = fopen(c_szFileName, "rb");
	if (!file)
	{
		*peError=ERROR_LOAD;
	}

	fseek(file, 0, SEEK_END);
	m_dwSymbolBufSize = ftell(file);
	fseek(file, 0, SEEK_SET);

	m_pbySymbolBuf = new BYTE [m_dwSymbolBufSize];
	fread(m_pbySymbolBuf, m_dwSymbolBufSize, 1, file);

	fclose(file);

	/////

	m_dwSymbolCRC32 = GetFileCRC32(c_szFileName);
	return true;
}
Пример #7
0
//---------------------------------------------------------------------
// Function:	~CObjectTexture
// Description:	Standard Desctructor
// Parameters:	.
// Returns:		.
//---------------------------------------------------------------------
CObjectTexture::~CObjectTexture()
{
	TEXOBJLIST::iterator toIT;

	if (m_ObjInfo.icon != NULL)
	{
		DestroyIcon(m_ObjInfo.icon);
		m_ObjInfo.icon = NULL;
	}

	for (toIT = m_TextureObjects.begin(); toIT != m_TextureObjects.end(); toIT++)
	{
		delete *toIT;
	}

	ilShutDown();
}
Пример #8
0
//---------------------------------------------------------------------
// Function:	~CObjLoader
// Description:	Standard Desctructor
// Parameters:	.
// Returns:		.
//---------------------------------------------------------------------
CObjLoader::~CObjLoader()
{
	WAVFOBJLIST::iterator toIT;

	if (m_ObjInfo.icon != NULL)
	{
		DestroyIcon(m_ObjInfo.icon);
		m_ObjInfo.icon = NULL;
	}

	for (toIT = m_WavfObjects.begin(); toIT != m_WavfObjects.end(); toIT++)
	{
		delete *toIT;
	}

	ilShutDown();
}
Пример #9
0
int main(int argc, char **argv) {
  ILuint  image     = 0;
  ILuint  reference = 0;

  // syntax: ILtestAlgoQuant <reference> 
  if (argc < 2) {
    return -1;
  }

  ilInit();
  iluInit();

  ilEnable(IL_ORIGIN_SET);    // flip image on load if necessary
  ilEnable(IL_FILE_MODE);     // overwrite files

  // load reference image
  ilGenImages(1, &reference);
  CHECK(reference != 0);
  CHECK(testLoadImage(argv[1], reference));

  // duplicate
  image = ilCloneCurImage();
  CHECK(image != 0);
  

  // quantize
  ilBindImage(image);
  ilSetInteger(IL_QUANTIZATION_MODE, IL_WU_QUANT);
  ilConvertImage(IL_COLOUR_INDEX, IL_UNSIGNED_BYTE);
  CHECK(testSaveImage("test_quant.png", image));

  // compare two images
  CHECK_GREATER(iluSimilarity(reference), 0.98f);

  // cleanup
  ilDeleteImages(1, &image);  
  ilDeleteImages(1, &reference);  
  ilShutDown();

  return 0;
}
Пример #10
0
int main(int argc, char *argv[])
{
	int retval;
	int image;

	ilInit();
	iluInit();
	ilutInit();

	ilGenImages(1, &image);
	ilBindImage(image);
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

	retval = MLMain(argc, argv);

	ilDeleteImages(1, &image);

	ilShutDown();  // Only need to shut down DevIL, not ILU or ILUT

	return retval;
}
Пример #11
0
int main(int argc, char **argv) {
  if (argc != 3) {
    return 1;
  }

  ilInit();
  iluInit();

  ilGenImages(1, &image);
  charToILchar(argv[2], fileName, 1024);
  data = argv[2];

  argv++;

  RUN_TEST(open_read)
  RUN_TEST(open_read_lump)
    fprintf(stderr, "unknown test %s\n", *argv);

  ilDeleteImages(1, &image);
  ilShutDown();

  return 0;
}
Пример #12
0
		//---------------------------------------------------------------------
		void LoadTexture(	const std::string& _filename,
							Texture2D& _texture,
							bool _srgb,
							bool _allocateMipmap,
							bool _verbose)
		{
			try
			{
				ilInit();
				
				ILuint imgH;
				ilGenImages(1, &imgH);
				ilBindImage(imgH);
				if(!ilLoadImage((const ILstring)_filename.c_str()))
				{
					Error("Load image error : file does not exist (%s)",_filename.c_str());
				}
				
				if(_verbose)
				{
					Info("Load image : %s",_filename.c_str());
				}

				// Convert all to RGBA. TODO Need improvement ...
				GLenum format;
				bool convert = false;
				ILenum target;
				switch(ilGetInteger(IL_IMAGE_FORMAT))
				{
					case IL_RGB  			: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					case IL_RGBA 			: format = GL_RGBA; break;
					case IL_BGR  			: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					case IL_BGRA 			: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					case IL_LUMINANCE 		: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					case IL_COLOUR_INDEX	: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					case IL_ALPHA			: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					case IL_LUMINANCE_ALPHA	: format = GL_RGBA; convert=true; target = IL_RGBA; break;
					default 				: Error("Load image error : unsupported format (%s)",_filename.c_str());
				}

				GLenum type;
				switch(ilGetInteger(IL_IMAGE_TYPE))
				{
					case IL_UNSIGNED_BYTE	: type = GL_UNSIGNED_BYTE; break;
					case IL_FLOAT			: type = GL_FLOAT; break;
					//case IL_BYTE			: type = GL_BYTE; break;
					//case IL_SHORT			: type = GL_SHORT; break;
					//case IL_UNSIGNED_SHORT: type = GL_UNSIGNED_SHORT; break;
					//case IL_INT			: type = GL_INTEGER; break;
					//case IL_UNSIGNED_INT	: type = GL_UNSIGNED_INT; break;
					//case IL_DOUBLE		: Error("Load image error : double data are not supported (%s)",_filename.c_str()); break;
					default 				: Error("Load image error : unsupported data (%s)",_filename.c_str());
				}

				if(convert)
					 ilConvertImage(target, ilGetInteger(IL_IMAGE_TYPE));

				// Flip image
				ILinfo ImageInfo;
				iluGetImageInfo(&ImageInfo);
				if( ImageInfo.Origin == IL_ORIGIN_UPPER_LEFT )
				{
					iluFlipImage();
					if(_verbose) Info("Flip image");
				}

				switch(type)
				{
					case GL_UNSIGNED_BYTE	:
					{
						if(_srgb)
						{
							_texture.Allocate( GL_SRGB8_ALPHA8, ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),_allocateMipmap);
							if(_verbose) Info("Allocate texture - format:GL_SRGB8_ALPHA8, w:%d, h:%d, mipmap:%s",ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT), (_allocateMipmap?"TRUE":"FALSE") );
						}
						else
						{
							_texture.Allocate( GL_RGBA8, ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),_allocateMipmap);
							if(_verbose) Info("Allocate texture - format:GL_RGBA8, w:%d, h:%d, mipmap:%s",ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT), (_allocateMipmap?"TRUE":"FALSE") );
						}
					}
					break;
					case GL_FLOAT			:
					{
						if(_srgb)
							Warning("Try to convert to SRGB, but texture format is not compatible");
						_texture.Allocate( GL_RGBA32F, ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),_allocateMipmap);
						if(_verbose) Info("Allocate texture - format:GL_RGBA32F, w:%d, h:%d, mipmap:%s",ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT), (_allocateMipmap?"TRUE":"FALSE") );
					}
					break;
					default 				:
					{
						Error("Load image error : unsupported data (%s)",_filename.c_str());
					}
				}
				_texture.Fill(format,type,ilGetData());

				ilDeleteImages(1, &imgH);
				ilShutDown();
			}
			catch (const std::exception &e) 
			{
				Error("Unable to read image file \"%s\": %s",_filename.c_str(),e.what());
			}
		}
Пример #13
0
		//----------------------------------------------------------------------
		void SaveTexture(	const std::string& _filename,
							Texture2D& _texture,
							bool _verbose)
		{
			#ifdef ENABLE_OPEN_EXR
			float* data = new float[_texture.size.x * _texture.size.y * 4];
			glBindTexture(_texture.target,_texture.id);
			glGetTexImage(_texture.target,0,GL_RGBA,GL_FLOAT,data);
			SaveTexture(_filename,data,_texture.size.x,_texture.size.y,_verbose);
			delete[] data;
			#else
			try
			{
				ilInit();
				
				ILuint imgH;
				ilGenImages(1, &imgH);
				ilBindImage(imgH);

				float* data = new float[_texture.size.x * _texture.size.y * 4];
				glBindTexture(_texture.target,_texture.id);
				glGetTexImage(_texture.target,0,GL_RGBA,GL_FLOAT,data);

				ILboolean result;
				result = ilTexImage(_texture.size.x, _texture.size.y, 1, 4, IL_RGBA, IL_FLOAT, data);
				assert(result);

				ilEnable(IL_FILE_OVERWRITE);
//				result = ilSave(IL_EXR, _filename.c_str());
//				result = ilSave(IL_TYPE_UNKNOWN, _filename.c_str());
				#if WIN32
				result = ilSaveImage(s2ws(_filename).c_str());			
				#else
				result = ilSaveImage(_filename.c_str());
				#endif

				if(!result)
				{
					ILenum errorID = ilGetError();
					if(errorID != IL_NO_ERROR)
					{
						Error("Save image error :  %s",_filename.c_str());
						Error("Error ID :  %d",errorID);
					}
				}
				assert(result);

				delete[] data;

				if(_verbose)
				{
					Info("Save image : %s",_filename.c_str());
				}

				ilDeleteImages(1, &imgH);
				ilShutDown();
			}
			catch (const std::exception &e) 
			{
				Error("Unable to write texture \"%s\": %s",_filename.c_str(),e.what());
			}
			#endif
		}
Пример #14
0
ImageReader::~ImageReader()
{
  if (use_DevIL) {
    ilShutDown();
  }
}
Пример #15
0
void DevILShutDown(void)
{
	ilShutDown();
}
Пример #16
0
//----------------------------------------------------------------------------------------------------
// Standard windows mainline, this is the program entry point
//
CrtInt32 WINAPI WinMain(	HINSTANCE	hInstance,		
					HINSTANCE	hPrevInstance,	
					LPSTR		lpCmdLine,			
					CrtInt32			nCmdShow)	
{
	(void)hPrevInstance; // Avoid warnings
	(void)nCmdShow; // Avoid warnings
	(void)hInstance; // Avoid warnings

#ifndef NO_DEVIL
	ilInit();
#endif

	MSG		msg;									
	BOOL	done=FALSE;								
	
	// Avoid warnings later
	msg.wParam = 0;

	// Turns on windows heap debugging
#if HEAP_DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF /*| _CRTDBG_DELAY_FREE_MEM_DF*/);
#endif

	// Ask The User Which Screen Mode They Prefer
	//	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
	{
		fullscreen=FALSE;							
	}

	// Set the default screen size
	_CrtRender.SetScreenWidth( 640);
	_CrtRender.SetScreenHeight( 480);

	// Create an OpenGL Window
	if (!CreateGLWindow("Collada Viewer for PC", _CrtRender.GetScreenWidth(), _CrtRender.GetScreenHeight(),32,fullscreen))
	{
		return 0;									
	}
	
	// Turn data dumping (debug) off
	//CrtBool dumpData = CrtFalse; 

	// Initialize the renderer
	// !!!GAC for compatibility with the new COLLADA_FX code, Init now forces UsingCg and UsingVBOs to
	// !!!GAC false.  It also calls CrtInitCg, creating the CG context and calling cgGLRegisterStates.
	// !!!GAC All these things are currently required for the cfx rendering path to work, changing them
	// !!!GAC may cause problems.  This is work in progress and will be much cleaner when the refactor is done.
	
	_CrtRender.Init();
	//_CrtRender.SetRenderDebug( CrtTrue ); 

	// !!!GAC kept for reference, changing these may cause problems with the cfx include path
	//_CrtRender.SetUsingCg( CrtFalse );
	// Turn off VBOs (the GL skinning path doesn't work with VBOs yet)
	_CrtRender.SetUsingVBOs( CrtTrue ); 
	_CrtRender.SetUsingNormalMaps( CrtTrue ); 	
	//_CrtRender.SetRenderDebug( CrtTrue ); 
	//_CrtRender.SetUsingShadowMaps(CrtTrue);

	// We might get a windows-style path on the command line, this can mess up the DOM which expects
	// all paths to be URI's.  This block of code does some conversion to try and make the input
	// compliant without breaking the ability to accept a properly formatted URI.  Right now this only
	// displays the first filename
	char
		file[512],
		*in = lpCmdLine,
		*out = file;
	*out = NULL;
	// If the first character is a ", skip it (filenames with spaces in them are quoted)
	if(*in == '\"')
	{
		in++;
	}
	if(*(in+1) == ':')
	{
		// Second character is a :, assume we have a path with a drive letter and add a slash at the beginning
		*(out++) = '/';
	}
	int i;
	for(i =0; i<512; i++)
	{
		// If we hit a null or a quote, stop copying.  This will get just the first filename.
		if(*in == NULL || *in == '\"')
			break;
		// Copy while swapping backslashes for forward ones
		if(*in == '\\')
		{
			*out = '/';
		}
		else
		{
			*out = *in;
		}
		in++;
		out++;
	}
	
	// Should throw an error if i>= 512, but we don't have error dialongs in the code yet so just let it try to load and fail
	if(i < 511)
		*out = NULL;

	time_t seconds =  time (NULL);
	clock_t clocka = clock ();

	cleaned_file_name = file;
	// Load the file name provided on the command line
	if ( !_CrtRender.Load( cleaned_file_name ))
	{
		exit(0);
	}
	time_t loadtime = time (NULL) - seconds;
	int clockload = (int) clock () - clocka;

	CrtPrint("\nLOAD TIME OF %s\n", file);
	CrtPrint("IS %d SECONDS\n", loadtime);
	CrtPrint("IS %d CLOCK TICKS\n\n", clockload);


	// This block of code shows how to enumerate all the effects, get their parameters and then
	// get their UI information.
#if 1
	{
		// Get the scene and setup to iterate over all the effects stored in the cfxLoader
		CrtScene *scene = _CrtRender.GetScene();
		std::map<std::string, cfxEffect*>::iterator effectIterator;
		effectIterator = scene->cfxEffects.begin();
		// Iterate over all the effects
		while(effectIterator != scene->cfxEffects.end())
		{
			// This is the effect name you would use in a UI
			CrtPrint("Effect name %s\n", effectIterator->first.c_str());
			cfxEffect *thiscfxEffect = effectIterator->second;
			CGeffect thisCGEffect = thiscfxEffect->getEffect();
			CGparameter thisCGParameter = cgGetFirstEffectParameter(thisCGEffect);
			while(thisCGParameter != NULL)
			{
				// This is the parameter name you would use in the UI
				const char *parameterName = cgGetParameterName(thisCGParameter);
				// This is for the example of how to tweek a parameter (doesn't work yet)
				if(CrtCmp(parameterName, "Amplitude"))
				{
					// Capture the parameter and save it in a global, in a GUI you would
					// save this handle in the widget so it would know what to tweek.
					amplitudeGlobalParameter = thisCGParameter;
				}
#if 0
				// This is here for debugging, it iterates over all the annotations and prints them out
				// so you can see what's in them.  Normally this code will be turned off.
				CrtPrint("  Parameter name %s\n",parameterName);
				CGannotation dbgCGAnnotation = cgGetFirstParameterAnnotation(thisCGParameter);
				while(dbgCGAnnotation != NULL)
				{
					const char *annotationName = cgGetAnnotationName(dbgCGAnnotation);
					CrtPrint("      Annotation: %s",annotationName);
					if(cgGetAnnotationType(dbgCGAnnotation) == CG_STRING)
					{
						const char *annotationString = cgGetStringAnnotationValue(dbgCGAnnotation);
						CrtPrint(" value: %s\n",annotationString);
					}
					else if(cgGetAnnotationType(dbgCGAnnotation) == CG_FLOAT)
					{
						int nvalues; 
						const float *value = cgGetFloatAnnotationValues(dbgCGAnnotation, &nvalues);
						CrtPrint(" value: %f\n",*value);  // Assume there is one value
					}
					else
					{
						CrtPrint("\n");
					}
					dbgCGAnnotation = cgGetNextAnnotation(dbgCGAnnotation);
				}
#endif
				// This code looks at the parameter annotations to see if they specify some kind of UI
				// cgGetNamedParameterAnnotation isn't used for this because it is case sensitive and at
				// least some of the annotations FXcomposer uses for UI appear to NOT be case sensitive.
				// This method should collect the parameter values regardless of case, but it has to scan
				// ALL the parameters and do case-blind compares on each one, which is slower.
				// This code currently only collects the annotation values for defining sliders and color pickers.
				const char *UIName		= "unknown";
				const char *UIWidget	= "unknown";
				float UIMin				= -99999.0f;
				float UIMax				= 99999.0f;
				float UIStep			= 0.0f;
				int   nvalues;
				CGannotation thisCGAnnotation = cgGetFirstParameterAnnotation(thisCGParameter);
				// Iterate over all the annotations
				while(thisCGAnnotation != NULL)
				{
					// Get the name of this annotation
					const char *annotationName = cgGetAnnotationName(thisCGAnnotation);
					// Do case-blind compares to see if the annotation is one of the ones used to make UI
					// and save the value if it is.
					if(CrtICmp("UIWidget",annotationName))
					{
						// This is the widget type
						UIWidget = cgGetStringAnnotationValue(thisCGAnnotation);
					}
					if(CrtICmp("UIName",annotationName))
					{
						// This is the name to attach to the widget
						UIName = cgGetStringAnnotationValue(thisCGAnnotation);
					}
					if(CrtICmp("UIMin",annotationName))
					{
						// This is the minimum value for a slider widget
						const float *value = cgGetFloatAnnotationValues(thisCGAnnotation, &nvalues);
						if(nvalues == 1)
							UIMin = *value;
					}
					if(CrtICmp("UIMax",annotationName))
					{
						// This is the maximum value for a slider widget
						const float *value = cgGetFloatAnnotationValues(thisCGAnnotation, &nvalues);
						if(nvalues == 1)
							UIMax = *value;
					}
					if(CrtICmp("UIStep",annotationName))
					{
						// This is the step (minimum change) for a slider widget
						const float *value = cgGetFloatAnnotationValues(thisCGAnnotation, &nvalues);
						if(nvalues == 1)
							UIStep = *value;
					}
					// Get the next annotation
					thisCGAnnotation = cgGetNextAnnotation(thisCGAnnotation);
				}
				// Is the UIWidget a type that we recognize? (just slider and color picker for now)
				// Replace the CrtPrint with the code that generates the UI, remember the UI needs to
				// store thisCGParameter someplace so it can use it to change the parameter later. 
				if(CrtICmp("slider", UIWidget))
				{
					CrtPrint("Parameter %s needs a slider named %s going from %f to %f with step %f\n",parameterName,UIName,UIMin,UIMax, UIStep );
				}
				if(CrtICmp("color", UIWidget))
				{
					CrtPrint("Parameter %s needs a color picker named %s\n",parameterName,UIName);
				}
				// Move on to the next parameter
				thisCGParameter = cgGetNextParameter(thisCGParameter);
			}
			// Move on to the next effect
			effectIterator++;
		}
	}
#endif
	while(!done)									
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	
		{
			if (msg.message==WM_QUIT)				
			{
				done=TRUE;							
			}
			else									
			{
				TranslateMessage(&msg);				
				DispatchMessage(&msg);				
			}
		}
		else										
		{
			// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()
			if ((active && !DrawGLScene()) || keys[VK_ESCAPE])	// Active?  Was There A Quit Received?
			{
				done=TRUE;							
			}
			else									
			{
				SwapBuffers(hDC);					
				ProcessInput( keys ); 				
			}
		}
	}

	_CrtRender.Destroy();

	// Shutdown
#ifndef NO_DEVIL
	ilShutDown();
#endif
	DestroyGLWindow();								
	return (int)(msg.wParam);						
}
Пример #17
0
BundlerMatcher::~BundlerMatcher()
{
    //DevIL shutdown
    ilShutDown();
}
Пример #18
0
	Image::~Image()
	{
		ilShutDown();
	}
Пример #19
0
ImagesLoader::~ImagesLoader(){
    ilShutDown();
}
Пример #20
0
void ilFShutDown_()
{
	ilShutDown();
	return;
}
Пример #21
0
int main(int argc, const char* argv[], char* envp[])
{
#ifdef WIN32
	_environ = envp;
#else //LINUX
	environ = envp;
#endif //WIN32 and LINUX
	if (argc != 3)
	{
		std::cout << "Expecting two arguments:" << std::endl;
		std::cout << "FCProcessImages.exe <input_filename> <output_filename>" <<std::endl;
		exit(-1);
	}

	fstring inputFilename = TO_FSTRING(argv[1]);
	fstring outputFilename = TO_FSTRING(argv[2]);

	// Create an empty COLLADA document and import the given file.
	FCollada::Initialize();
	FUErrorSimpleHandler errorHandler;
	FCDocument* document = FCollada::NewTopDocument();
	FCollada::LoadDocumentFromFile(document, inputFilename.c_str());
	std::cout << argv[1] << std::endl;
	if (errorHandler.IsSuccessful())
	{
		std::cout << "Import: Done." << std::endl;

		// Initialize DevIL.
		ilInit();
		iluInit();

		// Process the image library
		ProcessImageLibrary(document->GetImageLibrary());

		// Shutdown DevIL
		ilShutDown();

		// It is common practice for tools to add a new contributor to identify that they were run
		// on a COLLADA document.
		FCDAssetContributor* contributor = document->GetAsset()->AddContributor();
		const char* userName = getenv("USER");
		if (userName == NULL) userName = getenv("USERNAME");
		if (userName != NULL) contributor->SetAuthor(TO_FSTRING(userName));
		contributor->SetSourceData(inputFilename);
		char authoringTool[1024];
		snprintf(authoringTool, 1024, "FCProcessImages sample for FCollada v%d.%02d", FCOLLADA_VERSION >> 16, FCOLLADA_VERSION & 0xFFFF);
		authoringTool[1023] = 0;
		contributor->SetAuthoringTool(TO_FSTRING((const char*)authoringTool));

		// Write out the processed COLLADA document.
		FCollada::SaveDocument(document, outputFilename.c_str());
		if (errorHandler.IsSuccessful())
		{
			std::cout << "Export: Done." << std::endl;
		}
		else
		{
			std::cout << errorHandler.GetErrorString();
			std::cout << std::endl << std::endl;
		}
	}
Пример #22
0
	~InitializeOpenIL() {
		ilShutDown();
	}
Пример #23
0
void main(int argc, char **argv)
{
    ILubyte *Lump;
    ILubyte *final_tga;
    ILubyte *Data;
    ILuint Size;
    ILuint Image;
    FILE *File;
    ILenum Error;
    ILuint ilFormat;
    int x0,y0,x1,y1;

    //char filename[]="103,692-205,768.tga";
    char filename[64];

    if(argc!=0 && !strcmp(argv[2],"-laststep"))
    {
		File=fopen(argv[1], "r+");
        fseek(File, 17, SEEK_SET);
        fprintf(File, "%c", 0x20);
        fclose(File);

	    ilInit();

		ilGenImages(1, &Image);
		ilBindImage(Image);

		if(!ilLoadImage(argv[1]))
		{
			printf("Error loading image final.tga");
			return ;
		}
	    ilEnable(IL_FILE_OVERWRITE);
		strcpy(filename, argv[1]);
		*strchr(filename, '\\')='\0';
		strcat(filename, "\\final.png");

		if(!ilSave(IL_PNG, filename))
			printf("Error occurs when saving image.");
		else
			printf("Image is saved successfuly.");


        return ;
    }
    strcpy(filename, strchr(argv[2], '\\')+1);
    sscanf(filename, "%d, %d - %d, %d", &x0,&y0,&x1,&y1);
    //printf("%d %d %d %d\n", x0,y0,x1,y1);
    x0--;	//start from (0,0), not (1,1)
    y0--;
    ilInit();

    File = fopen(argv[2], "rb");
    fseek(File, 0, SEEK_END);
    Size = ftell(File);
    fclose(File);

    Data = (ILubyte*)malloc(Size);

    ilGenImages(1, &Image);
    ilBindImage(Image);

    if(!ilLoadImage(argv[2]))
    {
        printf("Error loading image %s", filename);
        return ;
    }
    ilFormat=ilGetInteger(IL_IMAGE_FORMAT);
    ilCopyPixels(x0, y0, 0, x1-x0, y1-y0, 1, ilFormat, IL_UNSIGNED_BYTE, Data);
    if(!ilLoadImage(argv[1]))
    {
        printf("Error loading image final.tga");
        return ;
    }
    ilSetPixels(x0, y0, 0, x1-x0, y1-y0, 1, ilFormat, IL_UNSIGNED_BYTE, Data);
    ilEnable(IL_FILE_OVERWRITE);

    if(!ilSaveImage(argv[1]))
		printf("Error occurs when saving image.");
    else
        printf("Image is saved successfuly.");
    ilDeleteImages(1, &Image);

    ilShutDown();

    while ((Error = ilGetError()) != IL_NO_ERROR)
    {
        printf("%d: %s/n", Error, iluErrorString(Error));
    }
}