From http://www.jwz.org/xscreensaver/xscreensaver-5.33.tar.gz
[xscreensaver] / hacks / xlockmoreI.h
1 /* xlockmore.h --- xscreensaver compatibility layer for xlockmore modules.
2  * xscreensaver, Copyright (c) 1997-2014 Jamie Zawinski <jwz@jwz.org>
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation.  No representations are made about the suitability of this
9  * software for any purpose.  It is provided "as is" without express or 
10  * implied warranty.
11  *
12  * See xlockmore.h and xlockmore.c.
13  */
14
15 #ifndef __XLOCKMORE_INTERNAL_H__
16 #define __XLOCKMORE_INTERNAL_H__
17
18 #include <time.h>
19
20 #include "screenhackI.h"
21
22 #ifdef HAVE_XSHM_EXTENSION
23 # include "xshm.h"
24 #endif /* HAVE_XSHM_EXTENSION */
25
26
27 typedef struct ModeInfo ModeInfo;
28
29 #ifdef USE_GL
30
31 /* I'm told that the Sun version of OpenGL needs to have the constant
32    SUN_OGL_NO_VERTEX_MACROS defined in order for morph3d to compile
33    (the number of arguments to the glNormal3f macro changes...)
34    Verified with gcc 2.7.2.2 and Sun cc 4.2 with OpenGL 1.1.1 dev 4
35    on Solaris 2.5.1.
36  */
37 # ifndef HAVE_MESA_GL
38 #  if defined(__sun) && defined(__SVR4) /* Solaris */
39 #   define SUN_OGL_NO_VERTEX_MACROS 1
40 #  endif /* Solaris */
41 # endif /* !HAVE_MESA_GL */
42
43 # ifdef HAVE_COCOA
44 #  ifndef USE_IPHONE
45 #   include <OpenGL/gl.h>
46 #   include <OpenGL/glu.h>
47 #  endif
48 # elif defined(HAVE_ANDROID)
49 #  include <GLES/gl.h>
50 # else
51 #  include <GL/gl.h>
52 #  include <GL/glu.h>
53 #  include <GL/glx.h>
54 # endif
55
56 # ifdef HAVE_JWZGLES
57 #  include "jwzgles.h"
58 # endif /* HAVE_JWZGLES */
59
60
61   extern GLXContext *init_GL (ModeInfo *);
62   extern void xlockmore_reset_gl_state(void);
63   extern void clear_gl_error (void);
64   extern void check_gl_error (const char *type);
65
66   extern Visual *xlockmore_pick_gl_visual (Screen *);
67   extern Bool xlockmore_validate_gl_visual (Screen *, const char *, Visual *);
68
69 #endif /* !USE_GL */
70
71 /* These are only used in GL mode, but I don't understand why XCode
72    isn't seeing the prototypes for them in glx/fps-gl.c... */
73 extern void do_fps (ModeInfo *);
74 extern void xlockmore_gl_compute_fps (Display *, Window, fps_state *, void *);
75 extern void xlockmore_gl_draw_fps (ModeInfo *);
76 # define do_fps xlockmore_gl_draw_fps
77
78
79 extern void xlockmore_setup (struct xscreensaver_function_table *, void *);
80 extern void xlockmore_do_fps (Display *, Window, fps_state *, void *);
81
82
83 /* The xlockmore RNG API is implemented in utils/yarandom.h. */
84
85
86 struct ModeInfo {
87   struct xlockmore_function_table *xlmft;
88   Display *dpy;
89   Window window;
90   Bool root_p;
91   int num_screens;
92   int screen_number;
93   int npixels;
94   unsigned long *pixels;
95   XColor *colors;
96   Bool writable_p;
97   unsigned long white;
98   unsigned long black;
99   XWindowAttributes xgwa;
100   GC gc;
101   long pause;
102   Bool fullrandom;
103   long cycles;
104   long batchcount;
105   long size;
106   Bool threed;
107   long threed_left_color;
108   long threed_right_color;
109   long threed_both_color;
110   long threed_none_color;
111   long threed_delta;
112   Bool wireframe_p;
113   Bool is_drawn;
114
115   /* Used only by OpenGL programs, since FPS is tricky there. */
116   fps_state *fpst;
117   Bool fps_p;
118   unsigned long polygon_count;  /* These values are for -fps display only */
119   double recursion_depth;
120
121 #ifdef HAVE_XSHM_EXTENSION
122   Bool use_shm;
123   XShmSegmentInfo shm_info;
124 #endif
125 };
126
127 typedef enum {  t_String, t_Float, t_Int, t_Bool } xlockmore_type;
128
129 typedef struct {
130   void *var;
131   char *name;
132   char *classname;
133   char *def;
134   xlockmore_type type;
135 } argtype;
136
137 typedef struct {
138   char *opt;
139   char *desc;
140 } OptionStruct;
141
142 typedef struct {
143   int numopts;
144   XrmOptionDescRec *opts;
145   int numvarsdesc;
146   argtype *vars;
147   OptionStruct *desc;
148 } ModeSpecOpt;
149
150 struct xlockmore_function_table {
151   const char *progclass;
152   const char *defaults;
153   Bool want_writable_colors;
154   enum { color_scheme_default, color_scheme_uniform, 
155          color_scheme_smooth, color_scheme_bright }
156     desired_color_scheme;
157   void (*hack_init) (ModeInfo *);
158   void (*hack_draw) (ModeInfo *);
159   void (*hack_reshape) (ModeInfo *, int, int);
160   void (*hack_refresh) (ModeInfo *);
161   void (*hack_free) (ModeInfo *);
162   Bool (*hack_handle_events) (ModeInfo *, XEvent *);
163   ModeSpecOpt *opts;
164
165   unsigned int screen_count; /* Only used on the OS X and iOS ports. */
166 };
167
168 #endif /* __XLOCKMORE_INTERNAL_H__ */