Passing class reference to renderscene() MainLoop

Hey, I can’t seem to get a texture loading class reference into my renderScene() function, it is not conducive to the glutDisplayfunc(). How the heck do I get the object in there?

The Function you pass to glutDisplayfunc is your actual rendering function.

So, to get your texture “in” there, you’ll need to define it globally or define a texture container class.


MyTexture gTexture;

void init()
{
   gTexture.Load("afile.png");
}

void renderScene()
{
  glBindTexture(GL_TEXTURE_2D, gTexture.getID() );
  // or
  gTexture.bind(); // depending on how you implemented your class
  // draw stuff
}



I suggest you buying a good book about C++ and asking such questions in the beginner forum.