Pour construire mes ombres je me suis guidé avec le tutorial de nehe n27.

Lorsque je fais le calcul brute de l'ombre tous vas bien...



Seulement voila lorsque je le paramétre de façon à ce qu'il montre
seulement l'ombre.. aucune ombre n'apparaît...



Si vous penser qu'il n'y a aucun font détromper vous , la camera ce trouve à
l'interieur d'une boite blanche.

Voici mon code ( à noter que j'utilise l'api de windows afin d'afficher l'image dans une fenêtre ):

Inicialisation...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
        glClearStencil(0);									
        glEnable(GL_DEPTH_TEST);					
        glEnable(GL_CULL_FACE);
        glCullFace(GL_BACK);

Pour commencer le frame...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
        glEnable(GL_MULTISAMPLE_ARB);
 
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
        glLoadIdentity();
Dans le fichier main en speudo code...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
        start_frame
             draw_cube
             draw_world
             update_shadow
        end_frame
Dans l'ajournement de l'ombre...

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
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
 
        glDisable(GL_LIGHTING);
        glDepthMask(GL_FALSE);
        glDepthFunc(GL_LEQUAL);
 
        glEnable(GL_STENCIL_TEST);
        glColorMask(0, 0, 0, 0);
        glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
 
        // first pass, stencil operation decreases stencil value
        glFrontFace(GL_CCW);
        glStencilOp(GL_KEEP, GL_KEEP, GL_INCR );
 
        mShadowList::const_iterator it;
        for(it=mShadowLocalList.begin(); it!=mShadowLocalList.end(); ++it)
        {
            Shadow* pShadow = *it;
 
            HardwareVertexBuffer* vb = pShadow->getVertexBuffer();
            float* vShadow = pShadow->getVertexShadow();
            size_t numberVertex = pShadow->getNumberVertexShadow();
 
            float* currentShadow = vb->lock();
 
            for(int i = 0; i < numberVertex; i++)
                currentShadow[i] = vShadow[i];
 
            vb->unlock();
 
            glColor3f(0.0, 0.0, 0.0);
            //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
            render(vb, NULL, NULL, NULL,
                    NULL, NULL, NULL, NULL,
                    NULL, GPT_QUADS);
            //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        }
 
        // Now we render the shadow volume again and this time we decrement the stencil every
        // where that is not in the area being rendered.  In other words this is for every
        // thing outside the shadow area.
 
        glFrontFace(GL_CW);
        glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
 
        for(it=mShadowLocalList.begin(); it!=mShadowLocalList.end(); ++it)
        {
            Shadow* pShadow = *it;
 
            HardwareVertexBuffer* vb = pShadow->getVertexBuffer();
 
            //glColor3f(1.0, 1.0, 0.0);
            render(vb, NULL, NULL, NULL,
                    NULL, NULL, NULL, NULL,
                    NULL, GPT_QUADS);
        }
 
        glFrontFace(GL_CCW);
        glColorMask(1, 1, 1, 1);
 
        //draw a shadowing rectangle covering the entire screen
        glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glStencilFunc(GL_NOTEQUAL, 0, 0xffffffff);
        glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
        glPushMatrix();
        glLoadIdentity();
        glBegin(GL_TRIANGLE_STRIP);
            glVertex3f(-0.1f, 0.1f,-0.10f);
            glVertex3f(-0.1f,-0.1f,-0.10f);
            glVertex3f( 0.1f, 0.1f,-0.10f);
            glVertex3f( 0.1f,-0.1f,-0.10f);
        glEnd();
        glPopMatrix();
        glDisable(GL_BLEND);
 
        glDepthFunc(GL_LEQUAL);
        glDepthMask(GL_TRUE);
        glEnable(GL_LIGHTING);
        glDisable(GL_STENCIL_TEST);
        glShadeModel(GL_SMOOTH);
Voila si vous avez une idée, une hypothése sur le disfonctionnement du code
faite le moi savoir savoir s.v.p