Bonsoir à tous.

Je travaille sur mon moteur 3D, sous Windows XP SP2 (si ça peut aider des fois...) et j'aimerai avoir une fonction qui calcule les ombres de mon heightmap(1024*1024) automatiquement au chargement d'un carte. La fonction est ok. Je stocke ce résultat dans un tableau 1d. Pour ce test, j'ai seulement pris les hauteurs pour déterminer les ombres, pour voir si déjà mon système de rendu offscreen est ok. Mais le problème est le suivant : quand je veux afficher ce tableau 1d, je suppose que je suis obligé de passer par un rendu offscreen, mais suivant la taille de la texture, il apparait des zones noires... :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
    int temp = 1024;//Map.GetWidth();
 
    OrthoMode(0, 0, temp, temp);
 
    lightmap = g_TexManage.GenerateTexture(temp, temp, GL_NEAREST, GL_NEAREST);
 
    glViewport(0,0,temp, temp);
    g_log.Write(LOG_PLAINTEXT, "temp = %i", temp);
    //glBindTexture(GL_TEXTURE_2D, lightmap);
 
    g_log.Write( LOG_PLAINTEXT , "Entering 'for' loop... width/height : %i", temp);
    glBegin(GL_POINTS);
        int j,i;
        for(j=0; j<temp; j++)    //scan en lignes
        {
            for (i=0; i<temp; i++)    //scan en colonnes
            {
                // Set the textures customizable color
                glColor3ub(Map.GetBrightnessAtPoint(i,j), Map.GetBrightnessAtPoint(i,j), Map.GetBrightnessAtPoint(i,j));
                //glColor3ub(128, 128, 255);
                //glColor3ub(Map.GetHeightAtPoint(j,i), Map.GetHeightAtPoint(j,i), Map.GetHeightAtPoint(j,i));
                glVertex2f(i,j);
            }
        }
    glEnd();
 
    g_log.Write(LOG_PLAINTEXT, "i=%i j=%i", i, j);
 
    glBindTexture(GL_TEXTURE_2D, lightmap);
    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, temp, temp, 0);
    ///On rétablit la résolution d'affichage
    glViewport(0, 0, RESO_X, RESO_Y);
    PerspectiveMode();
Hors, quand je divise par 2 pour le viewport et le copyteximage, j'obtient ceci (qui est ce que je devrais obtenir sans les divisions):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
    int temp = 1024;//Map.GetWidth();
 
    OrthoMode(0, 0, temp, temp);
 
    lightmap = g_TexManage.GenerateTexture(temp, temp, GL_NEAREST, GL_NEAREST);
 
    glViewport(0,0,temp/2, temp/2);
    g_log.Write(LOG_PLAINTEXT, "temp = %i", temp);
    //glBindTexture(GL_TEXTURE_2D, lightmap);
 
    g_log.Write( LOG_PLAINTEXT , "Entering 'for' loop... width/height : %i", temp);
    glBegin(GL_POINTS);
        int j,i;
        for(j=0; j<temp; j++)    //scan en lignes
        {
            for (i=0; i<temp; i++)    //scan en colonnes
            {
                // Set the textures customizable color
                glColor3ub(Map.GetBrightnessAtPoint(i,j), Map.GetBrightnessAtPoint(i,j), Map.GetBrightnessAtPoint(i,j));
                //glColor3ub(128, 128, 255);
                //glColor3ub(Map.GetHeightAtPoint(j,i), Map.GetHeightAtPoint(j,i), Map.GetHeightAtPoint(j,i));
                glVertex2f(i,j);
            }
        }
    glEnd();
 
    g_log.Write(LOG_PLAINTEXT, "i=%i j=%i", i, j);
 
    glBindTexture(GL_TEXTURE_2D, lightmap);
    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 0, 0, temp/2, temp/2, 0);
    ///On rétablit la résolution d'affichage
    glViewport(0, 0, RESO_X, RESO_Y);
    PerspectiveMode();
D'où ma question : existe t-il une limite de taille ? Est-ce en rapport avec la résolution du bureau sous windows ? (je travaille sur un portable 1280*800)
Je n'ai pas trouvé pour quelle taille de la texture (entre 512 et 1024 donc) je devrai obtenir le bon affichage, ça prendrait trop de temps je pense, même par dichotomie...

Merci à ceux qui auront une piste, là je deviens chèvre .