33 #include <mach-o/dyld.h>
36 #if defined(_DEBUG) && defined(_WINDOWS)
37 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
43 bool user_config =
true;
50 std::cerr <<
"User-specific config file loaded from '"
54 std::cerr <<
"User-specific config file not found." << std::endl;
68 bool bilinear_filtering;
84 config.textures.anisotropy = textures[
"Anisotropy"].
to_int();
85 if(
config.textures.anisotropy < 0)
86 config.textures.anisotropy = 16;
88 config.textures.bilinear_filtering = textures[
"Bilinear_Filtering"].
to_bool();
90 config.textures.mipmapping = textures[
"Mipmapping"].
to_bool();
97 #ifndef DISABLE_GL_FIXED
98 if(api ==
"OpenGL Fixed" || api ==
"OpenGL")
102 #ifndef DISABLE_GL_SHADER
103 if(api ==
"OpenGL Shader")
108 if(api ==
"Direct3D 9" || api ==
"DX9")
116 if(api ==
"Disabled")
123 config.video.multisampling = video[
"Multisampling"].
to_int();
124 if(
config.video.multisampling < 0)
125 config.video.multisampling = 16;
130 config.video.screen_resolution.x = screen_resolution[
"Width"].
to_int();
131 config.video.screen_resolution.y = screen_resolution[
"Height"].
to_int();
134 config.video.vertical_sync = video[
"Vertical_Sync"].
to_bool();
148 config.textures.bilinear_filtering,
149 config.textures.mipmapping);
156 #include <SDL/SDL_net.h>
160 std::cerr <<
"Printing all possible error strings:" << std::endl;
173 inline int main2(
const int argc,
const char *
const *
const argv) {
174 std::srand(static_cast<unsigned int>(std::time(0)));
224 std::cerr <<
"Exiting normally." << std::endl;
228 #pragma warning( push )
229 #pragma warning( disable : 4130 )
232 std::cerr << error.
msg << std::endl;
240 catch(std::exception &except) {
241 std::cerr << except.what() << std::endl;
246 if(strcmp(except.what(),
"std::exception"))
253 std::cerr <<
"Unknown Error (Neither Zeni::Error nor std::exception)";
262 #pragma warning( pop )
272 if(path[length] ==
'/') {
273 path[length + 1] =
'\0';
281 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
283 if(_chdir(
"..\\..\\assets")) {
284 std::cerr <<
"Setting working directory failed with error code ':" << GetLastError() <<
"'\n";
288 if(!SetDllDirectory(
"bin\\x64")) {
290 if(!SetDllDirectory(
"bin\\x32")) {
292 std::cerr <<
"Setting DLL directory failed with error code ':" << GetLastError() <<
"'\n";
297 char application_path[FILENAME_MAX];
299 int length = readlink(
"/proc/self/exe", application_path, FILENAME_MAX);
303 if(_NSGetExecutablePath(application_path, &size)) {
304 std::cerr <<
"Loading working directory failed.\n";
307 int length =
int(strlen(application_path));
309 for(
int i = 0;
i != 2; ++
i)
312 memcpy(application_path + length,
"/assets", 8);
313 if(chdir(application_path)) {
314 std::cerr <<
"chdir: " << application_path <<
'\n';
315 std::cerr <<
"Setting working directory failed with error code: '" << errno <<
"'\n";
316 std::cerr << strerror(errno) <<
'\n';
322 return main2(argc, argv);
String to_string() const
Get the contained string.
static void preinit_show_frame(const bool &show_frame_=true)
Show a frame around the rendering window when in windowed mode.
static const bool & is_enabled()
Determine whether the use of rendering is desired.
bool try_load(const String &filename)
DECLSPEC const char *SDLCALL SDL_GetError(void)
static void preinit_full_screen(const bool &full_screen=false)
Set the rendering window to be full screen at launch.
GLsizei const GLchar *const * path
Game & get_Game()
Get access to the singleton.
static void completely_destroy()
bool to_bool() const
Get the contained string as a boolean.
static void preinit_resolution(const Point2i &resolution=Point2i(800, 600))
Set the rendering window to have a given resolution.
static void preinit_multisampling(const int &multisampling=0)
Set a multisampling value.
static void set_enabled(const bool &enabled)
Enable/Disable the use of rendering; This will not close the rendering window once it is open...
void push_state(const Gamestate &state)
Push a new Gamestate onto the stack.
static String errorString()
static bool load_config()
A class to open an XML file and manage the root node.
Gamestate_Zero_Initializer * g_gzi
void message_box(const char *const &msg)
static void preinit_vertical_sync(const bool &vertical_sync=false)
Set vertical_sync to true.
A class to signal that the program is quitting.
static void preinit(const String &unique_app_identifier)
const char *const * g_argv
String get_appdata_path()
Get the path that should be used for user-modifiable storage.
static void up_one_dir(char path[], int &length)
GLsizei const GLuint * textures
static void set_texturing_mode(const int &anisotropic_filtering_, const bool &bilinear_filtering_, const bool &mipmapping_)
Check to see if Textures is set to use lazy loading if possible.
std::string std_str() const
int main2(const int argc, const char *const *const argv)
int to_int() const
Get the contained string as an integer.
static void print_errors()
int zenilib_main(int argc, char **argv)
Video & get_Video()
Get access to the singleton.
static void preinit_video_mode(const VIDEO_MODE &vm=ZENI_VIDEO_ANY)
Set which rendering engine to use.
File_Ops & get_File_Ops()
Get access to the singleton.
DECLSPEC const char *SDLCALL SDLNet_GetError(void)
static void print_errors()
Print any errors that may have occurred.
A 2D Point represented with integers.