Exemple #1
0
void init()
{
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	// OpenGL assumes all textures have their origin in lower left corner. We
	// must inform IL about this fact, or we shall get upside-down textures.
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

	// As mentioned, we use classes to simplify manipulation with images.
	// We use the following methods:
	//		- Load		.. loads image from file
	//		- Width		.. returns width of loaded image
	//		- Height	.. returns height of loaded image
	//		- GetData	.. returns pointer to data of image
	ilImage image;
	
	// Try several image formats, at least PNG and JPG. Try only textures with
	// power-of-two sizes (like 256x256, 512x512 etc.). Loading images with
	// other dimensions may need some additional steps to make them work, and
	// they are not necessary to deal with to get ready for the fourth lesson.
	// Also, some platforms needs 'const char *' and some 'const wchar_t *',
	// so add/remove 'L' before the path when necessary.
	image.Load(L"coordinates.png");		// We use Load method here

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	// We use Width, Height and GetData methods here
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.Width(), image.Height(), 0,
		GL_RGB, GL_UNSIGNED_BYTE, image.GetData());
}
TextureReaderDevil::TextureReaderDevil() {
    name_ = "DevIL Reader";
    extensions_.push_back("bmp");
    extensions_.push_back("cut");
    extensions_.push_back("dcx");
    extensions_.push_back("dds");
    extensions_.push_back("ico");
    extensions_.push_back("gif");
    extensions_.push_back("jpg");
    extensions_.push_back("jpeg");
    extensions_.push_back("lbm");
    extensions_.push_back("lif");
    extensions_.push_back("mdl");
    extensions_.push_back("pcd");
    extensions_.push_back("pcx");
    extensions_.push_back("pic");
    extensions_.push_back("png");
    extensions_.push_back("pnm");
    extensions_.push_back("psd");
    extensions_.push_back("psp");
    extensions_.push_back("raw");
    extensions_.push_back("sgi");
    extensions_.push_back("tga");
    extensions_.push_back("tif");
    extensions_.push_back("wal");
    extensions_.push_back("act");
    extensions_.push_back("pal");
    extensions_.push_back("hdr");

    // Initialize DevIL
    ilInit();
    ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
    ilEnable(IL_ORIGIN_SET); // Flip images
}
Exemple #3
0
void DevILInit(void)
{
	ilInit();
	ilEnable(IL_CONV_PAL);
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
}
Exemple #4
0
bool CGuildMarkImage::Build(const char * c_szFileName)
{
	sys_log(0, "GuildMarkImage: creating new file %s", c_szFileName);

	Destroy();
	Create();

	ilBindImage(m_uImg);
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);

	BYTE * data = (BYTE *) malloc(sizeof(Pixel) * WIDTH * HEIGHT);
	memset(data, 0, sizeof(Pixel) * WIDTH * HEIGHT);

	if (!ilTexImage(WIDTH, HEIGHT, 1, 4, IL_BGRA, IL_UNSIGNED_BYTE, data))
	{
		sys_err("GuildMarkImage: cannot initialize image");
		return false;
	}

	free(data);

	ilEnable(IL_FILE_OVERWRITE);

	if (!ilSave(IL_TGA, (const ILstring)c_szFileName))
		return false;

	return true;
}
Exemple #5
0
BundlerMatcher::BundlerMatcher(float matchThreshold, int firstOctave, bool binaryWritingEnabled, bool sequenceMatching, int sequenceMatchingLength)
{
    mBinaryKeyFileWritingEnabled = binaryWritingEnabled;
    mSequenceMatchingEnabled     = sequenceMatching;
    mSequenceMatchingLength      = sequenceMatchingLength;

    //DevIL init
    ilInit();
    ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
    ilEnable(IL_ORIGIN_SET);

    std::cout << "[BundlerMatcher]"<<std::endl;
    std::cout << "[Initialization]";

    mIsInitialized = true;
    mMatchThreshold = matchThreshold; //0.0 means few match and 1.0 many match

    char fo[10];
    sprintf(fo, "%d", firstOctave);
    char* args[] = {"-fo", fo};

    mSift = new SiftGPU;
    mSift->ParseParam(2, args);
    mSift->SetVerbose(-2);

    int support = mSift->CreateContextGL();
    if (support != SiftGPU::SIFTGPU_FULL_SUPPORTED)
        mIsInitialized = false;

    if (mIsInitialized)
        mSift->AllocatePyramid(1600, 1600);

    mMatcher = new SiftMatchGPU(4096);
}
Exemple #6
0
void CMainDlg::ExportTextures(const CString &path)
{
	ILuint handle;
	ilInit();
	iluInit();
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
	ilEnable(IL_ORIGIN_SET);
	for(int i = 0; i < m_Textures.GetCount(); i++)
	{
		if(texdata[i] != -1)
		{
			ilGenImages(1, & handle);
			ilBindImage(handle);
			CString file;
			m_Textures.GetText(i, file);
			vector<char> data;
			data.resize(sc.index[texdata[i]].fileSize);
			ifstream is;
			is.sync_with_stdio(false);
			is.open(sc.index[texdata[i]].cachename.c_str(), ios::binary|ios::in);
			is.read(reinterpret_cast<char*>(&data[0]), sc.index[texdata[i]].fileSize);
			is.close();
			ILboolean ret = ilLoadL(IL_DDS, reinterpret_cast<char*>(&data[0]), sc.index[texdata[i]].fileSize);
			file.Replace(".dds", ".png");
			iluFlipImage();
			ilSaveImage((path + file));
			/*ofstream out;
			out.sync_with_stdio(false);
			out.open(path + file, ios::binary);
			out.write(reinterpret_cast<char*>(&data[0]), sc.index[texdata[i]].fileSize);
			out.close();*/
			ilDeleteImages(1, & handle);
		}
	}
}
Exemple #7
0
void CBitmap::Save(string const& filename)
{
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
	ilEnable(IL_ORIGIN_SET);

	unsigned char* buf=new unsigned char[xsize*ysize*4];
	/* HACK Flip the image so it saves the right way up.
		(Fiddling with ilOriginFunc didn't do anything?)
		Duplicated with ReverseYAxis. */
	for(int y=0;y<ysize;++y){
		for(int x=0;x<xsize;++x){
			buf[((ysize-1-y)*xsize+x)*4+0]=mem[((y)*xsize+x)*4+0];
			buf[((ysize-1-y)*xsize+x)*4+1]=mem[((y)*xsize+x)*4+1];
			buf[((ysize-1-y)*xsize+x)*4+2]=mem[((y)*xsize+x)*4+2];
			buf[((ysize-1-y)*xsize+x)*4+3]=mem[((y)*xsize+x)*4+3];
		}
	}

	ilHint(IL_COMPRESSION_HINT, IL_USE_COMPRESSION);
	ilSetInteger (IL_JPG_QUALITY, 80);

	ILuint ImageName = 0;
	ilGenImages(1, &ImageName);
	ilBindImage(ImageName);

	ilTexImage(xsize,ysize,1,4,IL_RGBA,IL_UNSIGNED_BYTE,NULL);
	ilSetData(buf);
	ilSaveImage((char*)filename.c_str());
	ilDeleteImages(1,&ImageName);
	delete[] buf;
}
bool CGuildMarkUploader::__Load(const char* c_szFileName, UINT* peError)
{
	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)!=SGuildMark::WIDTH)	
	{
		*peError=ERROR_WIDTH;
		return false;
	}

	if (ilGetInteger(IL_IMAGE_HEIGHT)!=SGuildMark::HEIGHT)
	{
		*peError=ERROR_HEIGHT;
		return false;
	}

	ilConvertImage(IL_BGRA, IL_BYTE);

	ilCopyPixels(0, 0, 0, SGuildMark::WIDTH, SGuildMark::HEIGHT, 1, IL_BGRA, IL_BYTE, (ILvoid*)m_kMark.m_apxBuf);

	ilDeleteImages(1, &uImg);
	return true;
}
Exemple #9
0
// Image saver...
bit DevilSave(cstrconst filename,nat32 width,nat32 height,nat32 format,nat32 type,void * data,bit overwrite)
{
 unsigned int handle;
 ilGenImages(1,(unsigned int *)&handle); 
 ilBindImage(handle);
 ilEnable(0x0600);
 ilOriginFunc(0x0601);

 if (overwrite) ilEnable(DEVIL_FILE_SQUISH);
           else ilDisable(DEVIL_FILE_SQUISH);
  
 int num;
 switch (format)
 {
  case DEVIL_FORM_RGB: num = 3; break;
  case DEVIL_FORM_RGBA: num = 4; break;
  default: num =  1; break;
 }
 ilTexImage(width,height,1,num,format,type,data);

 ilSaveImage(filename);
 if (ilGetError())
 {
  ilDeleteImages(1,(unsigned int *)&handle);
  return false;
 }
 else
 { 
  ilDeleteImages(1,(unsigned int *)&handle);
  return true;
 }
}
Exemple #10
0
const ImageData Texture::loadFile(const std::string &path, const ImageFormat &format) {
	ilInit();

	ILuint image;
	ilGenImages(1, &image);
	ilBindImage(image);
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);

	ImageData imageData;

	ILboolean result = ilLoadImage(path.c_str());
	if (result) {
		//ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);

		imageData.format = format;

		imageData.width = ilGetInteger(IL_IMAGE_WIDTH);
		imageData.height = ilGetInteger(IL_IMAGE_HEIGHT);
		imageData.sizeInBytes = imageData.width * imageData.height * imageData.format.numberOfChannels * imageData.format.bytesPerChannel;

		imageData.data = new uint8_t[imageData.sizeInBytes];
		memcpy(imageData.data, ilGetData(), imageData.sizeInBytes);
	}
	else {
		std::cout << "Failed to load image from file: " << path << std::endl;
	}

	ilDeleteImages(1, &image);

	return imageData;
}
Exemple #11
0
bool CGuildMarkImage::Load(const char * c_szFileName) 
{
	Destroy();
	Create();	

	ilBindImage(m_uImg);
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);

	if (!ilLoad(IL_TYPE_UNKNOWN, (const ILstring) c_szFileName))
	{
		sys_err("GuildMarkImage: %s cannot open file.", c_szFileName);
		return false;
	}

	if (ilGetInteger(IL_IMAGE_WIDTH) != WIDTH)	
	{
		sys_err("GuildMarkImage: %s width must be %u", c_szFileName, WIDTH);
		return false;
	}

	if (ilGetInteger(IL_IMAGE_HEIGHT) != HEIGHT)
	{
		sys_err("GuildMarkImage: %s height must be %u", c_szFileName, HEIGHT);
		return false;
	}

	ilConvertImage(IL_BGRA, IL_UNSIGNED_BYTE);

	BuildAllBlocks();
	return true;
}
	void				TextureManager::loadTexture(const std::string &filename)
	{
		ILboolean		success;
		unsigned int	imageID;
		GLuint			textureId;

		ilGenImages(1, &imageID);
		ilBindImage(imageID);
		ilEnable(IL_ORIGIN_SET);
		ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
		success = ilLoadImage((ILstring)filename.c_str());
		if (!success) {
			GameTools::debugManager::getInstance().dAssert("png file not loaded : " + filename);
		}
		ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);

		glGenTextures(1, &textureId);
		glBindTexture(GL_TEXTURE_2D, textureId);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
			ilGetInteger(IL_IMAGE_WIDTH),
			ilGetInteger(IL_IMAGE_HEIGHT),
			0, GL_RGBA, GL_UNSIGNED_BYTE,
			ilGetData());
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
		this->textureMap.insert(std::pair<std::string, Texture>(filename, Texture(filename, textureId, ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT))));
	}
