Salut,

Le titre me semble assez explicite lol. En fait, j'ai une carte graphique intel Q965 qui ne supporte pas les shader et j'aimerais faire du shadow mapping. J'ai effectué un render to texture pour recupérer le depth buffer dans une texture. Mais ensuite, je n'arrive pas à transformer ma texture et à la plaquer sur le sol.

Voici le code:

Initialisation:
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
 
GLuint TextureId;
format=GL_DEPTH_COMPONENT;
texture_width=512;
texture_height=512
 
// create a texture object
    glGenTextures(1, &TextureId);
    glBindTexture(GL_TEXTURE_2D, TextureId);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); // automatic mipmap generation included in OpenGL v1.4
    glTexImage2D(GL_TEXTURE_2D, 0, format, texture_width, texture_height, 0, format, GL_UNSIGNED_BYTE, 0);
    glBindTexture(GL_TEXTURE_2D, 0);
Boucle de jeu:
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
 
ViewportPositionX=0;
ViewportPositionY=0;
ViewportWidth=512;
ViewportHeight=512;
Fovy=60.0;
Aspect=512/512;
ZNear=1.0;
ZFar=100.0;
RealTextureWidth=512;
RealTextureHeight=512;
 
glViewport(ViewportPositionX, ViewportPositionY, ViewportWidth, ViewportHeight);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(Fovy, Aspect, ZNear, ZFar);
	glClearColor(1, 1, 1, 1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
 
	gluLookAt(Light->GetPositionX(),Light->GetPositionY(),Light->GetPositionZ(),Light->GetTargetX(),Light->GetTargetY(),Light->GetTargetZ(),Light->GetUpVector().x,Light->GetUpVector().y,Light->GetUpVector().z);
 
    glPushAttrib(GL_COLOR_BUFFER_BIT | GL_PIXEL_MODE_BIT); // for GL_DRAW_BUFFER and GL_READ_BUFFER
    glDrawBuffer(GL_BACK);
    glReadBuffer(GL_BACK);
 
    DrawScene();
 
glEnable(GL_TEXTURE_2D);
 
	// copy the framebuffer pixels to a texture
    glBindTexture(GL_TEXTURE_2D, TextureId);
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, RealTextureWidth, RealTextureHeight);
    glBindTexture(GL_TEXTURE_2D, 0);
	glDisable(GL_TEXTURE_2D);
 
	glPopAttrib();
 
	// back to normal viewport and projection matrix
	glViewport(0, 0, GSEApplication->GetSizeX(), GSEApplication->GetSizeY());
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
	gluPerspective(GSEApplication->GetVerticalAngle(), (float)(GSEApplication->GetSizeX())/GSEApplication->GetSizeY(), GSEApplication->GetDepthMinimumView(), GSEApplication->GetDepthMaximumView());
 
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
 
    // clear framebuffer
    glClearColor(0, 0, 0, 0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 
	gluLookAt(GSECamera->GetPositionX(),GSECamera->GetPositionY(),GSECamera->GetPositionZ(),GSECamera->GetTargetX(),GSECamera->GetTargetY(),GSECamera->GetTargetZ(),GSECamera->GetUpVector().x,GSECamera->GetUpVector().y,GSECamera->GetUpVector().z);
 
DrawScene();
Voila ce que j'obtient (Le quad blanc represente ma texture de profondeur):


J'ai déjà fait plein de recherche pour des tutoriaux et des codes sur google. J'ai tenté d'adapter les codes sans succès.

Donc j'aimerais savoir comment puis je plaquer ma texture sans shader?

Merci