1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
if (!m_pTexture)
return;
if (!m_pPt3D)
return;
if (!glIsList(m_nTexturesList))
{
m_nTexturesList = glGenLists(1);
glNewList(m_nTexturesList, GL_COMPILE);
{
int nLiT = m_pTexture->GetLi();
int nCoT = m_pTexture->GetCo();
GLfloat *Texture = new GLfloat[4*nLiT*nCoT];
int il;
int ic;
for (il = 0; il<nLiT; il++)
for (ic = 0; ic<nCoT; ic++)
{
float z = (m_pTexture->GetAt(il, ic)-m_fTmin)/(m_fTmax-m_fTmin) ;
Texture[4*(il*nCoT+ic)] = GLfloat(1.0*z);
Texture[4*(il*nCoT+ic)+1] = GLfloat(1.0*z);
Texture[4*(il*nCoT+ic)+2] = GLfloat(1.0*z);
Texture[4*(il*nCoT+ic)+3] = GLfloat(1.0*m_fAlpha);
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GLuint Nom;
glEnable(GL_TEXTURE_2D);
glGenTextures(1,&Nom);
glBindTexture(GL_TEXTURE_2D,Nom);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glTexImage2D(GL_TEXTURE_2D, 0, 4, nCoT, nLiT, 0, GL_RGBA, GL_FLOAT, Texture);
delete [] Texture;
int nLi = m_pPt3D->GetLi();
int nCo = m_pPt3D->GetCo();
if (nLi != nLiT || nCo != nCoT)
{
nLi = __min(nLi, nLiT);
nCo = __min(nCo, nCoT);
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
///Partie affichage du maille EF
for (il = 0; il<nLi-m_nPointsSample; il+=m_nPointsSample)
for (ic = 0; ic<nCo-m_nPointsSample; ic+=m_nPointsSample)
{
long l1 = il;
long l2 = (il+m_nPointsSample);
long c1 = ic;
long c2 = (ic+m_nPointsSample);
POINT3D pt3D[4];
pt3D[0] = m_pPt3D->GetAt(l1, c1);
pt3D[1] = m_pPt3D->GetAt(l1, c2);
pt3D[2] = m_pPt3D->GetAt(l2, c2);
pt3D[3] = m_pPt3D->GetAt(l2, c1);
bool bnan = pt3D[0].IsNaN() || pt3D[1].IsNaN() || pt3D[2].IsNaN() || pt3D[3].IsNaN();
if (!bnan)
{
H3_POINT2D_FLT32 pt2D[4];
pt2D[0] = H3_POINT2D_FLT32(l1/float(nLi), c1/float(nCo));
pt2D[1] = H3_POINT2D_FLT32(l1/float(nLi), c2/float(nCo));
pt2D[2] = H3_POINT2D_FLT32(l2/float(nLi), c2/float(nCo));
pt2D[3] = H3_POINT2D_FLT32(l2/float(nLi), c1/float(nCo));
int ip;
glBegin(GL_QUADS);
for (ip=0; ip<4; ip++)
{
glTexCoord2f(pt2D[ip].y, pt2D[ip].x);
glVertex3f(pt3D[ip].x, m_fYmin+m_fYmax-pt3D[ip].y, pt3D[ip].z);
}
glEnd();
}
}
glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, 0);
glDeleteTextures(1,&Nom);
glDisable(GL_TEXTURE_2D);
}
glEndList();
} |
Partager