J'utilise d3d pour afficher de la 2d. Pour cela, je cree un device, un sprite et une texture en utilisant le code suivant:

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
EAPI int
ecore_win32_direct3d_init(Ecore_Win32_Window *window)
{
#ifdef HAVE_DIRECT3D
   D3DPRESENT_PARAMETERS       pp;
   D3DDISPLAYMODE              dm;
   D3DSURFACE_DESC             sd;
   D3DCAPS9                    caps;
   RECT                        rect;
   struct _Ecore_Win32_Window *w;
   DWORD                       flag;
 
   if (!window)
     return 0;
 
   w = (struct _Ecore_Win32_Window *)window;
 
   printf ("ecore_win32_direct3d_init debut : %p (%d %d) (%d %d)\n",
           w,
           w->min_width,
           w->min_height,
           w->max_width,
           w->max_height);
 
   w->d3d.object = Direct3DCreate9 (D3D_SDK_VERSION);
   if (!w->d3d.object)
     return 0;
 
   if (FAILED (w->d3d.object->GetAdapterDisplayMode (D3DADAPTER_DEFAULT,
                                                     &dm)))
     goto no_get_adapter;
 
   if (FAILED (w->d3d.object->GetDeviceCaps (D3DADAPTER_DEFAULT,
                                             D3DDEVTYPE_HAL,
                                             &caps)))
     goto no_caps;
 
   if (!GetClientRect(w->window, &rect))
     goto no_get_client;
 
   flag = (caps.VertexProcessingCaps != 0)
     ? D3DCREATE_HARDWARE_VERTEXPROCESSING
     : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
 
   ZeroMemory(&pp, sizeof(pp));
   pp.BackBufferWidth = rect.right - rect.left;
   pp.BackBufferHeight = rect.bottom - rect.top;
   pp.BackBufferFormat = dm.Format;
   pp.BackBufferCount = 1;
   pp.MultiSampleType = D3DMULTISAMPLE_NONE;
   pp.MultiSampleQuality = 0;
   pp.SwapEffect = D3DSWAPEFFECT_FLIP;
   pp.hDeviceWindow = w->window;
   pp.Windowed  = TRUE;
   pp.EnableAutoDepthStencil = FALSE;
   pp.FullScreen_RefreshRateInHz = 0;
   pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
 
   if (FAILED(w->d3d.object->CreateDevice (D3DADAPTER_DEFAULT,
                                           D3DDEVTYPE_HAL,
                                           w->window,
                                           flag,
                                           &pp,
                                           &w->d3d.device)))
     goto no_device;
 
   if (FAILED (D3DXCreateSprite (w->d3d.device, &w->d3d.sprite)))
     goto no_sprite;
 
   if (FAILED (w->d3d.device->CreateTexture (rect.right - rect.left,
                                             rect.bottom - rect.top,
                                             1,
                                             D3DUSAGE_DYNAMIC,
                                             dm.Format,
                                             D3DPOOL_DEFAULT,
                                             &w->d3d.texture, NULL)))
     goto no_texture;
 
   if (FAILED (w->d3d.texture->GetLevelDesc (0, &sd)))
     goto no_level_desc;
 
   switch (sd.Format) {
   case D3DFMT_A8R8G8B8:
   case D3DFMT_X8R8G8B8:
     w->d3d.depth = 32;
     break;
   case D3DFMT_R5G6B5:
     w->d3d.depth = 16;
     break;
   default:
     goto no_supported_depth;
   }
 
   w->backend = ECORE_WIN32_BACKEND_DIRECT3D;
 
   printf ("ecore_win32_direct3d_init fin : %p (%d %d) (%d %d)\n",
           w,
           w->min_width,
           w->min_height,
           w->max_width,
           w->max_height);
 
   return 1;
 
 no_supported_depth:
 no_level_desc:
   w->d3d.texture->Release();
 no_texture:
   w->d3d.sprite->Release();
 no_sprite:
   w->d3d.device->Release();
 no_device:
 no_get_client:
 no_caps:
 no_get_adapter:
   w->d3d.object->Release();
#endif /* HAVE_DIRECT3D */
 
   return 0;
}
En particulier, je suis en mode fenetre.

Ma fenetre est redimensionnee durant le programme. Pour gerer cela, j'ai pense a utilise la methode Reset d'un device :

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
 
void
evas_direct3d_device_resize(Outbuf *buf)
{
   D3DPRESENT_PARAMETERS pp;
   D3DDISPLAYMODE        dm;
   HRESULT res;
 
   if (FAILED (buf->priv.d3d.object->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm)))
     {
        printf ("[Evas] [D3D] Can not retrieve the display mode. No resize is done\n");
        return;
     }
 
   ZeroMemory(&pp, sizeof(pp));
   pp.BackBufferWidth = buf->width;
   pp.BackBufferHeight = buf->height;
   pp.BackBufferFormat = dm.Format;
   pp.BackBufferCount = 1;
   pp.MultiSampleType = D3DMULTISAMPLE_NONE;
   pp.MultiSampleQuality = 0;
   pp.SwapEffect = D3DSWAPEFFECT_FLIP;
   pp.hDeviceWindow = buf->priv.d3d.window;
   pp.Windowed  = TRUE;
   pp.EnableAutoDepthStencil = FALSE;
   pp.FullScreen_RefreshRateInHz = 0;
   pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
 
   res = buf->priv.d3d.device->Reset(&pp);
   if (res != D3D_OK)
     {
        printf ("[Evas] [D3D] Can not reset the device (device is now lost)\n");
        printf ("%d %d %d %d\n", res,
                D3DERR_DEVICELOST, D3DERR_DRIVERINTERNALERROR, D3DERR_OUTOFVIDEOMEMORY);
     }
}
buf->width et buf->height sont les nouvelles dimensions.

mais Reset ne renvoie pas D3D_OK et de ce fait, plus rien n'est affiche dans la feentre

Quelqu'un voit-il ou ce qui ne va pas, ou bien ce qui manque ?

merci