ivorium.cpp
Go to the documentation of this file.
1 #include "ivorium.hpp"
2 
6 
7 #include <ivorium_config.hpp>
8 
9 #include <FreeImage.h>
10 
11 #if IV_GLPLATFORM_GLFW
12 #include <GLFW/glfw3.h>
13 #endif
14 
15 namespace iv
16 {
17 
18 static bool l_initialized;
19 
20 #if IV_GLPLATFORM_GLFW
21 static void glfw_error_callback( int error, const char * description )
22 {
23  startup_warning( SRC_INFO, description );
24 }
25 #endif
26 
28 {
29  // initializa only once
30  if( l_initialized )
31  return;
32  l_initialized = true;
33 
34  // glfw initialization
35 #if IV_GLPLATFORM_GLFW
36  if( !glfwInit() )
37  {
38  startup_warning( SRC_INFO, "Call to glfwInit() failed." );
39  return;
40  }
41 
42  glfwSetErrorCallback( &glfw_error_callback );
43 #endif
44 
45  // freeimage initialization
46  FreeImage_Initialise();
47 
48  // StreamResourceProvider
49  StreamResourceProvider::RegisterType< DataStream_Subprovider, DataStream >();
50  StreamResourceProvider::RegisterType< StreamFont_Subprovider, Font, StreamFont >();
51  StreamResourceProvider::RegisterType< XcfInfo_Subprovider, XcfInfo >();
52  StreamResourceProvider::RegisterType< StreamTexture_Subprovider, Texture, StreamTexture >();
53 
54  // VirtualResourceProvider
55  VirtualResourceProvider::RegisterType< FlatShader_Subprovider, FlatShader >();
56  VirtualResourceProvider::RegisterType< SquareMesh_Subprovider, Mesh, SquareMesh >();
57 }
58 
60 {
61  FreeImage_DeInitialise();
62 #if IV_GLPLATFORM_GLFW
63  glfwTerminate();
64 #endif
65 
68 }
69 
70 }