|
...
#include "sliceO_include.hpp"
#include "sliceO_OpenGL.hpp"
static unsigned int *Gizmo_Texture_Text ;
// ----------------------------------------------------------------------------
//
// Draw some text on a tool. If the Flag_3D is set, the text will be a
// texture with an angle. Otherwise it is a simple horizontal text.
//
// ----------------------------------------------------------------------------
SLICEO_DB void OpenGL_Draw_Gizmo_Data( SliceO_Window *window, char *str,
Point_2D *pos_wnd, Point_2D *offset,
float angle, float dim_x, float dim_y,
unsigned int color, char flag_3D )
{
// char *str = Fct_Float_2_Dist( value ) ;
glPushMatrix() ;
// --- place the targets ---
glTranslatef( pos_wnd->x, pos_wnd->y, 0.0f ) ;
// --- keep the targets align to the ruler ---
glRotatef( angle*DEG, 0.0f, 0.0f, 1.0f ) ;
// --- now offset in this new direction ---
glTranslatef( offset->x, offset->y, 0.0f ) ;
if ( flag_3D ) {
// --- X does not have angled text, we have to write to a bit-map
// rotate the bit-map and display-it...
int i_x = 64 ;
int i_y = 16 ;
unsigned short *texte = OpenGL_Text_To_Bitmap( window->m_wind_draw, str, "helvetica", 18, i_x, i_y ) ;
glEnable( GL_TEXTURE_2D ) ;
if ( glIsTexture( Gizmo_Texture_Text[window->Id_Get()] ) == GL_FALSE ) {
glGenTextures( 1, &(Gizmo_Texture_Text[window->Id_Get()]) ) ;
glBindTexture( GL_TEXTURE_2D, Gizmo_Texture_Text[window->Id_Get()] ) ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glBindTexture") ;
glPixelStorei( GL_UNPACK_ALIGNMENT, 2 ) ;
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ) ;
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ) ;
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ) ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glPixelStore") ;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ) ;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ) ;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ) ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glTexParameter") ;
} else {
glBindTexture( GL_TEXTURE_2D, Gizmo_Texture_Text[window->Id_Get()] ) ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glBindTexture") ;
}
glTexImage2D( GL_TEXTURE_2D,
0, GL_LUMINANCE_ALPHA,
i_x, i_y, 0,
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,
texte ) ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glTexImage2D") ;
// --- white text on opaque background ---
{
glColor4f( 0.0f, 0.0f, 0.0f, 1.0f ) ;
float col[4] = { (float) (RED_BYTE(color)) / 255.0f,
(float) (GRN_BYTE(color)) / 255.0f,
(float) (BLU_BYTE(color)) / 255.0f,
0.0f } ;
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, col ) ;
}
glScalef( dim_x, dim_y, 1.0f ) ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glMatrix") ;
glBegin( GL_QUADS ) ;
glTexCoord2s( 0, 0 ) ;
glVertex2s( 0, 0 ) ;
glTexCoord2s( 1, 0 ) ;
glVertex2s( 1, 0 ) ;
glTexCoord2s( 1, 1 ) ;
glVertex2s( 1, 1 ) ;
glTexCoord2s( 0, 1 ) ;
glVertex2s( 0, 1 ) ;
glEnd() ;
YGL_ERROR("OpenGL_Draw_Gizmo_Data: glBegin/End") ;
FREE( texte ) ;
glDisable( GL_TEXTURE_2D ) ;
} else {
OpenGL_Text_DrawRasterFont( str, GIZMO_TEXT_SIZE,
RED_BYTE(color), GRN_BYTE(color), BLU_BYTE(color),
0.0f, 0.0f, 0.0f ) ;
}
glPopMatrix() ;
}
...
|