I'm lost here - without the slightest idea what could be wrong. The code runs (compiles and executes) fine in the Dev C++ IDE but as soon as I try to execute the linked file from the windows explorer, nothing happens. No error message, nothing.
I have tracked it down to the first line in my WinMain function that says:
CGLRenderer renderer;
CGLRenderer is a very simple OpenGL wrapper I coded for a small testproject. Everything in the CGLRenderer constructor is executed properly but then instead of executing the rest of my code, the program exits to windows.
The constructor looks like this: (Notice the 3 filestream lines that are commented out.)
Code:
CGLRenderer::CGLRenderer() {
p= new TGLRendererPriv;
// ofstream a_file("bm.log", ios::app);
// a_file << "lifesign" << endl;
// a_file.close();
p->hHostWnd= NULL;
p->hDC= NULL;
p->hRC= NULL;
p->iHostWidth= 0;
p->iHostHeight= 0;
p->iVertexArrayStride= 0;
p->pVertexArray= NULL;
for (int i; i <= MAX_TEXLAYERS; i++) {
p->aiTexCoordArrayStride[i]= 0;
p->apTexCoordArray[i]= NULL;
}
p->glActiveTextureARB= NULL;
p->glClientActiveTextureARB= NULL;
}
p-> is the pointer to the private implementation struct (greetings, Cat ) which looks like this:
Code:
struct CGLRenderer::TGLRendererPriv {
HWND hHostWnd;
HDC hDC;
HGLRC hRC;
int iHostWidth, iHostHeight;
void *pVertexArray;
int iVertexArrayStride;
void *apTexCoordArray[MAX_TEXLAYERS];
int aiTexCoordArrayStride[MAX_TEXLAYERS];
PFNGLACTIVETEXTUREARBPROC
glActiveTextureARB;
PFNGLCLIENTACTIVETEXTUREARBPROC
glClientActiveTextureARB;
};
When I launch the programm with the Windows Explorer, the code in the constructor is executed and then the program exits. Since I couldn't use the debugger (it works fine there) I added those 3 lines of code that simply create a file as soon as they are processed to allow me to track down where the problem is.
Now the stange thing: The program runs as soon as I uncomment the filestream lines. All of it, not just the constructor.
I know, I could leave the filestream stuff in the constructor and let if be, but there must be a reason why it doesn't work without it. I assume it's something so simple that I just can't see it.
Any help would be appreciated
- a lost C++ newbie...
ps: I'm using winxp, latest dev c++. The class CGLRenderer is derived from an abstract baseclass, but this can't be the reason because the problem occured even after I eliminated the baseclass.