I recently started opengl programming in visual c++ (VC98). Im running it on Windows 8 x64.
I just made a simple program that rotates a triangle along x, y and z axis. Actually im trying to make a 64k intro :D.
Now, I have a .xm sound file and I wanna know how to add it in my visual c++ project. Please teach me how to do this with minifmod. Im a n00b so please give me a full tutorial.
Hi.
First add the xm file as binary resource to your project and use LoadResource/LockResource to get the pointer with your XM.
(This code is not from me, I took it from the minifmod site, so credits goes to them)
typedef struct
{
int length;
int pos;
void *data;
} MEMFILE;
FMUSIC_MODULE *music_module;
FSOUND_File_SetCallbacks(memopen, memclose, memread, memseek, memtell);
music_module = FMUSIC_LoadSong("blubb", NULL);
FMUSIC_PlaySong (music_module);
unsigned int memopen(char *name) {
MEMFILE *memfile;
memfile = (MEMFILE *)malloc(sizeof(MEMFILE));
memfile->length = (int)music_size;
memfile->data = &music[0];
memfile->pos = 0;
return (unsigned int)memfile;
}
void memclose(unsigned int handle) {
MEMFILE *memfile = (MEMFILE *)handle;
free(memfile); // dont free it if it was initialized with LockResource
}
int memread(void *buffer, int size, unsigned int handle) {
MEMFILE *memfile = (MEMFILE *)handle;
if (memfile->pos + size >= memfile->length)
size = memfile->length - memfile->pos;
memcpy(buffer, (char *)memfile->data+memfile->pos, size);
memfile->pos += size;
return size;
}
void memseek(unsigned int handle, int pos, signed char mode) {
MEMFILE *memfile = (MEMFILE *)handle;
if (mode == SEEK_SET)
memfile->pos = pos;
else if (mode == SEEK_CUR)
memfile->pos += pos;
else if (mode == SEEK_END)
memfile->pos = memfile->length + pos;
if (memfile->pos > memfile->length)
memfile->pos = memfile->length;
}
int memtell(unsigned int handle) {
MEMFILE *memfile = (MEMFILE *)handle;
return memfile->pos;
}
Bye and have a nice day!