Sign in to follow this  
Xabbu

SDL Output Problem*solved*

Recommended Posts

When i try and run my program, i get no output, it compiles fine, but when executed, nothing happens.(And yes, there should be output). [Edited by - Xabbu on September 3, 2004 5:49:05 PM]

Share this post


Link to post
Share on other sites
I'm assuming you're writing to the standard output... Do you have any idea why it isn't showing up? Anything more information you can give us to narrow the problem down? How about showing us some code. Preferably, the function where you output, and perhaps where you set up SDL.

Share this post


Link to post
Share on other sites
Writing to stdout should function correctly if you set your project up as a console app (which you possibly didn't).

If you set up a Win32 app you should find some files in your game's working directory (check your project folder or whatever) called stdout.txt or suchlike.

Hope this helps

Pete

Share this post


Link to post
Share on other sites
Ok, here's the code.I got it from a tutorial.

#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>


SDL_Surface *screen;

void Draw(int x, int y, SDL_Surface *sprite);

int main(int nArgs, char **args)
{

SDL_Surface *image;
bool isRunning;

SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);

screen = SDL_SetVideoMode(300, 200, 0, SDL_HWSURFACE|SDL_DOUBLEBUF);
image = SDL_LoadBMP("image.bmp");

isRunning = true;

while(isRunning)
{
SDL_Event event;
SDL_PollEvent(&event);

if (event.type == SDL_QUIT)
isRunning = false;

Draw(0,0,image);

SDL_Flip(screen);

}

SDL_FreeSurface(image);

return 0;
}

void Draw(int x, int y, SDL_Surface *sprite)
{
SDL_Rect source;
SDL_Rect dest;

source.x = 0;
source.y = 0;
source.w = sprite->w;
source.h = sprite->h;

dest.x = x;
dest.y = y;
dest.w = source.w;
dest.h = source.h;

SDL_BlitSurface(sprite, &source, screen, &dest);

return;
}







edit:bah, now i have output, but it flashes for like half a second then closes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this