Advertisement

can someone tell me, how to programm a loop which reads in many textures?

Started by May 10, 2001 02:58 PM
18 comments, last by SpideY2k 23 years, 9 months ago
i had tried to programm a loop, which reads in more than 10 textures (bitmaps) but it doesnt work can someone tell me how i can programm a loop, which work?
i have no kiz, i have heard, they would need 9 month to download ;)
well, it depends on what you are try to do, you could make a for next loop and have the file name from 1 to 10.
for (a=1,a=10,a++)
{
readtex("filename"+a);
}

Something like that.
Advertisement
i had programmed first something like that:

char[3][32] = { "data/tex1.bmp", "data/tex2.bmp", "data/tex3.bmp" }

then i had programmed in the read in section:

int i;
for(i = 0; i < 3; i++)
{
//THE READ IN SECTION
}

but this doesnt work
i have no kiz, i have heard, they would need 9 month to download ;)
does it work if you load them individually, using the filename data from the array?

_________________________________I used to be indecisive. Now I'm not so sure...
yes
i have no kiz, i have heard, they would need 9 month to download ;)
Try this:
  char* FileNames[3] = {"bitmap01.bmp", "bitmap02.bmp", "bitmap03.bmp"};for (int i=0; i<3; i++){   LoadTexture(FileNames[i]);}  


Hope that helps.

  #define Jesus 1  
[source]#define Jesus 1[/source]
Advertisement
so, this is the loop, which i had programmed, to load textures:
int i;
for(i = 0; i < 3; i++)
{
if (TextureImage=LoadBMP(texname))<br> {<br> Status=TRUE; // Set The Status To TRUE<br><br> glGenTextures(1, &texture[1]); // Create Three Textures<br><br> // Create MipMapped Texture<br> glBindTexture(GL_TEXTURE_2D, texture);<br> glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);<br> glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);<br> gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage->sizeX, TextureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);<br> }<br><br> <br> if (TextureImage) // If Texture Exists<br> {<br> if (TextureImage->data) // If Texture Image Exists<br> {<br> free(TextureImage->data); // Free The Texture Image Memory<br> }<br><br> free(TextureImage); // Free The Image Structure<br> }<br> } </i>
i have no kiz, i have heard, they would need 9 month to download ;)
try this:
AUX_RGBImageRec *TextureImage[1];
int i;

[...]

for ( i = 0; i < 3; i++ ) {
if ( TextureImage[0] = LoadBMP ( texname ) ) {
if ( ( i > 0 ) && ( !Status ) ) { // if you don''t do so, the status will be overwritten
Status = FALSE;
} else {
Status = TRUE;
}

glGenTextures ( 1, &texture ); // create one texture<br>&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture ( GL_TEXTURE_2D, texture );<br>&nbsp;&nbsp;&nbsp;&nbsp;glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );<br>&nbsp;&nbsp;&nbsp;&nbsp;glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );<br>&nbsp;&nbsp;&nbsp;&nbsp;gluBuild2DMipmaps ( GL_TEXTURE_2D, 3, textureimage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);<br>&nbsp;&nbsp;} else {<br>&nbsp;&nbsp;&nbsp;&nbsp;Status = FALSE;<br>&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;if ( TextureImage[0] ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;if ( TextureImage[0]->data ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free ( TextureImage[0]->data );<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;free ( TextureImage[0] );<br>&nbsp;&nbsp;}<br>} </i>
Viel Spass,ChrisP--PBeM Base Germany - http://www.pbem-base.de/Atlantis PBeM - http://www.atlantis-pbem.de/
Hi!

I think I know what didn''t work in your first test with 3 textures:

the names were wrong!

if you want to define a directory you''ll have to double slash it!, cause in C one ''/'' is for escape charakters... a "//" is a normal slash...

so it would be "data//bitmap.bmp" instead of "data//bitmap.bmp"

hope that helps..
cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states
Visit Rarebyte! and no!, there are NO kangaroos in Austria (I got this question a few times over in the states ;) )
sorry, phuebl, but in c a backslash is for escape sequences.
i have no kiz, i have heard, they would need 9 month to download ;)

This topic is closed to new replies.

Advertisement