|
|
> I searched the previous articles in the forum. Now I understant why the text is transformed just like an object. My question still remains. How to draw the text specified in screen coordinates? Thanks for all helps.
>
> With best wishes,
>
> Linda
Linda,
Solution 1:
My_GL_Window::draw()
{
glViewport(0, 0, w(), h());
setup_3D_projection();
setup_3D_view();
draw_3D_stuff();
// setup 2D projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, w(), 0, h(), -1, 1);
// setup 2D view
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
draw_2D_Stuff();
}
However, if your draw() currently looks like this:
My_GL_Window::draw()
{
if(!valid)
{
glViewport(0, 0, w(), h());
setup_3D_projection();
}
setup_3D_view();
draw_3D_stuff();
}
then you will need solution 2:
My_GL_Window::draw()
{
if(!valid)
{
glViewport(0, 0, w(), h());
setup_3D_projection();
}
setup_3D_view();
draw_3D_stuff();
// save and setup 2D projection
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, w(), 0, h(), -1, 1);
// save and setup 2D view
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
draw_2D_Stuff();
// restore 3D state
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
Don.
[ Direct Link to Message ] | |
|
| |