vrchess

diff src/main.cc @ 2:879194e4b1f0

fixed line-endings
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 25 Apr 2014 05:44:09 +0300
parents b326d53321f7
children a797e426e309
line diff
     1.1 --- a/src/main.cc	Fri Apr 25 05:43:26 2014 +0300
     1.2 +++ b/src/main.cc	Fri Apr 25 05:44:09 2014 +0300
     1.3 @@ -1,111 +1,111 @@
     1.4 -#include <stdio.h>
     1.5 -#include <stdlib.h>
     1.6 -#include "opengl.h"
     1.7 -#include "game.h"
     1.8 -
     1.9 -static bool init();
    1.10 -static void cleanup();
    1.11 -
    1.12 -static void display();
    1.13 -static void idle();
    1.14 -static void reshape(int x, int y);
    1.15 -static void keyb(unsigned char key, int x, int y);
    1.16 -static void keyb_up(unsigned char key, int x, int y);
    1.17 -static void mouse(int bn, int st, int x, int y);
    1.18 -static void motion(int x, int y);
    1.19 -static void sball_motion(int x, int y, int z);
    1.20 -static void sball_rotate(int x, int y, int z);
    1.21 -
    1.22 -int main(int argc, char **argv)
    1.23 -{
    1.24 -	glutInitWindowSize(1024, 600);
    1.25 -	glutInit(&argc, argv);
    1.26 -	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    1.27 -	glutCreateWindow("VR Chess");
    1.28 -
    1.29 -	glutDisplayFunc(display);
    1.30 -	glutIdleFunc(idle);
    1.31 -	glutReshapeFunc(reshape);
    1.32 -	glutKeyboardFunc(keyb);
    1.33 -	glutKeyboardUpFunc(keyb_up);
    1.34 -	glutMouseFunc(mouse);
    1.35 -	glutMotionFunc(motion);
    1.36 -	glutSpaceballMotionFunc(sball_motion);
    1.37 -	glutSpaceballRotateFunc(sball_rotate);
    1.38 -
    1.39 -	if(!init()) {
    1.40 -		return 1;
    1.41 -	}
    1.42 -	atexit(cleanup);
    1.43 -
    1.44 -	glutMainLoop();
    1.45 -	return 0;
    1.46 -}
    1.47 -
    1.48 -static bool init()
    1.49 -{
    1.50 -	glewInit();
    1.51 -
    1.52 -	if(!game_init()) {
    1.53 -		return false;
    1.54 -	}
    1.55 -	return true;
    1.56 -}
    1.57 -
    1.58 -static void cleanup()
    1.59 -{
    1.60 -	game_cleanup();
    1.61 -}
    1.62 -
    1.63 -static void display()
    1.64 -{
    1.65 -	unsigned int msec = glutGet(GLUT_ELAPSED_TIME);
    1.66 -
    1.67 -	game_update(msec);
    1.68 -	game_render(0);
    1.69 -
    1.70 -	glutSwapBuffers();
    1.71 -}
    1.72 -
    1.73 -static void idle()
    1.74 -{
    1.75 -	glutPostRedisplay();
    1.76 -}
    1.77 -
    1.78 -static void reshape(int x, int y)
    1.79 -{
    1.80 -	game_reshape(x, y);
    1.81 -}
    1.82 -
    1.83 -static void keyb(unsigned char key, int x, int y)
    1.84 -{
    1.85 -	game_keyboard(key, true, x, y);
    1.86 -}
    1.87 -
    1.88 -static void keyb_up(unsigned char key, int x, int y)
    1.89 -{
    1.90 -	game_keyboard(key, false, x, y);
    1.91 -}
    1.92 -
    1.93 -static void mouse(int bn, int st, int x, int y)
    1.94 -{
    1.95 -	game_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
    1.96 -}
    1.97 -
    1.98 -static void motion(int x, int y)
    1.99 -{
   1.100 -	game_motion(x, y);
   1.101 -}
   1.102 -
   1.103 -#define SBALL_MOVE_SCALE	0.00025
   1.104 -#define SBALL_ROT_SCALE		0.01
   1.105 -
   1.106 -static void sball_motion(int x, int y, int z)
   1.107 -{
   1.108 -	game_6dof_move(x * SBALL_MOVE_SCALE, y * SBALL_MOVE_SCALE, z * SBALL_MOVE_SCALE);
   1.109 -}
   1.110 -
   1.111 -static void sball_rotate(int x, int y, int z)
   1.112 -{
   1.113 -	game_6dof_rotate(x * SBALL_ROT_SCALE, y * SBALL_ROT_SCALE, z * SBALL_ROT_SCALE);
   1.114 -}
   1.115 \ No newline at end of file
   1.116 +#include <stdio.h>
   1.117 +#include <stdlib.h>
   1.118 +#include "opengl.h"
   1.119 +#include "game.h"
   1.120 +
   1.121 +static bool init();
   1.122 +static void cleanup();
   1.123 +
   1.124 +static void display();
   1.125 +static void idle();
   1.126 +static void reshape(int x, int y);
   1.127 +static void keyb(unsigned char key, int x, int y);
   1.128 +static void keyb_up(unsigned char key, int x, int y);
   1.129 +static void mouse(int bn, int st, int x, int y);
   1.130 +static void motion(int x, int y);
   1.131 +static void sball_motion(int x, int y, int z);
   1.132 +static void sball_rotate(int x, int y, int z);
   1.133 +
   1.134 +int main(int argc, char **argv)
   1.135 +{
   1.136 +	glutInitWindowSize(1024, 600);
   1.137 +	glutInit(&argc, argv);
   1.138 +	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
   1.139 +	glutCreateWindow("VR Chess");
   1.140 +
   1.141 +	glutDisplayFunc(display);
   1.142 +	glutIdleFunc(idle);
   1.143 +	glutReshapeFunc(reshape);
   1.144 +	glutKeyboardFunc(keyb);
   1.145 +	glutKeyboardUpFunc(keyb_up);
   1.146 +	glutMouseFunc(mouse);
   1.147 +	glutMotionFunc(motion);
   1.148 +	glutSpaceballMotionFunc(sball_motion);
   1.149 +	glutSpaceballRotateFunc(sball_rotate);
   1.150 +
   1.151 +	if(!init()) {
   1.152 +		return 1;
   1.153 +	}
   1.154 +	atexit(cleanup);
   1.155 +
   1.156 +	glutMainLoop();
   1.157 +	return 0;
   1.158 +}
   1.159 +
   1.160 +static bool init()
   1.161 +{
   1.162 +	glewInit();
   1.163 +
   1.164 +	if(!game_init()) {
   1.165 +		return false;
   1.166 +	}
   1.167 +	return true;
   1.168 +}
   1.169 +
   1.170 +static void cleanup()
   1.171 +{
   1.172 +	game_cleanup();
   1.173 +}
   1.174 +
   1.175 +static void display()
   1.176 +{
   1.177 +	unsigned int msec = glutGet(GLUT_ELAPSED_TIME);
   1.178 +
   1.179 +	game_update(msec);
   1.180 +	game_render(0);
   1.181 +
   1.182 +	glutSwapBuffers();
   1.183 +}
   1.184 +
   1.185 +static void idle()
   1.186 +{
   1.187 +	glutPostRedisplay();
   1.188 +}
   1.189 +
   1.190 +static void reshape(int x, int y)
   1.191 +{
   1.192 +	game_reshape(x, y);
   1.193 +}
   1.194 +
   1.195 +static void keyb(unsigned char key, int x, int y)
   1.196 +{
   1.197 +	game_keyboard(key, true, x, y);
   1.198 +}
   1.199 +
   1.200 +static void keyb_up(unsigned char key, int x, int y)
   1.201 +{
   1.202 +	game_keyboard(key, false, x, y);
   1.203 +}
   1.204 +
   1.205 +static void mouse(int bn, int st, int x, int y)
   1.206 +{
   1.207 +	game_mouse(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y);
   1.208 +}
   1.209 +
   1.210 +static void motion(int x, int y)
   1.211 +{
   1.212 +	game_motion(x, y);
   1.213 +}
   1.214 +
   1.215 +#define SBALL_MOVE_SCALE	0.00025
   1.216 +#define SBALL_ROT_SCALE		0.01
   1.217 +
   1.218 +static void sball_motion(int x, int y, int z)
   1.219 +{
   1.220 +	game_6dof_move(x * SBALL_MOVE_SCALE, y * SBALL_MOVE_SCALE, z * SBALL_MOVE_SCALE);
   1.221 +}
   1.222 +
   1.223 +static void sball_rotate(int x, int y, int z)
   1.224 +{
   1.225 +	game_6dof_rotate(x * SBALL_ROT_SCALE, y * SBALL_ROT_SCALE, z * SBALL_ROT_SCALE);
   1.226 +}