当前位置: 首页>>代码示例>>C++>>正文


C++ FreeImage_GetFileType函数代码示例

本文整理汇总了C++中FreeImage_GetFileType函数的典型用法代码示例。如果您正苦于以下问题:C++ FreeImage_GetFileType函数的具体用法?C++ FreeImage_GetFileType怎么用?C++ FreeImage_GetFileType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FreeImage_GetFileType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadStereoBackground

/* Loads the stereo background */
void loadStereoBackground(void) {
	printf("Left Background loaded = %s", leftBackground.c_str());
	
	// Import left image
	FREE_IMAGE_FORMAT fImageFormatLeft = FreeImage_GetFileType(leftBackground.c_str(), 0);
	FIBITMAP *fBitMapLeft = FreeImage_Load(fImageFormatLeft, leftBackground.c_str(), 0);
	fBitMapLeft = FreeImage_ConvertTo24Bits(fBitMapLeft);
	
	glGenTextures(1, &bgLeftID);
	glBindTexture(GL_TEXTURE_2D, bgLeftID);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	BYTE *bitsLeft = new BYTE[FreeImage_GetWidth(fBitMapLeft) * FreeImage_GetHeight(fBitMapLeft) * 3];
	BYTE *pixelsLeft = (BYTE*)FreeImage_GetBits(fBitMapLeft);
	// Switch in RGB format
	for(int pix=0; pix<FreeImage_GetWidth(fBitMapLeft) * FreeImage_GetHeight(fBitMapLeft); pix++) {
		bitsLeft[pix*3+0]=pixelsLeft[pix*3+2];
		bitsLeft[pix*3+1]=pixelsLeft[pix*3+1];
		bitsLeft[pix*3+2]=pixelsLeft[pix*3+0];
	}
	
	glTexImage2D(GL_TEXTURE_2D, 0, 3, FreeImage_GetWidth(fBitMapLeft), FreeImage_GetHeight(fBitMapLeft), 
				 0, GL_RGB, GL_UNSIGNED_BYTE, bitsLeft);
	FreeImage_Unload(fBitMapLeft);
	delete bitsLeft;
	
	printf("Right Background loaded = %s", rightBackground.c_str());
	// Import right image
	FREE_IMAGE_FORMAT fImageFormatRight = FreeImage_GetFileType(rightBackground.c_str(), 0);
	FIBITMAP *fBitMapRight = FreeImage_Load(fImageFormatRight, rightBackground.c_str(), 0);
	fBitMapRight = FreeImage_ConvertTo24Bits(fBitMapRight);
	
	glGenTextures(1, &bgRightID);
	glBindTexture(GL_TEXTURE_2D, bgRightID);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	BYTE *bitsRight = new BYTE[FreeImage_GetWidth(fBitMapRight) * FreeImage_GetHeight(fBitMapRight) * 3];
	BYTE *pixelsRight = (BYTE*)FreeImage_GetBits(fBitMapRight);
	// Switch in RGB format
	for(int pix=0; pix<FreeImage_GetWidth(fBitMapRight) * FreeImage_GetHeight(fBitMapRight); pix++) {
		bitsRight[pix*3+0]=pixelsRight[pix*3+2];
		bitsRight[pix*3+1]=pixelsRight[pix*3+1];
		bitsRight[pix*3+2]=pixelsRight[pix*3+0];
	}
	
	glTexImage2D(GL_TEXTURE_2D, 0, 3, FreeImage_GetWidth(fBitMapRight), FreeImage_GetHeight(fBitMapRight), 
				 0, GL_RGB, GL_UNSIGNED_BYTE, bitsRight);
	FreeImage_Unload(fBitMapRight);
	delete bitsRight;
	
	stereoBackground = true;
}
开发者ID:biomood,项目名称:3D-Ink,代码行数:55,代码来源:main.cpp

示例2: CreateTexture

/**
 * Create twitch texture
 */
bool CreateTexture()
{
	const char* textureFile = "twitch.png";

	FREE_IMAGE_FORMAT format = FreeImage_GetFileType(textureFile, 0);

	FIBITMAP* bitmap = FreeImage_Load(format, textureFile);

	if ( bitmap == nullptr )
	{
		std::string filePath = std::string("..\\..\\") + textureFile;

		format = FreeImage_GetFileType(filePath.c_str(), 0);

		bitmap = FreeImage_Load(format, filePath.c_str() );

		if ( bitmap == nullptr )
		{
			ReportError("Failed to load texture");
			return false;
		}
	}	
 
	FIBITMAP* bitmap32 = FreeImage_ConvertTo32Bits(bitmap);	
 
	int w = FreeImage_GetWidth(bitmap32);
	int h = FreeImage_GetHeight(bitmap32);

	char* buffer = (char*)FreeImage_GetBits(bitmap32);
 
	glGenTextures(1, &gTwitchTexture);

	glBindTexture(GL_TEXTURE_2D, gTwitchTexture);

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_NEAREST );
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_NEAREST );

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*)buffer );

	FreeImage_Unload(bitmap32);
	FreeImage_Unload(bitmap);

	if ( glGetError() != GL_NO_ERROR )
	{
		ReportError("Failed to load texture");
		glBindTexture(GL_TEXTURE_2D, 0);
		return false;
	}
	
	glBindTexture(GL_TEXTURE_2D, 0);

	return true;
}
开发者ID:shawnh310,项目名称:sdk-dist,代码行数:56,代码来源:wavemesh_ogl.cpp

示例3: TextureFromFile

GLuint TextureFromFile(const char* filename)
{
    FREE_IMAGE_FORMAT fileFormat = FIF_UNKNOWN;
    FIBITMAP *image(0);
  
    BYTE* bits(0);
    unsigned int width(0), height(0);
     
    fileFormat = FreeImage_GetFileType(filename, 0);
    image = FreeImage_Load(fileFormat, filename);
  
    if(!image)
        return 0;
  
    bits = FreeImage_GetBits(image);
    width = FreeImage_GetWidth(image);
  
    height = FreeImage_GetHeight(image);
  
    GLuint tex;
    glGenTextures(1, &tex);
  
    glBindTexture(GL_TEXTURE_2D, tex);
    gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_BGR, GL_UNSIGNED_BYTE, bits);
  
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  
    FreeImage_Unload(image);
  
    return tex;
}
开发者ID:valasekg,项目名称:elu_fi_bsc_cg,代码行数:32,代码来源:GLUtils.hpp

示例4: FreeImage_GetFileType

BOOL fipImage::load(const char* lpszPathName, int flag) {
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;

	// check the file signature and get its format
	// (the second argument is currently not used by FreeImage)
	fif = FreeImage_GetFileType(lpszPathName, 0);
	if(fif == FIF_UNKNOWN) {
		// no signature ?
		// try to guess the file format from the file extension
		fif = FreeImage_GetFIFFromFilename(lpszPathName);
	}
	// check that the plugin has reading capabilities ...
	if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
		// Free the previous dib
		if(_dib) {
			FreeImage_Unload(_dib);			
		}
		// Load the file
		_dib = FreeImage_Load(fif, lpszPathName, flag);
		_bHasChanged = TRUE;
		if(_dib == NULL)
			return FALSE;
		return TRUE;
	}
	return FALSE;
}
开发者ID:MrMasterplan,项目名称:PIC-stuff,代码行数:26,代码来源:fipImage.cpp

示例5: createTexture

