Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem regarding OpenGL and the process of converting C to C++
    text
    copied!<p>Alright. So I wanted to use a file written in c in c++. I ran the code in c and had absolutely no problems.</p> <p>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.</p> <p>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:</p> <pre><code>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 </code></pre> <p>I included the first statement in the codeblock to show that it doesn't immediately blow up any any sort of OpenGl call.</p> <p>I keep getting errors along the lines of </p> <pre><code>Cannot access memory at address 0xfbad248c Cannot access memory at address 0xfbad248c Cannot access memory at address 0xaabbeeaa </code></pre> <p>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++?</p> <p>Thanks and let me know if you need any more information.</p> <hr> <p>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</p> <pre><code>#include &lt;GL/glut.h&gt; </code></pre> <p>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.</p> <p>I should probably include these additional details:</p> <p>A init() method is called at the beginning of the program before the actual input loop is called:</p> <pre><code>void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); makeCheckImage(); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } </code></pre> <p>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.</p> <p>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:</p> <pre><code>if (ImageData == NULL) {/*code*/} else{/*this is where the error code is*/} </code></pre> <p>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).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload