conworlds

changeset 21:2da585428507

added both glut and sdl2 versions just for fun...
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 27 Aug 2014 04:16:22 +0300
parents 782ff06817fb
children 5f53272ff612
files Makefile conworlds.vcxproj conworlds.vcxproj.filters src/glut/main.cc src/glut/main_glut.cc src/sdl/main_sdl.cc
diffstat 6 files changed, 354 insertions(+), 157 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Tue Aug 26 18:42:53 2014 +0300
     1.2 +++ b/Makefile	Wed Aug 27 04:16:22 2014 +0300
     1.3 @@ -1,5 +1,5 @@
     1.4  csrc = $(wildcard src/*.c) $(wildcard src/vr/*.c)
     1.5 -ccsrc = $(wildcard src/*.cc)
     1.6 +ccsrc = $(wildcard src/*.cc) $(wildcard src/sdl/*.cc)
     1.7  obj = $(csrc:.c=.o) $(ccsrc:.cc=.o)
     1.8  dep = $(obj:.o=.d)
     1.9  bin = conworlds
     2.1 --- a/conworlds.vcxproj	Tue Aug 26 18:42:53 2014 +0300
     2.2 +++ b/conworlds.vcxproj	Wed Aug 27 04:16:22 2014 +0300
     2.3 @@ -51,7 +51,7 @@
     2.4        </PrecompiledHeader>
     2.5        <WarningLevel>Level3</WarningLevel>
     2.6        <Optimization>Disabled</Optimization>
     2.7 -      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);USE_LIBOVR</PreprocessorDefinitions>
     2.8 +      <PreprocessorDefinitions>USE_GLUT;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);USE_LIBOVR</PreprocessorDefinitions>
     2.9        <DisableSpecificWarnings>4996;4244;4305</DisableSpecificWarnings>
    2.10        <AdditionalIncludeDirectories>$(SolutionDir)\src</AdditionalIncludeDirectories>
    2.11      </ClCompile>
    2.12 @@ -69,7 +69,7 @@
    2.13        <Optimization>MaxSpeed</Optimization>
    2.14        <FunctionLevelLinking>true</FunctionLevelLinking>
    2.15        <IntrinsicFunctions>true</IntrinsicFunctions>
    2.16 -      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);USE_LIBOVR</PreprocessorDefinitions>
    2.17 +      <PreprocessorDefinitions>USE_GLUT;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);USE_LIBOVR</PreprocessorDefinitions>
    2.18        <DisableSpecificWarnings>4996;4244;4305</DisableSpecificWarnings>
    2.19        <AdditionalIncludeDirectories>$(SolutionDir)\src</AdditionalIncludeDirectories>
    2.20      </ClCompile>
    2.21 @@ -87,15 +87,16 @@
    2.22      <ClCompile Include="src\game.cc" />
    2.23      <ClCompile Include="src\gameopt.cc" />
    2.24      <ClCompile Include="src\geom.cc" />
    2.25 +    <ClCompile Include="src\glut\main_glut.cc" />
    2.26      <ClCompile Include="src\image.cc" />
    2.27      <ClCompile Include="src\light.cc" />
    2.28      <ClCompile Include="src\logger.cc" />
    2.29 -    <ClCompile Include="src\main.cc" />
    2.30      <ClCompile Include="src\material.cc" />
    2.31      <ClCompile Include="src\mesh.cc" />
    2.32      <ClCompile Include="src\object.cc" />
    2.33      <ClCompile Include="src\opengl.cc" />
    2.34      <ClCompile Include="src\scene.cc" />
    2.35 +    <ClCompile Include="src\sdl\main_sdl.cc" />
    2.36      <ClCompile Include="src\sdr.c" />
    2.37      <ClCompile Include="src\shader.cc" />
    2.38      <ClCompile Include="src\texture.cc" />
     3.1 --- a/conworlds.vcxproj.filters	Tue Aug 26 18:42:53 2014 +0300
     3.2 +++ b/conworlds.vcxproj.filters	Wed Aug 27 04:16:22 2014 +0300
     3.3 @@ -8,11 +8,14 @@
     3.4      <Filter Include="src\vr">
     3.5        <UniqueIdentifier>{e881ab02-1a45-43f6-a15d-ee7f77256a1e}</UniqueIdentifier>
     3.6      </Filter>
     3.7 +    <Filter Include="src\sdl">
     3.8 +      <UniqueIdentifier>{4b658839-b773-4d11-9744-27a21bb1312c}</UniqueIdentifier>
     3.9 +    </Filter>
    3.10 +    <Filter Include="src\glut">
    3.11 +      <UniqueIdentifier>{0350ffd6-db06-4220-9274-8e2eb4bb33d1}</UniqueIdentifier>
    3.12 +    </Filter>
    3.13    </ItemGroup>
    3.14    <ItemGroup>
    3.15 -    <ClCompile Include="src\main.cc">
    3.16 -      <Filter>src</Filter>
    3.17 -    </ClCompile>
    3.18      <ClCompile Include="src\camera.cc">
    3.19        <Filter>src</Filter>
    3.20      </ClCompile>
    3.21 @@ -91,6 +94,12 @@
    3.22      <ClCompile Include="src\xform_node.cc">
    3.23        <Filter>src</Filter>
    3.24      </ClCompile>
    3.25 +    <ClCompile Include="src\glut\main_glut.cc">
    3.26 +      <Filter>src\glut</Filter>
    3.27 +    </ClCompile>
    3.28 +    <ClCompile Include="src\sdl\main_sdl.cc">
    3.29 +      <Filter>src\sdl</Filter>
    3.30 +    </ClCompile>
    3.31    </ItemGroup>
    3.32    <ItemGroup>
    3.33      <ClInclude Include="src\camera.h">
     4.1 --- a/src/glut/main.cc	Tue Aug 26 18:42:53 2014 +0300
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,150 +0,0 @@
     4.4 -#include <stdio.h>
     4.5 -#include <stdlib.h>
     4.6 -#include <SDL2/SDL.h>
     4.7 -#include "opengl.h"
     4.8 -#include "game.h"
     4.9 -#include "gameopt.h"
    4.10 -#include "vr/vr.h"
    4.11 -
    4.12 -#define ANYPOS	SDL_WINDOWPOS_UNDEFINED
    4.13 -
    4.14 -static bool init();
    4.15 -static void cleanup();
    4.16 -static void handle_event(SDL_Event *ev);
    4.17 -
    4.18 -static SDL_Window *win;
    4.19 -static SDL_GLContext ctx;
    4.20 -
    4.21 -int main(int argc, char **argv)
    4.22 -{
    4.23 -	if(!parse_args(argc, argv)) {
    4.24 -		return 1;
    4.25 -	}
    4.26 -
    4.27 -	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
    4.28 -
    4.29 -	unsigned int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
    4.30 -	if(!(win = SDL_CreateWindow("oculus test", ANYPOS, ANYPOS, 1024, 600, flags))) {
    4.31 -		fprintf(stderr, "failed to create window\n");
    4.32 -		return 1;
    4.33 -	}
    4.34 -
    4.35 -	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    4.36 -	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
    4.37 -
    4.38 -	if(!(ctx = SDL_GL_CreateContext(win))) {
    4.39 -		fprintf(stderr, "failed to create OpenGL context\n");
    4.40 -		return 1;
    4.41 -	}
    4.42 -
    4.43 -	if(!init()) {
    4.44 -		return 1;
    4.45 -	}
    4.46 -	atexit(cleanup);
    4.47 -
    4.48 -	int xsz, ysz;
    4.49 -	SDL_GetWindowSize(win, &xsz, &ysz);
    4.50 -	game_reshape(xsz, ysz);
    4.51 -
    4.52 -	for(;;) {
    4.53 -		SDL_Event ev;
    4.54 -
    4.55 -		while(SDL_PollEvent(&ev)) {
    4.56 -			handle_event(&ev);
    4.57 -		}
    4.58 -
    4.59 -		unsigned int msec = SDL_GetTicks();
    4.60 -
    4.61 -		game_update(msec);
    4.62 -		game_render();
    4.63 -	}
    4.64 -
    4.65 -	return 0;
    4.66 -}
    4.67 -
    4.68 -static bool init()
    4.69 -{
    4.70 -	glewInit();
    4.71 -
    4.72 -	if(!game_init()) {
    4.73 -		return false;
    4.74 -	}
    4.75 -
    4.76 -	if(opt.vr) {
    4.77 -		int win_xsz = vr_get_opti(VR_OPT_DISPLAY_WIDTH);
    4.78 -		int win_ysz = vr_get_opti(VR_OPT_DISPLAY_HEIGHT);
    4.79 -		if(win_xsz && win_ysz) {
    4.80 -			SDL_SetWindowSize(win, win_xsz, win_ysz);
    4.81 -		}
    4.82 -	}
    4.83 -	return true;
    4.84 -}
    4.85 -
    4.86 -static void cleanup()
    4.87 -{
    4.88 -	game_cleanup();
    4.89 -}
    4.90 -
    4.91 -static void handle_event(SDL_Event *ev)
    4.92 -{
    4.93 -	static bool fullscr;
    4.94 -	static int prev_xpos, prev_ypos;
    4.95 -	static int prev_xsz, prev_ysz;
    4.96 -
    4.97 -	switch(ev->type) {
    4.98 -	case SDL_KEYDOWN:
    4.99 -	case SDL_KEYUP:
   4.100 -		if(ev->key.keysym.sym == 'f' && ev->key.state == SDL_PRESSED) {
   4.101 -			fullscr = !fullscr;
   4.102 -			if(fullscr) {
   4.103 -				int xoffs, yoffs;
   4.104 -
   4.105 -				SDL_GetWindowPosition(win, &prev_xpos, &prev_ypos);
   4.106 -				SDL_GetWindowSize(win, &prev_xsz, &prev_ysz);
   4.107 -
   4.108 -				xoffs = vr_get_opti(VR_OPT_WIN_XOFFS);
   4.109 -				yoffs = vr_get_opti(VR_OPT_WIN_YOFFS);
   4.110 -				if(xoffs || yoffs) {
   4.111 -					printf("repositioning: %d,%d\n", xoffs, yoffs);
   4.112 -					SDL_SetWindowPosition(win, xoffs, yoffs);
   4.113 -				}
   4.114 -				SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN_DESKTOP);
   4.115 -			} else {
   4.116 -				SDL_SetWindowFullscreen(win, 0);
   4.117 -				/*SDL_SetWindowPosition(win, prev_xpos, prev_ypos);
   4.118 -				SDL_SetWindowSize(win, prev_xsz, prev_ysz);*/
   4.119 -			}
   4.120 -			break;
   4.121 -		}
   4.122 -
   4.123 -		game_keyboard(ev->key.keysym.sym, ev->key.state == SDL_PRESSED);
   4.124 -		break;
   4.125 -
   4.126 -	case SDL_MOUSEBUTTONDOWN:
   4.127 -	case SDL_MOUSEBUTTONUP:
   4.128 -		game_mouse(ev->button.button - SDL_BUTTON_LEFT, ev->button.state == SDL_PRESSED,
   4.129 -				ev->button.x, ev->button.y);
   4.130 -		break;
   4.131 -
   4.132 -	case SDL_MOUSEWHEEL:
   4.133 -		game_mwheel(ev->wheel.y);
   4.134 -		break;
   4.135 -
   4.136 -	case SDL_MOUSEMOTION:
   4.137 -		game_motion(ev->motion.x, ev->motion.y);
   4.138 -		break;
   4.139 -
   4.140 -	case SDL_WINDOWEVENT:
   4.141 -		switch(ev->window.event) {
   4.142 -		case SDL_WINDOWEVENT_RESIZED:
   4.143 -			game_reshape(ev->window.data1, ev->window.data2);
   4.144 -			break;
   4.145 -
   4.146 -		default:
   4.147 -			break;
   4.148 -		}
   4.149 -
   4.150 -	default:
   4.151 -		break;
   4.152 -	}
   4.153 -}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/glut/main_glut.cc	Wed Aug 27 04:16:22 2014 +0300
     5.3 @@ -0,0 +1,183 @@
     5.4 +#ifdef USE_GLUT
     5.5 +
     5.6 +#include <stdio.h>
     5.7 +#include <stdlib.h>
     5.8 +#include "opengl.h"
     5.9 +#ifdef __APPLE__
    5.10 +#include <GLUT/glut.h>
    5.11 +#else
    5.12 +#include <GL/glut.h>
    5.13 +#endif
    5.14 +#include "game.h"
    5.15 +#include "gameopt.h"
    5.16 +#include "vr/vr.h"
    5.17 +
    5.18 +static bool init();
    5.19 +static void cleanup();
    5.20 +
    5.21 +static void display();
    5.22 +static void idle();
    5.23 +static void reshape(int x, int y);
    5.24 +static void keyb(unsigned char key, int x, int y);
    5.25 +static void keyb_up(unsigned char key, int x, int y);
    5.26 +static void mouse(int bn, int st, int x, int y);
    5.27 +static void motion(int x, int y);
    5.28 +static void sball_motion(int x, int y, int z);
    5.29 +static void sball_rotate(int x, int y, int z);
    5.30 +
    5.31 +static bool fullscreen_pending;
    5.32 +
    5.33 +int main(int argc, char **argv)
    5.34 +{
    5.35 +	glutInitWindowSize(1024, 600);
    5.36 +	glutInit(&argc, argv);
    5.37 +
    5.38 +	if(!parse_args(argc, argv)) {
    5.39 +		return 1;
    5.40 +	}
    5.41 +
    5.42 +	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | (opt.stereo ? GLUT_STEREO : 0));
    5.43 +	glutCreateWindow("LD48 #30 - connected worlds");
    5.44 +
    5.45 +	glutDisplayFunc(display);
    5.46 +	glutIdleFunc(idle);
    5.47 +	glutReshapeFunc(reshape);
    5.48 +	glutKeyboardFunc(keyb);
    5.49 +	glutKeyboardUpFunc(keyb_up);
    5.50 +	glutMouseFunc(mouse);
    5.51 +	glutMotionFunc(motion);
    5.52 +	glutSpaceballMotionFunc(sball_motion);
    5.53 +	glutSpaceballRotateFunc(sball_rotate);
    5.54 +
    5.55 +	if(!init()) {
    5.56 +		return 1;
    5.57 +	}
    5.58 +	atexit(cleanup);
    5.59 +
    5.60 +	glutMainLoop();
    5.61 +	return 0;
    5.62 +}
    5.63 +
    5.64 +static bool init()
    5.65 +{
    5.66 +	glewInit();
    5.67 +
    5.68 +	if(!game_init()) {
    5.69 +		return false;
    5.70 +	}
    5.71 +
    5.72 +	if(opt.vr) {
    5.73 +		int win_xsz = vr_get_opti(VR_OPT_DISPLAY_WIDTH);
    5.74 +		int win_ysz = vr_get_opti(VR_OPT_DISPLAY_HEIGHT);
    5.75 +		if(win_xsz && win_ysz) {
    5.76 +			glutReshapeWindow(win_xsz, win_ysz);
    5.77 +		}
    5.78 +	}
    5.79 +	return true;
    5.80 +}
    5.81 +
    5.82 +static void cleanup()
    5.83 +{
    5.84 +	game_cleanup();
    5.85 +}
    5.86 +
    5.87 +static void display()
    5.88 +{
    5.89 +	unsigned int msec = glutGet(GLUT_ELAPSED_TIME);
    5.90 +
    5.91 +	game_update(msec);
    5.92 +	game_render();
    5.93 +}
    5.94 +
    5.95 +static void idle()
    5.96 +{
    5.97 +	if(fullscreen_pending) {
    5.98 +		glutFullScreen();
    5.99 +	}
   5.100 +
   5.101 +	glutPostRedisplay();
   5.102 +}
   5.103 +
   5.104 +static void reshape(int x, int y)
   5.105 +{
   5.106 +	game_reshape(x, y);
   5.107 +}
   5.108 +
   5.109 +static void keyb(unsigned char key, int x, int y)
   5.110 +{
   5.111 +	static bool fullscr;
   5.112 +	static int prev_xpos, prev_ypos;
   5.113 +	static int prev_xsz, prev_ysz;
   5.114 +
   5.115 +	switch(key) {
   5.116 +	case 'f':
   5.117 +		fullscr = !fullscr;
   5.118 +		if(fullscr) {
   5.119 +			int xoffs, yoffs;
   5.120 +
   5.121 +			prev_xpos = glutGet(GLUT_WINDOW_X);
   5.122 +			prev_ypos = glutGet(GLUT_WINDOW_Y);
   5.123 +			prev_xsz = glutGet(GLUT_WINDOW_WIDTH);
   5.124 +			prev_ysz = glutGet(GLUT_WINDOW_HEIGHT);
   5.125 +
   5.126 +			xoffs = vr_get_opti(VR_OPT_WIN_XOFFS);
   5.127 +			yoffs = vr_get_opti(VR_OPT_WIN_YOFFS);
   5.128 +			if(xoffs || yoffs) {
   5.129 +				printf("repositioning: %d,%d\n", xoffs, yoffs);
   5.130 +				glutPositionWindow(xoffs, yoffs);
   5.131 +			}
   5.132 +			fullscreen_pending = true;
   5.133 +		} else {
   5.134 +			fullscreen_pending = false;
   5.135 +			glutPositionWindow(prev_xpos, prev_ypos);
   5.136 +			glutReshapeWindow(prev_xsz, prev_ysz);
   5.137 +		}
   5.138 +		break;
   5.139 +	}
   5.140 +	game_keyboard(key, true);
   5.141 +}
   5.142 +
   5.143 +static void keyb_up(unsigned char key, int x, int y)
   5.144 +{
   5.145 +	game_keyboard(key, false);
   5.146 +}
   5.147 +
   5.148 +static void mouse(int bn, int st, int x, int y)
   5.149 +{
   5.150 +	switch(bn) {
   5.151 +	case GLUT_RIGHT_BUTTON + 1:
   5.152 +		if(st == GLUT_DOWN) {
   5.153 +			game_mwheel(1);
   5.154 +		}
   5.155 +		break;
   5.156 +
   5.157 +	case GLUT_RIGHT_BUTTON + 2:
   5.158 +		if(st == GLUT_DOWN) {
   5.159 +			game_mwheel(-1);
   5.160 +		}
   5.161 +		break;
   5.162 +
   5.163 +	default:
   5.164 +		game_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
   5.165 +	}
   5.166 +}
   5.167 +
   5.168 +static void motion(int x, int y)
   5.169 +{
   5.170 +	game_motion(x, y);
   5.171 +}
   5.172 +
   5.173 +#define SBALL_MOVE_SCALE	0.00025
   5.174 +#define SBALL_ROT_SCALE		0.01
   5.175 +
   5.176 +static void sball_motion(int x, int y, int z)
   5.177 +{
   5.178 +	game_6dof_move(x * SBALL_MOVE_SCALE, y * SBALL_MOVE_SCALE, z * SBALL_MOVE_SCALE);
   5.179 +}
   5.180 +
   5.181 +static void sball_rotate(int x, int y, int z)
   5.182 +{
   5.183 +	game_6dof_rotate(x * SBALL_ROT_SCALE, y * SBALL_ROT_SCALE, z * SBALL_ROT_SCALE);
   5.184 +}
   5.185 +
   5.186 +#endif	// USE_GLUT
   5.187 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/sdl/main_sdl.cc	Wed Aug 27 04:16:22 2014 +0300
     6.3 @@ -0,0 +1,154 @@
     6.4 +#ifdef USE_SDL
     6.5 +
     6.6 +#include <stdio.h>
     6.7 +#include <stdlib.h>
     6.8 +#include <SDL2/SDL.h>
     6.9 +#include "opengl.h"
    6.10 +#include "game.h"
    6.11 +#include "gameopt.h"
    6.12 +#include "vr/vr.h"
    6.13 +
    6.14 +#define ANYPOS	SDL_WINDOWPOS_UNDEFINED
    6.15 +
    6.16 +static bool init();
    6.17 +static void cleanup();
    6.18 +static void handle_event(SDL_Event *ev);
    6.19 +
    6.20 +static SDL_Window *win;
    6.21 +static SDL_GLContext ctx;
    6.22 +
    6.23 +int main(int argc, char **argv)
    6.24 +{
    6.25 +	if(!parse_args(argc, argv)) {
    6.26 +		return 1;
    6.27 +	}
    6.28 +
    6.29 +	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
    6.30 +
    6.31 +	unsigned int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
    6.32 +	if(!(win = SDL_CreateWindow("oculus test", ANYPOS, ANYPOS, 1024, 600, flags))) {
    6.33 +		fprintf(stderr, "failed to create window\n");
    6.34 +		return 1;
    6.35 +	}
    6.36 +
    6.37 +	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    6.38 +	SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
    6.39 +
    6.40 +	if(!(ctx = SDL_GL_CreateContext(win))) {
    6.41 +		fprintf(stderr, "failed to create OpenGL context\n");
    6.42 +		return 1;
    6.43 +	}
    6.44 +
    6.45 +	if(!init()) {
    6.46 +		return 1;
    6.47 +	}
    6.48 +	atexit(cleanup);
    6.49 +
    6.50 +	int xsz, ysz;
    6.51 +	SDL_GetWindowSize(win, &xsz, &ysz);
    6.52 +	game_reshape(xsz, ysz);
    6.53 +
    6.54 +	for(;;) {
    6.55 +		SDL_Event ev;
    6.56 +
    6.57 +		while(SDL_PollEvent(&ev)) {
    6.58 +			handle_event(&ev);
    6.59 +		}
    6.60 +
    6.61 +		unsigned int msec = SDL_GetTicks();
    6.62 +
    6.63 +		game_update(msec);
    6.64 +		game_render();
    6.65 +	}
    6.66 +
    6.67 +	return 0;
    6.68 +}
    6.69 +
    6.70 +static bool init()
    6.71 +{
    6.72 +	glewInit();
    6.73 +
    6.74 +	if(!game_init()) {
    6.75 +		return false;
    6.76 +	}
    6.77 +
    6.78 +	if(opt.vr) {
    6.79 +		int win_xsz = vr_get_opti(VR_OPT_DISPLAY_WIDTH);
    6.80 +		int win_ysz = vr_get_opti(VR_OPT_DISPLAY_HEIGHT);
    6.81 +		if(win_xsz && win_ysz) {
    6.82 +			SDL_SetWindowSize(win, win_xsz, win_ysz);
    6.83 +		}
    6.84 +	}
    6.85 +	return true;
    6.86 +}
    6.87 +
    6.88 +static void cleanup()
    6.89 +{
    6.90 +	game_cleanup();
    6.91 +}
    6.92 +
    6.93 +static void handle_event(SDL_Event *ev)
    6.94 +{
    6.95 +	static bool fullscr;
    6.96 +	static int prev_xpos, prev_ypos;
    6.97 +	static int prev_xsz, prev_ysz;
    6.98 +
    6.99 +	switch(ev->type) {
   6.100 +	case SDL_KEYDOWN:
   6.101 +	case SDL_KEYUP:
   6.102 +		if(ev->key.keysym.sym == 'f' && ev->key.state == SDL_PRESSED) {
   6.103 +			fullscr = !fullscr;
   6.104 +			if(fullscr) {
   6.105 +				int xoffs, yoffs;
   6.106 +
   6.107 +				SDL_GetWindowPosition(win, &prev_xpos, &prev_ypos);
   6.108 +				SDL_GetWindowSize(win, &prev_xsz, &prev_ysz);
   6.109 +
   6.110 +				xoffs = vr_get_opti(VR_OPT_WIN_XOFFS);
   6.111 +				yoffs = vr_get_opti(VR_OPT_WIN_YOFFS);
   6.112 +				if(xoffs || yoffs) {
   6.113 +					printf("repositioning: %d,%d\n", xoffs, yoffs);
   6.114 +					SDL_SetWindowPosition(win, xoffs, yoffs);
   6.115 +				}
   6.116 +				SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN_DESKTOP);
   6.117 +			} else {
   6.118 +				SDL_SetWindowFullscreen(win, 0);
   6.119 +				/*SDL_SetWindowPosition(win, prev_xpos, prev_ypos);
   6.120 +				SDL_SetWindowSize(win, prev_xsz, prev_ysz);*/
   6.121 +			}
   6.122 +			break;
   6.123 +		}
   6.124 +
   6.125 +		game_keyboard(ev->key.keysym.sym, ev->key.state == SDL_PRESSED);
   6.126 +		break;
   6.127 +
   6.128 +	case SDL_MOUSEBUTTONDOWN:
   6.129 +	case SDL_MOUSEBUTTONUP:
   6.130 +		game_mouse(ev->button.button - SDL_BUTTON_LEFT, ev->button.state == SDL_PRESSED,
   6.131 +				ev->button.x, ev->button.y);
   6.132 +		break;
   6.133 +
   6.134 +	case SDL_MOUSEWHEEL:
   6.135 +		game_mwheel(ev->wheel.y);
   6.136 +		break;
   6.137 +
   6.138 +	case SDL_MOUSEMOTION:
   6.139 +		game_motion(ev->motion.x, ev->motion.y);
   6.140 +		break;
   6.141 +
   6.142 +	case SDL_WINDOWEVENT:
   6.143 +		switch(ev->window.event) {
   6.144 +		case SDL_WINDOWEVENT_RESIZED:
   6.145 +			game_reshape(ev->window.data1, ev->window.data2);
   6.146 +			break;
   6.147 +
   6.148 +		default:
   6.149 +			break;
   6.150 +		}
   6.151 +
   6.152 +	default:
   6.153 +		break;
   6.154 +	}
   6.155 +}
   6.156 +
   6.157 +#endif	// USE_SDL