
can someone tell me, how to programm a loop which reads in many textures?
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.
for (a=1,a=10,a++)
{
readtex("filename"+a);
}
Something like that.
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
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...
Try this:
Hope that helps.
|
Hope that helps.
|
[source]#define Jesus 1[/source]
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>
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> 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[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);<br> } else {<br> Status = FALSE;<br> }<br><br> if ( TextureImage[0] ) {<br> if ( TextureImage[0]->data ) {<br> free ( TextureImage[0]->data );<br> }<br> free ( TextureImage[0] );<br> }<br>} </i>
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> 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[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);<br> } else {<br> Status = FALSE;<br> }<br><br> if ( TextureImage[0] ) {<br> if ( TextureImage[0]->data ) {<br> free ( TextureImage[0]->data );<br> }<br> free ( TextureImage[0] );<br> }<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
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 ;) )
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement