I’m trying to add some 2d effects to a GL program I’m working on,
however when anything failed to show up I wrote the following test
program, and I’m completely stumped as to why nothing shows up.--------------------------------------------------------------------
#include <SDL/SDL.h>
#include <SDL/SDL_video.h>
#include <SDL/SDL_image.h>
int main() {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf(“Failed 1\n”);
return 0;
}
SDL_Surface* s = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE);
if (!s) {
printf(“Failed 2\n”);
return 0;
}
SDL_Surface* i = IMG_Load(“console.png”);
if (!i) {
printf(“Failed 3\n”);
return 0;
}
SDL_Surface* img = SDL_DisplayFormat(i);
SDL_FreeSurface(i);
SDL_Rect sr = {0, 0, img->w, img->h};
SDL_Rect dr = {10, 10, 0, 0};
if (SDL_BlitSurface(s, &sr, img, &dr) < 0) {
printf(“Failed 4\n”);
return 0;
}
SDL_UpdateRects(s, 1, &dr);
while (1) {
SDL_Event e;
while (SDL_PollEvent(&e))
if (e.type == SDL_QUIT) {
SDL_FreeSurface(s);
SDL_FreeSurface(img);
SDL_Quit();
return 0;
}
}
}
None of the failed messages are printed… A window opens and sits there,
completely black… Can anyone tell me what I’m doing wrong?
Thanks in advance,
Jp Calderone