Alright. So I wanted to use a file written in c in c++. I ran the code in c and had absolutely no problems.
Since I don't know c, I worked with some conversion software for a while, but it wasn't effective (guessing the coding format wasn't in the style it needed). I decided to try it out myself and it looked like all I had to do was change a few malloc statements to new statments and replace free with delete. So I ran the program and it appears most of the functions work fine, but this one gives me trouble.
When I'm trying to update the display of a new image (I'm reading tiff image data and displaying it on the screen) I run into problems in these particular statements:
glutReshapeWindow(ImageWidth,ImageLength);
glClear(GL_COLOR_BUFFER_BIT);//these
glRasterPos2i(0, 0);//three
glDrawPixels(ImageWidth, ImageLength, GL_RGB,
GL_UNSIGNED_BYTE, ImageData);//statements are the ones giving me the error
I included the first statement in the codeblock to show that it doesn't immediately blow up any any sort of OpenGl call.
I keep getting errors along the lines of
Cannot access memory at address 0xfbad248c
Cannot access memory at address 0xfbad248c
Cannot access memory at address 0xaabbeeaa
I know this might be sort of vague, but what could be some common sources of this error? It worked in c, what may have caused this error in the quick switch to c++?
Thanks and let me know if you need any more information.
Alright, so I'm not really using the standard OpenGL library I believe (this is for a class and I was given the library files by an instructor). I have the the code
#include <GL/glut.h>
as my #include. These libraries are exactly the same as the one found in the c file as I merely copied and pasted them into my c++ project. (I've also worked with them in a limited manner in another c++ project). Just in case, I checked my file system for the files "OPENGL32.DLL" and "GLU32.DLL" and did not find them.
I should probably include these additional details:
A init() method is called at the beginning of the program before the actual input loop is called:
void
init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
makeCheckImage();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}
This method seems to work fine (a simple checkerboard pattern is created shortly after this function call). I'm not sure which sort of OpenGL files these pertain to ("OPENGL32.DLL" or "GLU32.DLL") but hopefully this can narrow the problem down a little bit.
As for the ImageData line, I don't believe the ImageData object is corrupted or something of the sort, because of some of reasons you were talking about and the fact that the code in the very first code block I posted (the source of errors) is within an else block as such:
if (ImageData == NULL) {/*code*/}
else{/*this is where the error code is*/}
I can post info on the makefiles if you think it would be helpful (just don't want to clutter up this thread with the stuff if it's not).