image* createTexture(char* filePath){
	//FreeImage_Initialise(FALSE);
	FREE_IMAGE_FORMAT formato = FreeImage_GetFileType(filePath,0);//Automatocally detects the format(from over 20 formats!)
	FIBITMAP* imagen = FreeImage_Load(formato, filePath,JPEG_ACCURATE);
	FIBITMAP* temp = imagen;
	imagen = FreeImage_ConvertTo32Bits(imagen);
	FreeImage_Unload(temp);

	int w = FreeImage_GetWidth(imagen);
	int h = FreeImage_GetHeight(imagen);
	GLubyte* textura = (GLubyte*) malloc(4*w*h);
	char* pixeles = (char*)FreeImage_GetBits(imagen);
	//FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
	int j = 0;
	for(; j<w*h; j++){
		textura[j*4+0]= pixeles[j*4+2];
		textura[j*4+1]= pixeles[j*4+1];
		textura[j*4+2]= pixeles[j*4+0];
		textura[j*4+3]= pixeles[j*4+3];
	}
	free(pixeles);
	FreeImage_Unload(imagen);
	image* imageToReturn = malloc(sizeof(image));
	imageToReturn->height = h;
	imageToReturn->width = w;
	imageToReturn->texture = textura;
	return imageToReturn;
}
开发者ID:laurenskz,项目名称:Game,代码行数:28,代码来源:textureLoader.c

示例6: FreeImage_Initialise

void pre_lzw::do_lzw(const QDir & d){
    FreeImage_Initialise(true);
    QString label_out = "";
    QString dst = ui.lineEdit_2->text();
    QString d_src = d.path();
    QString serial_str = d_src.right(5);
    QDir dst_dir(dst);
    dst_dir.mkdir(serial_str);
    QString image_name = "", image_name_path(""), saved_name("");
    int dot_pos = 0;
    QFileInfoList handled_images = d.entryInfoList();
    QList<QFileInfo>::iterator images_iter = handled_images.begin();
    
    FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
    for(; images_iter < handled_images.end(); ++images_iter){
        image_name_path = (*images_iter).absoluteFilePath();
        if((*images_iter).isDir()){
            continue;
        }
        FIBITMAP *handled_image = 0;
        image_name = (*images_iter).fileName();
        dot_pos = image_name.indexOf(".");
        saved_name = dst + "\\" + serial_str + "\\" + image_name.left(dot_pos) + "_c.tif";
        label_out += saved_name + "\n";
        fif = FreeImage_GetFileType(image_name_path.toStdString().c_str());
        handled_image = FreeImage_Load(fif, image_name_path.toStdString().c_str());
        FreeImage_Save(FIF_TIFF, handled_image, saved_name.toStdString().c_str(), TIFF_LZW);
        FreeImage_Unload(handled_image);
    }
//    ui.label->setText(label_out);
    FreeImage_DeInitialise();

}
开发者ID:sulei1324,项目名称:lab_codes,代码行数:33,代码来源:pre_lzw.cpp

示例7: dib

bool CTexture::loadTexture2D(string a_sPath, bool bGenerateMipMaps)
{
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	FIBITMAP* dib(0);

	fif = FreeImage_GetFileType(a_sPath.c_str(), 0); // Check the file signature and deduce its format

	if(fif == FIF_UNKNOWN) // If still unknown, try to guess the file format from the file extension
		fif = FreeImage_GetFIFFromFilename(a_sPath.c_str());
	
	if(fif == FIF_UNKNOWN) // If still unknown, return failure
		return false;

	if(FreeImage_FIFSupportsReading(fif)) // Check if the plugin has reading capabilities and load the file
		dib = FreeImage_Load(fif, a_sPath.c_str());
	if(!dib)
		return false;

	BYTE* bDataPointer = FreeImage_GetBits(dib); // Retrieve the image data

	// If somehow one of these failed (they shouldn't), return failure
	if(bDataPointer == NULL || FreeImage_GetWidth(dib) == 0 || FreeImage_GetHeight(dib) == 0)
		return false;

	GLenum format = FreeImage_GetBPP(dib) == 24 ? GL_BGR : FreeImage_GetBPP(dib) == 8 ? GL_LUMINANCE : 0;
	createFromData(bDataPointer, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), FreeImage_GetBPP(dib), format, bGenerateMipMaps);
	
	FreeImage_Unload(dib);

	sPath = a_sPath;

	return true; // Success
}
开发者ID:yumikokh,项目名称:bado,代码行数:33,代码来源:texture.cpp

