Jump to content
  • Advertisement
Sign in to follow this  
FlyingIsFun1217

[SDL] Quick Game Engine Troubles...

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

Hey! I've just begun to make a Stupid Game Engine (actually, that's it's name :P), and have the following code:
/*

This is the main file to link to when developing with the Stupid Game Engine.

NOTE:	This 'Game Engine' is not meant for any hardcore game development. It is meant to be a simple library to link to in the event that you may want to create a *simple* game or rendering of something using the OpenGL 3d Library.



Author:	FlyingIsFun1217

Website:	None, this is too insignificant...

Date:		5-7-07

*/



// First, the headers needed to use OpenGL and SDL... DUH!...
#include	"SDL.h"
#include	<cstdlib>



// Second, the headers needed for things *besides* OpenGL...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>

const char windowed = 'W';
const char fullscreen = 'F';

void fatalError(char *message)
{
	fprintf(stderr, "SGE: %s\n", message);
	exit(1);
}

const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();

class SGE
{
	public:
		SGE();
		~SGE();
		void InitializeVideo(char ScreenMode, int SreenSizeX, int ScreenSizeY, int bitsPerPixel);
		void UninitializeVideo();
	private:
		char SM;
		int SSX;
		int SSY;
		int BPP;
};

SGE::SGE()
{

}

SGE::~SGE()
{

}

void SGE::InitializeVideo(char ScreenMode, int ScreenSizeX, int ScreenSizeY, int bitsPerPixel)
{
	// Collect values from user for creation of the window...
	SM = ScreenMode;
	SSX = ScreenSizeX;
	SSY = ScreenSizeY;
	BPP = bitsPerPixel;

	// Create a pointer that references to the backbuffer...
	SDL_Surface	*ScreenSurface;

	// Initialize SDL with parameters given by user...
	SDL_Init (SDL_INIT_VIDEO);
 	if (SDL_Init(SDL_INIT_VIDEO) != 0)
 	{
        fatalError("Could not initialize SDL Video.");
 	}
  	exit(1);

	atexit(SDL_Quit);

	if (SM == windowed)
	{
		ScreenSurface = SDL_SetVideoMode (SSY, SSX, BPP, SDL_NOFRAME);
	}

	else if (SM == fullscreen)
	{
		SDL_SetVideoMode (SSX, SSY, BPP, SDL_FULLSCREEN);
	}
}

void SGE::UninitializeVideo()
{
	SDL_Quit();
	exit(0);
}
/*
This is an example program showing how to use the SGE.
It is also for use as a way to test out nightlies of the SGE, but the shipping version of this file is soley for an example, as everything has been tested to work.

Author:     FlyingIsFun1217
Date:       5-12-07
*/

#include "SGE.h"

int main()
{
    SGE sgeInstance;
    sgeInstance.InitializeVideo('F', 300, 300, 8);
    //sgeInstance.UninitializeVideo();
}
Now, everything compiles correctly, no errors even... but when I run it, I just get a status 1 exit. Is this code-related? Am I doing something wrong? Should I look into my system? Every other SDL program I have tried to run has run... Thanks for your understanding! FlyingIsFun1217

Share this post


Link to post
Share on other sites
Advertisement
Well, good news, and bad news...
Bad news: I wasted your time!
Good news: It works!

Sorry for wasting your time. Guess you know have a working template of a SDL 'game' engine :P

FlyingIsFun1217

Share this post


Link to post
Share on other sites
you are calling exit(1); in your InitializeVideo
look at the following lines in your InitializeVideo funtion

if (SDL_Init(SDL_INIT_VIDEO) != 0)

{

fatalError("Could not initialize SDL Video.");

}

exit(1);

I think you want the exit inside the if

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!