BRL-CAD
if_TEMPLATE.c
Go to the documentation of this file.
1 /* I F _ T E M P L A T E . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup if */
21 /** @{ */
22 /** @file if_TEMPLATE.c
23  *
24  * How to add a new device interface:
25  *
26  * Copy this file to if_devname.c
27  *
28  * Do a global replace of DEVNAME with your devname.
29  * (In the interest of non-flexnames, DEVNAME should be no more than
30  * three characters; except perhaps for DEVNAME_interface)
31  *
32  * Fill in the device description, max width and height, default width
33  * and height, and shortname (what you will look it up as).
34  *
35  * Set the unimplemented functions to "fb_null" (and remove the
36  * skeletons if you're tidy).
37  *
38  * Set DEVNAME_readrect to fb_sim_readrect, and DEVNAME_writerect to
39  * fb_sim_writerect, if not implemented.
40  *
41  * Make DEVNAME_free call DEVNAME_close if not implemented.
42  *
43  * Go add an "ifdef IF_DEVNAME" to fb_generic.c (two places).
44  *
45  * Add defines to CMakeLists.txt
46  *
47  * Replace this header.
48  */
49 /** @} */
50 
51 #include "common.h"
52 
53 #include <stdio.h>
54 
55 #include "fb.h"
56 
57 
58 HIDDEN int
59 DEVNAME_open(fb *ifp, const char *file, int width, int height)
60 {
61  FB_CK_fb(ifp);
62  return 0;
63 }
64 
65 
66 HIDDEN int
68 {
69  return 0;
70 }
71 
72 
73 HIDDEN int
74 DEVNAME_clear(fb *ifp, unsigned char *pp)
75 {
76  return 0;
77 }
78 
79 
80 HIDDEN int
81 DEVNAME_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
82 {
83  return (int)count;
84 }
85 
86 
87 HIDDEN int
88 DEVNAME_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
89 {
90  return (int)count;
91 }
92 
93 
94 HIDDEN int
96 {
97  return 0;
98 }
99 
100 
101 HIDDEN int
102 DEVNAME_wmap(fb *ifp, const ColorMap *cmp)
103 {
104  return 0;
105 }
106 
107 
108 HIDDEN int
109 DEVNAME_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
110 {
111  return 0;
112 }
113 
114 
115 HIDDEN int
116 DEVNAME_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
117 {
118  return 0;
119 }
120 
121 
122 HIDDEN int
123 DEVNAME_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
124 {
125  return 0;
126 }
127 
128 
129 HIDDEN int
130 DEVNAME_cursor(fb *ifp, int mode, int x, int y)
131 {
132  return 0;
133 }
134 
135 
136 HIDDEN int
137 DEVNAME_getcursor(fb *ifp, int *mode, int *x, int *y)
138 {
139  return 0;
140 }
141 
142 
143 HIDDEN int
144 DEVNAME_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
145 {
146  return width*height;
147 }
148 
149 
150 HIDDEN int
151 DEVNAME_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
152 {
153  return width*height;
154 }
155 
156 
157 HIDDEN int
159 {
160  return 0;
161 }
162 
163 
164 HIDDEN int
166 {
167  return 0;
168 }
169 
170 
171 HIDDEN int
173 {
174  return 0;
175 }
176 
177 
178 HIDDEN int
180 {
181  fb_log("Description: %s\n", DEVNAME_interface.if_type);
182  fb_log("Device: %s\n", ifp->if_name);
183  fb_log("Max width/height: %d %d\n",
186  fb_log("Default width/height: %d %d\n",
189  return 0;
190 }
191 
192 
193 /* This is the ONLY thing that we normally "export" */
195  0, /* magic number slot */
196  DEVNAME_open, /* open device */
197  DEVNAME_close, /* close device */
198  DEVNAME_clear, /* clear device */
199  DEVNAME_read, /* read pixels */
200  DEVNAME_write, /* write pixels */
201  DEVNAME_rmap, /* read colormap */
202  DEVNAME_wmap, /* write colormap */
203  DEVNAME_view, /* set view */
204  DEVNAME_getview, /* get view */
205  DEVNAME_setcursor, /* define cursor */
206  DEVNAME_cursor, /* set cursor */
207  DEVNAME_getcursor, /* get cursor */
208  DEVNAME_readrect, /* read rectangle */
209  DEVNAME_writerect, /* write rectangle */
210  DEVNAME_bwreadrect, /* read bw rectangle */
211  DEVNAME_bwwriterect, /* write bw rectangle */
212  DEVNAME_poll, /* process events */
213  DEVNAME_flush, /* flush output */
214  DEVNAME_free, /* free resources */
215  DEVNAME_help, /* help message */
216  "Device description", /* device description */
217  0, /* max width */
218  0, /* max height */
219  "/dev/shortname", /* short device name */
220  0, /* default/current width */
221  0, /* default/current height */
222  -1, /* select file desc */
223  -1, /* file descriptor */
224  1, 1, /* zoom */
225  0, 0, /* window center */
226  0, 0, 0, /* cursor */
227  PIXEL_NULL, /* page_base */
228  PIXEL_NULL, /* page_curp */
229  PIXEL_NULL, /* page_endp */
230  -1, /* page_no */
231  0, /* page_dirty */
232  0L, /* page_curpos */
233  0L, /* page_pixels */
234  0 /* debug */
235 };
236 
237 
238 /*
239  * Local Variables:
240  * mode: C
241  * tab-width: 8
242  * indent-tabs-mode: t
243  * c-file-style: "stroustrup"
244  * End:
245  * ex: shiftwidth=4 tabstop=8
246  */
HIDDEN int DEVNAME_open(fb *ifp, const char *file, int width, int height)
Definition: if_TEMPLATE.c:59
void fb_log(const char *fmt,...) _BU_ATTR_PRINTF12
Definition: fb_log.c:42
HIDDEN int DEVNAME_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
Definition: if_TEMPLATE.c:123
HIDDEN int DEVNAME_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
Definition: if_TEMPLATE.c:151
#define PIXEL_NULL
Definition: fb.h:89
HIDDEN int DEVNAME_free(fb *ifp)
Definition: if_TEMPLATE.c:172
Header file for the BRL-CAD common definitions.
HIDDEN int DEVNAME_flush(fb *ifp)
Definition: if_TEMPLATE.c:165
int if_max_width
max device width
Definition: fb_private.h:111
ustring width
#define HIDDEN
Definition: common.h:86
char * if_type
what "open" calls it
Definition: fb_private.h:110
HIDDEN int DEVNAME_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
Definition: if_TEMPLATE.c:88
HIDDEN int DEVNAME_getcursor(fb *ifp, int *mode, int *x, int *y)
Definition: if_TEMPLATE.c:137
HIDDEN int DEVNAME_close(fb *ifp)
Definition: if_TEMPLATE.c:67
int if_max_height
max device height
Definition: fb_private.h:112
HIDDEN int DEVNAME_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
Definition: if_TEMPLATE.c:109
HIDDEN int DEVNAME_help(fb *ifp)
Definition: if_TEMPLATE.c:179
Definition: fb.h:82
HIDDEN int DEVNAME_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
Definition: if_TEMPLATE.c:116
HIDDEN int DEVNAME_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
Definition: if_TEMPLATE.c:81
HIDDEN int DEVNAME_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
Definition: if_TEMPLATE.c:144
HIDDEN int DEVNAME_clear(fb *ifp, unsigned char *pp)
Definition: if_TEMPLATE.c:74
HIDDEN int DEVNAME_cursor(fb *ifp, int mode, int x, int y)
Definition: if_TEMPLATE.c:130
A frame-buffer IO structure.
Definition: fb_private.h:80
int if_width
current values
Definition: fb_private.h:115
char * if_name
what the user called it
Definition: fb_private.h:114
HIDDEN int DEVNAME_poll(fb *ifp)
Definition: if_TEMPLATE.c:158
fb DEVNAME_interface
Definition: if_TEMPLATE.c:194
HIDDEN int DEVNAME_rmap(fb *ifp, ColorMap *cmp)
Definition: if_TEMPLATE.c:95
HIDDEN int DEVNAME_wmap(fb *ifp, const ColorMap *cmp)
Definition: if_TEMPLATE.c:102