Bonjour à tous,

Je chercher une solution pour afficher des images rapidement, via la SDL, dans un contrôle wxPanel de la lib wxWidgets.

J'ai écumer le web en vain :

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
//SDL_Window * w = SDL_CreateWindow("Hi", 0, 0, 640, 480, SDL_WINDOW_SHOWN);
  SDL_Window * w = SDL_CreateWindowFrom((void *)GetHandle());
  if(!w)
  {
    cerr << "Unable to create SDL_Window" << endl;
  }
 
  SDL_Renderer * r = SDL_CreateRenderer(w, -1, SDL_RENDERER_ACCELERATED);
  if(!r)
  {
    cerr << "Unable to create SDL_Renderer" << endl;
  }
 
  SDL_Texture * s = NULL;
  SDL_Surface *bitmapSurface = SDL_LoadBMP("image.bmp");
  s = SDL_CreateTextureFromSurface(r, bitmapSurface);
  if (s == NULL)
  {
  cout << "FAILED TO FIND THE IMAGE" << endl; //we did this to check if IMG_LoadTexture found the image, if it showed this message in the cmd window (the black system-like one) then it means that the image can't be found
  }
  SDL_Rect s_rect; // CREATES THE IMAGE'S SPECS
  s_rect.x = 0;    // just like the window, the x and y values determine it's displacement from the origin which is the top left of your window
  s_rect.y = 0;
  s_rect.w = 640; //width of the texture
  s_rect.h = 480; // height of the texture
 
  SDL_RenderClear(r);
  SDL_RenderCopy(r, s, NULL, &s_rect); // THE NULL IS THE AREA YOU COULD USE TO CROP THE IMAGE
  SDL_RenderPresent(r);
  Refresh(false);
Le code ci-dessus fonctionne parfaitement lorsque je crée la fenêtre normalement (avec la ligne en commentaire #1).

Lorsque j'essaye d'obtenir ma fenêtre sdl depuis mon panel (#2), le programme m'affiche un tout petit carré blanc dans le panel, et impossible, d'y coller mon image...

Je travaille avec VisualStudio 2013, wxWidgets 3.0, et SDL 2

Est-ce que vous auriez des pistes à explorer pour faire cohabiter ces librairies ???

Merci :-)