Jump to content
  • Advertisement
Sign in to follow this  
Xabbu

SDL Output Problem*solved*

This topic is 5130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!