[C++] Fenêtre SDL ne s'affiche pas [RESOLU]

Fenêtre SDL ne s'affiche pas [RESOLU] [C++] - C++ - Programmation

Marsh Posté le 04-02-2011 à 11:41:44    

Bon jour a tous,
 
J'ai reproduit un problème que j'ai avec ce petit programme de test plus bas. Il ne fait rien d'autre que d'utiliser deux librairies et afficher une fenêtre SDL avec un pixel rouge. Je sais, passionant.
 
J'utilise log4cplus comme logger. Si je commente les deux lignes 32 et 33 plus bas, alors tout se passe nickel. Si je les exécute (ou n'importe quoi relatif au logger semble t'il, comme une simple déclaration de variable), alors ma fenêtre SDL ne s'affiche plus bien que je n'aie aucune erreur. A la place dans la console d'eclispe cdt j'ai un message du genre [New thread: 0x8168d] et c'est tout.
 
Si vous voyez ce qui pourrait clocher hésitez pas, google ne me retourne rien.
 
 

Code :
  1. #include <stdlib.h>
  2. #include <SDL/SDL.h>
  3. #include <SDL/SDL_endian.h> /* Used for the endian-dependent 24 bpp mode */
  4. #include "Screen.h"
  5. #include <log4cplus/logger.h>
  6. #include <iomanip>
  7. using namespace log4cplus;
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include <unistd.h>
  12. #include "iniparser.h"
  13. int main(int argc, char **argv) {
  14.     dictionary * ini ;
  15.     char      * ini_name ;
  16.     if (argc<2) {
  17.         ini_name = "twisted.ini";
  18.     } else {
  19.         ini_name = argv[1] ;
  20.     }
  21.     ini = iniparser_load(ini_name);
  22.     iniparser_dump(ini, stdout);
  23.     iniparser_freedict(ini);
  24. Logger root = Logger::getRoot();
  25.     Logger log_1 =  Logger::getInstance(LOG4CPLUS_TEXT("test.log_1" ));
  26.       SDL_Surface *screen;
  27.         screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
  28.         if ( screen == NULL ) {
  29.             fprintf(stderr, "Impossible de passer en 640x480 en 16 bpp: %s\n", SDL_GetError());
  30.             exit(1);
  31.         }
  32.         while(true)
  33.         {
  34.             SDL_Event event;
  35.             SDL_WaitEvent(&event);
  36.                         switch (event.type) {
  37.                             case SDL_KEYDOWN:
  38.                                 printf("La touche %s a été préssée!\n",
  39.                                       SDL_GetKeyName(event.key.keysym.sym));
  40.                                     //SDL_Quit();
  41.                                 break;
  42.                             case SDL_QUIT:
  43.                                 exit(0);
  44.                         }
  45.                         Screen::DrawPixel(screen,20,20,200,10,10);
  46.         }
  47. }


Message édité par gelatine_velue le 04-02-2011 à 23:34:33
Reply

Marsh Posté le 04-02-2011 à 11:41:44   

Reply

Marsh Posté le 04-02-2011 à 23:34:03    

I found the problem. I hadn't noticed the error gdb gave me when running the program: " gdb: unknown target exception 0xc0000135". In fact the program didn't start at all.
 
This means it could not load a dll because of some path problems. I tried putting the dll I use for log4cplus in the system path, tried other workarounds like starting eclipse from but to no avail. One way I found to make it work is simply to put the dll in the Debug folder.
 
The problem with this gdb error is quite widespread (see google). This is not a proper fix, but I will live with it for the time being, so I consider the problem solved.

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed