[SDL] Problems using Video and CDROM together...

Sebastien Dieu dieu.j.sebastien at gmail.com
Thu Aug 23 01:26:20 PDT 2007


Hi,

I think that there is something wrong with your library initialzation code:
you use a logical OR instead of a binary one...

try using SDL_Init(SDL_INIT_VIDEO | SDL_INIT_CDROM); instead, and it should
works fine.

---------- Message transféré ----------
> From: "Matthew Johnson" <levifiction at gmail.com>
> To: "A list for developers using the SDL library. (includes SDL-announce)"
> <sdl at lists.libsdl.org>
> Date: Wed, 22 Aug 2007 23:46:51 -0500
> Subject: [SDL] Problems using Video and CDROM together...
> Well I gave up and started working on learning C++ again but this time
> in conjunction with SDL.  I was experimenting with the CD functions
> when I encountered a strange problem and I'm not sure why this
> happens.
>
> If I initialize the CD subsystem, only, the use of SDL_CDNumDrives()
> gives me 1 drive.  SDL_CDName(0); gets me E:\ as is expected.  It even
> opens the CD with SDL_CDOpen as expected allowing me access to the
> status and all of that.
>
> However if I also initialize the video subsystem
>
> SDL_Init(SDL_INIT_VIDEO||SDL_INIT_CDROM);
>
> the use of SDL_CDNumDrives() returns a -1 and SDL_CDOpen(0) causes an
> error that forces the program to shut down.  And so far only when I
> activate the video subsystem does this occur. When I use
> SDL_INIT_EVERYTHING it works fine.  So obviously I'm not in a bind
> here.  However I am curious as to why this would be.  If it's
> something with SDL or the way I've been doing things.
>
> All code displayed here is as is in my program.  But for the sake of
> not being asked to show it here's the complete code.
>
> #include "sdl.h"
> #include <stdlib.h>
>
> SDL_Event mainEvent;
> SDL_Surface* mainScreen= NULL;
> SDL_CD* cdToPlay;
>
>
> int main(int argc, char* argv[])
> {
>
>    SDL_Init(SDL_INIT_VIDEO||SDL_INIT_CD);
>    atexit(SDL_Quit);
>
>    mainScreen = SDL_SetVideoMode(640,480,0,SDL_ANYFORMAT);
>
>    fprintf(stdout, "Number of drives: %d \n", SDL_CDNumDrives());
>    for(int CDIndex = 0; CDIndex < SDL_CDNumDrives(); CDIndex++)
>    {
>       fprintf(stdout, "The name of Drive # %d is %s \n", CDIndex,
> SDL_CDName(CDIndex));
>    }
>
>    for(;;)
>    {
>       SDL_WaitEvent(&mainEvent);
>
>       if(mainEvent.type == SDL_KEYDOWN)
>          break;
>
>       if(mainEvent.type == SDL_QUIT)
>          break;
>    }
>
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070823/d4ef2f27/attachment.html 


More information about the SDL mailing list