c++ - glutBitmapString access violation -


(OS: Windows 7, compiler: Visual Studio 2010 C ++ compiler)

The OpenGL program is working in a manner that draws some areas and models, applies to some shaders etc. e.t.c.

Now I thought it would be good to add some text, so I added the following three lines in my Draw method:

  glColor3f (0.5F, 0.5F, 0.5 F); GlRasterPos2f (0, 0); GlutBitmapString (GLUT_BITMAP_HELVETICA_12, (unsigned char *) "some text"); Now in any way, all of this is trapped in my infinite "access violation" loop, which I can not do properly, just for the output of the text, all the other draws Also commented the code, and it still gives access violation error, I am at a loss here because there is nothing that does not affect it, then there is some indication to anyone;)) How does this issue To fix?  

I could post all my Draw Code, but I also tried an empty project, so I'm pretty sure that it does not have the rest of the code.

Edit: I tried to reduce the error even further, and it seems that glRasterPos2f is throwing acces violation (odd enough). This is not between any Globin and Glend calls, and there is no OpenGL error.

Edit2: After some advice, I tried the following code, I got rid of access violation, but still no text is displayed

 < Code> glColor3f (0.5 F, 0.5 F, 0.5F); GlRasterPos2f (0.0f, 0.0f); Std :: string str ("Hello World"); Char * p = new four [strangle (str.c_str (+ 1)]; Strcpy (p, str.c_str ()); GlutBeatMapString (GLUT_BITMAP_HELVETICA_12, (CONST unsigned char *) P);    

type const indigned char * and no more < Code> unsigned char * will it help? > string . There was a snippet that solved it with the same parameter type:

  string fullPath = TextureManager :: s_sTEXTUREFOLDER + filename; Char * filePath = new char [strlen (fullPath.c_str ()) + 1]; Strcpy (filepath, fullPath.c_str ());   

And then you have four * .

Comments