Update of /cvsroot/netrek/client/cow
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28402
Modified Files:
camera.c input.c playback.c
Added Files:
camera.h
Log Message:
add camera frame counter
Index: camera.c
===================================================================
RCS file: /cvsroot/netrek/client/cow/camera.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- camera.c 16 May 2006 12:59:38 -0000 1.1
+++ camera.c 22 May 2006 13:12:48 -0000 1.2
@@ -1,6 +1,7 @@
/* prototype camera support */
#include <stdio.h>
+#include <stdlib.h>
#include <X11/Xlib.h>
#include <Imlib2.h>
#include "defs.h"
@@ -13,13 +14,27 @@
static Window rw, tw;
static int rx, ry;
static unsigned int rdx, rdy;
+static int frame;
+static int initialised = 0;
+
+/* maximum file name size */
+#define MAXFRAMEFILENAMESIZE 80
/* set the display used by the camera */
void camera_set_display(Display *arg_disp)
{
- int depth;
-
disp = arg_disp;
+}
+
+/* set the window used by the camera */
+void camera_set_window(Window *arg_window)
+{
+ tw = *arg_window;
+}
+
+void camera_init() {
+ if (initialised) return;
+ int depth;
scr = ScreenOfDisplay(disp, DefaultScreen(disp));
vis = DefaultVisual(disp, XScreenNumberOfScreen(scr));
depth = DefaultDepth(disp, XScreenNumberOfScreen(scr));
@@ -31,26 +46,30 @@
imlib_context_set_colormap(cm);
imlib_context_set_color_modifier(NULL);
imlib_context_set_operation(IMLIB_OP_COPY);
-}
+ frame = 0;
-/* set the window used by the camera */
-void camera_set_window(Window arg_window, int arg_width, int arg_height)
-{
- tw = arg_window;
rx = 0;
ry = 0;
rdx = TWINSIDE; /* restrict to tactical */
rdy = TWINSIDE;
imlib_context_set_drawable(tw);
+
+ initialised++;
}
void camera_snap()
{
Imlib_Image image;
+ char *name;
+ camera_init();
image = imlib_create_image_from_drawable(rw, rx, ry, rdx, rdy, 0);
imlib_context_set_image(image);
imlib_image_attach_data_value("quality", NULL, 15, NULL);
- imlib_save_image("cow-camera-frame.png");
+ name = malloc(MAXFRAMEFILENAMESIZE);
+ snprintf(name, MAXFRAMEFILENAMESIZE-1, "netrek-%03d.png", frame++);
+ imlib_save_image(name);
imlib_free_image_and_decache();
+ fprintf(stderr, "camera_snap: %s\n", name);
+ free(name);
}
Index: input.c
===================================================================
RCS file: /cvsroot/netrek/client/cow/input.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- input.c 16 May 2006 06:25:25 -0000 1.12
+++ input.c 22 May 2006 13:12:48 -0000 1.13
@@ -2,6 +2,9 @@
/* input.c
*
* $Log$
+ * Revision 1.13 2006/05/22 13:12:48 quozl
+ * add camera frame counter
+ *
* Revision 1.12 2006/05/16 06:25:25 quozl
* some compilation fixes
*
@@ -1107,6 +1110,7 @@
case 'R':
case 'j':
case 'J':
+ case 's':
pbsetspeed(key);
return;
break;
@@ -1981,6 +1985,7 @@
Key67(void)
{
sendCoupReq();
+ camera_snap();
}
Key68(void)
--- NEW FILE: camera.h ---
/* camera.c */
void camera_set_display(Display *arg_disp);
void camera_set_window(Window *arg_window);
void camera_init(void);
void camera_snap(void);
Index: playback.c
===================================================================
RCS file: /cvsroot/netrek/client/cow/playback.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- playback.c 27 Jan 2006 09:57:27 -0000 1.13
+++ playback.c 22 May 2006 13:12:48 -0000 1.14
@@ -5,6 +5,9 @@
* Routines neccessary to playback a game recording.
*
* $Log$
+ * Revision 1.14 2006/05/22 13:12:48 quozl
+ * add camera frame counter
+ *
* Revision 1.13 2006/01/27 09:57:27 quozl
* *** empty log message ***
*
@@ -189,6 +192,7 @@
int pb_num_fast_forward = 0;
int pb_sequence_count = 0;
int pb_stepping = 0; /* non-zero if doing a step */
+int pb_snapping = 0; /* non-zero if taking camera snapshots */
const char *INDEX_FORMAT = "%d,%d,%d";
const int INDEX_GRANULARITY = 100;
@@ -215,14 +219,6 @@
struct player *packetsme;
struct player *displayme;
-/* We want reverse-playback!!! */
-#define REVERSE_PLAYBACK
-
-/* Forward declarations for reverse playback */
-void rpb_init(void);
-void rpb_analyze(int diskpos, void *packet);
-void rpb_dorev(char *buf);
-
int
pbmain(char *name)
{
@@ -496,6 +492,7 @@
intrupt();
W_Flush();
if (!pb_stepping) usleep(pbdelay);
+ if (pb_snapping) camera_snap();
}
}
@@ -639,6 +636,10 @@
jump_idx = 0;
jump_str[0] = '\0';
break;
+ case 's':
+ fprintf(stderr, "toggle-snap\n");
+ pb_snapping = ~pb_snapping;
+ break;
}
end: