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
|
glm::mat4 Projection = glm::perspective(60.0f, 1.0f, 0.05f, 960.f);
glm::mat4 Model;
//glm::mat4 View = glm::rotate(mat4(1.0f), ang, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 View = glm::rotate(mat4(1.0f), ang, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 ViewTranslate = glm::translate(View, glm::vec3(xp, haut, yp));
//glm::mat4 ViewTranslate = glm::translate(View, glm::vec3(xp, haut, yp));
glm::mat4 MVPint = ViewTranslate * Model;
int naelt=0;
for (int rcx=0;rcx<rc;rcx++)
{
for (int rcy=0;rcy<rc;rcy++)
{
int ps=rcx+(rcy*rc);
glm::mat4 MVP = Projection * ViewTranslate * Model;
//bug ????
MVP=glm::translate(MVP,glm::vec3(rcx*8,0,rcy*8));
////////////
GLfloat *f=glm::value_ptr(MVP);
glActiveTexture(GL_TEXTURE+0);
glBindTexture(GL_TEXTURE_2D,mur);
glUniformMatrix4fv(mamat,1,GL_FALSE,f);
glUniform4f(mafogcolor,0.0,0.0,0.0,0.0);
glUniform1f(mamlt_fp,1.0); //echelle texture
glUniform1f(mafogdensity,0.02);
// Utilisation des données des buffers
int err;
glEnable(GL_TEXTURE_2D);
glBindBuffer(GL_ARRAY_BUFFER, alesvertex[ps]);
glVertexPointer( 3, GL_FLOAT, 5 * sizeof(float),( 0 ));
glTexCoordPointer(2, GL_FLOAT, 5 * sizeof(float),(GLvoid*)( 3*sizeof(GLfloat)));
glEnableClientState( GL_VERTEX_ARRAY );
int ns=ne/5.0;
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
if (iselement)
{
glDrawElements(GL_TRIANGLES,numberelement[ps],GL_UNSIGNED_INT,0);
naelt+=numberelement[ps];
}
else
{
glBindBuffer(GL_ARRAY_BUFFER, alesid[ps]);
glDrawArrays(GL_TRIANGLES,0,numbervertex[ps]);
}
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
}
}
//DrawPanneau(1.5,0);
SwapBuffers( hDC );
static int nufps=0;
static int ds=GetTickCount();
nufps++;
if ((GetTickCount()-ds)>1000)
{
char tmp[64];
sprintf(tmp,"%d fps %d",nufps,naelt);
SetWindowText(hStatic,tmp);
nufps=0;
ds=GetTickCount();
}
//theta += 1.0f;
}
} |
Partager