Note that there are some explanatory texts on larger screens.

plurals
  1. POglutBitmapString access violation
    primarykey
    data
    text
    <p>(OS: Windows 7, Compiler: Visual Studio 2010 C++ compiler)</p> <p>I've got a correctly working OpenGL program that draws some spheres and models, applies some shaders etc.. etc..</p> <p>Now I thought it would be nice to add some text, so I added the following three lines to my draw method:</p> <pre><code>glColor3f(0.5f, 0.5f, 0.5f); glRasterPos2f(0, 0); glutBitmapString(GLUT_BITMAP_HELVETICA_12, (unsigned char*)"some text"); </code></pre> <p>Now somehow this all makes my program get stuck in an infinite "access violation" loop, which I can't seem to fix. I even commented all the other draw code out, to just output the text, and it still gives the access violation error, I'm at a loss here because there is nothing that seems to affect this. So does anybody have some pointers ;)) on how to fix this issue?</p> <p>I could post all my draw code, but I even tried an empty project, so I'm pretty sure it's not the rest of the code.</p> <p>Edit: I tried narrowing down the error even more, and it seems that glRasterPos2f is throwing the acces violation (weirdly enough). It's not between any glBegin and glEnd calls, and there is no OpenGL error.</p> <p><strong>Edit2:</strong> After some advice I tried the following code, I got rid of the access violation, but still no text is displayed</p> <pre><code>glColor3f(0.5f, 0.5f, 0.5f); glRasterPos2f(0.0f, 0.0f); std::string str("Hello World"); char* p = new char[strlen(str.c_str() + 1)]; strcpy(p, str.c_str()); glutBitmapString(GLUT_BITMAP_HELVETICA_12, (const unsigned char*)p); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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