Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4110818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:59:01+00:00 2026-05-20T21:59:01+00:00

(OS: Windows 7, Compiler: Visual Studio 2010 C++ compiler) I’ve got a correctly working

  • 0

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

I’ve got a correctly working OpenGL program that draws some spheres and models, applies some shaders etc.. etc..

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

glColor3f(0.5f, 0.5f, 0.5f);
glRasterPos2f(0, 0);
glutBitmapString(GLUT_BITMAP_HELVETICA_12, (unsigned char*)"some text");

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?

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.

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.

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

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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:59:02+00:00Added an answer on May 20, 2026 at 9:59 pm

    glutBitmapString is of type const unsigned char* and not of unsigned char*. Would that help? I had problems with string casting as well.

    And I found out, that I wasn’t closing my string, because the unsigned char* should be 1 longer than a string. Here was a snippet that solved it for another method 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 your char*.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do some C development in Windows environment using Visual Studio
I would like to use Visual Studio 2010 to create a C++ application that
Apparently visual studio 2010 built DLLs do not support Windows 2000. Is there a
Windows Forms allows you to develop Components, non-visual elements that can have a designer.
I'm a beginner starting to use Microsoft Visual C++ Express 2010 for Windows Programming.
I'm trying to compile an SFML program I've writting in Visual C++ 2010. It
I've created a new project using the Visual Studio 2010's wizard. Once VS was
When trying to compile a file that include winnt.h via windows.h, I get the
I have added some code which compiles cleanly and have just received this Windows
I am trying to use MinGW to compile a C program under Windows XP.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.