本文整理汇总了C++中LoadBMP函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadBMP函数的具体用法?C++ LoadBMP怎么用?C++ LoadBMP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadBMP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadGLTextures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[3]; // Create Storage Space For The Textures
memset(TextureImage,0,sizeof(void *)*3); // Set The Pointer To NULL
if ((TextureImage[0]=LoadBMP("Data/EnvWall.bmp")) &&// Load The Floor Texture
(TextureImage[1]=LoadBMP("Data/Ball.bmp")) && // Load the Light Texture
(TextureImage[2]=LoadBMP("Data/EnvRoll.bmp"))) // Load the Wall Texture
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(3, &texture[0]); // Create The Texture
for (int loop=0; loop<3; loop++) // Loop Through 5 Textures
{
glBindTexture(GL_TEXTURE_2D, texture[loop]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
for (loop=0; loop<3; loop++) // Loop Through 5 Textures
{
if (TextureImage[loop]) // If Texture Exists
{
if (TextureImage[loop]->data) // If Texture Image Exists
{
free(TextureImage[loop]->data); // Free The Texture Image Memory
}
free(TextureImage[loop]); // Free The Image Structure
}
}
}
return Status; // Return The Status
}
示例2: chargerTextures
void chargerTextures()
{
SImage* Image = NULL;
if( Image = LoadBMP("textures/stonewalldiffuse.bmp" ) )
{
glGenTextures( 1, &Variable::texture0 );
init2DTexture(Variable::texture0, Image->width, Image->height, Image->data );
delete Image;
}
if( Image = LoadBMP( "textures/rust.bmp" ) )
{
glGenTextures( 1, &Variable::texture1 );
init2DTexture(Variable::texture1, Image->width, Image->height, Image->data );
delete Image;
}
if( Image = LoadBMP( "textures/3dlabs.bmp" ) )
{
glGenTextures( 1, &Variable::texture2 );
init2DTexture(Variable::texture2, Image->width, Image->height, Image->data );
delete Image;
}
}
示例3: LoadGLTextures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Textures
memset(TextureImage,0,sizeof(void *)*2); // Set The Pointer To NULL
if ((TextureImage[0]=LoadBMP("Data/Font.bmp")) && // Load The Font
(TextureImage[1]=LoadBMP("Data/Image.bmp"))) // Load Background Image
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(2, &texture[0]); // Create The Texture
for (loop1=0; loop1<2; loop1++) // Loop Through 2 Textures
{
glBindTexture(GL_TEXTURE_2D, texture[loop1]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop1]->sizeX, TextureImage[loop1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop1]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
for (loop1=0; loop1<2; loop1++) // Loop Through 2 Textures
{
if (TextureImage[loop1]) // If Texture Exists
{
if (TextureImage[loop1]->data) // If Texture Image Exists
{
free(TextureImage[loop1]->data); // Free The Texture Image Memory
}
free(TextureImage[loop1]); // Free The Image Structure
}
}
}
return Status; // Return The Status
}
示例4: LoadGLTextures
int LoadGLTextures()
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage[1];
memset(TextureImage,0,sizeof(void *)*1);
if (TextureImage[0]=LoadBMP("Data/Font.bmp"))
{
Status=TRUE;
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
if (TextureImage[0]=LoadBMP("Data/Floor.bmp"))
{
Status=TRUE;
glGenTextures(1, &texture[1]);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
if (TextureImage[0]=LoadBMP("Data/Smoke.bmp"))
{
Status=TRUE;
glGenTextures(1, &texture[2]);
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
if (TextureImage[0])
{
if (TextureImage[0]->data)
{
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
return Status;
}
示例5: LoadGLTextures
static void LoadGLTextures() //Bitmaps laden und in Texturen umwandeln
{
myRGBImage *textureImage[NUM_TEXTURES];
int i;
for (i = 0; i<NUM_TEXTURES; i++) {
textureImage[i] = (myRGBImage *)malloc(sizeof(myRGBImage));
if (textureImage[i] == NULL) {
printf("Fehler bei der Speicherreservierung fuer die Bilddaten");
exit(0);
}
}
//memset(textureImage,0,sizeof(void *)*1); //sicherheitshalber den Inhalt loeschen
if (
LoadBMP("waldboden.bmp", textureImage[0]) && LoadBMP("himmel.bmp", textureImage[1]) && LoadBMP("baum.bmp", textureImage[2])
&& LoadBMP("himmel2.bmp", textureImage[3]) && LoadBMP("himmel3.bmp", textureImage[4]) && LoadBMP("himmel4.bmp", textureImage[5])) {
for (i = 0; i < NUM_TEXTURES; i++) {
glGenTextures(1, &texture[i]); //Textur erzeugen
// Textur Erstellung mit Daten vom Bitmap
glBindTexture(GL_TEXTURE_2D, texture[i]);
glTexImage2D(GL_TEXTURE_2D, //target (Gibt an, welche Texture erreicht werden soll)
0, //level (Grad der Mipmap-Reduzierung, 0 ist das Basisbild)
3, //components (1 fuer R, 2 fuer R+A, 3 fuer RGB, 4 fuer RGBA)
textureImage[i]->sizeX, //width (Bildbreite in Pixeln)
textureImage[i]->sizeY, //height (Bildhoehe in Pixeln)
0, //border (Rand: 0 oder 1)
GL_RGB, //format (z.B. GL_COLOR_INDEX, GL_RGBA, GL_LUMINANCE, ...)
GL_UNSIGNED_BYTE, //type (Typ der Daten; z.B. GL_BYTE, GL_INT, GL_FLOAT, ...)
textureImage[i]->data); //pixels (eigentlichen Bilddaten)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filterMode);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
}
//Aufraeumen
for (i = 0; i<NUM_TEXTURES; i++) {
if (textureImage[i]) { //falls existiert
if (textureImage[i]->data) { //falls Daten existieren
free(textureImage[i]->data); //Datenbereich freigeben
}
free(textureImage[i]); //Bitmap-Struktur freigeben
}
}
}
else{
textureLoaded = false;
}
}
示例6: LoadGLTextures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*2); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if ((TextureImage[0]=LoadBMP("Data/BG.bmp")) &&
(TextureImage[1]=LoadBMP("Data/Reflect.bmp")))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(6, &texture[0]); // Create Three Textures (For Two Images)
for (int loop=0; loop<2; loop++)
{
// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[loop]); // Gen Tex 0 and 1
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[loop+2]); // Gen Tex 2 and 3 4
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[loop+4]); // Gen Tex 4 and 5
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data);
}
for (loop=0; loop<2; loop++)
{
if (TextureImage[loop]) // If Texture Exists
{
if (TextureImage[loop]->data) // If Texture Image Exists
{
free(TextureImage[loop]->data); // Free The Texture Image Memory
}
free(TextureImage[loop]); // Free The Image Structure
}
}
}
return Status; // Return The Status
}
示例7: InitTexture
//Inicializar texturas
void InitTexture(){
//determinação dos ficheiros a carregar que vão servir de texturas
glEnable(GL_TEXTURE_2D);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(11, texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id[0]);
LoadBMP("aquario.bmp", 0);
glBindTexture(GL_TEXTURE_2D, texture_id[1]);
LoadBMP("aquariomask.bmp", 1);
glBindTexture(GL_TEXTURE_2D, texture_id[2]);
LoadBMP("Clown_fish.bmp", 2);
glBindTexture(GL_TEXTURE_2D, texture_id[3]);
LoadBMP("Clown_fishmask.bmp", 3);
}
示例8: strncmp
//Load - load a texture from a file
bool IMAGE::Load(char * filename)
{
//Clear the data if already used
if(data)
delete [] data;
data=NULL;
bpp=0;
width=0;
height=0;
format=0;
int filenameLength=strlen(filename);
if( strncmp((filename+filenameLength-3), "BMP", 3)==0 ||
strncmp((filename+filenameLength-3), "bmp", 3)==0)
return LoadBMP(filename);
if( strncmp((filename+filenameLength-3), "PCX", 3)==0 ||
strncmp((filename+filenameLength-3), "pcx", 3)==0)
return LoadPCX(filename);
if( strncmp((filename+filenameLength-3), "TGA", 3)==0 ||
strncmp((filename+filenameLength-3), "tga", 3)==0)
return LoadTGA(filename);
errorLog.OutputError("%s does not end in \".tga\", \".bmp\" or \"pcx\"", filename);
return false;
}
示例9: LoadGLTextures
int LoadGLTextures() // Load Bitmap And Convert To A Texture
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Textures
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
if (TextureImage[0]=LoadBMP("Data/Particle.bmp")) // Load Particle Texture
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[0]); // Create One Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}
free(TextureImage[0]); // Free The Image Structure
}
return Status; // Return The Status
}
示例10: LoadGLTextures
int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("Data/NeHe.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[0]); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}
free(TextureImage[0]); // Free The Image Structure
}
return Status; // Return The Status
}
示例11: LoadGLTextures
int LoadGLTextures()
{
int status = false;
AUX_RGBImageRec * TextureImage[1];
memset(TextureImage, 0, sizeof(void*)* 1);
if (TextureImage[0] = LoadBMP("loc"))
status = true;
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
if (status)
{
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // 线形滤波
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // 线形滤波
if (TextureImage[0])
{
if (TextureImage[0]->data)
free(TextureImage[0]->data);
free(TextureImage[0]);
}
return status;
}
示例12: LoadGLTexture
int LoadGLTexture()
{
int Status = FALSE;
std::string tab[3] = { "pliki/tex.bmp", "pliki/tex2.bmp","pliki/tex3.bmp"};
AUX_RGBImageRec *TextureImage[3];//rezerwujemy miejsce na teksture
memset(TextureImage, 0, sizeof(void*) * 1); //ustawiamy na 0
for (int i = 0; i < 3; i++)
{
if (TextureImage[i] = LoadBMP(tab[i]))
{
Status = true;
glGenTextures(3, &texture[i]);
glBindTexture(GL_TEXTURE_2D, texture[i]);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, TextureImage[i]->sizeX, TextureImage[i]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data);//przypisawanie teksturze danych obrazowych
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);//filtrowanie liniowe
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);//filtrowanie liniowe
}
if (TextureImage[i])
{
if (TextureImage[i]->data)
{
free(TextureImage[i]->data);//zwolnij pamiec tekstury obrazu
}
free(TextureImage[i]);//zwolnij pamiec struktury obrazu
}
}
return Status;
}
示例13: Create_panel_from_bmp
int Create_panel_from_bmp(char* background_filename, char* name, Sint16 x_location, Sint16 y_location, Uint16 picture_width, Uint16 picture_height, control** control_toRet, char** error)
{
SDL_Surface* Panel_Background;
if ( -1 ==LoadBMP(background_filename, &Panel_Background, error))
{
*control_toRet = NULL;
return -1;
}
SDL_Rect* Panel_Rect = malloc(sizeof(SDL_Rect));
if (Panel_Rect == NULL) {
SDL_FreeSurface(Panel_Background);
Panel_Background = NULL;
*control_toRet = NULL;
*error = "ERROR: failed to allocate memory for SDL_Rect";
return -1;
}
Panel_Rect->x = x_location;
Panel_Rect->y = y_location;
Panel_Rect->h = picture_height;
Panel_Rect->w = picture_width;
if (-1 == CreateControl(Panel_Background, NULL, Panel_Rect, name, NULL, WINDOWTYPE, control_toRet, error))
{
SDL_FreeSurface(Panel_Background);
Panel_Background = NULL;
free(Panel_Rect);
Panel_Rect = NULL;
return -1;
}
return 0;
}
示例14: LoadDensityMap
void LoadDensityMap( const char* FileName )
{
std::cout << "Loading density map " << FileName << std::endl;
int W, H;
unsigned char* Data = LoadBMP( FileName, &W, &H );
std::cout << "Loaded ( " << W << " x " << H << " ) " << std::endl;
if ( W != ImageSize || H != ImageSize )
{
std::cout << "ERROR: density map should be " << ImageSize << " x " << ImageSize << std::endl;
exit( 255 );
}
g_DensityMap = new float[ W * H ];
for ( int y = 0; y != H; y++ )
{
for ( int x = 0; x != W; x++ )
{
g_DensityMap[ x + y * W ] = float( Data[ 3 * (x + y * W) ] ) / 255.0f;
}
}
delete[]( Data );
}
示例15: tekstur
void tekstur() {
int i,size,j;
char c[64];
unsigned char t;
unsigned char *p;
/* allocate space for texture in graphics card */
glGenTextures(7,texture);
for(i=0;i<7;i++) {
sprintf(c,"t%d.bmp",i+1);
/* fprintf(debug,"%s\n",c);*/
img[i]=LoadBMP(c);
buf[i]=(unsigned char*)malloc(512*512*3);
memcpy(buf[i],img[i]->pixels,512*512*3);
p=buf[i];
/* fprintf(debug,"bits: %d\n",(int)img[i]->format->BytesPerPixel);*/
size=3*512*512;
/* reverser */
for(j=0;j<size/2;j++) {
t=p[j]; p[j]=p[size-j-1]; p[size-j-1]=t;
}
loadtexture(&texture[i],512,512,buf[i]);
}
glEnable(GL_TEXTURE_2D);
}