Sign in to follow this  
willthiswork89

SDL ERROR with .NET

Recommended Posts

okay when i try o compile this code
#include <SDL.h>
#include <string>

#define SWIDTH = 640
#define SHEIGHT = 480
#define BPP = 32
using namespace std;

SDL_Surface *message = NULL;
SDL_Surface *background = NULL;
SDL_Surface *Screen = NULL;

SDL_Surface* load_image(string filename)
{
	SDL_Surface *loadedimage = NULL;

	SDL_Surface *optimizedimage = NULL;

	loadedimage = SDL_LoadBMP(filename.c_str());

	if(loadedimage != NULL)
	{
		optimizedimage = SDL_DisplayFormat(loadedimage);

		SDL_FreeSurface(loadedimage);
	}
return optimizedimage;
}

void apply(int x, int y,SDL_Surface* Source, SDL_Surface* destination)
{
	SDL_Rect ofs;

	ofs.x = x;
	ofs.y = y;

	SDL_BlitSurface(Source, NULL, destination, &ofs);
}

int main( int argc, char* args[] )
{
 
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return 1;    
    }
    

    Screen = SDL_SetVideoMode( SWIDTH, SHEIGHT, BPP, SDL_SWSURFACE );
    

    if( Screen == NULL )
    {
        return 1;    
    }
    

    SDL_WM_SetCaption( "Hello World", NULL );
    

    message = load_image( "hello_world.bmp" );
    background = load_image( "background.bmp" );
    

    apply( 0, 0, background, Screen );
    

    apply( 180, 140, message, Screen );
    

    if( SDL_Flip( Screen ) == -1 )
    {
        return 1;    
    }
    

    SDL_Delay( 2000 );

    SDL_FreeSurface( message );
    SDL_FreeSurface( background );
    
    //Quit SDL
    SDL_Quit();
    
    return 0;    
}

it gives me these errors c:\Documents and Settings\Kevin Stowe\My Documents\Visual Studio Projects\SDL\sdl.cpp(49): error C2143: syntax error : missing ')' before '=' c:\Documents and Settings\Kevin Stowe\My Documents\Visual Studio Projects\SDL\sdl.cpp(49): error C2660: 'SDL_SetVideoMode' : function does not take 0 arguments c:\Documents and Settings\Kevin Stowe\My Documents\Visual Studio Projects\SDL\sdl.cpp(49): error C2059: syntax error : '=' c:\Documents and Settings\Kevin Stowe\My Documents\Visual Studio Projects\SDL\sdl.cpp(49): error C2059: syntax error : ')' now the problematic area its having is this Screen = SDL_SetVideoMode( SWIDTH, SHEIGHT, BPP, SDL_SWSURFACE ); i dont understand why its not reading it right..im using visual studio .net and ive compiled sdl before like on the tutorials before this one. help?

Share this post


Link to post
Share on other sites
your syntax for your #defines are wrong

#define SWIDTH = 640
should be
#define SWIDTH 640

[edit]
to elaborate
this makes the compiler read line 49 as this:
Screen = SDL_SetVideoMode( =, =, =, SDL_SWSURFACE);
So, the error is in fact referring to the second = in that line, even though it may appear like it's referring to the first (the only one you actually thought would be there)

i went through figuring the same thing out with my first attempt at using defines just the other day ;) (i also tried it with a semi-colon at the ends)
[/edit]

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