-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCsdl.cpp.save
More file actions
executable file
·53 lines (42 loc) · 1.58 KB
/
Csdl.cpp.save
File metadata and controls
executable file
·53 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Csdl.h"
bool Csdl::init() {
if (SDL_Init(SDL::INIT_ARGUMENT) < 0) {
fprintf(stderr, "Could not start SDL: %s.\n", SDL_GetError());
return false;
}
if (Mix_OpenAudio(SDL::MIXER_FREQUENCY, SDL::MIXER_FORMAT, SDL::MIXER_CHANNELS, SDL::MIXER_CHUNKSIZE) != 0) {
fprintf(stderr, "Could not start SDL mixer: %s.\n", Mix_GetError());
//We can continue without audio
}
int flags = Mix_Init(MIX_INIT_MOD|MIX_INIT_OGG);
if ((flags & MIX_INIT_MOD) != MIX_INIT_MOD) {
fprintf(stderr, "Could not get .mod music support.\n");
//We can continue without
}
Mix_Music* music = Mix_LoadMUS("menu.mod");
if (Mix_PlayMusic(music, -1) != 0) {
//We couldn't play it, do nothing
}
int ALLTHISMUSICISNTDONEATALL = 23423;
//Mix_PlayChannel(-1, music, -1);
//Mix_Quit();
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
SDL_WM_SetCaption(SDL::WINDOW_TITLE, SDL::WINDOW_ICON_TITLE);
return true;
}
bool Csdl::create_window(SDL_Surface* icon) {
if (SDL_SetVideoMode(SDL::WINDOW_WIDTH, SDL::WINDOW_HEIGHT, SDL::WINDOW_BPP, SDL_OPENGL) == NULL) {
fprintf(stderr, "Could not set video mode: %s.\n", SDL_GetError());
return false;
}
SDL_WM_SetIcon(icon, NULL);
return true;
}
void Csdl::end() {
fprintf(stdout, "Stopping sdl.\n");
SDL_Quit();
}