| Alx101 (73) | ||||||
|
Hello! I was working on a class that would abstract the OpenGL subsystem from the rest of the program using a set of functions, however I keep getting several runtime exceptions which I am unable to decode. I could really use someone else's eyes on this since I am unable to find the error myself. OGLAbstr.h:
OGLAbstr.cpp:
The exception itself:
Thanks in advance! | ||||||
|
|
||||||
| Telion (107) | |
| Check where you are calling testDraw(). It looks like you're using an uninitialized pointer. | |
|
|
|
| Alx101 (73) | ||||||
I am calling testDraw() in my application, however all the pointers associated to the function call is in the header file, as you can see.
is where i call it, which in turn gets called by this:
core->initEngine() initializes everything needed in the program, here is the log file:
| ||||||
|
Last edited on
|
||||||
| Alx101 (73) | ||||
Ok there seems to be a problem when i create the variable testDrawVAO inside my class header, i moved it to the function instead and i no longer get the same exception, now i get this:
Here:
| ||||
|
Last edited on
|
||||
| cire (1845) | |
subsystems.gl->testDraw();Where is sybstems.gl set to an address? My suspicion is that the this pointer is invalid when OGLAbstr::testDraw() is called. 0xcdcdcdcd is the bit bit pattern VS uses to mark uninitialized pointers in debug mode. [ Edit: Useful info @ http://www.nobugs.org/developer/win32/debug_crt_heap.html ] | |
|
Last edited on
|
|
| Alx101 (73) | |||||||||
|
Here is the full class of subsystems. aka middleLayer Header:
.cpp file
Now Core calls MiddleLayer::startUp() and initializes OpenGL with calls to the gl subsystem in MiddleLayer:
and
The main class that i use for the application creates an Engine object, which in it's constructor creates Core and Editor objects. I later use those objects to call core->initEngine() and edtior->testDraw() | |||||||||
|
|
|||||||||
| ne555 (4037) | |
callback = new hMsg(); ¿is there a good reason to use dynamic allocation?¿Is subsystems global? | |
|
|
|
| Alx101 (73) | |
That's how i designed it, and no, subsystems is not global. I made the constructors of each class/subsystem grab a prointer to a logMgr class, do some initializing and stuff, and that was the way i saw it work. Can i do the same thing using only hMsg callback and still make it public in the class?
| |
|
|
|
| ne555 (4037) | |
|
Use the constructor and initialization lists. > subsystems is not global. ¿How is that an editor and a core can access it? | |
|
|
|
| Alx101 (73) | |
Does not the object call the constructer when declared like this: hMsg callback?And the Editor and Core class creates an object to subsystems. | |
|
|
|
| ne555 (4037) | |||||
When you wrote a class you only say how it is composed.
> And the Editor and Core class creates an object to subsystems. ¿So they are different objects? | |||||
|
|
|||||
| Alx101 (73) | |
| Yes, the Objetcs are provate to each class. I think i know where you are going here, i had the assumption that an object simply was a reference to the class. | |
|
|
|
| Alx101 (73) | |
| Because that could explain some of the other errors i have been having | |
|
|
|
| Alx101 (73) | |
But i can't control when the constructor is called if i use this: hMsg callback correct? Because i want to call the constructor at specific times in the engine.
| |
|
|
|
| ne555 (4037) | |
|
The constructor is called when the object is constructed. ¿do you want to `reconstruct' it several times? | |
|
|
|
| Alx101 (73) | |
| No, i want to control the construction. I.e i want to control when the constructor is called | |
|
|
|
| Alx101 (73) | |
| I solved it by sharing the subsystems object with Editor from Core | |
|
|
|