Jump to content
  • Advertisement
Sign in to follow this  
Stromberg

process terminated with status 1

This topic is 3664 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

Whats wrong in my code? -> ERROR: process terminated with status 1
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include "SDL/SDL_ttf.h"
#include <string>
using namespace std;

SDL_Surface *background = NULL;
SDL_Surface *message    = NULL;
SDL_Surface *screen     = NULL;
SDL_Event event;
TTF_Font *font = NULL;
SDL_Color textcolor = {255,255,255};

SDL_Surface * LoadImage(const string &filename);
void ApplySurface(short x, short y, SDL_Surface *source, SDL_Surface *desination, SDL_Rect *clip = NULL);
bool Init(short x, short y, short BPP);
bool LoadFiles();
void clean();

int main(int argc, char* args[] )
{
    if(!Init(900,600,32)) return 1;
    if(!LoadFiles()) return 1;

    message = TTF_RenderText_Solid(font, "HELLO WORLD!", textcolor); //!?
    if(message == NULL)
    {
        return 1;
    }

    ApplySurface(0,0,background,screen);
    ApplySurface(10,10,message,screen);
    if(SDL_Flip(screen) == -1)
    {
        return 1;
    }

    bool quit = false;
    while(!quit)
    {
        while(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT)
            {
                quit = true;
            }
        }
    }

    clean();

    return 0;
}

SDL_Surface * LoadImage(const string &filename)
{
    SDL_Surface *loadedImage    = NULL;
    SDL_Surface *optimizedImage = NULL;
    loadedImage = IMG_Load(filename.c_str());
    if(loadedImage != NULL)
    {
        optimizedImage = SDL_DisplayFormat(loadedImage);
        SDL_FreeSurface(loadedImage);
    }
    return optimizedImage;
}

void ApplySurface(short x, short y, SDL_Surface *source, SDL_Surface *destination, SDL_Rect *clip)
{
    SDL_Rect offset;
    offset.x = x;
    offset.y = y;
    SDL_BlitSurface(source , clip, destination, &offset);
}


bool Init(short x, short y, short BPP)
{
    if(SDL_Init(SDL_INIT_EVERYTHING) == -1)
    {
        return false;
    }
    screen = SDL_SetVideoMode(x,y,BPP,SDL_SWSURFACE);

    if(screen == NULL)
    {
        return false;
    }

    if(TTF_Init() == -1)
    {
        return false;
    }

    SDL_WM_SetCaption("TTF_TEST",NULL);

    return true;
}

bool LoadFiles()
{
    background = LoadImage("background.bmp"); // = FALSE!?
    if(background == NULL)
    {
        return false;
    }

    font = TTF_OpenFont("font.ttf",24);
    if(font == NULL)
    {
        return false;
    }

    return true;
}

void clean()
{
    SDL_FreeSurface(message);
    SDL_FreeSurface(background);
    TTF_CloseFont(font);
    TTF_Quit();
    SDL_Quit();
}

Stromberg [Edited by - Stromberg on June 12, 2008 4:57:34 PM]

Share this post


Link to post
Share on other sites
Advertisement
Use [source][/source] tags around blocks of code. You may need to re-paste the code from the IDE to retain the formatting.

As for the error, there are a number of areas in main where you return 1 as an error handler. Can you step through the program in a debugger to see which one is running?

Share this post


Link to post
Share on other sites
Sry, I have no idea of debuggers.
Anyway, I started the Debugger from my IDE (Code::blocks), but I don't know what all that mean. Here's the output:
Quote:

Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: E:\Andis kleine Welt\Andis kranke Welt (don't destroy this fucking directory!!!)\ttfAdding source dir: E:\Andis kleine Welt\Andis kranke Welt (don't destroy this fucking directory!!!)\ttfAdding file: bin\Debug\ttf.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.7.50.20071127
Child process PID: 6092
Program exited with code 01.
Debugger finished with status 0


Stromberg

PS: Excuse my bad english. I would be nice of you to correct my english a little bit, in order that i can learn it better.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!