Cube  Diff

Differences From Artifact [d63e158bb1]:

To Artifact [c32806b2e7]:


50
51
52
53
54
55
56

57
58
59
60
61
62
63
{
	void *b = calloc(1, s);
	if (!b)
		fatal(@"out of memory!");
	return b;
}


int scr_w = 640;
int scr_h = 480;

void
screenshot()
{
	SDL_Surface *image;







>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
	void *b = calloc(1, s);
	if (!b)
		fatal(@"out of memory!");
	return b;
}

SDL_Window *window;
int scr_w = 640;
int scr_h = 480;

void
screenshot()
{
	SDL_Surface *image;
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
		SDL_FreeSurface(image);
	};
}

COMMAND(screenshot, ARG_NONE)
COMMAND(quit, ARG_NONE)

void
keyrepeat(bool on)
{
	SDL_EnableKeyRepeat(
	    on ? SDL_DEFAULT_REPEAT_DELAY : 0, SDL_DEFAULT_REPEAT_INTERVAL);
}

VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);

int framesinmap = 0;

- (void)applicationDidFinishLaunching:(OFNotification *)notification







<
|
<
<
<
<







87
88
89
90
91
92
93

94




95
96
97
98
99
100
101
		SDL_FreeSurface(image);
	};
}

COMMAND(screenshot, ARG_NONE)
COMMAND(quit, ARG_NONE)


bool keyrepeat = false;





VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100);
VARP(minmillis, 0, 5, 1000);

int framesinmap = 0;

- (void)applicationDidFinishLaunching:(OFNotification *)notification
172
173
174
175
176
177
178

179

180

181
182
183
184
185
186
187
188
189
190
191
192
193

	log("video: sdl");
	if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
		fatal(@"Unable to initialize SDL Video");

	log("video: mode");
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

	if (SDL_SetVideoMode(scr_w, scr_h, 0,

	        SDL_OPENGL | (!windowed ? SDL_FULLSCREEN : 0)) == NULL)

		fatal(@"Unable to create OpenGL screen");

	log("video: misc");
	SDL_WM_SetCaption("cube engine", NULL);
	SDL_WM_GrabInput(SDL_GRAB_ON);
	keyrepeat(false);
	SDL_ShowCursor(0);

	log("gl");
	gl_init(scr_w, scr_h);

	log("basetex");
	int xs, ys;







>
|
>
|
>



|
|
|







168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192

	log("video: sdl");
	if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
		fatal(@"Unable to initialize SDL Video");

	log("video: mode");
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
	if ((window = SDL_CreateWindow("cube engine", SDL_WINDOWPOS_UNDEFINED,
	         SDL_WINDOWPOS_UNDEFINED, scr_w, scr_h,
	         SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL |
	             (!windowed ? SDL_WINDOW_FULLSCREEN : 0))) == NULL ||
	    SDL_GL_CreateContext(window) == NULL)
		fatal(@"Unable to create OpenGL screen");

	log("video: misc");
	SDL_SetWindowGrab(window, SDL_TRUE);
	SDL_SetRelativeMouseMode(SDL_TRUE);
	keyrepeat = false;
	SDL_ShowCursor(0);

	log("gl");
	gl_init(scr_w, scr_h);

	log("basetex");
	int xs, ys;
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
		updateworld(millis);
		if (!demoplayback)
			serverslice((int)time(NULL), 0);
		static float fps = 30.0f;
		fps = (1000.0f / curtime + fps * 50) / 51;
		computeraytable(player1->o.x, player1->o.y);
		readdepth(scr_w, scr_h);
		SDL_GL_SwapBuffers();
		extern void updatevol();
		updatevol();
		if (framesinmap++ <
		    5) // cheap hack to get rid of initial sparklies, even when
		       // triple buffering etc.
		{
			player1->yaw += 5;







|







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
		updateworld(millis);
		if (!demoplayback)
			serverslice((int)time(NULL), 0);
		static float fps = 30.0f;
		fps = (1000.0f / curtime + fps * 50) / 51;
		computeraytable(player1->o.x, player1->o.y);
		readdepth(scr_w, scr_h);
		SDL_GL_SwapWindow(window);
		extern void updatevol();
		updatevol();
		if (framesinmap++ <
		    5) // cheap hack to get rid of initial sparklies, even when
		       // triple buffering etc.
		{
			player1->yaw += 5;
259
260
261
262
263
264
265

266
267
268
269
270
271
272
273
274
275

276
277
278
279
280
281
282
			switch (event.type) {
			case SDL_QUIT:
				quit();
				break;

			case SDL_KEYDOWN:
			case SDL_KEYUP:

				keypress(event.key.keysym.sym,
				    event.key.state == SDL_PRESSED,
				    event.key.keysym.unicode);
				break;

			case SDL_MOUSEMOTION:
				if (ignore) {
					ignore--;
					break;
				};

				mousemove(event.motion.xrel, event.motion.yrel);
				break;

			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				if (lasttype == event.type &&
				    lastbut == event.button.button)







>
|
|
|






<
>







258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274

275
276
277
278
279
280
281
282
			switch (event.type) {
			case SDL_QUIT:
				quit();
				break;

			case SDL_KEYDOWN:
			case SDL_KEYUP:
				if (keyrepeat || event.key.repeat == 0)
					keypress(event.key.keysym.sym,
					    event.key.state == SDL_PRESSED,
					    event.key.keysym.sym);
				break;

			case SDL_MOUSEMOTION:
				if (ignore) {
					ignore--;
					break;

				}
				mousemove(event.motion.xrel, event.motion.yrel);
				break;

			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				if (lasttype == event.type &&
				    lastbut == event.button.button)