goat3dgfx

changeset 5:18879c956eb1

- skycube example - added fatal_log - changed the dataset to keep the whole path while searching for data files
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 17 Nov 2013 03:22:40 +0200
parents ae47239c8c0d
children 3d96734fd477
files examples/cubemap/cubemap.vcproj examples/cubemap/sdr/sky.p.glsl examples/cubemap/sdr/sky.v.glsl examples/cubemap/src/main.cc examples/examples-debug.vsprop examples/examples.vsprop goat3dgfx.sln goat3dgfx.vcproj src/dataset.inl src/logger.cc src/logger.h
diffstat 11 files changed, 460 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/cubemap/cubemap.vcproj	Sun Nov 17 03:22:40 2013 +0200
     1.3 @@ -0,0 +1,200 @@
     1.4 +<?xml version="1.0" encoding="Windows-1252"?>
     1.5 +<VisualStudioProject
     1.6 +	ProjectType="Visual C++"
     1.7 +	Version="9.00"
     1.8 +	Name="cubemap"
     1.9 +	ProjectGUID="{21606BDB-5E01-45F3-9431-D5F4AF5F2CC0}"
    1.10 +	RootNamespace="cubemap"
    1.11 +	Keyword="Win32Proj"
    1.12 +	TargetFrameworkVersion="196613"
    1.13 +	>
    1.14 +	<Platforms>
    1.15 +		<Platform
    1.16 +			Name="Win32"
    1.17 +		/>
    1.18 +	</Platforms>
    1.19 +	<ToolFiles>
    1.20 +	</ToolFiles>
    1.21 +	<Configurations>
    1.22 +		<Configuration
    1.23 +			Name="Debug|Win32"
    1.24 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
    1.25 +			IntermediateDirectory="$(ConfigurationName)"
    1.26 +			ConfigurationType="1"
    1.27 +			InheritedPropertySheets="..\examples-debug.vsprop"
    1.28 +			CharacterSet="1"
    1.29 +			>
    1.30 +			<Tool
    1.31 +				Name="VCPreBuildEventTool"
    1.32 +			/>
    1.33 +			<Tool
    1.34 +				Name="VCCustomBuildTool"
    1.35 +			/>
    1.36 +			<Tool
    1.37 +				Name="VCXMLDataGeneratorTool"
    1.38 +			/>
    1.39 +			<Tool
    1.40 +				Name="VCWebServiceProxyGeneratorTool"
    1.41 +			/>
    1.42 +			<Tool
    1.43 +				Name="VCMIDLTool"
    1.44 +			/>
    1.45 +			<Tool
    1.46 +				Name="VCCLCompilerTool"
    1.47 +				Optimization="0"
    1.48 +				AdditionalIncludeDirectories=""
    1.49 +				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
    1.50 +				MinimalRebuild="true"
    1.51 +				BasicRuntimeChecks="3"
    1.52 +				RuntimeLibrary="3"
    1.53 +				UsePrecompiledHeader="0"
    1.54 +				WarningLevel="3"
    1.55 +				DebugInformationFormat="4"
    1.56 +			/>
    1.57 +			<Tool
    1.58 +				Name="VCManagedResourceCompilerTool"
    1.59 +			/>
    1.60 +			<Tool
    1.61 +				Name="VCResourceCompilerTool"
    1.62 +			/>
    1.63 +			<Tool
    1.64 +				Name="VCPreLinkEventTool"
    1.65 +			/>
    1.66 +			<Tool
    1.67 +				Name="VCLinkerTool"
    1.68 +				LinkIncremental="2"
    1.69 +				AdditionalLibraryDirectories=""
    1.70 +				GenerateDebugInformation="true"
    1.71 +				SubSystem="1"
    1.72 +				TargetMachine="1"
    1.73 +			/>
    1.74 +			<Tool
    1.75 +				Name="VCALinkTool"
    1.76 +			/>
    1.77 +			<Tool
    1.78 +				Name="VCManifestTool"
    1.79 +			/>
    1.80 +			<Tool
    1.81 +				Name="VCXDCMakeTool"
    1.82 +			/>
    1.83 +			<Tool
    1.84 +				Name="VCBscMakeTool"
    1.85 +			/>
    1.86 +			<Tool
    1.87 +				Name="VCFxCopTool"
    1.88 +			/>
    1.89 +			<Tool
    1.90 +				Name="VCAppVerifierTool"
    1.91 +			/>
    1.92 +			<Tool
    1.93 +				Name="VCPostBuildEventTool"
    1.94 +			/>
    1.95 +		</Configuration>
    1.96 +		<Configuration
    1.97 +			Name="Release|Win32"
    1.98 +			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
    1.99 +			IntermediateDirectory="$(ConfigurationName)"
   1.100 +			ConfigurationType="1"
   1.101 +			InheritedPropertySheets="$(SolutionDir)\examples\examples.vsprop"
   1.102 +			CharacterSet="1"
   1.103 +			WholeProgramOptimization="1"
   1.104 +			>
   1.105 +			<Tool
   1.106 +				Name="VCPreBuildEventTool"
   1.107 +			/>
   1.108 +			<Tool
   1.109 +				Name="VCCustomBuildTool"
   1.110 +			/>
   1.111 +			<Tool
   1.112 +				Name="VCXMLDataGeneratorTool"
   1.113 +			/>
   1.114 +			<Tool
   1.115 +				Name="VCWebServiceProxyGeneratorTool"
   1.116 +			/>
   1.117 +			<Tool
   1.118 +				Name="VCMIDLTool"
   1.119 +			/>
   1.120 +			<Tool
   1.121 +				Name="VCCLCompilerTool"
   1.122 +				Optimization="2"
   1.123 +				EnableIntrinsicFunctions="true"
   1.124 +				AdditionalIncludeDirectories=""
   1.125 +				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
   1.126 +				RuntimeLibrary="2"
   1.127 +				EnableFunctionLevelLinking="true"
   1.128 +				UsePrecompiledHeader="0"
   1.129 +				WarningLevel="3"
   1.130 +				DebugInformationFormat="3"
   1.131 +			/>
   1.132 +			<Tool
   1.133 +				Name="VCManagedResourceCompilerTool"
   1.134 +			/>
   1.135 +			<Tool
   1.136 +				Name="VCResourceCompilerTool"
   1.137 +			/>
   1.138 +			<Tool
   1.139 +				Name="VCPreLinkEventTool"
   1.140 +			/>
   1.141 +			<Tool
   1.142 +				Name="VCLinkerTool"
   1.143 +				AdditionalDependencies="goat3dgfx.lib"
   1.144 +				LinkIncremental="1"
   1.145 +				AdditionalLibraryDirectories=""
   1.146 +				GenerateDebugInformation="true"
   1.147 +				SubSystem="1"
   1.148 +				OptimizeReferences="2"
   1.149 +				EnableCOMDATFolding="2"
   1.150 +				TargetMachine="1"
   1.151 +			/>
   1.152 +			<Tool
   1.153 +				Name="VCALinkTool"
   1.154 +			/>
   1.155 +			<Tool
   1.156 +				Name="VCManifestTool"
   1.157 +			/>
   1.158 +			<Tool
   1.159 +				Name="VCXDCMakeTool"
   1.160 +			/>
   1.161 +			<Tool
   1.162 +				Name="VCBscMakeTool"
   1.163 +			/>
   1.164 +			<Tool
   1.165 +				Name="VCFxCopTool"
   1.166 +			/>
   1.167 +			<Tool
   1.168 +				Name="VCAppVerifierTool"
   1.169 +			/>
   1.170 +			<Tool
   1.171 +				Name="VCPostBuildEventTool"
   1.172 +			/>
   1.173 +		</Configuration>
   1.174 +	</Configurations>
   1.175 +	<References>
   1.176 +	</References>
   1.177 +	<Files>
   1.178 +		<Filter
   1.179 +			Name="src"
   1.180 +			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
   1.181 +			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
   1.182 +			>
   1.183 +			<File
   1.184 +				RelativePath=".\src\main.cc"
   1.185 +				>
   1.186 +			</File>
   1.187 +		</Filter>
   1.188 +		<Filter
   1.189 +			Name="sdr"
   1.190 +			>
   1.191 +			<File
   1.192 +				RelativePath=".\sdr\sky.p.glsl"
   1.193 +				>
   1.194 +			</File>
   1.195 +			<File
   1.196 +				RelativePath=".\sdr\sky.v.glsl"
   1.197 +				>
   1.198 +			</File>
   1.199 +		</Filter>
   1.200 +	</Files>
   1.201 +	<Globals>
   1.202 +	</Globals>
   1.203 +</VisualStudioProject>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/examples/cubemap/sdr/sky.p.glsl	Sun Nov 17 03:22:40 2013 +0200
     2.3 @@ -0,0 +1,8 @@
     2.4 +uniform samplerCube cubemap;
     2.5 +
     2.6 +varying vec3 norm;
     2.7 +
     2.8 +void main()
     2.9 +{
    2.10 +	gl_FragColor = textureCube(cubemap, norm);
    2.11 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/examples/cubemap/sdr/sky.v.glsl	Sun Nov 17 03:22:40 2013 +0200
     3.3 @@ -0,0 +1,7 @@
     3.4 +varying vec3 norm;
     3.5 +
     3.6 +void main()
     3.7 +{
     3.8 +	gl_Position = ftransform();
     3.9 +	norm = gl_NormalMatrix * gl_Normal;
    3.10 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/examples/cubemap/src/main.cc	Sun Nov 17 03:22:40 2013 +0200
     4.3 @@ -0,0 +1,192 @@
     4.4 +#include <stdio.h>
     4.5 +#include <stdlib.h>
     4.6 +#include <algorithm>
     4.7 +#include <goat3dgfx/goat3dgfx.h>
     4.8 +#include <vmath/vmath.h>
     4.9 +
    4.10 +#define CUBEMAP_FILENAME	"data/cubemap3.jpg"
    4.11 +
    4.12 +static bool init();
    4.13 +static void cleanup();
    4.14 +static void display();
    4.15 +static void skybox(const TextureCube *cubemap = 0);
    4.16 +static void reshape(int x, int y);
    4.17 +static void keyboard(unsigned char key, int x, int y);
    4.18 +static void mouse(int bn, int st, int x, int y);
    4.19 +static void motion(int x, int y);
    4.20 +
    4.21 +static float cam_theta, cam_phi;
    4.22 +
    4.23 +static TextureCube *cubemap;
    4.24 +static ShaderProg *sdrsky;
    4.25 +
    4.26 +int main(int argc, char **argv)
    4.27 +{
    4.28 +	glutInit(&argc, argv);
    4.29 +	glutInitWindowSize(800, 600);
    4.30 +	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    4.31 +	glutCreateWindow("cubemap");
    4.32 +
    4.33 +	glutDisplayFunc(display);
    4.34 +	glutReshapeFunc(reshape);
    4.35 +	glutKeyboardFunc(keyboard);
    4.36 +	glutMouseFunc(mouse);
    4.37 +	glutMotionFunc(motion);
    4.38 +
    4.39 +	if(!init()) {
    4.40 +		return 1;
    4.41 +	}
    4.42 +	atexit(cleanup);
    4.43 +
    4.44 +	glutMainLoop();
    4.45 +	return 0;
    4.46 +}
    4.47 +
    4.48 +static bool init()
    4.49 +{
    4.50 +	glewInit();
    4.51 +
    4.52 +	glEnable(GL_DEPTH_TEST);
    4.53 +	//glEnable(GL_CULL_FACE);
    4.54 +
    4.55 +	cubemap = new TextureCube;
    4.56 +	if(!cubemap->load(CUBEMAP_FILENAME)) {
    4.57 +		fatal_log("Failed to load cubemap: %s\n", CUBEMAP_FILENAME);
    4.58 +		return false;
    4.59 +	}
    4.60 +
    4.61 +	if(!(sdrsky = get_sdrprog("sdr/sky.v.glsl", "sdr/sky.p.glsl"))) {
    4.62 +		fatal_log("failed to load skybox shader\n");
    4.63 +		return false;
    4.64 +	}
    4.65 +
    4.66 +	return true;
    4.67 +}
    4.68 +
    4.69 +static void cleanup()
    4.70 +{
    4.71 +	delete cubemap;
    4.72 +}
    4.73 +
    4.74 +static void display()
    4.75 +{
    4.76 +	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    4.77 +
    4.78 +	Matrix4x4 view_matrix;
    4.79 +	view_matrix.rotate(Vector3(1, 0, 0), M_PI * cam_phi / 180.0);
    4.80 +	view_matrix.rotate(Vector3(0, 1, 0), M_PI * cam_theta / 180.0);
    4.81 +	set_view_matrix(view_matrix);
    4.82 +
    4.83 +	setup_gl_matrices();
    4.84 +
    4.85 +	skybox();
    4.86 +
    4.87 +	/*glBegin(GL_QUADS);
    4.88 +	glColor3f(1, 1, 1);
    4.89 +	glNormal3f(0, 1, 0);
    4.90 +	glVertex3f(-0.8, -1, 0.8);
    4.91 +	glVertex3f(0.8, -1, 0.8);
    4.92 +	glVertex3f(0.8, -1, -0.8);
    4.93 +	glVertex3f(-0.8, -1, -0.8);
    4.94 +	glEnd();*/
    4.95 +
    4.96 +	glutSwapBuffers();
    4.97 +	CHECKGLERR;
    4.98 +}
    4.99 +
   4.100 +static void skybox(const TextureCube *cubemap)
   4.101 +{
   4.102 +	glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT);
   4.103 +	glDisable(GL_DEPTH_TEST);
   4.104 +	glDisable(GL_CULL_FACE);
   4.105 +	glDisable(GL_LIGHTING);
   4.106 +
   4.107 +	if(cubemap) cubemap->bind();
   4.108 +	sdrsky->bind();
   4.109 +
   4.110 +	glBegin(GL_QUADS);
   4.111 +	// +X
   4.112 +	glColor3f(1, 0, 0);
   4.113 +	glVertex3f(1, -1, 1);
   4.114 +	glVertex3f(1, -1, -1);
   4.115 +	glVertex3f(1, 1, -1);
   4.116 +	glVertex3f(1, 1, 1);
   4.117 +	// -Z
   4.118 +	glColor3f(0, 1, 0);
   4.119 +	glVertex3f(1, -1, -1);
   4.120 +	glVertex3f(-1, -1, -1);
   4.121 +	glVertex3f(-1, 1, -1);
   4.122 +	glVertex3f(1, 1, -1);
   4.123 +	// -X
   4.124 +	glColor3f(0, 0, 1);
   4.125 +	glVertex3f(-1, -1, -1);
   4.126 +	glVertex3f(-1, -1, 1);
   4.127 +	glVertex3f(-1, 1, 1);
   4.128 +	glVertex3f(-1, 1, -1);
   4.129 +	// +Z
   4.130 +	glColor3f(1, 1, 0);
   4.131 +	glVertex3f(-1, -1, 1);
   4.132 +	glVertex3f(1, -1, 1);
   4.133 +	glVertex3f(1, 1, 1);
   4.134 +	glVertex3f(-1, 1, 1);
   4.135 +	// +Y
   4.136 +	glColor3f(0, 1, 1);
   4.137 +	glVertex3f(-1, 1, 1);
   4.138 +	glVertex3f(1, 1, 1);
   4.139 +	glVertex3f(1, 1, -1);
   4.140 +	glVertex3f(-1, 1, -1);
   4.141 +	// -Y
   4.142 +	glColor3f(1, 0, 1);
   4.143 +	glVertex3f(-1, -1, -1);
   4.144 +	glVertex3f(1, -1, -1);
   4.145 +	glVertex3f(1, -1, 1);
   4.146 +	glVertex3f(-1, -1, 1);
   4.147 +	glEnd();
   4.148 +
   4.149 +	glUseProgram(0);
   4.150 +	glPopAttrib();
   4.151 +}
   4.152 +
   4.153 +static void reshape(int x, int y)
   4.154 +{
   4.155 +	glViewport(0, 0, x, y);
   4.156 +
   4.157 +	Matrix4x4 proj;
   4.158 +	proj.set_perspective(M_PI / 4.0, (float)x / (float)y, 0.5, 500.0);
   4.159 +	set_projection_matrix(proj);
   4.160 +}
   4.161 +
   4.162 +static void keyboard(unsigned char key, int x, int y)
   4.163 +{
   4.164 +	switch(key) {
   4.165 +	case 27:
   4.166 +		exit(0);
   4.167 +	}
   4.168 +}
   4.169 +
   4.170 +static bool bnstate[16];
   4.171 +static int prev_x, prev_y;
   4.172 +
   4.173 +static void mouse(int bn, int st, int x, int y)
   4.174 +{
   4.175 +	bnstate[bn - GLUT_LEFT_BUTTON] = st == GLUT_DOWN;
   4.176 +	prev_x = x;
   4.177 +	prev_y = y;
   4.178 +}
   4.179 +
   4.180 +static void motion(int x, int y)
   4.181 +{
   4.182 +	int dx = x - prev_x;
   4.183 +	int dy = y - prev_y;
   4.184 +	prev_x = x;
   4.185 +	prev_y = y;
   4.186 +
   4.187 +	if(!dx && !dy) return;
   4.188 +
   4.189 +	if(bnstate[0]) {
   4.190 +		cam_theta += dx * 0.5;
   4.191 +		cam_phi += dy * 0.5;
   4.192 +		cam_phi = std::max(-90.0f, std::min(90.0f, cam_phi));
   4.193 +		glutPostRedisplay();
   4.194 +	}
   4.195 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/examples/examples-debug.vsprop	Sun Nov 17 03:22:40 2013 +0200
     5.3 @@ -0,0 +1,7 @@
     5.4 +<?xml version="1.0"?>
     5.5 +<VisualStudioPropertySheet 
     5.6 +	ProjectType="Visual C++" 
     5.7 +	Version="8.00" 
     5.8 +	Name="examples-debug"
     5.9 +	>
    5.10 +</VisualStudioPropertySheet>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/examples/examples.vsprop	Sun Nov 17 03:22:40 2013 +0200
     6.3 @@ -0,0 +1,7 @@
     6.4 +<?xml version="1.0"?>
     6.5 +<VisualStudioPropertySheet 
     6.6 +	ProjectType="Visual C++" 
     6.7 +	Version="8.00" 
     6.8 +	Name="examples"
     6.9 +	>
    6.10 +</VisualStudioPropertySheet>
     7.1 --- a/goat3dgfx.sln	Sat Nov 16 21:09:42 2013 +0200
     7.2 +++ b/goat3dgfx.sln	Sun Nov 17 03:22:40 2013 +0200
     7.3 @@ -3,6 +3,11 @@
     7.4  # Visual Studio 2008
     7.5  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "goat3dgfx", "goat3dgfx.vcproj", "{251F8AFF-5A37-4F10-A519-C55C40E127AF}"
     7.6  EndProject
     7.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubemap", "examples\cubemap\cubemap.vcproj", "{21606BDB-5E01-45F3-9431-D5F4AF5F2CC0}"
     7.8 +	ProjectSection(ProjectDependencies) = postProject
     7.9 +		{251F8AFF-5A37-4F10-A519-C55C40E127AF} = {251F8AFF-5A37-4F10-A519-C55C40E127AF}
    7.10 +	EndProjectSection
    7.11 +EndProject
    7.12  Global
    7.13  	GlobalSection(SolutionConfigurationPlatforms) = preSolution
    7.14  		Debug|Win32 = Debug|Win32
    7.15 @@ -13,6 +18,10 @@
    7.16  		{251F8AFF-5A37-4F10-A519-C55C40E127AF}.Debug|Win32.Build.0 = Debug|Win32
    7.17  		{251F8AFF-5A37-4F10-A519-C55C40E127AF}.Release|Win32.ActiveCfg = Release|Win32
    7.18  		{251F8AFF-5A37-4F10-A519-C55C40E127AF}.Release|Win32.Build.0 = Release|Win32
    7.19 +		{21606BDB-5E01-45F3-9431-D5F4AF5F2CC0}.Debug|Win32.ActiveCfg = Debug|Win32
    7.20 +		{21606BDB-5E01-45F3-9431-D5F4AF5F2CC0}.Debug|Win32.Build.0 = Debug|Win32
    7.21 +		{21606BDB-5E01-45F3-9431-D5F4AF5F2CC0}.Release|Win32.ActiveCfg = Release|Win32
    7.22 +		{21606BDB-5E01-45F3-9431-D5F4AF5F2CC0}.Release|Win32.Build.0 = Release|Win32
    7.23  	EndGlobalSection
    7.24  	GlobalSection(SolutionProperties) = preSolution
    7.25  		HideSolutionNode = FALSE
     8.1 --- a/goat3dgfx.vcproj	Sat Nov 16 21:09:42 2013 +0200
     8.2 +++ b/goat3dgfx.vcproj	Sun Nov 17 03:22:40 2013 +0200
     8.3 @@ -21,7 +21,7 @@
     8.4  			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
     8.5  			IntermediateDirectory="$(ConfigurationName)"
     8.6  			ConfigurationType="4"
     8.7 -			CharacterSet="1"
     8.8 +			CharacterSet="2"
     8.9  			>
    8.10  			<Tool
    8.11  				Name="VCPreBuildEventTool"
    8.12 @@ -61,6 +61,7 @@
    8.13  			/>
    8.14  			<Tool
    8.15  				Name="VCLibrarianTool"
    8.16 +				OutputFile="$(OutDir)\$(ProjectName)-dbg.lib"
    8.17  			/>
    8.18  			<Tool
    8.19  				Name="VCALinkTool"
    8.20 @@ -76,6 +77,7 @@
    8.21  			/>
    8.22  			<Tool
    8.23  				Name="VCPostBuildEventTool"
    8.24 +				CommandLine="mkdir usr\include\goat3dgfx&#x0D;&#x0A;mkdir usr\lib&#x0D;&#x0A;copy /Y src\*.h usr\include\goat3dgfx\&#x0D;&#x0A;copy /Y src\*.inl usr\include\goat3dgfx\&#x0D;&#x0A;copy /Y $(TargetPath) usr\lib\"
    8.25  			/>
    8.26  		</Configuration>
    8.27  		<Configuration
    8.28 @@ -84,7 +86,7 @@
    8.29  			IntermediateDirectory="$(ConfigurationName)"
    8.30  			ConfigurationType="4"
    8.31  			InheritedPropertySheets=".\goat3dgfx.vsprops"
    8.32 -			CharacterSet="1"
    8.33 +			CharacterSet="2"
    8.34  			WholeProgramOptimization="1"
    8.35  			>
    8.36  			<Tool
     9.1 --- a/src/dataset.inl	Sat Nov 16 21:09:42 2013 +0200
     9.2 +++ b/src/dataset.inl	Sun Nov 17 03:22:40 2013 +0200
     9.3 @@ -35,14 +35,7 @@
     9.4  		return iter->second;
     9.5  	}
     9.6  
     9.7 -	const char *fname, *slash;
     9.8 -	if((slash = strrchr(name, '/'))) {
     9.9 -		fname = slash + 1;
    9.10 -	} else {
    9.11 -		fname = name;
    9.12 -	}
    9.13 -
    9.14 -	std::string path = datafile_path(fname);
    9.15 +	std::string path = datafile_path(name);
    9.16  	if(path.empty()) {
    9.17  		fprintf(stderr, "can't find data file: %s\n", name);
    9.18  		return 0;
    10.1 --- a/src/logger.cc	Sat Nov 16 21:09:42 2013 +0200
    10.2 +++ b/src/logger.cc	Sun Nov 17 03:22:40 2013 +0200
    10.3 @@ -4,9 +4,11 @@
    10.4  
    10.5  #if defined(unix) || defined(__unix__) || defined(__APPLE__)
    10.6  #include <unistd.h>
    10.7 +#elif defined(WIN32)
    10.8 +#include <windows.h>
    10.9  #endif
   10.10  
   10.11 -enum { LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG };
   10.12 +enum { LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL, LOG_DEBUG };
   10.13  
   10.14  static int typecolor(int type);
   10.15  
   10.16 @@ -25,9 +27,18 @@
   10.17  	{
   10.18  		vfprintf(fp, fmt, ap);
   10.19  	}
   10.20 -	if(type == LOG_ERROR || type == LOG_DEBUG) {
   10.21 +	if(type == LOG_ERROR || type == LOG_FATAL || type == LOG_DEBUG) {
   10.22  		fflush(fp);
   10.23  	}
   10.24 +
   10.25 +#ifdef WIN32
   10.26 +	if(type == LOG_FATAL) {
   10.27 +		static char msgbuf[1024];
   10.28 +		vsnprintf(msgbuf, sizeof msgbuf - 1, fmt, ap);
   10.29 +		msgbuf[sizeof msgbuf - 1] = 0;
   10.30 +		MessageBox(0, msgbuf, "Fatal error", MB_OK | MB_ICONSTOP);
   10.31 +	}
   10.32 +#endif
   10.33  }
   10.34  
   10.35  void info_log(const char *fmt, ...)
   10.36 @@ -57,6 +68,15 @@
   10.37  	va_end(ap);
   10.38  }
   10.39  
   10.40 +void fatal_log(const char *fmt, ...)
   10.41 +{
   10.42 +	va_list ap;
   10.43 +
   10.44 +	va_start(ap, fmt);
   10.45 +	logmsg(LOG_FATAL, fmt, ap);
   10.46 +	va_end(ap);
   10.47 +}
   10.48 +
   10.49  void debug_log(const char *fmt, ...)
   10.50  {
   10.51  	va_list ap;
   10.52 @@ -85,6 +105,8 @@
   10.53  	switch(type) {
   10.54  	case LOG_ERROR:
   10.55  		return ANSI_FGCOLOR(RED);
   10.56 +	case LOG_FATAL:
   10.57 +		return ANSI_FGCOLOR(RED);	// TODO differentiate from LOG_ERROR
   10.58  	case LOG_WARNING:
   10.59  		return ANSI_FGCOLOR(YELLOW);
   10.60  	case LOG_DEBUG:
    11.1 --- a/src/logger.h	Sat Nov 16 21:09:42 2013 +0200
    11.2 +++ b/src/logger.h	Sun Nov 17 03:22:40 2013 +0200
    11.3 @@ -4,6 +4,7 @@
    11.4  void info_log(const char *fmt, ...);
    11.5  void warning_log(const char *fmt, ...);
    11.6  void error_log(const char *fmt, ...);
    11.7 +void fatal_log(const char *fmt, ...);
    11.8  void debug_log(const char *fmt, ...);
    11.9  
   11.10  #endif	// LOGGER_H_