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

fix

parent 3c536f38
No related branches found
No related tags found
No related merge requests found
...@@ -189,12 +189,10 @@ void drawContext::drawImage(const std::string &name, double x, double y, double ...@@ -189,12 +189,10 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
w = h * img->w / img->h; w = h * img->w / img->h;
} }
GLboolean valid = GL_TRUE;
GLint matrixMode = 0; GLint matrixMode = 0;
if(billboard){ if(billboard){
glRasterPos3d(x, y, z); glRasterPos3d(x, y, z);
GLboolean valid;
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
if(valid == GL_FALSE) return; // the primitive is culled
GLfloat pos[4]; GLfloat pos[4];
glGetFloatv(GL_CURRENT_RASTER_POSITION, pos); glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
glGetIntegerv(GL_MATRIX_MODE, &matrixMode); glGetIntegerv(GL_MATRIX_MODE, &matrixMode);
...@@ -206,12 +204,13 @@ void drawContext::drawImage(const std::string &name, double x, double y, double ...@@ -206,12 +204,13 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
glLoadIdentity(); glLoadIdentity();
double fact = isHighResolution() ? 2. : 1.; double fact = isHighResolution() ? 2. : 1.;
glOrtho((double)viewport[0], (double)viewport[2] * fact, glOrtho((double)viewport[0], (double)viewport[2] * fact,
(double)viewport[1], (double)viewport[3] * fact, -1e3, 1e3); (double)viewport[1], (double)viewport[3] * fact, -1, 1);
x = pos[0]; y = pos[1]; z = 0; x = pos[0]; y = pos[1]; z = 0;
w *= fact * s[0] / pixel_equiv_x; w *= fact * s[0] / pixel_equiv_x;
h *= fact * s[1] / pixel_equiv_y; h *= fact * s[1] / pixel_equiv_y;
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
} }
if(valid == GL_TRUE){
switch(align){ switch(align){
case 1: x -= w/2.; break; // bottom center case 1: x -= w/2.; break; // bottom center
case 2: x -= w; break; // bottom right case 2: x -= w; break; // bottom right
...@@ -223,13 +222,11 @@ void drawContext::drawImage(const std::string &name, double x, double y, double ...@@ -223,13 +222,11 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
case 8: x -= w; y -= h/2.; break; // center right case 8: x -= w; y -= h/2.; break; // center right
default: break; default: break;
} }
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, img->tex); glBindTexture(GL_TEXTURE_2D, img->tex);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex3d(x+wx*w, y+wy*w, z+wz*w); glTexCoord2f(1.0f, 1.0f); glVertex3d(x+wx*w, y+wy*w, z+wz*w);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x+wx*w+hx*h, y+wy*w+hy*h, z+wz*w+hz*h); glTexCoord2f(1.0f, 0.0f); glVertex3d(x+wx*w+hx*h, y+wy*w+hy*h, z+wz*w+hz*h);
...@@ -238,7 +235,7 @@ void drawContext::drawImage(const std::string &name, double x, double y, double ...@@ -238,7 +235,7 @@ void drawContext::drawImage(const std::string &name, double x, double y, double
glEnd(); glEnd();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
}
if(billboard){ if(billboard){
glPopMatrix(); glPopMatrix();
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment