Answer the question
In order to leave comments, you need to log in
What is the best way to pass data from class to class?
There is such a class
//#include "FileReader.h"
struct Image
{
float**TextureCoordinats;
float**VertexCoordinats;
unsigned int*IndexTexture;
std::string *Name;
int *number;
};
class Scene1
{
public:
Scene1(void);
void LoadImage(const ILstring path);
void ShowWelcome(bool show);
void EnableTexture(float*texcoor, float*vercoor);
int FindTexture(std::string name);
~Scene1();
unsigned char*copyData;
static const int CountTexture = 53;//40
Image *image;
int CountIndexTexture;
};
void Scene1::LoadImage(const ILstring path)
{
...
copyData = ilGetData();
...
glGenTextures(1, &image->IndexTexture[CountIndexTexture]);
...
glBindTexture(GL_TEXTURE_2D, image->IndexTexture[CountIndexTexture]);
...
gluBuild2DMipmaps(GL_TEXTURE_2D, type, width, height, type, GL_UNSIGNED_BYTE, copyData);
...
CountIndexTexture++;
};
#include "FileReader.h"
class Scene
{
...
FileReader*filereader;
...
}
void Scene1::ShowWelcome(bool show)
{
...
int numb = FindTexture("welcome",filereader->getimagetexture());
glBindTexture(GL_TEXTURE_2D, filereader->getimagetexture(IndexTexture[numb]));
EnableTexture(filereader->getimagetexturecoordinats(TextureCoordinats[numb]), filereader->getimagevertexcoordinats(VertexCoordinats[numb]);
...
}
class FileReader
{
...
LoadImage(const ILstring path);
unsigned char*copyData;
...
}
void FileReader::LoadImage(const ILstring path)
{
...
copyData = ilGetData();
...
glGenTextures(1, &image->IndexTexture[CountIndexTexture]);
...
glBindTexture(GL_TEXTURE_2D, image->IndexTexture[CountIndexTexture]);
...
gluBuild2DMipmaps(GL_TEXTURE_2D, type, width, height, type, GL_UNSIGNED_BYTE, copyData);
...
CountIndexTexture++;
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question