Skip to content
Snippets Groups Projects
Commit f3c7b855 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix drawing of gl text in 64 bit mac cocoa version by making sure the raster position is valid

parent 0892b8c9
No related branches found
No related tags found
No related merge requests found
...@@ -17,32 +17,32 @@ void drawContext::drawString(const std::string &s, const std::string &font_name, ...@@ -17,32 +17,32 @@ void drawContext::drawString(const std::string &s, const std::string &font_name,
{ {
if(CTX::instance()->printing && !CTX::instance()->print.text) return; if(CTX::instance()->printing && !CTX::instance()->print.text) return;
GLboolean valid;
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
if(valid == GL_FALSE) return; // the primitive is culled
// change the raster position only if not creating TeX files // change the raster position only if not creating TeX files
if(align > 0 && (!CTX::instance()->printing || if(align > 0 && (!CTX::instance()->printing ||
CTX::instance()->print.fileFormat != FORMAT_TEX)){ CTX::instance()->print.fileFormat != FORMAT_TEX)){
GLboolean valid; GLdouble pos[4];
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid); glGetDoublev(GL_CURRENT_RASTER_POSITION, pos);
if(valid == GL_TRUE){ double x[3], w[3] = {pos[0], pos[1], pos[2]};
GLdouble pos[4]; drawContext::global()->setFont(font_enum, font_size);
glGetDoublev(GL_CURRENT_RASTER_POSITION, pos); double width = drawContext::global()->getStringWidth(s.c_str());
double x[3], w[3] = {pos[0], pos[1], pos[2]}; double height = drawContext::global()->getStringHeight();
drawContext::global()->setFont(font_enum, font_size); switch(align){
double width = drawContext::global()->getStringWidth(s.c_str()); case 1: w[0] -= width/2.; break; // bottom center
double height = drawContext::global()->getStringHeight(); case 2: w[0] -= width; break; // bottom right
switch(align){ case 3: w[1] -= height; break; // top left
case 1: w[0] -= width/2.; break; // bottom center case 4: w[0] -= width/2.; w[1] -= height; break; // top center
case 2: w[0] -= width; break; // bottom right case 5: w[0] -= width; w[1] -= height; break; // top right
case 3: w[1] -= height; break; // top left case 6: w[1] -= height/2.; break; // center left
case 4: w[0] -= width/2.; w[1] -= height; break; // top center case 7: w[0] -= width/2.; w[1] -= height/2.; break; // center center
case 5: w[0] -= width; w[1] -= height; break; // top right case 8: w[0] -= width; w[1] -= height/2.; break; // center right
case 6: w[1] -= height/2.; break; // center left default: break;
case 7: w[0] -= width/2.; w[1] -= height/2.; break; // center center
case 8: w[0] -= width; w[1] -= height/2.; break; // center right
default: break;
}
viewport2World(w, x);
glRasterPos3d(x[0], x[1], x[2]);
} }
viewport2World(w, x);
glRasterPos3d(x[0], x[1], x[2]);
} }
if(!CTX::instance()->printing){ if(!CTX::instance()->printing){
...@@ -128,7 +128,8 @@ void drawContext::drawSphere(double R, double x, double y, double z, ...@@ -128,7 +128,8 @@ void drawContext::drawSphere(double R, double x, double y, double z,
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
} }
void drawContext::drawEllipse(double x, double y, double z, float v0[3], float v1[3], int light) void drawContext::drawEllipse(double x, double y, double z, float v0[3], float v1[3],
int light)
{ {
if(light) glEnable(GL_LIGHTING); if(light) glEnable(GL_LIGHTING);
glPushMatrix(); glPushMatrix();
...@@ -144,7 +145,8 @@ void drawContext::drawEllipse(double x, double y, double z, float v0[3], float v ...@@ -144,7 +145,8 @@ void drawContext::drawEllipse(double x, double y, double z, float v0[3], float v
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
} }
void drawContext::drawEllipsoid(double x, double y, double z, float v0[3], float v1[3], float v2[3], int light) void drawContext::drawEllipsoid(double x, double y, double z, float v0[3], float v1[3],
float v2[3], int light)
{ {
if(light) glEnable(GL_LIGHTING); if(light) glEnable(GL_LIGHTING);
glPushMatrix(); glPushMatrix();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment