diff --git a/.gitignore b/.gitignore index 01f424f..25c9fff 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ *pack *core *screenshot.png +*VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 8a9ecc2..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.1 \ No newline at end of file diff --git a/bin/Makefile b/bin/Makefile index 253fe40..5c23df1 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -35,7 +35,7 @@ LDFLAGS += -pg endif DATA = data -DATAFILES = ../$(VERSIONFILE) $(shell find ../scripts/ ../gfx/ ../dat/ -name '*.lua' -o -name '*.png' -o -name '*.xml' -o -name '*.ttf') +DATAFILES = $(VERSIONFILE) $(shell find ../scripts/ ../gfx/ ../dat/ -name '*.lua' -o -name '*.png' -o -name '*.xml' -o -name '*.ttf') %.o: %.c %.h @gcc -c $(CFLAGS) -o $@ $< @@ -54,11 +54,11 @@ pack: ../src/pack.c ../utils/pack/main.c mksprite: ../utils/mkspr/main.c @(cd ../utils/mkspr; $(MAKE)) -../$(VERSIONFILE): - @echo -n "$(VMAJOR).$(VMINOR).$(VREV)" > ../$(VERSIONFILE) +$(VERSIONFILE): + @echo -n "$(VMAJOR).$(VMINOR).$(VREV)" > $(VERSIONFILE) data: pack $(DATAFILES) ../src/pack.c ../utils/pack/main.c - @echo -n "$(VMAJOR).$(VMINOR).$(VREV)" > ../$(VERSIONFILE) + @echo -n "$(VMAJOR).$(VMINOR).$(VREV)" > $(VERSIONFILE) @echo -e "\tCreating data..\n" @./pack $(DATA) $(DATAFILES) diff --git a/bin/conf b/bin/conf index f854873..6f963b4 100644 --- a/bin/conf +++ b/bin/conf @@ -1,6 +1,6 @@ --WINDOW. -width = 800 -height = 640 +width = 1024 +height = 768 fullscreen = 0 -- SCREEN. @@ -29,12 +29,12 @@ target_nearest = { type = "jbutton", key = 3 } face = { type = "keyboard", key = 38 } board = { type = "keyboard", key = 57 } secondary = { type = "jbutton", key = 7 } -secondary_next = { type = "jbutotn", key = 5 } +secondary_next = { type = "jbutton", key = 5 } -- Space. -- Gui. mapzoomin = { type = "jbutton", key = 4 } -mapzoomout = { type = "jbuton", key = 6 } +mapzoomout = { type = "jbutton", key = 6 } screenshot = { type = "keyboard", key = 82 } diff --git a/bin/conf.example b/bin/conf.example index f854873..c5cc3b0 100644 --- a/bin/conf.example +++ b/bin/conf.example @@ -29,12 +29,12 @@ target_nearest = { type = "jbutton", key = 3 } face = { type = "keyboard", key = 38 } board = { type = "keyboard", key = 57 } secondary = { type = "jbutton", key = 7 } -secondary_next = { type = "jbutotn", key = 5 } +secondary_next = { type = "jbutton", key = 5 } -- Space. -- Gui. mapzoomin = { type = "jbutton", key = 4 } -mapzoomout = { type = "jbuton", key = 6 } +mapzoomout = { type = "jbutton", key = 6 } screenshot = { type = "keyboard", key = 82 } diff --git a/src/opengl.c b/src/opengl.c index 0461649..c157e7f 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -422,7 +422,7 @@ void gl_bindCamera(const Vec2* pos) { // Initialize SDL/OpenGL etc. int gl_init(void) { - int doublebuf, depth, i, supported = 0; + int doublebuf, depth, i, j, off, toff, supported = 0; SDL_Rect** modes; int flags = SDL_OPENGL; flags |= SDL_FULLSCREEN * (gl_has(OPENGL_FULLSCREEN) ? 1: 0); @@ -447,7 +447,7 @@ int gl_init(void) { DEBUG("All fullscreen modes available"); else { DEBUG("Available fullscreen modes:"); - for(i = 0; modes[i]; ++i) { + for(i = 0; modes[i]; i++) { DEBUG("\t%dx%d", modes[i]->w, modes[i]->h); if((flags & SDL_FULLSCREEN) && (modes[i]->w == gl_screen.w) && (modes[i]->h == gl_screen.h)) supported = 1; // Mode we asked for is supported. @@ -455,11 +455,23 @@ int gl_init(void) { } // Make sure fullscreen mode is supported. - if(flags & SDL_FULLSCREEN && !supported) { - WARN("Fullscreen mode %dx%d is not supported by your current setup, attempting %dx%d", - gl_screen.w, gl_screen.h, modes[0]->w, modes[0]->h); - gl_screen.w = modes[0]->w; - gl_screen.h = modes[0]->h; + if((flags & SDL_FULLSCREEN) && !supported) { + // Try to get the closest aproximation to mode we asked for. + off = -1; + j = 0; + for(i = 0; modes[i]; i++) { + toff = ABS(gl_screen.w-modes[i]->w) + ABS(gl_screen.h-modes[i]->h); + if((off == -1) || (toff < off)) { + j = i; + off = toff; + } + } + WARN("Fullscreen mode %dx%d is not supported by your setup\n" + " Switching to %dx%d", gl_screen.w, gl_screen.h, + modes[j]->w, modes[j]->h); + + gl_screen.w = modes[j]->w; + gl_screen.h = modes[j]->h; } // Free the video modes. for(i = 0; modes[i]; ++i)