I'm trying to continue development of my little opensource GUI.
Now I'm studying the texture in openGL. I know here is OT talk of
specific openGL, but the question is not about the usage of this lib,
but about a (perhaps) general case, very technical.
To resume briefly, I've two files:
main.cpp
mhwindow.cpp
the second contain a singleton I use to store global variables.
The singleton is very simple (I've reduced it to post this question):
----------------------------------------------------
class MHwindow {
private:
static MHwindow MHw;
GLuint texture;
//Constructor is private, because this is a singleton
MHwindow(){};
MHwindow& operator=(MHwindow&); // Disallowed
MHwindow(const MHwindow&); // Disallowed
public:
static MHwindow& instance() { return MHw; }
void setTexture(GLuint);
GLuint getTextures();
};
#endif //MHWINDOW_H
-----------------------------------------------------
the setTexture(GLuint) method set a private GLuint texture variable.
OK.
In main code I use a function that return a GLuint.
This psudocode work fine:
-----------main.cpp------------
GLuint myVar;
myVar = function_that_return_a_GLuint()
-------------------------------
This pseudocode don't work:
-----------main.cpp------------
singleton mysingleton;
mysingleton.setTexture(function_that_return_a_GLui nt())
-------------------------------
I don't understand the reason. Independently from
function_that_return_a_GLuint(), both the cases should be identical:
in first case I assign the value to a global GLuint variable,
in second case I assing the value to a singleton GLuint variable,
but it's always a GLuint variable, so I don't understand the reason
because it not work.
If you want try, the files (I've minimized them) are here:
www.dedalo-3d.com/lab/try_ogl_texture.zip
The files as are work fine.
but, if you comment "textureID = pngBind etc..." and decomment the line:
MainWindow.setTexture(pngBind("pippo.png", PNG_NOMIPMAP, PNG_ALPHA,
&texInfo, GL_CLAMP, GL_NEAREST, GL_LINEAR));
it don't work.
Ah...to try the code, you need little glpng lib:
http://www.wyatt100.freeserve.co.uk/download.htm
Thanks,
Manuel