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;
}
}