Original Post
Hi all, I'm working on a program written in C++ with some class to represent the different objects to draw in OpenGL. I have some trouble with textures. Here is an example of what my program is doing : I have a main class which creates the OpenGL window and then draws the OpenGL scene (with the drawGLScene() function). The drawGLScene function will create objects from another class called Image and give them the ID of the texture needed to draw. After that there is a loop wich will call the draw() function of all the "Images" created before.
class Main {
HDC hDC;
HGLRC hRC;
HWND hWnd;
HINSTANCE hInstance;
GLuint texturesID[256]; // array containing id of the textures
int nextTexID; // id of the next texture
Image * img;
// public functions of the class
public:
Main();
~Main();
private:
void createGLWindow(int width, int height, int bits);
int drawGLScene(GLvoid);
GLvoid destroyGLWindow(GLvoid);
GLuint getNextTextureID();
};
All the initialization is done in createGLWindow(). The textures are created this function with
glGenTextures(256, texturesID);
The problem is here : when I call the draw() function of the Image class, I bind the texture with:
glBindTexture(GL_TEXTURE_2D, texID);
And unfortunately, the texture is not drawn. I just have a blank square.
class Image {
GLuint texID; // ID of the texture
float size; // size of the picture
// public functions of the Information object
public:
Information(LPCSTR file, float size, GLuint texID);
~Information();
void draw(float x, float y);
};
So, my question is : is this possible to bind textures in a class when they have been created in another ? Thank you for your help. Xavier [Edited by - zoulou2356 on October 6, 2008 7:19:36 AM]