示例8: testAcquireMemIO

/**
Test extracting a memory buffer from a memory stream
*/
void testAcquireMemIO(const char *lpszPathName) {

	// load a regular file
	FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(lpszPathName);
	FIBITMAP *dib = FreeImage_Load(fif, lpszPathName, 0);

	// open and allocate a memory stream
	fipMemoryIO memIO;

	// save the file to memory
	memIO.write(FIF_PNG, dib, PNG_DEFAULT);

	// get the buffer from the memory stream
	BYTE *mem_buffer = NULL;
	DWORD size_in_bytes = 0;

	memIO.acquire(&mem_buffer, &size_in_bytes);

	// save the buffer in a file stream
	FILE *stream = fopen("buffer.png", "wb");
	if(stream) {
		fwrite(mem_buffer, sizeof(BYTE), size_in_bytes, stream);
		fclose(stream);
	}

	// close and free the memory stream (memIO is destroyed)
}
开发者ID:MichaelH13,项目名称:sdkpub,代码行数:30,代码来源:fipTestMemIO.cpp

示例9: make_texture

GLuint make_texture(const char *filename) {

    GLuint texture;

    // Get the image file type from FreeImage.
    FREE_IMAGE_FORMAT fifmt = FreeImage_GetFileType(filename, 0);

    // Actually load the image file.
    FIBITMAP *dib = FreeImage_Load(fifmt, filename, 0);

    // Now, there is no guarantee that the image file
    // loaded will be GL_RGB, so we force FreeImage to
    // convert the image to GL_RGB.
    dib = FreeImage_ConvertTo32Bits(dib);

    if (dib != NULL) {
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        // This is important to note, FreeImage loads textures in
        // BGR format. Now we could just use the GL_BGR extension
        // But, we will simply swap the B and R components ourselves.
        // Firstly, allocate the new bit data doe the image.
        //BYTE *bits = malloc(FreeImage_GetWidth(dib) * FreeImage_GetHeight(dib) * 4);

        // get a pointer to FreeImage's data.
        BYTE *pixels = (BYTE*) FreeImage_GetBits(dib);

        // Iterate through the pixels, copying the data
        // from 'pixels' to 'bits' except in RGB format.
        /*
        int pix;
        for (pix = 0; pix < FreeImage_GetWidth(dib) * FreeImage_GetHeight(dib); pix++) {
            bits[pix * 4 + 0] = pixels[pix * 4 + 2];
            bits[pix * 4 + 1] = pixels[pix * 4 + 1];
            bits[pix * 4 + 2] = pixels[pix * 4 + 0];
            bits[pix * 4 + 3] = pixels[pix * 4 + 3];
        }*/

        // The new 'glTexImage2D' function, the prime difference
        // being that it gets the width, height and pixel information
        // from 'bits', which is the RGB pixel data..
        //glTexImage2D(GL_TEXTURE_2D, 0, 4, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 0,
        //       GL_RGBA, GL_UNSIGNED_BYTE, bits);
        glTexImage2D(GL_TEXTURE_2D, 0, 4, FreeImage_GetWidth(dib), FreeImage_GetHeight(dib), 0,
                GL_BGRA, GL_UNSIGNED_BYTE, pixels);


        // Unload the image.
        // and free the bit data.
        FreeImage_Unload(dib);
        //free(bits);
    } else {
        fprintf(stderr, "Can't load texture: %s\n", filename);
    }
    
    return texture;
}
开发者ID:rnentjes,项目名称:OpenGL,代码行数:60,代码来源:shaderUtils.c

示例10: FreeImage_JPEGCrop

BOOL DLL_CALLCONV 
FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom) {
	char crop[64];

	try {
		// check the src file format
		if(FreeImage_GetFileType(src_file) != FIF_JPEG) {
			throw FI_MSG_ERROR_MAGIC_NUMBER;
		}
		
		// normalize the rectangle
		if(right < left) {
			INPLACESWAP(left, right);
		}
		if(bottom < top) {
			INPLACESWAP(top, bottom);
		}

		// build the crop option
		sprintf(crop, "%dx%d+%d+%d", right - left, bottom - top, left, top);

		// setup IO
		FilenameIO filenameIO;
		memset(&filenameIO, 0, sizeof(FilenameIO));
		filenameIO.src_file = src_file;
		filenameIO.dst_file = dst_file;

		// perform the transformation
		return LosslessTransform(&filenameIO, FIJPEG_OP_NONE, crop, FALSE);

	} catch(const char *text) {
		FreeImage_OutputMessageProc(FIF_JPEG, text);
		return FALSE;
	}
}
开发者ID:AntiMoron,项目名称:YSLib,代码行数:35,代码来源:JPEGTransform.cpp

示例11: LoadTexture

bool LoadTexture(const char* filename,	//where to load the file from
	GLuint &texID,
	//does not have to be generated with glGenTextures
	GLenum image_format,		//format the image is in
	GLint internal_format,		//format to store the image in
	GLint level ,					//mipmapping level
	GLint border ) {
	//image format
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	//pointer to the image, once loaded
	FIBITMAP *dib(0);
	//pointer to the image data
	BYTE* bits(0);
	//image width and height
	unsigned int width(0), height(0);

	//check the file signature and deduce its format
	fif = FreeImage_GetFileType(filename, 0);
	//if still unknown, try to guess the file format from the file extension
	if (fif == FIF_UNKNOWN)
		fif = FreeImage_GetFIFFromFilename(filename);
	//if still unkown, return failure
	if (fif == FIF_UNKNOWN)
		return false;

	//check that the plugin has reading capabilities and load the file
	if (FreeImage_FIFSupportsReading(fif))
		dib = FreeImage_Load(fif, filename);
	//if the image failed to load, return failure
	if (!dib)
		return false;

	//retrieve the image data
	bits = FreeImage_GetBits(dib);
	//get the image width and height
	width = FreeImage_GetWidth(dib);
	height = FreeImage_GetHeight(dib);
	//if this somehow one of these failed (they shouldn't), return failure
	if ((bits == 0) || (width == 0) || (height == 0))
		return false;
	//generate an OpenGL texture ID for this texture
	glGenTextures(1, &texID);
	//store the texture ID mapping
	//bind to the new texture ID
	
	glBindTexture(GL_TEXTURE_2D, texID);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);	// 线形滤波
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);   // 线形滤波
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
																		//store the texture data for OpenGL use
	glTexImage2D(GL_TEXTURE_2D, level, internal_format, width, height,
		border, image_format, GL_UNSIGNED_BYTE, bits);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	//Free FreeImage's copy of the data
	FreeImage_Unload(dib);

	//return success
	return true;
}
开发者ID:abucraft,项目名称:opengl-balls,代码行数:60,代码来源:textureLoader.cpp

示例12: ofLog

//----------------------------------------------------------------
void  ofImage::saveImageFromPixels(string fileName, ofPixels &pix){

	if (pix.bAllocated == false){
		ofLog(OF_LOG_ERROR,"error saving image - pixels aren't allocated");
		return;
	}

	#ifdef TARGET_LITTLE_ENDIAN
		if (pix.bytesPerPixel != 1) swapRgb(pix);
	#endif

	FIBITMAP * bmp	= getBmpFromPixels(pix);

	#ifdef TARGET_LITTLE_ENDIAN
		if (pix.bytesPerPixel != 1) swapRgb(pix);
	#endif

	fileName = ofToDataPath(fileName);
	if (pix.bAllocated == true){
		FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
		fif = FreeImage_GetFileType(fileName.c_str(), 0);
		if(fif == FIF_UNKNOWN) {
			// or guess via filename
			fif = FreeImage_GetFIFFromFilename(fileName.c_str());
		}
		if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
			FreeImage_Save(fif, bmp, fileName.c_str(), 0);
		}
	}

	if (bmp != NULL){
		FreeImage_Unload(bmp);
	}
}
开发者ID:andyli,项目名称:openFrameworks,代码行数:35,代码来源:ofImage.cpp

