Problem in displaying text
Dear Friends
I am finding some difficulty in displaying the text in properposition mean at proper coordinate position. I am using bitmap fonts.. Using nehe tutorials I am able to draw a text. but now I want customize the text. Basically I want to display X, Y, Z at x=10, y=10 and z=10 location. I have an axes xyz threee lines I have already drawn.
For that I am doing like this.
glRasterPos3f(10.0f, 0.0f, 0.0f);
glPrint("X");
glRasterPos3f(0.0f, 10.0f, 0.0f);
glPrint("Y");
glRasterPos3f(0.0f, 0.0f, 10.0f);
glPrint("Z");
But I can see XYandZ all are coming at (10,0,0) position....Y and Z shoulb be at 0,10,0 and 0,0,10 respectively. Please help me someone whats going wrong in this.
My glPrint is like this
///////////////////////////////////////////////////////////////
GLvoid CRevolutionProjView::glPrint(const char *fmt, ...) // Custom GL "Print" Routine
{
CDC* pDC = GetDC();
wglMakeCurrent(pDC->m_hDC, m_hrc);
char text[256]; // Holds Our String
va_list ap; // Pointer To List Of Arguments
if (fmt == NULL) // If There's No Text
return; // Do Nothing
va_start(ap, fmt); // Parses The String For Variables
vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers
va_end(ap); // Results Are Stored In Text
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(base - 32); // Sets The Base Character to 32
glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text
glPopAttrib(); // Pops The Display List Bits
wglMakeCurrent(NULL,NULL);
}
//////////////////////////////////////////////////////////////
and I am creating font like this....
//////////////////////////////////////////////////////////////
GLvoid CRevolutionProjView::BuildFont(GLvoid) // Build Our Bitmap Font
{
CDC* pDC = GetDC();
wglMakeCurrent(pDC->m_hDC, m_hrc);
HFONT font; // Windows Font ID
HFONT oldfont; // Used For Good House Keeping
base = glGenLists(96); // Storage For 96 Characters
font = CreateFont( -24, // Height Of Font
0, // Width Of Font
0, // Angle Of Escapement
0, // Orientation Angle
FW_BOLD, // Font Weight
FALSE, // Italic
FALSE, // Underline
FALSE, // Strikeout
ANSI_CHARSET, // Character Set Identifier
OUT_TT_PRECIS, // Output Precision
CLIP_DEFAULT_PRECIS, // Clipping Precision
ANTIALIASED_QUALITY, // Output Quality
FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch
L"Courier New"); // Font Name
oldfont = (HFONT)SelectObject(pDC->m_hDC, font); // Selects The Font We Want
wglUseFontBitmaps(pDC->m_hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32
SelectObject(pDC->m_hDC, oldfont); // Selects The Font We Want
DeleteObject(font); // Delete The Font
wglMakeCurrent(NULL,NULL);
}
////////////////////////////////////////////////////////
I am calling BuildFont in PrepareScene like this
///////////////////////////////////////////////////////////
void CRevolutionProjView::PrepareScene(CDC *pDC)
{
wglMakeCurrent(pDC->m_hDC, m_hrc);
//---------------------------------
glClearColor (0.0, 0.0, 0.0, 1.0);
drawAxes();
BuildFont();
wglMakeCurrent(NULL, NULL);
}
///////////////////////////////////////////////////////////
Please tell me why they'are not coming at their proper positions. How can I achieve this. Thanks a lot in advance for the reply. Thanks Sujan
Re: Problem in displaying text
Re: Problem in displaying text
Quote:
Originally Posted by
S_M_A
I've mentioned it in another post to him, please use the [ code ] tags, as it makes your code and posts easier to read.
Re: Problem in displaying text
how to use tags...pls tell me
Re: Problem in displaying text
That what's described in the link I gave...
The code tags only version of the description is: [code] Place your properly indented code here [/code]