Re: C++ Unhandled exception error
Quote:
Originally Posted by
Paul McKenzie
Nowhere do you mention use of a debugger. Are you using one?
You can't write programs if you're not prepared to debug them on your own. It sounds like you took some code, compiled it, and hoped for the best, and if something goes wrong, throw together arbitrary bits of code to see if the problem goes away.
Instead, you should have prepared for the inevitable step of having to debug the program at some point, whether that point is now or in the future.
Code:
WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
That should give you a clue as to what happened.
Regards,
Paul McKenzie
Thank you very much
actually I am building the code step by step (on my own!)and it was working properly for all the previous steps, but now I encounter this problem since few days and I have no clue about how to solve it. I tried all the ways I am familiar with. but i am a student and trying to learn.
many thanks for your time
Re: C++ Unhandled exception error
Quote:
Originally Posted by
itsmeandnobodyelse
I assume for each call of MD2Model::load there is memory allocated. But you never call cleanup what should free the memory.
I used cleanup but it really doesn't make a big diference. it only changes the point where the program crashes . at any case I will keep calling it after loading the file.
Thank you for help
Re: C++ Unhandled exception error
Quote:
Originally Posted by
Paul McKenzie
Nowhere do you mention use of a debugger. Are you using one?
You can't write programs if you're not prepared to debug them on your own. It sounds like you took some code, compiled it, and hoped for the best, and if something goes wrong, throw together arbitrary bits of code to see if the problem goes away.
Instead, you should have prepared for the inevitable step of having to debug the program at some point, whether that point is now or in the future.
Code:
WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
That should give you a clue as to what happened.
Regards,
Paul McKenzie
WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
from thisshould I assume that the problem is about the video memory? if so, any suggestion to do ?
many thanks again
Re: C++ Unhandled exception error
Quote:
Originally Posted by
Lindley
The majority of the GPU-side allocations in that code would have occurred in gluBuild2DMipmaps() and glTexImage2D().
FYI, if you are ever planning to modify an OpenGL texture without resizing it, the second download should be done with glTexSubImage2D() even if you're overwriting the entire image, because that is guaranteed not to do any reallocation.
Here it looks like a WGL issue, though, so I'm not sure what's going on.
thank you very much
based on your note I am going to use subimage then
Re: C++ Unhandled exception error
Just remember you need to glTexImage2d() at least once for each texture, in order to get the memory for TexSubImage to work with!
Re: C++ Unhandled exception error
Quote:
Originally Posted by
Lindley
Just remember you need to glTexImage2d() at least once for each texture, in order to get the memory for TexSubImage to work with!
thanks for remark
I will be aware of that.
At any case, this part of the code is not reached at the moment because of the mentioned problem. the texture that is meant to be displayed with this part can not be reached before the row_index reaches the maximum value of 128:
Code:
if (row_index < 128){glutTimerFunc(100, update, 0);}
else {.the texture displayed with this part..}
I hope this would help to solve the problem but I dont have to try. and any other suggestion would be appreciated
thanks again
Re: C++ Unhandled exception error
Quote:
Originally Posted by
Yohanna
thank you
if I understand properly, you mean the location of the exception?
the debugger points to the line of code where the pixels values are assigned to the array of pointers after reading the buffer with glReadPixels, the pixels values are saved in an array pixels_index_temp and assigned to pixels_index array
pixels_index[global_index] = pixels_index_temp[local_index];
the global array pixels_index is going to be displayed on screen after the whole scanning process
I hope I answered your question
many thanks to you
No, the error message you got means that the process runs out-of-memory. You therefore need to locate all calls where the process requests for memory (and the function called returns a pointer to that memory). Then you need to check whether the memory was freed later. I spotted one call where you load the model but where you never delete the pointer. If that function was called 1024 * 768 times you definitively have a memory problem even for big physical memory...
If I am right the exception is only a follow-up of the fact that the system can't provide ay more memory.
Re: C++ Unhandled exception error
Quote:
Originally Posted by
itsmeandnobodyelse
No, the error message you got means that the process runs out-of-memory. You therefore need to locate all calls where the process requests for memory (and the function called returns a pointer to that memory). Then you need to check whether the memory was freed later. I spotted one call where you load the model but where you never delete the pointer. If that function was called 1024 * 768 times you definitively have a memory problem even for big physical memory...
If I am right the exception is only a follow-up of the fact that the system can't provide ay more memory.
Thank you so much for help
I think I did what you suggested (to the best of my knowledge)
to locat memory I used the expressions such as :
unsigned char *pixels_index_temp = new unsigned char[144];
and after using the pointer the memory was freed using delete:
delete [] pixels_index_temp;
also, the model and the image loaded were deleted using cleanup function and delete image.
the function (update) is the only function that can return a pointer to the array pixels_index, but the array should be kept to be displayed within the same function and delete it later.
this funtion should load the image and the model 128*128 times and form the data array pixels_index_temp, this array will be displayed using OpengGL commands.
I got the same result with the same messages saying:
Unhandled exception at 0x7c812afb in OPENGL_......exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012fbb4..
and
There is no source code available for the current location.
and here i sthe last bit of information displayed just before it crashes, these are information about the values stored in the array pixels_index and the address of the array pixels_index_temp before and after using the function delete (the same address):
row_index 20
the value stored in pixels_index[384351] B
row_index 20
the value stored in pixels_index[384354] /
row_index 20
the value stored in pixels_index[384357] รถ
address of pixels_index_temp BEFORE delete 0012FF1C
address of pixels_index_temp AFTER delete 0012FF1C
address of pixels_index 0012FF20 (only 4 bytes after the address of pixels_index_temp)
address of _model 004097E0
I hope to have any idea from you.
Re: C++ Unhandled exception error
Quote:
Originally Posted by
Paul McKenzie
Nowhere do you mention use of a debugger. Are you using one?
You can't write programs if you're not prepared to debug them on your own. It sounds like you took some code, compiled it, and hoped for the best, and if something goes wrong, throw together arbitrary bits of code to see if the problem goes away.
Instead, you should have prepared for the inevitable step of having to debug the program at some point, whether that point is now or in the future.
Code:
WGL Message:WGL: DDraw: Allocate: Create: DDERROR = DDERR_OUTOFVIDEOMEMORY
That should give you a clue as to what happened.
Regards,
Paul McKenzie
I am still waiting to hear your opinion
many thanks in advance