示例13: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	const char* filename = "1.jpg";
	FREE_IMAGE_FORMAT fif = FreeImage_GetFileType(filename, 0);
	FIBITMAP *dib(0);
	//pointer to the image data
	BYTE* bits(0);
	//image width and height
	unsigned int width(0), height(0);

	if(fif == FIF_UNKNOWN) 
		fif = FreeImage_GetFIFFromFilename(filename);

	if(fif == FIF_UNKNOWN)
		return 1;

	if(FreeImage_FIFSupportsReading(fif))
		dib = FreeImage_Load(fif, filename);

	//retrieve the image data
	bits = FreeImage_GetBits(dib);
	//get the image width and height
	width = FreeImage_GetWidth(dib);
	height = FreeImage_GetHeight(dib);
	//if this somehow one of these failed (they shouldn't), return failure
	if((bits == 0) || (width == 0) || (height == 0))
		return 1;
	return 0;
}
开发者ID:skatebill,项目名称:MyEngineVersion3,代码行数:29,代码来源:变长模板.cpp

示例14: bits

/*
* \brief Method that import a texture to be used on the model
* \param[in] fTexture a constant char array containing the path to the file of the texture
* \param[in] tex_number an unsigned integer representing the type of texture (i.e. 0 = Diffuse color, 1 = Normalmap, 2 = Specular Color)
* \return a boolean indicating if the import was successful of not
*/
GLboolean Model::importTexture(const GLchar * fTexture, GLuint tex_number)
{
	GLboolean import_is_ok = GL_FALSE;
	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	FIBITMAP *dib(0);
	BYTE* bits(0);
	GLuint width(0), height(0);

	fif = FreeImage_GetFileType(fTexture, 0);

	if (FreeImage_FIFSupportsReading(fif))
	{
		dib = FreeImage_Load(fif, fTexture);
		dib = FreeImage_ConvertTo32Bits(dib);
		bits = FreeImage_GetBits(dib);
		width = FreeImage_GetWidth(dib);
		height = FreeImage_GetHeight(dib);
		import_is_ok = GL_TRUE;

		glBindTexture(GL_TEXTURE_2D, m_texture_id[tex_number]);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, &bits[0]);
		glGenerateMipmap(GL_TEXTURE_2D);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);

		FreeImage_Unload(dib);
	}
	return import_is_ok;
}
开发者ID:mobeaudoin,项目名称:ogl-first-engine,代码行数:35,代码来源:Model.cpp

示例15: FreeImage_ConvertTo32Bits

GLuint Engine::useTexture(char* texDir, bool wrap) {
	FIBITMAP* imagePtr =
		FreeImage_ConvertTo32Bits(
			FreeImage_Load(
				FreeImage_GetFileType(texDir, 0), texDir)
			);
	GLuint texture;
	glGenTextures(1, &texture); // i used to be 1
	glBindTexture(GL_TEXTURE_2D, texture);

	glTexImage2D(GL_TEXTURE_2D, 0,
		GL_SRGB_ALPHA,
		FreeImage_GetWidth(imagePtr),
		FreeImage_GetHeight(imagePtr),
		0, GL_BGRA, GL_UNSIGNED_BYTE,
		(void*)FreeImage_GetBits(imagePtr));

	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap ? GL_REPEAT : GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap ? GL_REPEAT : GL_CLAMP);

	// Clear from RAM
	FreeImage_Unload(imagePtr);
	// Unbind when finished uplloading
	glBindTexture(GL_TEXTURE_2D, 0);
	return texture;
}
开发者ID:martinsuas,项目名称:ms7605Engine,代码行数:28,代码来源:Engine.cpp


注:本文中的FreeImage_GetFileType函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。