Resulta que estoy trabajando con la librería SDL, en Eclipse. Tengo 2 proyectos diferentes, con un archivo source cada uno. Aclaro que ambos proyectos están en el mismo directorio y tienen exactamente las mismas propiedades.
Ahora bien, en un source tengo este código:
Código
#include <stdio.h> #include <SDL/SDL.h> int main (int argc, char* argv[]) { SDL_Surface* screen; SDL_Surface* surface; Uint32 rmask = 0xff000000; Uint32 gmask = 0x00ff0000; Uint32 bmask = 0x0000ff00; Uint32 amask = 0x000000ff; if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0) { } screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE | SDL_DOUBLEBUF); if ((screen == NULL)) { } surface = SDL_CreateRGBSurface(SDL_SWSURFACE,640,480,32,rmask,gmask,bmask,amask); if ((surface == NULL)) { } return 0; }
Algo muy simple en SDL, recién para arrancar. Compila, lo corro, y funciona de pelos.
Ahora bien en el otro source tengo este otro código:
Código
#include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> int main (int argc, char* argv[]) { SDL_Surface *screen, *image; Uint32 rmask, bmask, gmask, amask; SDL_Rect dest; /*Destiny of the image*/ SDL_Event event; int done = 0; /*INIT SDL*/ if (SDL_Init(SDL_INIT_VIDEO) < 0); { } /*ACTIVATE VIDEO MODE*/ screen = SDL_SetVideoMode(640,480,32,SDL_HWSURFACE); if ((screen == NULL)) { } /*UPLOAD GRAPHIC*/ image = SDL_LoadBMP("Ruta.bmp"); if (image == NULL) { } /*Defining destiny of the image*/ dest.x = 100; dest.y = 100; dest.w = image->w; dest.h = image->w; SDL_BlitSurface(image,NULL,screen,&dest); /*Show Screen*/ SDL_Flip(screen); /*Free Surface*/ SDL_FreeSurface(image); /*Waiting for the user to press to quit*/ while (done == 0) { while (SDL_PollEvent(&event)) { if (event.type == SDL_KEYDOWN) done = 1; } } /*FINISH SDL*/ return 0; }
También compila perfecto. El problema es que al correrlo, me da un error en el SDL_Init. Es decir, entra al if del SDL_Init.
Lo curioso es que limpio esa parte del código, es decir, no inicializo el SDL, y funciona perfectamente el programa. Carga la ventana con la respectiva imágen.
No entiendo, ¿Alguien sabe qué está ocurriendo?