Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sky

glPrint Function

This topic is 5634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I did the bitmap font tutorial thing, but when I compile and run i get a error message that says the memory at 0x000000 cannot be read... I think I need to make ap equal to something, but I''m not sure what... I used some message box things to find out exactly where the error occurs in my code...
  
// --------------------------------------Causes Error

GLvoid glPrint(const char *fmt,...) {
  char text[256]; // holds the string

  va_list ap; // pointer to list of arguements                        


  if (fmt = NULL) 
    return;
  
// between here...

  va_start(ap, fmt);
    vsprintf(text, fmt, ap);
  va_end(ap); 
// and here, is where the error occurs.


  glPushAttrib(GL_LIST_BIT);
  glListBase(base - 32);
   
  glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
  glPopAttrib();
}
// ---------------------------------------------------------


// Draw Scene and Text -------------------------------------

int DrawGLScene(GLvoid) {   //Drawing Stuff

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear Screen adn Depth Buffer

  glLoadIdentity(); // Reset Modelview Matrix

  glTranslatef(0.0f,0.0f,-1.0f);

  glColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));
  glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)), 0.35f*float(sin(cnt2)));

  glPrint("Sky''s Box made with NeHe - %7.2f", cnt1);
  cnt1+=0.051f;
  cnt2+=0.005f;
  return TRUE;
}
// ---------------------------------------------------------

  

Share this post


Link to post
Share on other sites
Advertisement
i have found that this works better, though it will not work like before


    
glPrint(char text[60])
{
glPushAttrib(GL_LIST_BIT);
glListBase(base - 32);
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
}



[edited by - lc_overlord on January 19, 2003 9:40:02 AM]

Share this post


Link to post
Share on other sites
Nonono I think it can''t be there...
1. Do you pass a NULL to the function?
2. Where EXACTLY the error occurs?
2 lc_overlord:
Change it to:
glPrint(char *text)
that should work better

Share this post


Link to post
Share on other sites
va_start(ap, fmt);
vsprintf(text, fmt, ap);
va_end(ap);

that''s where it gave me the error ^

Share this post


Link to post
Share on other sites
quote:
Original post by Dave Hunt
Try replacing "if (fmt = NULL)" with "if (fmt == NULL)".



that would probably work... I''ll try it later.


Share this post


Link to post
Share on other sites
quote:
Original post by PM
lc_overlord:
Change it to:
glPrint(char *text)
that should work better


Perhaps but serioulsly,
1. i hate pointers.
2. it''s not like im going to need to print 5000 chars in one line, it just doesn''t fit.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!