This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SDL tutorials?


On Mon, 2004-11-15 at 19:02, Eric McDonald wrote:
> Lincoln Peters wrote:
> > I've been trying to learn SDL so that I can pitch in on the SDL
> > interface, but every SDL tutorial I've found on the Internet fails to
> > compile on my computer.  And I'm fairly sure that the problem isn't my
> > computer, because I have no difficulty compiling Xconq with the SDL
> > interface, and I can't quite figure out why.
> > 
> > Any recommended websites or other sources for learning SDL?
> 
> The source code of various programs can be instructive. For example, if 
> you download the ParaGUI tarball, there are sources for the test 
> programs in the 'test' directory. Most of these are simple little apps, 
> but can give you a good feel for ParaGUI. I am sure that you can 
> probably find similar examples for pure SDL; I would try the sources of 
> some of the programs here:
>    http://www.libsdl.org/games.php

I'll look at the 'test' directory and see if I can figure out how it
works.

> 
> Also, what sort of troubles are you having wrt compiling the tutorials?

The code I've included below generates the following errors:

main.o(.text+0x6d):/home/lincoln/test/main.cpp:44: undefined reference to `SDL_SetVideoMode' 
main.o(.text+0xa8):/home/lincoln/test/main.cpp:57: undefined reference to `SDL_Quit' 
collect2: ld returned 1 exit status 

The code itself is (in C++):

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

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

//using namespace std;

//void DrawPixel(SDL_Surface *screen, int x, int y,
//                                    Uint8 R, Uint8 G, Uint8 B);
//void Slock(SDL_Surface *screen);
//void Sulock(SDL_Surface *screen);

int main( /*int argc, char *argv[] */ )
{
  if ( SDL_Init( SDL_INIT_VIDEO ) != 0 ) {
    cout << "Unable to initialize video" << endl;
    return 1;
  }

  SDL_Surface *screen;

  screen = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF );

  if ( screen == NULL ) {
    cout << "Unable to set up window" << endl;
    return 2;
  }

  // Slock( screen );

  // Nothing to do, yet.

  // Sulock( screen );

  SDL_Quit();
  return EXIT_SUCCESS;
}

[End of code]

---
Lincoln Peters
<sampln@sbcglobal.net>

Every program has (at least) two purposes:
	the one for which it was written and another for which it wasn't.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]