1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/* $XConsortium$ */
/*
NOTICE TO USER: The source code in this file is copyrighted under
U.S. and international laws. SunSoft, Inc., a Sun Microsystems,
Inc. business of Mountain View, California owns the copyright.
Users and possessors of this source code are hereby granted a
nonexclusive, royalty-free copyright and design patent license
to use this code in individual and commercial software.
Any use of this source code must include, in the user documentation
and internal comments to the code, notices to the end user as follows:
(c) Copyright 1992, 1993 SunSoft, Inc., a Sun Microsystems, Inc. business.
SUNSOFT, INC. AND SUN MICROSYSTEMS, INC. MAKE NO REPRESENTATIONS
ABOUT THE SUITABILITY OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS
PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND.
SUNSOFT, INC., AND SUN MICROSYSTEMS, INC., SEVERALLY AND
INDIVIDUALLY, DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOURCE
CODE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUNSOFT, INC.
OR SUN MICROSYSTEMS, INC., BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.
*/
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/PEX5/PEXlib.h>
#include <stdio.h>
/* utility functions we use */
extern void find_best_visual();
extern int get_standard_colormap();
extern void set_stdcmap_approx();
extern Window create_window();
extern PEXRenderer setup_renderer();
extern void outputCommands();
extern void misc_setup();
extern char *optarg; /* for getopt */
extern int optind, opterr;
extern char test_description[];
int rendering_loops = 1;
#define ERROR_LEN 80
char error_string[ERROR_LEN];
#define IMM_MODE_SPT(info) \
(((info)->subset_info & 0xFFFF) == PEXCompleteImplementation \
|| (info)->subset_info & PEXImmediateMode)
main (argc, argv)
int argc;
char *argv[];
{
Display *dpy;
Window window;
XVisualInfo vis_info;
XStandardColormap cmap_info;
PEXColorApproxEntry capx_info;
PEXExtensionInfo *pexinfo;
PEXRenderer renderer;
PEXStructure structure;
int c;
int i;
int x = 50;
int y = 50;
int w = 200;
int h = 200;
if (!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "Could not open display %s\n",
DisplayString(dpy));
exit(1);
}
if (PEXInitialize(dpy, &pexinfo, ERROR_LEN, error_string)) {
fprintf(stderr, "%s\n", error_string);
exit(2);
}
/* process command line options */
while ((c = getopt(argc,argv,"iv")) != EOF) {
switch(c) {
case 'i':
break;
case 'v':
printf("\n%s\n",test_description);
break;
case '?':
printf("usage: %s: -[iv]\n",argv[0]);
printf("-i immediate mode\n");
printf("-v verbose mode (test descriptions)\n");
printf("default immediate mode\n");
exit(1);
}
}
/* Determine the best visual to use */
find_best_visual(dpy, &vis_info);
/* Get a standard colormap for the visual */
if (!get_standard_colormap(dpy, &vis_info, &cmap_info)) {
if (!create_colormap(dpy, &vis_info, &cmap_info, &capx_info)) {
fprintf(stderr, "Fails to create colormap\n");
exit(3);
}
} else
set_stdcmap_approx(&vis_info, &cmap_info, &capx_info);
/* Handle window geometry string if present */
{
int parse_status;
int window_x, window_y;
unsigned int window_width, window_height;
int i;
for (i=1; i<argc; i++)
{
if (argv[i][0] == '=')
{
parse_status = XParseGeometry(argv[i], &window_x, &window_y,
&window_width, &window_height);
if (parse_status & XValue)
x = window_x;
if (parse_status & YValue)
y = window_y;
if (parse_status & WidthValue)
w = window_width;
if (parse_status & HeightValue)
h = window_height;
}
}
}
/* Set up the window */
window = setup_window(dpy, &vis_info, &cmap_info, x,y,w,h);
setup_LUT(dpy, window, &capx_info);
pexinfo = PEXGetExtensionInfo(dpy);
if (!IMM_MODE_SPT(pexinfo)) {
fprintf(stderr, "No immediate mode support\n");
exit(4);
}
renderer = setup_renderer(dpy, window);
misc_setup(dpy, window, renderer);
for (i = 0; i < rendering_loops; i++) {
PEXBeginRendering(dpy, window, renderer);
outputCommands(dpy, (XID)renderer, PEXOCRender);
PEXEndRendering(dpy, renderer, True);
}
XFlush(dpy);
XSync(dpy, 0);
testproc(dpy,window,0,0,w,h);
XCloseDisplay(dpy);
return 0;
}
|