Exemple #13
0
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG			msg;
    WNDCLASSEX	wcex;
    HACCEL		hAccelTable;

    hInstance = hInst;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style			= CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc	= (WNDPROC)WndProc;
    wcex.cbClsExtra		= 0;
    wcex.cbWndExtra		= 0;
    wcex.hInstance		= hInstance;
    wcex.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
    wcex.hCursor		= LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground	= (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName	= (LPCSTR)IDR_MENU1;
    wcex.lpszClassName	= TITLE;
    wcex.hIconSm		= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_ICON1);

    RegisterClassEx(&wcex);

    HWnd = CreateWindow(TITLE, TITLE, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                        50, 50, 400, 300, NULL, NULL, hInstance, NULL);
    if (HWnd == NULL)
        return FALSE;

    // Display the window
    ShowWindow(HWnd, nCmdShow);
    UpdateWindow(HWnd);

    ilInit();
    ilEnable(IL_ORIGIN_SET);
    ilEnable(IL_TYPE_SET);
    ilEnable(IL_FORMAT_SET);

    ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
    ilTypeFunc(IL_UNSIGNED_BYTE);
    ilFormatFunc(IL_BGR);

    // Is there a file to load from the command-line?
    if (__argc > 1) {
        LoadImages(__argv[1]);
    }

    hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDR_MENU1);

    while (GetMessage(&msg, NULL, 0, 0)) {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return msg.wParam;
}
Exemple #14
0
void IMG_InitDevil()
{
	//initialize devIL
	ilInit();
	ilOriginFunc( IL_ORIGIN_UPPER_LEFT );
	ilEnable( IL_ORIGIN_SET );
	ilEnable( IL_TYPE_SET );
	ilTypeFunc( IL_UNSIGNED_BYTE );
}
Exemple #15
0
int main(const int argc, const char* const argv[]) {
	param_t parameters;
	if(!parse_args(argc, argv, &parameters)) {
		return EXIT_FAILURE;
	}

	ilInit();
	ilEnable(IL_ORIGIN_SET);
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
	ILuint image;
	ilGenImages(1, &image);
	ilBindImage(image);
	const ILboolean load_success = ilLoadImage(parameters.in);
	if(load_success== IL_FALSE) {
		// handle error TODO
		ilDeleteImages(1, &image);
		return EXIT_FAILURE;
	}
	const ILboolean convert_success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
	if(convert_success == IL_FALSE) {
		// handle error TODO
		ilDeleteImages(1, &image);
		return EXIT_FAILURE;
	}

	const ILint width = ilGetInteger(IL_IMAGE_WIDTH);
	const ILint height = ilGetInteger(IL_IMAGE_HEIGHT);
	const ILint out_width = width / parameters.scale;
	const ILint out_height = height / parameters.scale;

	ILubyte out_data[out_width * out_height];

	const image_t in = {
		.width = width,
		.height = height,
		.data = ilGetData(),
	};
	const image_t out = {
		.width = out_width,
		.height = out_height,
		.data = out_data,
	};
	convert(in, out, parameters);

	ilDeleteImages(1, &image);

	ILuint out_image;
	ilGenImages(1, &out_image);
	ilBindImage(out_image);

	ilTexImage(out_width, out_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, &out_data);
	ilEnable(IL_FILE_OVERWRITE);
	ilSaveImage(parameters.out);
	ilDeleteImages(1, &image);
	return EXIT_SUCCESS;
}
Texture* DevILImageCodec::load(const RawDataContainer& data, Texture* result)
{
    ilPushAttrib(IL_ORIGIN_SET);
    ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
    ilEnable(IL_ORIGIN_SET);

    ILuint imgName;
    ilGenImages(1, &imgName);
    ilBindImage(imgName);

    if (IL_FALSE != ilLoadL(IL_TYPE_UNKNOWN,
                            static_cast<const void*>(data.getDataPtr()),
                            data.getSize()))
    {
        // get details about size of loaded image
        ILinfo imgInfo;
        memset(&imgInfo, 0, sizeof(ILinfo));
        iluGetImageInfo(&imgInfo);
        // set dimensions of texture
        size_t width = imgInfo.Width;
        size_t height = imgInfo.Height;
        // allocate temp buffer to receive image data
        uchar* tmpBuff = new uchar[width * height * 4];

        // get image data in required format
        Texture::PixelFormat cefmt;
        ILenum ilfmt;
        switch (imgInfo.Format)
        {
        case IL_RGBA:
        case IL_BGRA:
            ilfmt = IL_RGBA;
            cefmt = Texture::PF_RGBA;
            break;
        default:
            ilfmt = IL_RGB;
            cefmt = Texture::PF_RGB;
            break;
        };
        ilCopyPixels(0, 0, 0, width, height, 1, ilfmt, IL_UNSIGNED_BYTE,
                     static_cast<void*>(tmpBuff));

        // delete DevIL image
        ilDeleteImages(1, &imgName);
        ilPopAttrib();

        // create cegui texture
        CEGUI_TRY
        {
            result->loadFromMemory(tmpBuff, Size(width, height), cefmt);
        }
        CEGUI_CATCH(...)
        {
            delete [] tmpBuff;
            CEGUI_RETHROW;
        }
Exemple #17
0
Image::Image(const string& filename) : 
    _data(NULL)
{
   
    const boost::regex normalmap_pattern(rtr::kNormalMapFormat());

    if (!devil_initialized) {
        ilInit();
        ilEnable(IL_ORIGIN_SET);
        ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
        devil_initialized = true;
    }

    ILuint il_image;
    ilGenImages(1, &il_image);
    ilBindImage(il_image);

    ILboolean success = ilLoadImage(filename.c_str());

    if (!success) {
        cerr << "Image::Image "
             << "Failed to load image file " << filename << endl;
        
        _data = NULL;
        return;
    }

    _dimensions = 2;
    _format = ilGetInteger(IL_IMAGE_FORMAT);
    if (_format == IL_LUMINANCE) {
        _format = GL_RED;
        
    }

    _type = ilGetInteger(IL_IMAGE_TYPE);
    _width = ilGetInteger(IL_IMAGE_WIDTH);
    _height = ilGetInteger(IL_IMAGE_HEIGHT);
    _depth = 0;
    _bpp = ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
    _data = malloc(_bpp * _width * _height);

    if (boost::regex_match(filename, normalmap_pattern)) {

        _internal_format = get_linear_format(_format, _type);
    } else {
        _internal_format = get_internal_format(_format, _type);
    }

    ilCopyPixels(0, 0, 0, _width, _height, 1, 
                 ilGetInteger(IL_IMAGE_FORMAT), _type, _data);

    ilBindImage(0);
    ilDeleteImages(1, &il_image);

}
void cRenderer::initExternals(){
	glewExperimental = GL_TRUE;												//új GLEW extensionok 
	glewInit();																//GLEW inicializálása

	ilInit();																//DevIL / IL inicializálása
	iluInit();																//DevIL / ILU iniclializálása
	ilutRenderer(ILUT_OPENGL);												//DevIL OpenGL-re állítása
	ilEnable(IL_ORIGIN_SET);												//DevIL origin beállítása
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);										//DevIL bal lent legyen az origin
	ilutEnable(ILUT_GL_USE_S3TC);											//S3TC formátum használata
}
Exemple #19
0
ImagesLoader::ImagesLoader(){
    ilInit();

    ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
    ilEnable(IL_ORIGIN_SET);

    ilEnable(IL_FILE_OVERWRITE);

    ilSetInteger(IL_FORMAT_MODE, IL_BGRA);
    ilEnable(IL_FORMAT_SET);
}
Exemple #20
0
	CubeMap(std::string posx, std::string negx, 
			std::string posy, std::string negy,
			std::string posz, std::string negz) {
		ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
		loadImage(posx, this->posx);
		loadImage(negx, this->negx);
		loadImage(posy, this->posy);
		loadImage(negy, this->negy);
		loadImage(posz, this->posz);
		loadImage(negz, this->negz);
	}
Exemple #21
0
void LoadImages(char *FileName)
{
    ILuint Image, i;

    hDC = GetDC(HWnd);
    hMemDC = CreateCompatibleDC(hDC);

    ilGenImages(1, &Image);
    ilBindImage(Image);
    if (!ilLoadImage(FileName)) {
        ilDeleteImages(1, &Image);
        return;
    }

    ilEnable(IL_ORIGIN_SET);
    ilEnable(IL_FORMAT_SET);
    ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
    //ilFormatFunc(IL_BGRA);
    ilConvertImage(IL_BGR, IL_UNSIGNED_BYTE);
    ilutRenderer(ILUT_WIN32);

    CurImage = 0;
    NumImages = ilGetInteger(IL_NUM_IMAGES) + 1;
    Bitmaps = new HBITMAP[NumImages];
    BmpInfo = new BITMAPINFOHEADER[NumImages];
    Durations = new ILuint[NumImages];
    if (Bitmaps == NULL || BmpInfo == NULL || Durations == NULL) {
        ilDeleteImages(1, &Image);
        return;
    }

    for (i = 0; i < NumImages; i++) {
        ilActiveImage(0);
        ilActiveImage(i);
        Durations[i] = ilGetInteger(IL_IMAGE_DURATION);
        *(Bitmaps + i) = ilutConvertToHBitmap(hDC);
        ilutGetBmpInfo((BITMAPINFO*)(BmpInfo + i));
    }

    SelectObject(hMemDC, Bitmaps[0]);

    ilDeleteImages(1, &Image);

    sprintf(NewTitle, "%s - %s", TITLE, FileName);
    SetWindowText(HWnd, NewTitle);

    QueryPerformanceFrequency((LARGE_INTEGER*)&TimerFreq);
    TimerRes = 1.0 / TimerFreq;
    QueryPerformanceCounter((LARGE_INTEGER*)&StartTime);

    return;
}
Exemple #22
0
int main(int argc, char* argv[])
{
	ilInit();                                //inicializa biblioteca de imagens
	ilEnable(IL_FILE_OVERWRITE);             //permite que a biblioteca sobrescreva arquivos em disco
	ilEnable(IL_ORIGIN_SET);                 //define a origem das imagens como o canto superior esquerdo
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
	setlocale(LC_ALL, "Portuguese");

	while (1)
		interface();

	return 0;
}
Exemple #23
0
nTextureManager::nTextureManager() {
    texDir = nGine::instance()->appPath();
    mutex = new nMutex;

    errorTex = 0;
    fbo = 0;

    ilInit();
    iluInit();
    ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
    ilEnable(IL_ORIGIN_SET);

    nGine::instance()->getJobPool()->addJob(new nTextureJob(this), nJobPool::Medium);
}
Exemple #24
0
        Texture::Texture()
        {
            if(!s_initLib)
            {
                // initialize DevIL
                ilInit();
#if defined ODIN_DEBUG
                iluInit();
#endif
                ILDEBUG(ilEnable(IL_ORIGIN_SET));
                ILDEBUG(ilOriginFunc(IL_ORIGIN_LOWER_LEFT));
                s_initLib = true;
            }
        }
Exemple #25
0
GLuint loadTextureFile(const char *fn_in, GLuint tex_in, 
  GLenum target_texture, GLenum target_image,
  int HDR) {
  ILuint img=0;
  GLuint tex=tex_in;
  char *fn=0;
  
  
  if (!(fn=vfs_locate(fn_in,REPOSITORY_MASK_TEXTURE))) {
    LOG_WARNING(
      "WARNING: unable to find texture file '%s'\n",
      fn_in);
    goto finalize;
  }
  
  ilEnable(IL_ORIGIN_SET);
  ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
  ilGenImages(1,&img);
  ilBindImage(img);
  
  if (ilLoadImage(fn)!=1) {
    LOG_WARNING(
      "WARNING: unable to load texture file '%s'\n",
      fn);
    goto finalize;
  }
  
  #if DIYYMA_FILE_LIST>=2
  file_list_append(fn);
  #endif
  
  ilConvertImage(HDR?IL_RGB:IL_RGBA,HDR?IL_FLOAT:IL_UNSIGNED_BYTE);
  
  if (!tex) glGenTextures(1,&tex);
  glBindTexture(target_texture,tex);
  glTexImage2D(
    target_image,0,HDR?GL_R11F_G11F_B10F:GL_RGBA,
    ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),
    0,HDR?GL_RGB:GL_RGBA,HDR?GL_FLOAT:GL_UNSIGNED_BYTE,
    ilGetData());
  glTexParameteri(target_texture,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  glTexParameteri(target_texture,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  finalize:
  
  if (fn) free((void*)fn);
  if (img) ilDeleteImages(1,&img);
  
  return tex;
}
Exemple #26
0
void initExtLibs()
{
	// glew
	GLenum err = glewInit();
	ASSERT(GLEW_OK == err );
	TRACE( "Using GLEW %s\n", glewGetString(GLEW_VERSION));

	// devil
	ilInit();
	iluInit();

    // force same origin for all image files (pngs can be flipped on Y, etc)
    ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
    ilEnable(IL_ORIGIN_SET);
}
Exemple #27
0
bool CBitmap::Save(std::string const& filename, bool opaque) const
{
	if (type == BitmapTypeDDS) {
#ifndef BITMAP_NO_OPENGL
		return ddsimage->save(filename);
#else
		return false;
#endif // !BITMAP_NO_OPENGL
	}

	unsigned char* buf = new unsigned char[xsize * ysize * 4];
	const int ymax = (ysize - 1);
	/* HACK Flip the image so it saves the right way up.
		(Fiddling with ilOriginFunc didn't do anything?)
		Duplicated with ReverseYAxis. */
	for (int y = 0; y < ysize; ++y) {
		for (int x = 0; x < xsize; ++x) {
			const int bi = 4 * (x + (xsize * (ymax - y)));
			const int mi = 4 * (x + (xsize * (y)));
			buf[bi + 0] = mem[mi + 0];
			buf[bi + 1] = mem[mi + 1];
			buf[bi + 2] = mem[mi + 2];
			buf[bi + 3] = opaque ? 0xff : mem[mi + 3];
		}
	}

	boost::mutex::scoped_lock lck(devilMutex);
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
	ilEnable(IL_ORIGIN_SET);

	ilHint(IL_COMPRESSION_HINT, IL_USE_COMPRESSION);
	ilSetInteger(IL_JPG_QUALITY, 80);

	ILuint ImageName = 0;
	ilGenImages(1, &ImageName);
	ilBindImage(ImageName);

	ilTexImage(xsize, ysize, 1, 4, IL_RGBA, IL_UNSIGNED_BYTE, buf);

	const std::string fullpath = dataDirsAccess.LocateFile(filename, FileQueryFlags::WRITE);
	const bool success = ilSaveImage((char*)fullpath.c_str());

	ilDeleteImages(1, &ImageName);
	ilDisable(IL_ORIGIN_SET);
	delete[] buf;

	return success;
}
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;
}
Exemple #29
0
GLubyte* OpenImageDevIL(const std::string& filename, unsigned int& w, unsigned int& h, unsigned int& d)
{
	static bool first = true;
	if(first) {
		first = false;

		// Init DevIL
		ilInit();

		// Set origin of image to upper left corner
		ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
		ilEnable(IL_ORIGIN_SET);

		ilEnable(IL_TYPE_SET);
		ilTypeFunc(IL_UNSIGNED_BYTE);
	}

    // Generating a new texture
    ILuint ilTexture;
    ilGenImages(1, &ilTexture);
    ilBindImage(ilTexture);

    // Loading image
	if (!ilLoadImage(filename.c_str()))
		return false;

	w = ilGetInteger(IL_IMAGE_WIDTH);
	h = ilGetInteger(IL_IMAGE_HEIGHT);
	d = ilGetInteger(IL_IMAGE_BPP);
	
	if(d==4)
		ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);

    // Get the size of image
    const unsigned char* Pixels = ilGetData();

	GLubyte* img = new GLubyte[(size_t)(w) * (size_t)(h) * (size_t)(d)];
	memcpy(img, Pixels, (size_t)(w) * (size_t)(h) * (size_t)(d));
	
    // Remove the texture
    ilBindImage(0);
    ilDeleteImages(1, &ilTexture);
	
	return img;
	//return NULL;
}
Exemple #30
0
void nIL::init()  {
	if(initialized) {
		return;
	}
	mutex.lock();
	#ifndef NO_IL
	ilInit();
	iluInit();
	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
	ilEnable(IL_ORIGIN_SET);
	#endif
	loadThread = new nPooledThread<nTextureLoadInstance>("nIL::loadThread");

	loadThread->start();
	initialized = true;
	mutex.unlock();
}