Need Help! Words,Array ...
Hi,
I hope somebody can help me.
My Problem:
I have got a normal TEXTfile, in this
TEXTfile i have stored the paths or only
the names of textures. Now i want to load this
path/name and want to load the texture with
a BMP_loading function. Now the problem:
The BMP_loadding func. awaits a ''char *TextureFile''
When i want to read the path i must use eg ''char TF[255]'',
i mean to read the complete string, in my eyes it is a string,
i need an array, and the BMP_loading func. do not accepts
arrays. What could i do ?
Let me see if I have this right.
You are reading in the name of your texture from a text file and putting the filename into this character array:
char TF[255];
You then want to pass that filename to your bitmap loading function to use it as a texture
Okay, when you pass the name to your funtion, pass it like this:
LoadBitmap(..., TF, ...);
that passed the address of the array (or a pointer to that array, to be more precise), which is what you want.
make sure that your array ends with a null terminator character, or you could have major problems later on, though ''\0''
Hope that helps
-Brian
"Back to the code mines... ka-chink... ka-chink..."
You are reading in the name of your texture from a text file and putting the filename into this character array:
char TF[255];
You then want to pass that filename to your bitmap loading function to use it as a texture
Okay, when you pass the name to your funtion, pass it like this:
LoadBitmap(..., TF, ...);
that passed the address of the array (or a pointer to that array, to be more precise), which is what you want.
make sure that your array ends with a null terminator character, or you could have major problems later on, though ''\0''
Hope that helps
-Brian
"Back to the code mines... ka-chink... ka-chink..."
I think i understand what you mean and
i think i tried this and it wouldn''t work.
So i want to write it more detailed:
Textures.txt //TEXTfile with the Textur-Paths
C:\Project\Data\Texture\Floor1.bmp //
C:\Project\Data\Texture\Floor2.bmp // Content of File
C:\Project\Data\Texture\Floor3.bmp //
Main.cpp //my Code
AUX_RGBImageRec *LoadBMP(char *Filename);
int SetupWorld (void)
{
FILE *FileIn;
char TexturName[255];
FileIn = fopen("Textures.txt","rt");
fscanf(FileIn, "%s", &TexturName);
LoadBMP(TexturName);
return TRUE;
}
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if (!Filename)
return NULL;
File=fopen(Filename,"r"); !!!!!!
if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
Ok i think you can follow this Code,
and there where are the !!!!!! this ''fopen'' doesn''t work,
it doesn''t return a ''FILE''
Is it a better description ?
i think i tried this and it wouldn''t work.
So i want to write it more detailed:
Textures.txt //TEXTfile with the Textur-Paths
C:\Project\Data\Texture\Floor1.bmp //
C:\Project\Data\Texture\Floor2.bmp // Content of File
C:\Project\Data\Texture\Floor3.bmp //
Main.cpp //my Code
AUX_RGBImageRec *LoadBMP(char *Filename);
int SetupWorld (void)
{
FILE *FileIn;
char TexturName[255];
FileIn = fopen("Textures.txt","rt");
fscanf(FileIn, "%s", &TexturName);
LoadBMP(TexturName);
return TRUE;
}
AUX_RGBImageRec *LoadBMP(char *Filename)
{
FILE *File=NULL;
if (!Filename)
return NULL;
File=fopen(Filename,"r"); !!!!!!
if (File)
{
fclose(File);
return auxDIBImageLoad(Filename);
}
return NULL;
}
Ok i think you can follow this Code,
and there where are the !!!!!! this ''fopen'' doesn''t work,
it doesn''t return a ''FILE''
Is it a better description ?
I think it has to do with the fact that the Paths in Textures.txt are typed with single backslashes.
One backslash creates a special code of the character behind it (\n = CR, \r = newline, for example)
Try to write the Paths like this instead and see if it works,
C:\\Project\\Data\\Texture\\Floor1.bmp
return 1;
One backslash creates a special code of the character behind it (\n = CR, \r = newline, for example)
Try to write the Paths like this instead and see if it works,
C:\\Project\\Data\\Texture\\Floor1.bmp
return 1;
Did you try putting your slashes the other way.
eg- "Data/Gfx/Hey.bmp" works with my programs while
...."Data\Gfx\Hey.bmp" doesn''t work with me.
Probly not the problem but I thought I''d let you know.
eg- "Data/Gfx/Hey.bmp" works with my programs while
...."Data\Gfx\Hey.bmp" doesn''t work with me.
Probly not the problem but I thought I''d let you know.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement