Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to draw ° using OpenGL

Posted on 2006-06-22
14
Medium Priority
?
1,198 Views
Last Modified: 2013-12-06
Hello experts,

Could someone tell me how to draw ° using OpenGL?
Thanks
Alison
0
Comment
Question by:lzha022
  • 6
  • 4
  • 4
14 Comments
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 16972754
void drawCircle( float radius )
{
   glBegin( GL_LINE_LOOP ) ;
   
   int i;
   for ( i=0; i<360; i++ )
   {
      float angle = i * 0.01745329252 ;
      glVertex2f( cos(angle)*radius, sin(angle)*radius ) ;
   }
   
   glEnd() ;
}


E.g., of use:

drawCircle( 2.0f ) ;
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 16972769
And to specify the central position of the circle on the display:


void drawCircle( float x, float y, float radius )
{
   glBegin( GL_LINE_LOOP ) ;
   
   int i;
   for ( i=0; i<360; i++ )
   {
      float angle = i * 0.01745329252 ;
      glVertex2d( x+cos(angle)*radius, y+sin(angle)*radius ) ;
   }
   
   glEnd() ;
}


Example of use:

drawCircle( 100, 200, 2 ) ;
0
 

Author Comment

by:lzha022
ID: 16979974
Hi InteractiveMind,

Thanks for your reply.
I am sorry, i did not make it clear. I want to draw degree in symbol, not a circle. It is a special character, does OpenGL have some functions to draw special characters?

Thanks
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 25

Expert Comment

by:InteractiveMind
ID: 16980069
Are you able to draw ordinary text to the display?
0
 

Author Comment

by:lzha022
ID: 16980820
yes, i can draw text displayed on keyboard.
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 16982559
But special characters are not supported with this? :\
0
 
LVL 2

Expert Comment

by:davidnsc1
ID: 16987908
If your program is unicode, then pre-render character 0x00B0.  If your program isn't, then you can try using WideCharToMultiByte on character 0x00B0 to figure out the proper character code in the current codepage.  Either way you'll have to extend your font pre-rendering to either render through (bad) or jump to (better) that character.
0
 

Author Comment

by:lzha022
ID: 16987977
Hi Davidnsc1,
I find your comment is quite hard to understand - lots of new things to me.
I am programming in vs .net 2003.
Do you mean it is very complicately to print degree sign using openGL?
0
 
LVL 2

Expert Comment

by:davidnsc1
ID: 16988008
Ah, I'll take a step back then.  What method are you currently using to render text to the OpenGL window?
0
 

Author Comment

by:lzha022
ID: 16988073
I implemented a method like this to draw strings.
void drawBitmapFonts(char *string, float x, float y, void *font)
{
  if (string != (char *)NULL)
  {
    glRasterPos3f(x, y, 1.0);
    int len = (int) strlen(string);
    for (int i = 0; i < len; i++)
    {
      glutBitmapCharacter(font, string[i]);
    }
  }
}
0
 
LVL 2

Expert Comment

by:davidnsc1
ID: 16988187
Oh!  Wow, I was expecting the wgl and display lists method--I didn't realize you were using GLUT.
Try character 0xB0 (176).
0
 

Author Comment

by:lzha022
ID: 16988288
Sorry for the confusion. I just started to use OpenGL - so still not clear about it. I tried 176 in my code, but it does not show anything.
here is my code:
label = cimSprintf("%s  (%2.0f %c)", p->getGPName(),  theta*360/(2*PI), 176 );
drawBitmapFonts(label, startX, startY, GLUT_BITMAP_HELVETICA_18);
0
 
LVL 2

Accepted Solution

by:
davidnsc1 earned 400 total points
ID: 16988320
Well, I'm just taking a stab at this, but try putting a (unsigned char) before string[i] in your drawBitmapFonts procedure.  Since 176 is greater than 128, in a signed char the number will be negative.  If glutBitmapCharacter's second parameter is an int or something, then it'd stay negative and give you the wrong character.  So casting it to unsigned could hopefully fix it.
0
 

Author Comment

by:lzha022
ID: 16988434
Great!
It is working now.
Thank you very much.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question