Compare commits
17
Commits
subprocess
...
osg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b18f380fc3 | ||
|
|
26a01f3835 | ||
|
|
f36bff584d | ||
|
|
eeacc176e7 | ||
|
|
0633e1a049 | ||
|
|
567f20d7ad | ||
|
|
e2d9a70541 | ||
|
|
7e1f499fef | ||
|
|
e374a44685 | ||
|
|
8268d67295 | ||
|
|
0a23f5c8db | ||
|
|
dee77027b8 | ||
|
|
2abc2e65f1 | ||
|
|
dcadc7228c | ||
|
|
484e15b389 | ||
|
|
ae11b2bf34 | ||
|
|
55fa867f47 |
+1
-9
@@ -1027,15 +1027,7 @@ endif(NOT Qt5Widgets_FOUND AND BRLCAD_ENABLE_QT)
|
||||
mark_as_advanced(Qt5Widgets_DIR)
|
||||
|
||||
# Enable features requiring OpenSceneGraph
|
||||
option(BRLCAD_ENABLE_OSG "Enable features requiring OpenSceneGraph" OFF)
|
||||
mark_as_advanced(BRLCAD_ENABLE_OSG)
|
||||
if(BRLCAD_ENABLE_OSG)
|
||||
find_package(OpenSceneGraph 3.2.0 REQUIRED osgText osgViewer)
|
||||
if(NOT OSG_LIBRARY)
|
||||
message("OpenSceneGraph interface requested, but OSG is not found - disabling")
|
||||
set(BRLCAD_ENABLE_OSG OFF)
|
||||
endif(NOT OSG_LIBRARY)
|
||||
endif(BRLCAD_ENABLE_OSG)
|
||||
option(BRLCAD_ENABLE_OSG "Enable features requiring OpenSceneGraph" ${OPENGL_FOUND})
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# The following are fine-grained options for enabling/disabling compiler
|
||||
|
||||
@@ -536,6 +536,16 @@ first for a system version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
Aliases: ENABLE_ZLIB, ENABLE_LIBZ
|
||||
|
||||
|
||||
--- BRLCAD_FREETYPE ---
|
||||
|
||||
Option for enabling and disabling compilation of the FreeType
|
||||
libraries provided with BRL-CAD's source code. Default is AUTO, responsive to
|
||||
the toplevel BRLCAD_BUNDLED_LIBS option and testing first for a system
|
||||
version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
|
||||
Aliases: ENABLE_FREETYPE
|
||||
|
||||
|
||||
--- BRLCAD_TERMLIB ---
|
||||
|
||||
Option for enabling and disabling compilation of the termlib library
|
||||
@@ -703,6 +713,16 @@ AUTO.
|
||||
Aliases: ENABLE_VDS
|
||||
|
||||
|
||||
--- BRLCAD_OSG ---
|
||||
|
||||
Option for enabling and disabling compilation of the OpenSceneGraph
|
||||
libraries provided with BRL-CAD's source code. Default is AUTO, responsive to
|
||||
the toplevel BRLCAD_BUNDLED_LIBS option and testing first for a system
|
||||
version if BRLCAD_BUNDLED_LIBS is also AUTO.
|
||||
|
||||
Aliases: ENABLE_OPENSCENEGRAPH
|
||||
|
||||
|
||||
--- BRLCAD_GDIAM ---
|
||||
|
||||
Option for enabling and disabling compilation of the libgdiam approximate
|
||||
|
||||
@@ -126,6 +126,10 @@ do
|
||||
shift;;
|
||||
--disable-libz) options="$options -DBRLCAD_ZLIB=SYSTEM";
|
||||
shift;;
|
||||
--enable-freetype) options="$options -DBRLCAD_FREETYPE=BUNDLED";
|
||||
shift;;
|
||||
--disable-freetype) options="$options -DBRLCAD_FREETYPE=SYSTEM";
|
||||
shift;;
|
||||
--enable-termlib) options="$options -DBRLCAD_TERMLIB=BUNDLED";
|
||||
shift;;
|
||||
--disable-termlib) options="$options -DBRLCAD_TERMLIB=SYSTEM";
|
||||
@@ -190,6 +194,10 @@ do
|
||||
shift;;
|
||||
--disable-vds) options="$options -DBRLCAD_VDS=SYSTEM";
|
||||
shift;;
|
||||
--enable-openscenegraph) options="$options -DBRLCAD_OSG=BUNDLED";
|
||||
shift;;
|
||||
--disable-openscenegraph) options="$options -DBRLCAD_OSG=SYSTEM";
|
||||
shift;;
|
||||
--enable-gdiam) options="$options -DBRLCAD_GDIAM=BUNDLED";
|
||||
shift;;
|
||||
--disable-gdiam) options="$options -DBRLCAD_GDIAM=SYSTEM";
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
<funcsynopsis>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef><function>FBIO</function> *fb_open</funcdef>
|
||||
<funcdef><function>fb</function> *fb_open</funcdef>
|
||||
<paramdef>* <parameter>fbfile</parameter></paramdef>
|
||||
<paramdef>int fb_close ( fbp ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_read ( fbp , x , y , addr , count ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_close ( fbp ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_read ( fbp , x , y , addr , count ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>RGBpixel <parameter>*addr;</parameter></paramdef>
|
||||
<paramdef>long <parameter>count;</parameter></paramdef>
|
||||
</funcprototype>
|
||||
@@ -35,7 +35,7 @@
|
||||
<paramdef>* <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>RGBpixel * <parameter>addr</parameter></paramdef>
|
||||
<paramdef>long <parameter>count</parameter></paramdef>
|
||||
<paramdef>int fb_rmap ( fbp , cmap ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_rmap ( fbp , cmap ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>ColorMap * <parameter>cmap</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
@@ -78,8 +78,8 @@
|
||||
<funcprototype>
|
||||
<funcdef>int <function>fb_cursor</function></funcdef>
|
||||
<paramdef>* <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_scursor ( fbp , mode , x , y ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_setcursor ( fbp , bits , xbits , ybits , xorig , yorig ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_scursor ( fbp , mode , x , y ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_setcursor ( fbp , bits , xbits , ybits , xorig , yorig ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>unsigned char <parameter>bits</parameter>[]</paramdef>
|
||||
<paramdef>int <parameter>xbits</parameter>, <parameter>ybits</parameter>;</paramdef>
|
||||
<paramdef>int <parameter>xorig</parameter>, <parameter>yorig</parameter>;</paramdef>
|
||||
@@ -88,14 +88,14 @@
|
||||
<funcprototype>
|
||||
<funcdef>int <function>fb_window</function></funcdef>
|
||||
<paramdef>* <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_zoom ( fbp , x , y ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>/ *Buffered frame buffer I/O: */ int fb_ioinit ( fbp ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int fb_zoom ( fbp , x , y ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>/ *Buffered frame buffer I/O: */ int fb_ioinit ( fbp ) fb * <parameter>fbp</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int <function>fb_seek</function></funcdef>
|
||||
<paramdef>* <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>void fb_tell ( fbp , xp , yp ) FBIO * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>void fb_tell ( fbp , xp , yp ) fb * <parameter>fbp</parameter></paramdef>
|
||||
<paramdef>int *xp , * <parameter>yp</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
@@ -168,10 +168,10 @@
|
||||
See below for more details. The <emphasis remap="I">width</emphasis>
|
||||
and <emphasis remap="I">height</emphasis> parameters specify the initial
|
||||
size of display desired. If these are zero the default sizes for that
|
||||
device will be used. On a successful open, the frame buffer I/O (FBIO)
|
||||
device will be used. On a successful open, the frame buffer I/O (fb)
|
||||
structure pointer is returned. This structure contains size you were
|
||||
actually given, as well as the maximum possible size for the selected
|
||||
device. A return of FBIO_NULL indicates failure.
|
||||
device. A return of fb_NULL indicates failure.
|
||||
</para>
|
||||
<para><emphasis remap="I">Fb_close</emphasis> simply closes the frame buffer.
|
||||
</para>
|
||||
@@ -214,11 +214,11 @@
|
||||
</para>
|
||||
<para><emphasis remap="I">Fb_gettype</emphasis>
|
||||
returns a pointer to a string describing the frame buffer
|
||||
specified by the FBIO pointer.
|
||||
specified by the fb pointer.
|
||||
</para>
|
||||
<para><emphasis remap="I">Fb_getwidth</emphasis>
|
||||
and <emphasis remap="I">Fb_getheight</emphasis>
|
||||
returns the current size of the FBIO frame buffer.
|
||||
returns the current size of the fb frame buffer.
|
||||
</para>
|
||||
<para>
|
||||
The following routines work in conjunction with those described above
|
||||
@@ -433,7 +433,7 @@
|
||||
<emphasis remap="I">fb_flush</emphasis>
|
||||
return -1 to indicate failure.
|
||||
<emphasis remap="I">Fb_open</emphasis>
|
||||
returns FBIO_NULL to indicate failure, and a non-null FBIO structure pointer
|
||||
returns fb_NULL to indicate failure, and a non-null fb structure pointer
|
||||
upon success.
|
||||
<emphasis remap="I">fb_read</emphasis>,
|
||||
and
|
||||
|
||||
@@ -3850,7 +3850,7 @@ view_pixel(ap)
|
||||
register struct application *ap;
|
||||
{
|
||||
....
|
||||
if( fbp != FBIO_NULL ) {
|
||||
if( fbp != fb_NULL ) {
|
||||
/* Framebuffer output */
|
||||
RES_ACQUIRE( &rt_g.res_syscall );
|
||||
fb_write( fbp, ap->a_x, ap->a_y, (char *)p, 1 );
|
||||
@@ -3891,7 +3891,7 @@ followed a little later by the actual output section:
|
||||
|
||||
<p>
|
||||
case BUFMODE_DYNAMIC:
|
||||
if( fbp != FBIO_NULL ) {
|
||||
if( fbp != fb_NULL ) {
|
||||
RES_ACQUIRE( &rt_g.res_syscall );
|
||||
fb_write( fbp, 0, ap->a_y,
|
||||
scanline[ap->a_y].sl_buf, width );
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
add_subdirectory(bu)
|
||||
add_subdirectory(dm)
|
||||
add_subdirectory(rt)
|
||||
add_subdirectory(fb)
|
||||
|
||||
set(public_hdrs
|
||||
RtServerImpl.h
|
||||
@@ -26,7 +27,6 @@ set(public_hdrs
|
||||
dm.h
|
||||
dvec.h
|
||||
fb.h
|
||||
fbio.h
|
||||
fbserv_obj.h
|
||||
fft.h
|
||||
gcv.h
|
||||
|
||||
@@ -198,6 +198,7 @@ __BEGIN_DECLS
|
||||
#define FB_MAGIC 0xfbfb00fb /**< ???? */
|
||||
#define FB_WGL_MAGIC 0x574f4642 /**< WOFB */
|
||||
#define FB_OGL_MAGIC 0x584f4642 /**< XOFB */
|
||||
#define FB_OSG_MAGIC 0x4f534642 /**< OSFB */
|
||||
#define FB_X24_MAGIC 0x58324642 /**< X2FB */
|
||||
#define FB_TK_MAGIC 0x544b4642 /**< TKFB */
|
||||
#define FB_QT_MAGIC 0x51544642 /**< QTFB */
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ struct dm {
|
||||
int (*dm_getDisplayImage)(struct dm *dmp, unsigned char **image);
|
||||
void (*dm_reshape)(struct dm *dmp, int width, int height);
|
||||
int (*dm_makeCurrent)(struct dm *dmp);
|
||||
int (*dm_openFb)(struct dm *dmp, FBIO *ifp);
|
||||
int (*dm_openFb)(struct dm *dmp, fb *ifp);
|
||||
unsigned long dm_id; /**< @brief window id */
|
||||
int dm_displaylist; /**< @brief !0 means device has displaylist */
|
||||
int dm_stereo; /**< @brief stereo flag */
|
||||
|
||||
@@ -187,7 +187,7 @@ null_processEvents(struct dm *dmp);
|
||||
|
||||
|
||||
DM_EXPORT extern int
|
||||
null_openFb(struct dm *dmp, FBIO *ifp);
|
||||
null_openFb(struct dm *dmp, fb *ifp);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
+17
-3
@@ -31,6 +31,7 @@
|
||||
#include "common.h"
|
||||
|
||||
#include "bu/vls.h"
|
||||
#include "dm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <iostream>
|
||||
@@ -38,9 +39,14 @@
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osg/Timer>
|
||||
|
||||
#include <osgViewer/api/X11/GraphicsWindowX11>
|
||||
#if defined(DM_WIN32)
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/CompositeViewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <osgViewer/api/Win32/GraphicsWindowWin32>
|
||||
#else
|
||||
# include <osgViewer/api/X11/GraphicsWindowX11>
|
||||
#endif
|
||||
|
||||
#include <osgText/Font>
|
||||
@@ -91,12 +97,20 @@ struct osg_vars {
|
||||
#ifdef __cplusplus
|
||||
osg::ref_ptr<osg::GraphicsContext> graphicsContext;
|
||||
osg::Timer *timer;
|
||||
osgViewer::Viewer *testviewer;
|
||||
osg::Group *osg_root;
|
||||
#endif
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern void osg_fogHint();
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void osg_fogHint(struct dm *dmp, int fastfog);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
+111
-119
@@ -28,10 +28,17 @@
|
||||
#ifndef FB_H
|
||||
#define FB_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <limits.h> /* For INT_MAX */
|
||||
#include <stdlib.h>
|
||||
#ifndef FB_EXPORT
|
||||
# if defined(FB_DLL_EXPORTS) && defined(FB_DLL_IMPORTS)
|
||||
# error "Only FB_DLL_EXPORTS or FB_DLL_IMPORTS can be defined, not both."
|
||||
# elif defined(FB_DLL_EXPORTS)
|
||||
# define FB_EXPORT __declspec(dllexport)
|
||||
# elif defined(FB_DLL_IMPORTS)
|
||||
# define FB_EXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define FB_EXPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Needed for fd_set, avoid including sys/select.h outright since it
|
||||
@@ -47,141 +54,127 @@
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "fbio.h"
|
||||
|
||||
#include "bu/bu_tcl.h"
|
||||
#include "bu/magic.h"
|
||||
#include "bu/vls.h"
|
||||
|
||||
/* Library entry points which are macros.
|
||||
*
|
||||
* FIXME: turn these into proper functions so we can appropriately
|
||||
* avoid dereferencing a NULL _ifp or calling an invalid callback.
|
||||
/**
|
||||
* Format of disk pixels is .pix raw image files. Formerly used as
|
||||
* arguments to many of the library routines, but has fallen into
|
||||
* disuse due to the difficulties with ANSI function prototypes, and
|
||||
* the fact that arrays are not real types in C. The most notable
|
||||
* problem is that of passing a pointer to an array of RGBpixel. It
|
||||
* looks doubly dimensioned, but isn't.
|
||||
*/
|
||||
#define fb_gettype(_ifp) (_ifp->if_type)
|
||||
#define fb_getwidth(_ifp) (_ifp->if_width)
|
||||
#define fb_getheight(_ifp) (_ifp->if_height)
|
||||
#define fb_poll(_ifp) (*_ifp->if_poll)(_ifp)
|
||||
#define fb_help(_ifp) (*_ifp->if_help)(_ifp)
|
||||
#define fb_free(_ifp) (*_ifp->if_free)(_ifp)
|
||||
#define fb_clear(_ifp, _pp) (*_ifp->if_clear)(_ifp, _pp)
|
||||
#define fb_read(_ifp, _x, _y, _pp, _ct) (*_ifp->if_read)(_ifp, _x, _y, _pp, _ct)
|
||||
#define fb_write(_ifp, _x, _y, _pp, _ct) (*_ifp->if_write)(_ifp, _x, _y, _pp, _ct)
|
||||
#define fb_rmap(_ifp, _cmap) (*_ifp->if_rmap)(_ifp, _cmap)
|
||||
#define fb_wmap(_ifp, _cmap) (*_ifp->if_wmap)(_ifp, _cmap)
|
||||
#define fb_view(_ifp, _xc, _yc, _xz, _yz) (*_ifp->if_view)(_ifp, _xc, _yc, _xz, _yz)
|
||||
#define fb_getview(_ifp, _xcp, _ycp, _xzp, _yzp) (*_ifp->if_getview)(_ifp, _xcp, _ycp, _xzp, _yzp)
|
||||
#define fb_setcursor(_ifp, _bits, _xb, _yb, _xo, _yo) (*_ifp->if_setcursor)(_ifp, _bits, _xb, _yb, _xo, _yo)
|
||||
#define fb_cursor(_ifp, _mode, _x, _y) (*_ifp->if_cursor)(_ifp, _mode, _x, _y)
|
||||
#define fb_getcursor(_ifp, _modep, _xp, _yp) (*_ifp->if_getcursor)(_ifp, _modep, _xp, _yp)
|
||||
#define fb_readrect(_ifp, _xmin, _ymin, _width, _height, _pp) (*_ifp->if_readrect)(_ifp, _xmin, _ymin, _width, _height, _pp)
|
||||
#define fb_writerect(_ifp, _xmin, _ymin, _width, _height, _pp) (*_ifp->if_writerect)(_ifp, _xmin, _ymin, _width, _height, _pp)
|
||||
#define fb_bwreadrect(_ifp, _xmin, _ymin, _width, _height, _pp) (*_ifp->if_bwreadrect)(_ifp, _xmin, _ymin, _width, _height, _pp)
|
||||
#define fb_bwwriterect(_ifp, _xmin, _ymin, _width, _height, _pp) (*_ifp->if_bwwriterect)(_ifp, _xmin, _ymin, _width, _height, _pp)
|
||||
typedef unsigned char RGBpixel[3];
|
||||
|
||||
|
||||
/**
|
||||
* These generic color maps have up to 16 bits of significance,
|
||||
* left-justified in a short. Think of this as fixed-point values
|
||||
* from 0 to 1.
|
||||
*/
|
||||
/* FIXME: ColorMap is same as RLEColorMap defined in 'orle.h' */
|
||||
typedef struct {
|
||||
unsigned short cm_red[256];
|
||||
unsigned short cm_green[256];
|
||||
unsigned short cm_blue[256];
|
||||
} ColorMap;
|
||||
|
||||
|
||||
#define PIXEL_NULL (unsigned char *) 0
|
||||
#define RGBPIXEL_NULL (unsigned char *) 0
|
||||
#define COLORMAP_NULL (ColorMap *) 0
|
||||
|
||||
/* Use a typedef to hide the details of the framebuffer structure */
|
||||
typedef struct fb_internal fb;
|
||||
#define FB_NULL (fb *) 0
|
||||
|
||||
/**
|
||||
* assert the integrity of a framebuffer struct.
|
||||
*/
|
||||
#define FB_CK_FB(_p) BU_CKMAG(_p, FB_MAGIC, "FB")
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Library entry points which are true functions. */
|
||||
FB_EXPORT extern void fb_configureWindow(FBIO *, int, int);
|
||||
FB_EXPORT extern FBIO *fb_open(const char *file, int _width, int _height);
|
||||
FB_EXPORT extern int fb_close(FBIO *ifp);
|
||||
FB_EXPORT extern int fb_close_existing(FBIO *ifp);
|
||||
/* Library entry points */
|
||||
|
||||
FB_EXPORT fb *fb_get();
|
||||
FB_EXPORT void fb_put(fb *ifp);
|
||||
FB_EXPORT extern char *fb_gettype(fb *ifp);
|
||||
FB_EXPORT extern int fb_get_max_width(fb *ifp);
|
||||
FB_EXPORT extern int fb_get_max_height(fb *ifp);
|
||||
FB_EXPORT extern int fb_getwidth(fb *ifp);
|
||||
FB_EXPORT extern int fb_getheight(fb *ifp);
|
||||
FB_EXPORT extern int fb_poll(fb *ifp);
|
||||
FB_EXPORT extern int fb_help(fb *ifp);
|
||||
FB_EXPORT extern int fb_free(fb *ifp);
|
||||
FB_EXPORT extern int fb_clear(fb *ifp, unsigned char *pp);
|
||||
FB_EXPORT extern ssize_t fb_read(fb *ifp, int x, int y, unsigned char *pp, size_t count);
|
||||
FB_EXPORT extern ssize_t fb_write(fb *ifp, int x, int y, const unsigned char *pp, size_t count);
|
||||
FB_EXPORT extern int fb_rmap(fb *ifp, ColorMap *cmap);
|
||||
FB_EXPORT extern int fb_wmap(fb *ifp, const ColorMap *cmap);
|
||||
FB_EXPORT extern int fb_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom);
|
||||
FB_EXPORT extern int fb_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom);
|
||||
FB_EXPORT extern int fb_setcursor(fb *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo);
|
||||
FB_EXPORT extern int fb_cursor(fb *ifp, int mode, int x, int y);
|
||||
FB_EXPORT extern int fb_getcursor(fb *ifp, int *mode, int *x, int *y);
|
||||
FB_EXPORT extern int fb_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp);
|
||||
FB_EXPORT extern int fb_bwreadrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_bwwriterect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp);
|
||||
|
||||
FB_EXPORT extern fb *fb_open(const char *file, int _width, int _height);
|
||||
FB_EXPORT extern int fb_close(fb *ifp);
|
||||
FB_EXPORT extern int fb_close_existing(fb *ifp);
|
||||
FB_EXPORT extern int fb_genhelp(void);
|
||||
FB_EXPORT extern int fb_ioinit(FBIO *ifp);
|
||||
FB_EXPORT extern int fb_seek(FBIO *ifp, int x, int y);
|
||||
FB_EXPORT extern int fb_tell(FBIO *ifp, int *xp, int *yp);
|
||||
FB_EXPORT extern int fb_rpixel(FBIO *ifp, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_wpixel(FBIO *ifp, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_flush(FBIO *ifp);
|
||||
FB_EXPORT extern int fb_ioinit(fb *ifp);
|
||||
FB_EXPORT extern int fb_seek(fb *ifp, int x, int y);
|
||||
FB_EXPORT extern int fb_tell(fb *ifp, int *xp, int *yp);
|
||||
FB_EXPORT extern int fb_rpixel(fb *ifp, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_wpixel(fb *ifp, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_flush(fb *ifp);
|
||||
FB_EXPORT extern int fb_configure_window(fb *, int, int);
|
||||
FB_EXPORT extern int fb_refresh(fb *ifp, int x, int y, int w, int h);
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
FB_EXPORT extern void fb_log(const char *fmt, ...) _BU_ATTR_PRINTF12;
|
||||
#endif
|
||||
FB_EXPORT extern int fb_null(FBIO *ifp);
|
||||
FB_EXPORT extern int fb_null_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig);
|
||||
FB_EXPORT extern int fb_null(fb *ifp);
|
||||
FB_EXPORT extern int fb_null_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig);
|
||||
|
||||
/* utility functions */
|
||||
FB_EXPORT extern int fb_common_file_size(size_t *widthp, size_t *heightp, const char *filename, int pixel_size);
|
||||
FB_EXPORT extern int fb_common_image_size(size_t *widthp, size_t *heightp, size_t npixels);
|
||||
FB_EXPORT extern int fb_common_name_size(size_t *widthp, size_t *heightp, const char *name);
|
||||
FB_EXPORT extern int fb_write_fp(FBIO *ifp, FILE *fp, int req_width, int req_height, int crunch, int inverse, struct bu_vls *result);
|
||||
FB_EXPORT extern int fb_read_fd(FBIO *ifp, int fd, int file_width, int file_height, int file_xoff, int file_yoff, int scr_width, int scr_height, int scr_xoff, int scr_yoff, int fileinput, char *file_name, int one_line_only, int multiple_lines, int autosize, int inverse, int clear, int zoom, struct bu_vls *result);
|
||||
FB_EXPORT extern int fb_write_fp(fb *ifp, FILE *fp, int req_width, int req_height, int crunch, int inverse, struct bu_vls *result);
|
||||
FB_EXPORT extern int fb_read_fd(fb *ifp, int fd, int file_width, int file_height, int file_xoff, int file_yoff, int scr_width, int scr_height, int scr_xoff, int scr_yoff, int fileinput, char *file_name, int one_line_only, int multiple_lines, int autosize, int inverse, int clear, int zoom, struct bu_vls *result);
|
||||
|
||||
FB_EXPORT extern void fb_set_interface(fb *ifp, const char *interface_type);
|
||||
FB_EXPORT extern void fb_set_name(fb *ifp, const char *name);
|
||||
FB_EXPORT extern char *fb_get_name(fb *ifp);
|
||||
FB_EXPORT extern void fb_set_magic(fb *ifp, uint32_t magic);
|
||||
FB_EXPORT extern long fb_get_pagebuffer_pixel_size(fb *ifp);
|
||||
|
||||
FB_EXPORT extern int fb_is_set_fd(fb *ifp, fd_set *infds);
|
||||
FB_EXPORT extern int fb_set_fd(fb *ifp, fd_set *select_list);
|
||||
FB_EXPORT extern int fb_clear_fd(fb *ifp, fd_set *select_list);
|
||||
|
||||
/* color mapping */
|
||||
FB_EXPORT extern int fb_is_linear_cmap(const ColorMap *cmap);
|
||||
FB_EXPORT extern void fb_make_linear_cmap(ColorMap *cmap);
|
||||
|
||||
/* open_existing functionality. */
|
||||
struct fb_platform_specific {uint32_t magic; void *data;};
|
||||
FB_EXPORT extern struct fb_platform_specific *fb_get_platform_specific(uint32_t magic);
|
||||
FB_EXPORT extern void fb_put_platform_specific(struct fb_platform_specific *fb_p);
|
||||
FB_EXPORT extern fb *fb_open_existing(const char *file, int _width, int _height, struct fb_platform_specific *fb_p);
|
||||
|
||||
/* backward compatibility hacks */
|
||||
FB_EXPORT extern int fb_reset(FBIO *ifp);
|
||||
FB_EXPORT extern int fb_viewport(FBIO *ifp, int left, int top, int right, int bottom);
|
||||
FB_EXPORT extern int fb_window(FBIO *ifp, int xcenter, int ycenter);
|
||||
FB_EXPORT extern int fb_zoom(FBIO *ifp, int xzoom, int yzoom);
|
||||
FB_EXPORT extern int fb_scursor(FBIO *ifp, int mode, int x, int y);
|
||||
|
||||
/*
|
||||
* Some functions and variables we couldn't hide.
|
||||
* Not for general consumption.
|
||||
*/
|
||||
FB_EXPORT extern int _fb_disk_enable;
|
||||
FB_EXPORT extern int fb_sim_readrect(FBIO *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_writerect(FBIO *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_bwreadrect(FBIO *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_bwwriterect(FBIO *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom);
|
||||
FB_EXPORT extern int fb_sim_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom);
|
||||
FB_EXPORT extern int fb_sim_cursor(FBIO *ifp, int mode, int x, int y);
|
||||
FB_EXPORT extern int fb_sim_getcursor(FBIO *ifp, int *mode, int *x, int *y);
|
||||
|
||||
/* FIXME: these IF_* sections need to die. they don't belong in a public header. */
|
||||
|
||||
#ifdef IF_X
|
||||
# ifdef HAVE_X11_XLIB_H
|
||||
# include <X11/Xlib.h>
|
||||
# include <X11/Xutil.h>
|
||||
# endif
|
||||
FB_EXPORT extern int _X24_open_existing(FBIO *ifp, Display *dpy, Window win, Window cwinp, Colormap cmap, XVisualInfo *vip, int width, int height, GC gc);
|
||||
#endif
|
||||
|
||||
#ifdef IF_OGL
|
||||
# ifdef HAVE_X11_XLIB_H
|
||||
# include <X11/Xlib.h>
|
||||
# include <X11/Xutil.h>
|
||||
# endif
|
||||
/* glx.h on Mac OS X (and perhaps elsewhere) defines a slew of
|
||||
* parameter names that shadow system symbols. protect the system
|
||||
* symbols by redefining the parameters prior to header inclusion.
|
||||
*/
|
||||
# define j1 J1
|
||||
# define y1 Y1
|
||||
# define read rd
|
||||
# define index idx
|
||||
# define access acs
|
||||
# define remainder rem
|
||||
# ifdef HAVE_GL_GLX_H
|
||||
# include <GL/glx.h>
|
||||
# endif
|
||||
# undef remainder
|
||||
# undef access
|
||||
# undef index
|
||||
# undef read
|
||||
# undef y1
|
||||
# undef j1
|
||||
# ifdef HAVE_GL_GL_H
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
FB_EXPORT extern int _ogl_open_existing(FBIO *ifp, Display *dpy, Window win, Colormap cmap, XVisualInfo *vip, int width, int height, GLXContext glxc, int double_buffer, int soft_cmap);
|
||||
#endif
|
||||
|
||||
#ifdef IF_WGL
|
||||
# include <windows.h>
|
||||
# include <tk.h>
|
||||
# ifdef HAVE_GL_GL_H
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
FB_EXPORT extern int _wgl_open_existing(FBIO *ifp, Display *dpy, Window win, Colormap cmap, PIXELFORMATDESCRIPTOR *vip, HDC hdc, int width, int height, HGLRC glxc, int double_buffer, int soft_cmap);
|
||||
#endif
|
||||
|
||||
#ifdef IF_QT
|
||||
FB_EXPORT extern int _qt_open_existing(FBIO *ifp, int width, int height, void *qapp, void *qwin, void *qpainter, void *draw, void **qimg);
|
||||
#endif
|
||||
FB_EXPORT extern int fb_reset(fb *ifp);
|
||||
FB_EXPORT extern int fb_viewport(fb *ifp, int left, int top, int right, int bottom);
|
||||
FB_EXPORT extern int fb_window(fb *ifp, int xcenter, int ycenter);
|
||||
FB_EXPORT extern int fb_zoom(fb *ifp, int xzoom, int yzoom);
|
||||
FB_EXPORT extern int fb_scursor(fb *ifp, int mode, int x, int y);
|
||||
|
||||
/*
|
||||
* Copy one RGB pixel to another.
|
||||
@@ -200,14 +193,13 @@ FB_EXPORT extern int _qt_open_existing(FBIO *ifp, int width, int height, void *q
|
||||
/* The presence of Tcl_Interp as an arg prevents giving arg list */
|
||||
FB_EXPORT extern void fb_tcl_setup(void);
|
||||
FB_EXPORT extern int Fb_Init(Tcl_Interp *interp);
|
||||
FB_EXPORT extern int fb_refresh(FBIO *ifp, int x, int y, int w, int h);
|
||||
|
||||
|
||||
/**
|
||||
* report version information about LIBFB
|
||||
*/
|
||||
FB_EXPORT extern const char *fb_version(void);
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* FB_H */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
set(fb_noinstall_headers
|
||||
fb_platform_specific.h
|
||||
)
|
||||
|
||||
CMAKEFILES(${fb_noinstall_headers})
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
@@ -0,0 +1,151 @@
|
||||
/* F B _ P L A T F O R M _ S P E C I F I C . H
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @addtogroup if */
|
||||
/** @{*/
|
||||
/** @file fb_platform_specific.h
|
||||
*
|
||||
* Structure holding information necessary for embedding a
|
||||
* framebuffer in an X11 parent window. This is NOT public API
|
||||
* for libfb, and is not guaranteed to be stable from one
|
||||
* release to the next.
|
||||
*
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
#ifdef FB_USE_INTERNAL_API
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef IF_X
|
||||
#include <X11/X.h>
|
||||
#ifdef HAVE_X11_XLIB_H
|
||||
# include <X11/Xlib.h>
|
||||
# include <X11/Xutil.h>
|
||||
#endif
|
||||
|
||||
struct X24_fb_info {
|
||||
Display *dpy;
|
||||
Window win;
|
||||
Window cwinp;
|
||||
Colormap cmap;
|
||||
XVisualInfo *vip;
|
||||
GC gc;
|
||||
};
|
||||
|
||||
#endif /* IF_X */
|
||||
|
||||
#ifdef IF_OGL
|
||||
#include <X11/X.h>
|
||||
#ifdef HAVE_X11_XLIB_H
|
||||
# include <X11/Xlib.h>
|
||||
# include <X11/Xutil.h>
|
||||
#endif
|
||||
/* glx.h on Mac OS X (and perhaps elsewhere) defines a slew of
|
||||
* * * parameter names that shadow system symbols. protect the system
|
||||
* * * symbols by redefining the parameters prior to header inclusion.
|
||||
* * */
|
||||
# define j1 J1
|
||||
# define y1 Y1
|
||||
# define read rd
|
||||
# define index idx
|
||||
# define access acs
|
||||
# define remainder rem
|
||||
# ifdef HAVE_GL_GLX_H
|
||||
# include <GL/glx.h>
|
||||
# endif
|
||||
# undef remainder
|
||||
# undef access
|
||||
# undef index
|
||||
# undef read
|
||||
# undef y1
|
||||
# undef j1
|
||||
# ifdef HAVE_GL_GL_H
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
|
||||
struct ogl_fb_info {
|
||||
Display *dpy;
|
||||
Window win;
|
||||
Colormap cmap;
|
||||
XVisualInfo *vip;
|
||||
GLXContext glxc;
|
||||
int double_buffer;
|
||||
int soft_cmap;
|
||||
};
|
||||
#endif /* IF_OGL */
|
||||
|
||||
|
||||
#ifdef IF_WGL
|
||||
# include <windows.h>
|
||||
/* The wgl interface as currently implemented uses some
|
||||
* X11 types, supplied by Tk. */
|
||||
# include <tk.h>
|
||||
# ifdef HAVE_GL_GL_H
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
|
||||
struct wgl_fb_info {
|
||||
Display *dpy;
|
||||
Window win;
|
||||
Colormap cmap;
|
||||
PIXELFORMATDESCRIPTOR *vip;
|
||||
HDC hdc;
|
||||
HGLRC glxc;
|
||||
int double_buffer;
|
||||
int soft_cmap;
|
||||
};
|
||||
#endif /* IF_WGL */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef IF_QT
|
||||
struct qt_fb_info {
|
||||
void *qapp;
|
||||
void *qwin;
|
||||
void *qpainter;
|
||||
void *draw;
|
||||
void *qimg;
|
||||
};
|
||||
#endif /* IF_QT */
|
||||
|
||||
#ifdef IF_OSG
|
||||
struct osg_fb_info {
|
||||
void *draw;
|
||||
};
|
||||
#endif /* IF_OSG */
|
||||
|
||||
#endif /* FB_USE_INTERNAL_API */
|
||||
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
-185
@@ -1,185 +0,0 @@
|
||||
/* F B I O . H
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2005-2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @addtogroup libfb */
|
||||
/** @{ */
|
||||
/** @file fbio.h
|
||||
*
|
||||
* BRL-CAD Framebuffer Library I/O Interfaces
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FBIO_H
|
||||
#define FBIO_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "bu/magic.h"
|
||||
|
||||
#ifndef FB_EXPORT
|
||||
# if defined(FB_DLL_EXPORTS) && defined(FB_DLL_IMPORTS)
|
||||
# error "Only FB_DLL_EXPORTS or FB_DLL_IMPORTS can be defined, not both."
|
||||
# elif defined(FB_DLL_EXPORTS)
|
||||
# define FB_EXPORT __declspec(dllexport)
|
||||
# elif defined(FB_DLL_IMPORTS)
|
||||
# define FB_EXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define FB_EXPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Format of disk pixels is .pix raw image files. Formerly used as
|
||||
* arguments to many of the library routines, but has fallen into
|
||||
* disuse due to the difficulties with ANSI function prototypes, and
|
||||
* the fact that arrays are not real types in C. The most notable
|
||||
* problem is that of passing a pointer to an array of RGBpixel. It
|
||||
* looks doubly dimensioned, but isn't.
|
||||
*/
|
||||
typedef unsigned char RGBpixel[3];
|
||||
|
||||
|
||||
/**
|
||||
* These generic color maps have up to 16 bits of significance,
|
||||
* left-justified in a short. Think of this as fixed-point values
|
||||
* from 0 to 1.
|
||||
*/
|
||||
/* FIXME: ColorMap is same as RLEColorMap defined in 'orle.h' */
|
||||
typedef struct {
|
||||
unsigned short cm_red[256];
|
||||
unsigned short cm_green[256];
|
||||
unsigned short cm_blue[256];
|
||||
} ColorMap;
|
||||
|
||||
|
||||
#define PIXEL_NULL (unsigned char *) 0
|
||||
#define RGBPIXEL_NULL (unsigned char *) 0
|
||||
#define COLORMAP_NULL (ColorMap *) 0
|
||||
#define FBIO_NULL (FBIO *) 0
|
||||
|
||||
|
||||
/**
|
||||
*@brief
|
||||
* A frame-buffer IO structure.
|
||||
*
|
||||
* One of these is allocated for each active framebuffer. A pointer
|
||||
* to this structure is the first argument to all the library
|
||||
* routines.
|
||||
*/
|
||||
typedef struct FBIO_ {
|
||||
uint32_t if_magic;
|
||||
/* Static information: per device TYPE. */
|
||||
int (*if_open)(struct FBIO_ *ifp, const char *file, int _width, int _height); /**< @brief open device */
|
||||
int (*if_close)(struct FBIO_ *ifp); /**< @brief close device */
|
||||
int (*if_clear)(struct FBIO_ *ifp, unsigned char *pp); /**< @brief clear device */
|
||||
ssize_t (*if_read)(struct FBIO_ *ifp, int x, int y, unsigned char *pp, size_t count); /**< @brief read pixels */
|
||||
ssize_t (*if_write)(struct FBIO_ *ifp, int x, int y, const unsigned char *pp, size_t count); /**< @brief write pixels */
|
||||
int (*if_rmap)(struct FBIO_ *ifp, ColorMap *cmap); /**< @brief read colormap */
|
||||
int (*if_wmap)(struct FBIO_ *ifp, const ColorMap *cmap); /**< @brief write colormap */
|
||||
int (*if_view)(struct FBIO_ *ifp, int xcent, int ycent, int xzoom, int yzoom); /**< @brief set view */
|
||||
int (*if_getview)(struct FBIO_ *ifp, int *xcent, int *ycent, int *xzoom, int *yzoom); /**< @brief get view */
|
||||
int (*if_setcursor)(struct FBIO_ *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo); /**< @brief define cursor */
|
||||
int (*if_cursor)(struct FBIO_ *ifp, int mode, int x, int y); /**< @brief set cursor */
|
||||
int (*if_getcursor)(struct FBIO_ *ifp, int *mode, int *x, int *y); /**< @brief get cursor */
|
||||
int (*if_readrect)(struct FBIO_ *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp); /**< @brief read rectangle */
|
||||
int (*if_writerect)(struct FBIO_ *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp); /**< @brief write rectangle */
|
||||
int (*if_bwreadrect)(struct FBIO_ *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp); /**< @brief read monochrome rectangle */
|
||||
int (*if_bwwriterect)(struct FBIO_ *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp); /**< @brief write rectangle */
|
||||
int (*if_poll)(struct FBIO_ *ifp); /**< @brief handle events */
|
||||
int (*if_flush)(struct FBIO_ *ifp); /**< @brief flush output */
|
||||
int (*if_free)(struct FBIO_ *ifp); /**< @brief free resources */
|
||||
int (*if_help)(struct FBIO_ *ifp); /**< @brief print useful info */
|
||||
char *if_type; /**< @brief what "open" calls it */
|
||||
int if_max_width; /**< @brief max device width */
|
||||
int if_max_height; /**< @brief max device height */
|
||||
/* Dynamic information: per device INSTANCE. */
|
||||
char *if_name; /**< @brief what the user called it */
|
||||
int if_width; /**< @brief current values */
|
||||
int if_height;
|
||||
int if_selfd; /**< @brief select(fd) for input events if >= 0 */
|
||||
/* Internal information: needed by the library. */
|
||||
int if_fd; /**< @brief internal file descriptor */
|
||||
int if_xzoom; /**< @brief zoom factors */
|
||||
int if_yzoom;
|
||||
int if_xcenter; /**< @brief pan position */
|
||||
int if_ycenter;
|
||||
int if_cursmode; /**< @brief cursor on/off */
|
||||
int if_xcurs; /**< @brief cursor position */
|
||||
int if_ycurs;
|
||||
unsigned char *if_pbase;/**< @brief Address of malloc()ed page buffer. */
|
||||
unsigned char *if_pcurp;/**< @brief Current pointer into page buffer. */
|
||||
unsigned char *if_pendp;/**< @brief End of page buffer. */
|
||||
int if_pno; /**< @brief Current "page" in memory. */
|
||||
int if_pdirty; /**< @brief Page modified flag. */
|
||||
long if_pixcur; /**< @brief Current pixel number in framebuffer. */
|
||||
long if_ppixels; /**< @brief Sizeof page buffer (pixels). */
|
||||
int if_debug; /**< @brief Buffered IO debug flag. */
|
||||
/* State variables for individual interface modules */
|
||||
union {
|
||||
char *p;
|
||||
size_t l;
|
||||
} u1, u2, u3, u4, u5, u6;
|
||||
} FBIO;
|
||||
|
||||
/**
|
||||
* assert the integrity of an FBIO struct.
|
||||
*/
|
||||
#define FB_CK_FBIO(_p) BU_CKMAG(_p, FB_MAGIC, "FBIO")
|
||||
|
||||
/* declare all the possible interfaces */
|
||||
#ifdef IF_REMOTE
|
||||
FB_EXPORT extern FBIO remote_interface; /* not in list[] */
|
||||
#endif
|
||||
|
||||
#ifdef IF_OGL
|
||||
FB_EXPORT extern FBIO ogl_interface;
|
||||
#endif
|
||||
|
||||
#ifdef IF_WGL
|
||||
FB_EXPORT extern FBIO wgl_interface;
|
||||
#endif
|
||||
|
||||
#ifdef IF_X
|
||||
FB_EXPORT extern FBIO X24_interface;
|
||||
FB_EXPORT extern FBIO X_interface;
|
||||
#endif
|
||||
|
||||
#ifdef IF_TK
|
||||
FB_EXPORT extern FBIO tk_interface;
|
||||
#endif
|
||||
|
||||
#ifdef IF_QT
|
||||
FB_EXPORT extern FBIO qt_interface;
|
||||
#endif
|
||||
|
||||
/* Always included */
|
||||
FB_EXPORT extern FBIO debug_interface, disk_interface, stk_interface;
|
||||
FB_EXPORT extern FBIO memory_interface, null_interface;
|
||||
|
||||
#endif /* FBIO_H */
|
||||
/** @} */
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
@@ -59,7 +59,7 @@ struct fbserv_client {
|
||||
|
||||
|
||||
struct fbserv_obj {
|
||||
FBIO *fbs_fbp; /**< @brief framebuffer pointer */
|
||||
fb *fbs_fbp; /**< @brief framebuffer pointer */
|
||||
Tcl_Interp *fbs_interp; /**< @brief tcl interpreter */
|
||||
struct fbserv_listener fbs_listener; /**< @brief data for listening */
|
||||
struct fbserv_client fbs_clients[MAX_CLIENTS]; /**< @brief connected clients */
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ __BEGIN_DECLS
|
||||
}
|
||||
|
||||
#define GED_CHECK_FBSERV_FBP(_gedp, _flags) \
|
||||
if (_gedp->ged_fbsp->fbs_fbp == FBIO_NULL) { \
|
||||
if (_gedp->ged_fbsp->fbs_fbp == FB_NULL) { \
|
||||
int ged_check_view_quiet = (_flags) & GED_QUIET; \
|
||||
if (!ged_check_view_quiet) { \
|
||||
bu_vls_trunc((_gedp)->ged_result_str, 0); \
|
||||
|
||||
Regular → Executable
Executable → Regular
Executable → Regular
+1
-1
@@ -116,7 +116,7 @@ extern void brst_log(const char *, ...);
|
||||
extern int roundToInt(fastf_t f);
|
||||
|
||||
extern Colors colorids;
|
||||
extern FBIO *fbiop;
|
||||
extern fb *fbiop;
|
||||
extern FILE *burstfp;
|
||||
extern FILE *gridfp;
|
||||
extern FILE *histfp;
|
||||
|
||||
+4
-4
@@ -58,7 +58,7 @@ imageInit()
|
||||
zoom = 1;
|
||||
|
||||
/* Determine whether it is necessary to open fbfile. */
|
||||
if (fbiop == FBIO_NULL || fb_getwidth(fbiop) != devwid)
|
||||
if (fbiop == FB_NULL || fb_getwidth(fbiop) != devwid)
|
||||
needopen = 1; /* not currently open or size changed */
|
||||
else
|
||||
if (lastfbfile[0] != NUL && !BU_STR_EQUAL(fbfile, lastfbfile))
|
||||
@@ -89,7 +89,7 @@ openFbDevice(char *fbdev)
|
||||
ret = 0;
|
||||
goto safe_exit;
|
||||
}
|
||||
if (((fbiop != FBIO_NULL && fb_getwidth(fbiop) != devwid)
|
||||
if (((fbiop != FB_NULL && fb_getwidth(fbiop) != devwid)
|
||||
|| pixgrid == NULL)
|
||||
&& (pixgrid = (unsigned char *) calloc(devwid*3, sizeof(unsigned char)))
|
||||
== (unsigned char *) NULL) {
|
||||
@@ -99,7 +99,7 @@ openFbDevice(char *fbdev)
|
||||
goto safe_exit;
|
||||
}
|
||||
(void) memset((char *) pixgrid, NUL, sizeof(unsigned char)*devwid*3);
|
||||
if (fbiop != FBIO_NULL) {
|
||||
if (fbiop != FB_NULL) {
|
||||
if (! closFbDevice()) {
|
||||
ret = 0;
|
||||
goto safe_exit;
|
||||
@@ -132,7 +132,7 @@ closFbDevice()
|
||||
ret = 0;
|
||||
else {
|
||||
ret = 1;
|
||||
fbiop = FBIO_NULL;
|
||||
fbiop = FB_NULL;
|
||||
}
|
||||
notify(NULL, NOTIFY_DELETE);
|
||||
return ret;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
|
||||
|
||||
Colors colorids; /* ident range to color mappings for plots */
|
||||
FBIO *fbiop = NULL; /* frame buffer specific access from libfb */
|
||||
fb *fbiop = NULL; /* frame buffer specific access from libfb */
|
||||
FILE *burstfp = NULL; /* input stream for burst point locations */
|
||||
FILE *gridfp = NULL; /* grid file output stream (2-d shots) */
|
||||
FILE *histfp = NULL; /* histogram output stream (statistics) */
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ static int blueflag = 0;
|
||||
static char *framebuffer = NULL;
|
||||
static char *file_name;
|
||||
static int infd;
|
||||
static FBIO *fbp;
|
||||
static fb *fbp;
|
||||
|
||||
static char usage[] = "\
|
||||
Usage: bw-fb [-a -i -c -z -R -G -B] [-F framebuffer]\n\
|
||||
|
||||
+2
-2
@@ -188,7 +188,7 @@ static int xorigin = 0, yorigin = 0; /* Pixel location of image low lft */
|
||||
static int view_flag = 0; /* The view that is of interest */
|
||||
|
||||
static long maxcells = 10000; /* Max number of cells in the image */
|
||||
static FBIO *fbiop = FBIO_NULL; /* Frame-buffer device */
|
||||
static fb *fbiop = FB_NULL; /* Frame-buffer device */
|
||||
static FILE *filep; /* Input stream */
|
||||
static struct locrec gp_locs;
|
||||
|
||||
@@ -427,7 +427,7 @@ display_Cells(long int ncells)
|
||||
|
||||
zoom = 1;
|
||||
fbiop = fb_open((fbfile[0] != '\0') ? fbfile : NULL, fb_width, fb_height);
|
||||
if (fbiop == FBIO_NULL)
|
||||
if (fbiop == FB_NULL)
|
||||
return 0;
|
||||
if (compute_fb_height || compute_fb_width) {
|
||||
bu_log("fb_size requested: %d %d\n", fb_width, fb_height);
|
||||
|
||||
+2
-2
@@ -91,7 +91,7 @@ main(int argc, char **argv)
|
||||
ColorMap cm;
|
||||
char usage[] = "Usage: cmap-fb [-H -o] [colormap]\n";
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
FILE *fp;
|
||||
int fbsize = 512;
|
||||
int overlay = 0;
|
||||
@@ -124,7 +124,7 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "%s Program continues running:\n", usage);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(NULL, fbsize, fbsize)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(NULL, fbsize, fbsize)) == FB_NULL)
|
||||
bu_exit(3, "Unable to open framebuffer\n");
|
||||
|
||||
if (overlay)
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ get_args(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
int x, y;
|
||||
int xin, yin; /* number of sceen output lines */
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ Usage: fb-cmap [-H] [colormap]\n";
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
FILE *fp;
|
||||
int fbsize = 512;
|
||||
int i;
|
||||
@@ -69,7 +69,7 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "%s Program continues running:\n", usage);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(NULL, fbsize, fbsize)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(NULL, fbsize, fbsize)) == FB_NULL)
|
||||
bu_exit(2, "Unable to open framebuffer\n");
|
||||
|
||||
i = fb_rmap(fbp, &cm);
|
||||
|
||||
+2
-2
@@ -87,7 +87,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int y;
|
||||
FBIO *in_fbp, *out_fbp;
|
||||
fb *in_fbp, *out_fbp;
|
||||
int n, m;
|
||||
int height;
|
||||
|
||||
@@ -117,7 +117,7 @@ main(int argc, char **argv)
|
||||
if (verbose)
|
||||
fprintf(stderr, "fb-fb: width=%d height=%d\n", scr_width, scr_height);
|
||||
|
||||
if ((out_fbp = fb_open(out_fb_name, scr_width, scr_height)) == FBIO_NULL) {
|
||||
if ((out_fbp = fb_open(out_fb_name, scr_width, scr_height)) == FB_NULL) {
|
||||
if (out_fb_name)
|
||||
fprintf(stderr, "fb-fb: unable to open output '%s'\n", out_fb_name);
|
||||
bu_exit(12, NULL);
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ get_args(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int y;
|
||||
|
||||
unsigned char *scanline; /* 1 scanline pixel buffer */
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ main(int argc, char **argv)
|
||||
static int scanpix; /* # of pixels of scanline */
|
||||
static ColorMap cmap; /* libfb color map */
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int y;
|
||||
int got;
|
||||
png_structp png_p;
|
||||
|
||||
+3
-3
@@ -159,7 +159,7 @@ get_args(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
unsigned char *scan_buf;
|
||||
int y;
|
||||
int cm_save_needed;
|
||||
@@ -176,7 +176,7 @@ main(int argc, char **argv)
|
||||
if (screen_height == 0 && file_height > 0)
|
||||
screen_height = file_height;
|
||||
|
||||
if ((fbp = fb_open(framebuffer, screen_width, screen_height)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(framebuffer, screen_width, screen_height)) == FB_NULL)
|
||||
bu_exit(12, NULL);
|
||||
|
||||
/* Honor original screen size desires, if set, unless they shrank */
|
||||
@@ -256,7 +256,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* Add comments to the header file, since we have one */
|
||||
if (framebuffer == (char *)0)
|
||||
framebuffer = fbp->if_name;
|
||||
framebuffer = fb_get_name(fbp);
|
||||
snprintf(comment, COMMENT_SIZE, "encoded_from=%s", framebuffer);
|
||||
rle_putcom(bu_strdup(comment), &outrle);
|
||||
now = time(0);
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ int usec;
|
||||
|
||||
void newframe(int i);
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int screen_width; /* Number of pixels/line in frame buffer */
|
||||
int screen_height;
|
||||
int verbose = 0;
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int x, y;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
if (argc == 1 && isatty(fileno(stdin)) && isatty(fileno(stdout)))
|
||||
printusage();
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
|
||||
|
||||
static char *framebuffer = NULL;
|
||||
static FBIO *fbp;
|
||||
static fb *fbp;
|
||||
static int scr_width = 0; /* use default size */
|
||||
static int scr_height = 0;
|
||||
static int clear_and_reset = 0;
|
||||
|
||||
+1
-1
@@ -651,7 +651,7 @@ main(int argc, char **argv)
|
||||
int fudge;
|
||||
ColorMap cmap;
|
||||
ColorMap *cp = &cmap;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
if (argc == 1 && isatty(fileno(stdin)) && isatty(fileno(stdout)))
|
||||
usage();
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ double fps = 0.0; /* frames per second */
|
||||
int increment = 1;
|
||||
int onestep = 0;
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
static char usage[] = "\
|
||||
Usage: fbcmrot [-H -i increment] steps_per_second\n";
|
||||
@@ -113,7 +113,7 @@ main(int argc, char **argv)
|
||||
tv.tv_usec = (long) (((1.0 / fps) - tv.tv_sec) * 1000000);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(NULL, size, size)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(NULL, size, size)) == FB_NULL) {
|
||||
fprintf(stderr, "fbcmrot: fb_open failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ ColorMap old_map;
|
||||
ColorMap cm;
|
||||
|
||||
static char *framebuffer = NULL;
|
||||
static FBIO *fbp;
|
||||
static fb *fbp;
|
||||
static int scr_height;
|
||||
static int scr_width;
|
||||
|
||||
@@ -80,7 +80,7 @@ main(int argc, char **argv)
|
||||
bu_exit(1, NULL);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == FB_NULL) {
|
||||
fprintf(stderr, "fbcolor: fb_open(%s) failure\n", framebuffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+6
-6
@@ -75,7 +75,7 @@ typedef int bool_t;
|
||||
static bool_t hires = 0; /* set for 1024x1024; clear for 512x512 */
|
||||
static char *in_fb_file = NULL; /* input image name */
|
||||
static char *out_fb_file = NULL; /* output frame buffer name */
|
||||
static FBIO *fbp = FBIO_NULL; /* libfb input/output handle */
|
||||
static fb *fbp = FB_NULL; /* libfb input/output handle */
|
||||
static int src_width = 0; /* input image width */
|
||||
static int src_height = 0; /* input image height */
|
||||
static int dst_width = 0; /* output frame buffer size */
|
||||
@@ -85,7 +85,7 @@ static RGBpixel bg = { 0, 0, 0 }; /* background */
|
||||
|
||||
/* in ioutil.c */
|
||||
extern void Message(const char *format, ...);
|
||||
extern void Fatal(FBIO *fbiop, const char *format, ...);
|
||||
extern void Fatal(fb *fbiop, const char *format, ...);
|
||||
|
||||
|
||||
static void
|
||||
@@ -215,7 +215,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (in_fb_file != NULL) {
|
||||
|
||||
if ((fbp = fb_open(in_fb_file, src_width, src_height)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(in_fb_file, src_width, src_height)) == FB_NULL)
|
||||
Fatal(fbp, "Couldn't open input frame buffer");
|
||||
else {
|
||||
int y;
|
||||
@@ -239,7 +239,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (fb_close(fbp) == -1) {
|
||||
fbp = FBIO_NULL; /* avoid second try */
|
||||
fbp = FB_NULL; /* avoid second try */
|
||||
Fatal(fbp, "Error closing input frame buffer");
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ main(int argc, char **argv)
|
||||
if (dst_height == 0)
|
||||
dst_height = src_height; /* default */
|
||||
|
||||
if ((fbp = fb_open(out_fb_file, dst_width, dst_height)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(out_fb_file, dst_width, dst_height)) == FB_NULL)
|
||||
Fatal(fbp, "Couldn't open output frame buffer");
|
||||
else {
|
||||
int wt = fb_getwidth(fbp);
|
||||
@@ -316,7 +316,7 @@ main(int argc, char **argv)
|
||||
/* Close the frame buffer. */
|
||||
|
||||
if (fb_close(fbp) == -1) {
|
||||
fbp = FBIO_NULL; /* avoid second try */
|
||||
fbp = FB_NULL; /* avoid second try */
|
||||
Fatal(fbp, "Error closing output frame buffer");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int x;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int xsize, ysize;
|
||||
int len;
|
||||
char *framebuffer = (char *)NULL;
|
||||
@@ -90,7 +90,7 @@ main(int argc, char **argv)
|
||||
if (argc == 1 && isatty(fileno(stdin)) && isatty(fileno(stdout)))
|
||||
USAGE_EXIT(*argv);
|
||||
|
||||
if ((fbp = fb_open(framebuffer, xsize, ysize)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(framebuffer, xsize, ysize)) == FB_NULL)
|
||||
bu_exit(1, NULL);
|
||||
|
||||
if (xsize <= 0)
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
while ((c = bu_getopt(argc, argv, "F:h?")) != -1) {
|
||||
switch (c) {
|
||||
@@ -59,7 +59,7 @@ main(int argc, char **argv)
|
||||
fprintf(stderr, "fbfree: excess argument(s) ignored\n");
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(framebuffer, 0, 0)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(framebuffer, 0, 0)) == FB_NULL) {
|
||||
fprintf(stderr, "fbfree: Can't open frame buffer\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
+16
-16
@@ -49,7 +49,7 @@ int image = 0;
|
||||
static char usage[] = "\
|
||||
Usage: fbgamma [-H -o -i] [-F framebuffer] val [gval bval]\n";
|
||||
|
||||
void mk_ramp(FBIO *fb, int r, int g, int b, int n)
|
||||
void mk_ramp(fb *fb_i, int r, int g, int b, int n)
|
||||
{
|
||||
|
||||
/* grey ramp */
|
||||
@@ -62,7 +62,7 @@ void mk_ramp(FBIO *fb, int r, int g, int b, int n)
|
||||
else line[x*3+2] = 0;
|
||||
}
|
||||
for (y=patch_height*n; y < patch_height*(n+1) && y < scr_height; ++y) {
|
||||
fb_write(fb, 0, y, line, scr_width);
|
||||
fb_write(fb_i, 0, y, line, scr_width);
|
||||
}
|
||||
|
||||
for (x=0; x < scr_width; ++x) {
|
||||
@@ -74,17 +74,17 @@ void mk_ramp(FBIO *fb, int r, int g, int b, int n)
|
||||
else line[x*3+2] = 0;
|
||||
}
|
||||
for (y=patch_height*(n+1); y < patch_height*(n+2) && y < scr_height; y += 2) {
|
||||
fb_write(fb, 0, y, altline, scr_width);
|
||||
fb_write(fb, 0, y+1, line, scr_width);
|
||||
fb_write(fb_i, 0, y, altline, scr_width);
|
||||
fb_write(fb_i, 0, y+1, line, scr_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void disp_image(FBIO *fb)
|
||||
void disp_image(fb *fb_i)
|
||||
{
|
||||
|
||||
scr_width = fb_getwidth(fb);
|
||||
scr_height = fb_getheight(fb);
|
||||
scr_width = fb_getwidth(fb_i);
|
||||
scr_height = fb_getheight(fb_i);
|
||||
|
||||
patch_width = scr_width / 8;
|
||||
patch_height = scr_height / 14;
|
||||
@@ -92,13 +92,13 @@ void disp_image(FBIO *fb)
|
||||
line = (unsigned char *) bu_malloc(scr_width*3, "line");
|
||||
altline = (unsigned char *) bu_calloc(scr_width*3, sizeof(unsigned char), "altline");
|
||||
|
||||
mk_ramp(fb, 1, 1, 1, 0);
|
||||
mk_ramp(fb, 1, 0, 0, 2);
|
||||
mk_ramp(fb, 1, 1, 0, 4);
|
||||
mk_ramp(fb, 0, 1, 0, 6);
|
||||
mk_ramp(fb, 0, 1, 1, 8);
|
||||
mk_ramp(fb, 0, 0, 1, 10);
|
||||
mk_ramp(fb, 1, 0, 1, 12);
|
||||
mk_ramp(fb_i, 1, 1, 1, 0);
|
||||
mk_ramp(fb_i, 1, 0, 0, 2);
|
||||
mk_ramp(fb_i, 1, 1, 0, 4);
|
||||
mk_ramp(fb_i, 0, 1, 0, 6);
|
||||
mk_ramp(fb_i, 0, 1, 1, 8);
|
||||
mk_ramp(fb_i, 0, 0, 1, 10);
|
||||
mk_ramp(fb_i, 1, 0, 1, 12);
|
||||
|
||||
(void)bu_free(line, "line");
|
||||
(void)bu_free(altline, "altline");
|
||||
@@ -115,7 +115,7 @@ main(int argc, char **argv)
|
||||
double gamr = 0, gamg = 0, gamb = 0; /* gamma's */
|
||||
double f;
|
||||
ColorMap cm;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
onegamma = 0;
|
||||
|
||||
@@ -152,7 +152,7 @@ main(int argc, char **argv)
|
||||
bu_exit(1, "%s", usage);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(framebuffer, fbsize, fbsize)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(framebuffer, fbsize, fbsize)) == FB_NULL) {
|
||||
bu_exit(2, "Unable to open framebuffer\n");
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -101,9 +101,9 @@ do_file(void)
|
||||
void
|
||||
do_fb(void)
|
||||
{
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
if ((fbp = fb_open(framebuffer, 0, 0)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(framebuffer, 0, 0)) == FB_NULL) {
|
||||
bu_exit(2, "Unable to open framebuffer\n");
|
||||
}
|
||||
if (fb_wmap(fbp, &map) < 0)
|
||||
|
||||
+4
-4
@@ -31,7 +31,7 @@
|
||||
#include "fb.h"
|
||||
|
||||
static unsigned char *white_line, *grey_line, *dark_line;
|
||||
static FBIO *fbp;
|
||||
static fb *fbp;
|
||||
static char *framebuffer = NULL;
|
||||
|
||||
#define OLD 0
|
||||
@@ -43,7 +43,7 @@ static int fbheight = 0;
|
||||
static int flavor = DECIMAL;
|
||||
static int clear = 0;
|
||||
|
||||
void grid(FBIO *fbiop, unsigned char *line, int spacing), oldflavor(void);
|
||||
void grid(fb *fbiop, unsigned char *line, int spacing), oldflavor(void);
|
||||
|
||||
static char usage[] = "\
|
||||
Usage: fbgrid [-c] [-b | -d | -o] [-F framebuffer]\n\
|
||||
@@ -155,7 +155,7 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
void
|
||||
grid(FBIO *fbiop, unsigned char *line, int spacing)
|
||||
grid(fb *fbiop, unsigned char *line, int spacing)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@@ -170,7 +170,7 @@ grid(FBIO *fbiop, unsigned char *line, int spacing)
|
||||
void
|
||||
oldflavor(void)
|
||||
{
|
||||
FBIO *fbiop;
|
||||
fb *fbiop;
|
||||
int x, y;
|
||||
int middle;
|
||||
int mask;
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
while ((c = bu_getopt(argc, argv, "F:h?")) != -1) {
|
||||
switch (c) {
|
||||
@@ -71,7 +71,7 @@ Type \"man brlcad\" for more information.\n");
|
||||
fb_genhelp();
|
||||
|
||||
printf("=============== Current Selection ================\n");
|
||||
if ((fbp = fb_open(framebuffer, 0, 0)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(framebuffer, 0, 0)) == FB_NULL) {
|
||||
fprintf(stderr, "fbhelp: Can't open frame buffer\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
static char *framebuffer = NULL;
|
||||
static char *font1 = NULL;
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
static char usage[] = "\
|
||||
Usage: fblabel [-c -a] [-F framebuffer] [-C r/g/b]\n\
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ struct stroke {
|
||||
}; /* rasterization descriptor */
|
||||
|
||||
static char *framebuffer = NULL;
|
||||
FBIO *fbp; /* Current framebuffer */
|
||||
fb *fbp; /* Current framebuffer */
|
||||
|
||||
static int screen_width = 512; /* default input width */
|
||||
static int screen_height = 512; /* default input height */
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
#include "fb.h"
|
||||
#include "libtermio.h"
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
int JumpSpeed; /* # pixels skiped with fast commands. */
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ int fb_overlay = 0; /* plot on background, else black with grid */
|
||||
int cmap_crunch = 0; /* Plot values after passing through color map */
|
||||
int reverse = 0; /* highlight chosen line by inverting it */
|
||||
char *outframebuffer = NULL;
|
||||
FBIO *fbp, *fboutp;
|
||||
fb *fbp, *fboutp;
|
||||
ColorMap map;
|
||||
|
||||
char usage[] = "\
|
||||
|
||||
+11
-11
@@ -97,9 +97,9 @@ static float y_scale = -1.0; /* vertical scaling factor */
|
||||
static bool_t x_compress; /* set if compressing horizontally */
|
||||
static bool_t y_compress; /* set if compressing vertically */
|
||||
static char *src_file = NULL; /* source frame buffer name */
|
||||
static FBIO *src_fbp = FBIO_NULL; /* source frame buffer handle */
|
||||
static fb *src_fbp = FB_NULL; /* source frame buffer handle */
|
||||
static char *dst_file = NULL; /* destination frame buffer name */
|
||||
static FBIO *dst_fbp = FBIO_NULL; /* destination frame buffer handle */
|
||||
static fb *dst_fbp = FB_NULL; /* destination frame buffer handle */
|
||||
static int src_width = 512;
|
||||
static int src_height = 512; /* source image size */
|
||||
static int dst_width = 0;
|
||||
@@ -109,23 +109,23 @@ static unsigned char *dst_buf; /* calloc()ed output scan line buffer */
|
||||
|
||||
/* in ioutil.c */
|
||||
extern void Message(const char *format, ...);
|
||||
extern void Fatal(FBIO *fbiop, const char *format, ...);
|
||||
extern void Fatal(fb *fbiop, const char *format, ...);
|
||||
|
||||
|
||||
static void
|
||||
Stretch_Fatal(const char *str)
|
||||
{
|
||||
if (src_fbp != FBIO_NULL && fb_close(src_fbp) == -1) {
|
||||
if (src_fbp != FB_NULL && fb_close(src_fbp) == -1) {
|
||||
Message("Error closing input frame buffer");
|
||||
src_fbp = FBIO_NULL;
|
||||
src_fbp = FB_NULL;
|
||||
}
|
||||
|
||||
if (dst_fbp != FBIO_NULL && fb_close(dst_fbp) == -1) {
|
||||
if (dst_fbp != FB_NULL && fb_close(dst_fbp) == -1) {
|
||||
Message("Error closing output frame buffer");
|
||||
src_fbp = FBIO_NULL;
|
||||
src_fbp = FB_NULL;
|
||||
}
|
||||
|
||||
Fatal(FBIO_NULL, "%s", str);
|
||||
Fatal(FB_NULL, "%s", str);
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ main(int argc, char **argv)
|
||||
if ((src_fbp = fb_open(src_file == NULL ? dst_file : src_file,
|
||||
src_width, src_height
|
||||
)
|
||||
) == FBIO_NULL
|
||||
) == FB_NULL
|
||||
)
|
||||
Stretch_Fatal("Couldn't open input image");
|
||||
else {
|
||||
@@ -331,7 +331,7 @@ main(int argc, char **argv)
|
||||
)
|
||||
dst_fbp = src_fbp; /* No No No Not a Second Time */
|
||||
else if ((dst_fbp = fb_open(dst_file, dst_width, dst_height))
|
||||
== FBIO_NULL
|
||||
== FB_NULL
|
||||
)
|
||||
Stretch_Fatal("Couldn't open output frame buffer");
|
||||
|
||||
@@ -791,7 +791,7 @@ main(int argc, char **argv)
|
||||
done:
|
||||
/* Close the frame buffers. */
|
||||
|
||||
assert(src_fbp != FBIO_NULL && dst_fbp != FBIO_NULL);
|
||||
assert(src_fbp != FB_NULL && dst_fbp != FB_NULL);
|
||||
|
||||
if (fb_close(src_fbp) == -1)
|
||||
Message("Error closing input frame buffer");
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ static int scr_width = 512; /* screen size */
|
||||
static int scr_height = 512;
|
||||
static int toggle_pan = 0; /* Reverse sense of pan commands? */
|
||||
static char *framebuffer = NULL;
|
||||
static FBIO *fbp;
|
||||
static fb *fbp;
|
||||
|
||||
static char usage[] = "\
|
||||
Usage: fbzoom [-T] [-F framebuffer]\n\
|
||||
|
||||
+5
-5
@@ -89,7 +89,7 @@ static int image = 0; /* # of image to display (0 => all) */
|
||||
static char *gif_file = NULL; /* GIF file name */
|
||||
static FILE *gfp = NULL; /* GIF input stream handle */
|
||||
static char *fb_file = NULL; /* frame buffer name */
|
||||
static FBIO *fbp = FBIO_NULL; /* frame buffer handle */
|
||||
static fb *fbp = FB_NULL; /* frame buffer handle */
|
||||
static int ht; /* virtual frame buffer height */
|
||||
static int width, height; /* overall "screen" size */
|
||||
static int write_width; /* used width of screen, <= width */
|
||||
@@ -112,7 +112,7 @@ static RGBpixel *cmap; /* bu_malloc()ed local color map */
|
||||
|
||||
/* in ioutil.c */
|
||||
void Message(const char *format, ...);
|
||||
void Fatal(FBIO *fbiop, const char *format, ...);
|
||||
void Fatal(fb *fbiop, const char *format, ...);
|
||||
|
||||
|
||||
static void
|
||||
@@ -670,7 +670,7 @@ main(int argc, char **argv)
|
||||
|
||||
pixbuf = (unsigned char *)bu_malloc(width * sizeof(RGBpixel), "pixbuf");
|
||||
|
||||
if ((fbp = fb_open(fb_file, width, height)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(fb_file, width, height)) == FB_NULL) {
|
||||
Fatal(fbp, "Couldn't open frame buffer");
|
||||
}
|
||||
|
||||
@@ -738,11 +738,11 @@ main(int argc, char **argv)
|
||||
also "screen clear", but they're impractical. */
|
||||
|
||||
if (fb_close(fbp) == -1) {
|
||||
fbp = FBIO_NULL; /* avoid second try */
|
||||
fbp = FB_NULL; /* avoid second try */
|
||||
Fatal(fbp, "Error closing frame buffer");
|
||||
}
|
||||
|
||||
fbp = FBIO_NULL;
|
||||
fbp = FB_NULL;
|
||||
|
||||
if (image > 0)
|
||||
Fatal(fbp, "Specified image not found");
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ main(int argc, char **argv)
|
||||
static int lace[4] = {8, 8, 4, 2};
|
||||
static int offs[4] = {0, 4, 2, 1};
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
FILE *fp;
|
||||
|
||||
while ((code = bu_getopt(argc, argv, "HvFh?")) != -1) {
|
||||
|
||||
+3
-3
@@ -61,7 +61,7 @@ Message(const char *format, ...)
|
||||
|
||||
|
||||
void
|
||||
Fatal(FBIO *fbp, const char *format, ...)
|
||||
Fatal(fb *fbp, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -69,9 +69,9 @@ Fatal(FBIO *fbp, const char *format, ...)
|
||||
VMessage(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fbp != FBIO_NULL && fb_close(fbp) == -1) {
|
||||
if (fbp != FB_NULL && fb_close(fbp) == -1) {
|
||||
Message("Error closing frame buffer");
|
||||
fbp = FBIO_NULL;
|
||||
fbp = FB_NULL;
|
||||
}
|
||||
|
||||
bu_exit(EXIT_FAILURE, NULL);
|
||||
|
||||
+1
-1
@@ -206,7 +206,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int y;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int xout, yout, n, m, xstart, xskip;
|
||||
|
||||
if (!get_args(argc, argv)) {
|
||||
|
||||
+2
-2
@@ -55,7 +55,7 @@ char *input_basename; /* basename of input file(s) */
|
||||
int framenumber = 0; /* starting frame number (default is 0) */
|
||||
int fps = 8; /* frames/second */
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int verbose = 0;
|
||||
int rocking = 0;
|
||||
int passes = 100; /* limit on number of passes */
|
||||
@@ -189,7 +189,7 @@ main(int argc, char **argv)
|
||||
bu_exit(12, NULL);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(NULL, screen_width, screen_height)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(NULL, screen_width, screen_height)) == FB_NULL) {
|
||||
fprintf(stderr, "pixflip-fb: fb_open failed\n");
|
||||
bu_exit(12, NULL);
|
||||
}
|
||||
|
||||
+2
-2
@@ -310,7 +310,7 @@ static int sigs[] = {
|
||||
|
||||
|
||||
static FILE *pfin; /* input file FIO block ptr */
|
||||
FBIO *fbp; /* Current framebuffer */
|
||||
fb *fbp; /* Current framebuffer */
|
||||
|
||||
|
||||
/*
|
||||
@@ -1359,7 +1359,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Open frame buffer, adapt to slightly smaller ones */
|
||||
if ((fbp = fb_open(framebuffer, Npixels, Nscanlines)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(framebuffer, Npixels, Nscanlines)) == FB_NULL) {
|
||||
fprintf(stderr, "plot3-fb: fb_open failed\n");
|
||||
bu_exit(1, NULL);
|
||||
}
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int y;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int i;
|
||||
int xout, yout, m, xstart;
|
||||
png_structp png_p;
|
||||
|
||||
+2
-2
@@ -382,7 +382,7 @@ main (int argc, char **argv)
|
||||
int unit_r = -1; /* Radius of unit circle (in pixels) */
|
||||
int x, y; /* Cartesian coordinates of current pixel */
|
||||
int Xprime, Yprime; /* Translated pixel */
|
||||
FBIO *fbPtr; /* Pointer to the frame-buffer file */
|
||||
fb *fbPtr; /* Pointer to the frame-buffer file */
|
||||
unsigned char *fbb; /* Buffer for current line of frame buffer */
|
||||
unsigned char *fbbPtr; /* Pointer to within fbb */
|
||||
|
||||
@@ -723,7 +723,7 @@ main (int argc, char **argv)
|
||||
arc_max *= Deg2Rad;
|
||||
|
||||
/* Prep the frame buffer */
|
||||
if ((fbPtr = fb_open(FB_Name, fb_width, fb_height)) == FBIO_NULL)
|
||||
if ((fbPtr = fb_open(FB_Name, fb_width, fb_height)) == FB_NULL)
|
||||
(void) bu_exit (1, NULL);
|
||||
fb_width = fb_getwidth(fbPtr);
|
||||
fb_height = fb_getheight(fbPtr);
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@
|
||||
#include "libtermio.h"
|
||||
|
||||
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
|
||||
char ibuf[1024]; /* pp file buffer */
|
||||
|
||||
|
||||
+2
-2
@@ -139,7 +139,7 @@ get_args(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
int i;
|
||||
int file_width; /* unclipped width of rectangle */
|
||||
int file_skiplen; /* # of pixels to skip on l.h.s. */
|
||||
@@ -218,7 +218,7 @@ main(int argc, char **argv)
|
||||
rle_dflt_hdr.xmax -= screen_xbase;
|
||||
rle_dflt_hdr.xmin = 0;
|
||||
|
||||
if ((fbp = fb_open(framebuffer, screen_width, screen_height)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(framebuffer, screen_width, screen_height)) == FB_NULL)
|
||||
bu_exit(12, NULL);
|
||||
|
||||
/* Honor original screen size desires, if set, unless they shrank */
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@
|
||||
#include "spm.h"
|
||||
|
||||
|
||||
static FBIO *fbp;
|
||||
static fb *fbp;
|
||||
|
||||
static char *framebuffer = NULL;
|
||||
static int scr_width = 0;
|
||||
@@ -155,13 +155,13 @@ main(int argc, char **argv)
|
||||
bu_exit(1, NULL);
|
||||
}
|
||||
|
||||
if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == FBIO_NULL)
|
||||
if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == FB_NULL)
|
||||
bu_exit(12, NULL);
|
||||
scr_width = fb_getwidth(fbp);
|
||||
scr_height = fb_getheight(fbp);
|
||||
|
||||
mp = bn_spm_init(vsize, sizeof(RGBpixel));
|
||||
if (mp == BN_SPM_MAP_NULL || fbp == FBIO_NULL)
|
||||
if (mp == BN_SPM_MAP_NULL || fbp == FB_NULL)
|
||||
bu_exit(1, NULL);
|
||||
|
||||
bn_spm_load(mp, file_name);
|
||||
|
||||
@@ -192,8 +192,8 @@ main(int argc, char **argv)
|
||||
bu_exit(1, NULL);
|
||||
}
|
||||
|
||||
FBIO *ifp;
|
||||
ifp = (FBIO *) calloc(sizeof(FBIO), 1);
|
||||
fb *ifp;
|
||||
ifp = (fb *) calloc(sizeof(fb), 1);
|
||||
ifp->if_name = "/dev/tk";
|
||||
ifp->if_magic = FB_MAGIC;
|
||||
char *fbname = "/dev/tk";
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ typedef struct
|
||||
}
|
||||
Panel;
|
||||
|
||||
extern FBIO *fbp;
|
||||
extern fb *fbp;
|
||||
extern RGBpixel *menu_addr;
|
||||
extern RGBpixel paint;
|
||||
extern Point cursor_pos;
|
||||
|
||||
+4
-4
@@ -324,7 +324,7 @@ Func_Tab func_tab[] = {
|
||||
static Func_Tab *bindings[DEL+1];
|
||||
static Func_Tab *macro_entry = FT_NULL; /* Last keyboard macro defined. */
|
||||
|
||||
FBIO *fbp; /* Current framebuffer */
|
||||
fb *fbp; /* Current framebuffer */
|
||||
static int cur_width = 512;
|
||||
|
||||
int
|
||||
@@ -1721,13 +1721,13 @@ HIDDEN int
|
||||
f_Rd_Fb() /* Read frame buffer image from file. */
|
||||
{
|
||||
static char image[MAX_LN];
|
||||
static FBIO *imp;
|
||||
static fb *imp;
|
||||
if (!get_Input(image, MAX_LN, "Enter framebuffer name : "))
|
||||
return 0;
|
||||
if (image[0] == NUL) {
|
||||
fb_log("No default.\n");
|
||||
return 0;
|
||||
} else if ((imp = fb_open(image, 512, 512)) == FBIO_NULL) {
|
||||
} else if ((imp = fb_open(image, 512, 512)) == FB_NULL) {
|
||||
/* XXX */
|
||||
|
||||
fb_log( "Can't open \"%s\" for reading.\n", image);
|
||||
@@ -1873,7 +1873,7 @@ pars_Argv(int argc, char **argv)
|
||||
HIDDEN int
|
||||
fb_Setup(void)
|
||||
{
|
||||
if ((fbp = fb_open(NULL, cur_width, cur_width)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(NULL, cur_width, cur_width)) == FB_NULL) {
|
||||
fb_log("Could not open default frame buffer.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
+6
-8
@@ -80,6 +80,7 @@
|
||||
#include "bio.h"
|
||||
#include "bin.h"
|
||||
|
||||
#include "../libfb/fb_private.h" /* for _fb_disk_enable */
|
||||
#include "fb.h"
|
||||
#include "pkg.h"
|
||||
#include "bu.h"
|
||||
@@ -109,7 +110,7 @@ int verbose = 0;
|
||||
|
||||
/* from server.c */
|
||||
extern const struct pkg_switch fb_server_pkg_switch[];
|
||||
extern FBIO *fb_server_fbp;
|
||||
extern fb *fb_server_fbp;
|
||||
extern fd_set *fb_server_select_list;
|
||||
extern int *fb_server_max_fd;
|
||||
extern int fb_server_got_fb_free; /* !0 => we have received an fb_free */
|
||||
@@ -199,7 +200,7 @@ static void
|
||||
sigalarm(int UNUSED(code))
|
||||
{
|
||||
printf("alarm %s\n", fb_server_fbp ? "FBP" : "NULL");
|
||||
if ( fb_server_fbp != FBIO_NULL ) {
|
||||
if ( fb_server_fbp != FB_NULL ) {
|
||||
fb_poll(fb_server_fbp);
|
||||
}
|
||||
#ifdef SIGALRM
|
||||
@@ -341,7 +342,7 @@ main_loop(void)
|
||||
continue;
|
||||
}
|
||||
/* Handle any events from the framebuffer */
|
||||
if (fb_server_fbp && fb_server_fbp->if_selfd > 0 && FD_ISSET(fb_server_fbp->if_selfd, &infds)) {
|
||||
if (fb_is_set_fd(fb_server_fbp, &infds)) {
|
||||
fb_poll(fb_server_fbp);
|
||||
}
|
||||
|
||||
@@ -445,12 +446,9 @@ main(int argc, char **argv)
|
||||
fb_server_retain_on_close = 1; /* don't ever close the frame buffer */
|
||||
|
||||
/* open a frame buffer */
|
||||
if ( (fb_server_fbp = fb_open(framebuffer, width, height)) == FBIO_NULL )
|
||||
if ( (fb_server_fbp = fb_open(framebuffer, width, height)) == FB_NULL )
|
||||
bu_exit(1, NULL);
|
||||
if ( fb_server_fbp->if_selfd > 0 ) {
|
||||
FD_SET(fb_server_fbp->if_selfd, &select_list);
|
||||
max_fd = fb_server_fbp->if_selfd;
|
||||
}
|
||||
max_fd = fb_set_fd(fb_server_fbp, &select_list);
|
||||
|
||||
/* check/default port */
|
||||
if ( port_set ) {
|
||||
|
||||
+14
-18
@@ -49,7 +49,7 @@
|
||||
* These are the only symbols intended for export to LIBFB users.
|
||||
*/
|
||||
|
||||
FBIO *fb_server_fbp = FBIO_NULL;
|
||||
fb *fb_server_fbp = FB_NULL;
|
||||
fd_set *fb_server_select_list;
|
||||
int *fb_server_max_fd = (int *)NULL;
|
||||
int fb_server_got_fb_free = 0; /* !0 => we have received an fb_free */
|
||||
@@ -92,7 +92,7 @@ fb_server_fb_open(struct pkg_conn *pcp, char *buf)
|
||||
width = pkg_glong(&buf[0*NET_LONG_LEN]);
|
||||
height = pkg_glong(&buf[1*NET_LONG_LEN]);
|
||||
|
||||
if (fb_server_fbp == FBIO_NULL) {
|
||||
if (fb_server_fbp == FB_NULL) {
|
||||
/* Attempt to open new framebuffer */
|
||||
if (strlen(&buf[8]) == 0)
|
||||
fb_server_fbp = fb_open(NULL, width, height);
|
||||
@@ -102,24 +102,22 @@ fb_server_fb_open(struct pkg_conn *pcp, char *buf)
|
||||
/* Use existing framebuffer */
|
||||
}
|
||||
|
||||
if (fb_server_fbp == FBIO_NULL) {
|
||||
if (fb_server_fbp == FB_NULL) {
|
||||
(void)pkg_plong(&rbuf[0*NET_LONG_LEN], -1); /* ret */
|
||||
(void)pkg_plong(&rbuf[1*NET_LONG_LEN], 0);
|
||||
(void)pkg_plong(&rbuf[2*NET_LONG_LEN], 0);
|
||||
(void)pkg_plong(&rbuf[3*NET_LONG_LEN], 0);
|
||||
(void)pkg_plong(&rbuf[4*NET_LONG_LEN], 0);
|
||||
} else {
|
||||
int selfd = 0;
|
||||
(void)pkg_plong(&rbuf[0*NET_LONG_LEN], 0); /* ret */
|
||||
(void)pkg_plong(&rbuf[1*NET_LONG_LEN], fb_server_fbp->if_max_width);
|
||||
(void)pkg_plong(&rbuf[2*NET_LONG_LEN], fb_server_fbp->if_max_height);
|
||||
(void)pkg_plong(&rbuf[3*NET_LONG_LEN], fb_server_fbp->if_width);
|
||||
(void)pkg_plong(&rbuf[4*NET_LONG_LEN], fb_server_fbp->if_height);
|
||||
if (fb_server_fbp->if_selfd > 0 && fb_server_select_list) {
|
||||
FD_SET(fb_server_fbp->if_selfd, fb_server_select_list);
|
||||
if (fb_server_max_fd != NULL &&
|
||||
fb_server_fbp->if_selfd > *fb_server_max_fd)
|
||||
*fb_server_max_fd = fb_server_fbp->if_selfd;
|
||||
}
|
||||
(void)pkg_plong(&rbuf[1*NET_LONG_LEN], fb_get_max_width(fb_server_fbp));
|
||||
(void)pkg_plong(&rbuf[2*NET_LONG_LEN], fb_get_max_height(fb_server_fbp));
|
||||
(void)pkg_plong(&rbuf[3*NET_LONG_LEN], fb_getwidth(fb_server_fbp));
|
||||
(void)pkg_plong(&rbuf[4*NET_LONG_LEN], fb_getheight(fb_server_fbp));
|
||||
selfd = fb_set_fd(fb_server_fbp, fb_server_select_list);
|
||||
if (fb_server_max_fd != NULL && selfd > *fb_server_max_fd)
|
||||
*fb_server_max_fd = selfd;
|
||||
}
|
||||
|
||||
want = 5*NET_LONG_LEN;
|
||||
@@ -142,11 +140,9 @@ fb_server_fb_close(struct pkg_conn *pcp, char *buf)
|
||||
(void)fb_flush(fb_server_fbp);
|
||||
(void)pkg_plong(&rbuf[0], 0); /* return success */
|
||||
} else {
|
||||
if (fb_server_fbp->if_selfd > 0 && fb_server_select_list) {
|
||||
FD_CLR(fb_server_fbp->if_selfd, fb_server_select_list);
|
||||
}
|
||||
(void)fb_clear_fd(fb_server_fbp, fb_server_select_list);
|
||||
(void)pkg_plong(&rbuf[0], fb_close(fb_server_fbp));
|
||||
fb_server_fbp = FBIO_NULL;
|
||||
fb_server_fbp = FB_NULL;
|
||||
}
|
||||
/* Don't check for errors, SGI linger mode or other events
|
||||
* may have already closed down all the file descriptors.
|
||||
@@ -176,7 +172,7 @@ fb_server_fb_free(struct pkg_conn *pcp, char *buf)
|
||||
(void)pkg_plong(&rbuf[0], -1);
|
||||
} else {
|
||||
(void)pkg_plong(&rbuf[0], fb_free(fb_server_fbp));
|
||||
fb_server_fbp = FBIO_NULL;
|
||||
fb_server_fbp = FB_NULL;
|
||||
}
|
||||
|
||||
if (pkg_send(MSG_RETURN, rbuf, NET_LONG_LEN, pcp) != NET_LONG_LEN)
|
||||
|
||||
@@ -987,7 +987,7 @@ f_Cursor_Module()
|
||||
(void) fb_window(fbiop, cx, cy);
|
||||
break;
|
||||
case IN :
|
||||
if (zoom <= fbiop->if_width/2) {
|
||||
if (zoom <= fb_getwidth(fbiop)/2) {
|
||||
zoom *= 2;
|
||||
cx = x;
|
||||
cy = y;
|
||||
@@ -1207,14 +1207,14 @@ f_Animate()
|
||||
return -1;
|
||||
(void) signal(SIGINT, abort_RT);
|
||||
for (frame_no = 0; ! user_interrupt; frame_no++) {
|
||||
FBIO *movie_fbiop;
|
||||
fb *movie_fbiop;
|
||||
int y;
|
||||
if (frame_no == noframes)
|
||||
frame_no = 0;
|
||||
(void) sprintf(suffixptr, ".%04d", frame_no);
|
||||
if (!bu_file_exists(movie_file, NULL))
|
||||
continue;
|
||||
if ((movie_fbiop = fb_open(movie_file, grid_sz, grid_sz)) == FBIO_NULL) {
|
||||
if ((movie_fbiop = fb_open(movie_file, grid_sz, grid_sz)) == FB_NULL) {
|
||||
(void) signal(SIGINT, norml_sig);
|
||||
close_Output_Device(0);
|
||||
return -1;
|
||||
@@ -1359,7 +1359,7 @@ f_Wrt_Fb(char **args)
|
||||
{
|
||||
int y;
|
||||
static char save_fb_file[MAX_LN] = { 0 };
|
||||
FBIO *save_fbiop;
|
||||
fb *save_fbiop;
|
||||
if (args != NULL && args[1] != NULL)
|
||||
bu_strlcpy(save_fb_file, args[1], MAX_LN);
|
||||
else
|
||||
@@ -1382,7 +1382,7 @@ f_Wrt_Fb(char **args)
|
||||
return -1;
|
||||
prnt_Event("Saving image...");
|
||||
if ((save_fbiop =
|
||||
fb_open(save_fb_file, grid_sz, grid_sz))== FBIO_NULL) {
|
||||
fb_open(save_fb_file, grid_sz, grid_sz))== FB_NULL) {
|
||||
close_Output_Device(0);
|
||||
return -1;
|
||||
}
|
||||
@@ -1421,7 +1421,7 @@ f_Rd_Fb(char **args)
|
||||
{
|
||||
int y;
|
||||
static char save_fb_file[MAX_LN] = { 0 };
|
||||
FBIO *save_fbiop;
|
||||
fb *save_fbiop;
|
||||
if (args != NULL && args[1] != NULL)
|
||||
bu_strlcpy(save_fb_file, args[1], MAX_LN);
|
||||
else
|
||||
@@ -1443,7 +1443,7 @@ f_Rd_Fb(char **args)
|
||||
return -1;
|
||||
prnt_Event("Reading saved image...");
|
||||
if ((save_fbiop =
|
||||
fb_open(save_fb_file, grid_sz, grid_sz)) == FBIO_NULL) {
|
||||
fb_open(save_fb_file, grid_sz, grid_sz)) == FB_NULL) {
|
||||
close_Output_Device(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ extern void update_Screen();
|
||||
extern void user_Interaction();
|
||||
|
||||
/* variables */
|
||||
extern FBIO *fbiop;
|
||||
extern fb *fbiop;
|
||||
|
||||
extern RGBpixel bgpixel;
|
||||
extern RGBpixel *ir_table;
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ fb_Setup(char *file, int size)
|
||||
file = "/dev/debug";
|
||||
prnt_Event( "Opening device..." );
|
||||
|
||||
if (((fbiop = fb_open(file[0] == '\0' ? NULL : file, size, size)) == FBIO_NULL) ||
|
||||
if (((fbiop = fb_open(file[0] == '\0' ? NULL : file, size, size)) == FB_NULL) ||
|
||||
(fb_ioinit( fbiop ) == -1) ||
|
||||
(fb_wmap( fbiop, COLORMAP_NULL ) == -1))
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
#include "./lgt.h"
|
||||
#include "./extern.h"
|
||||
#include "./tree.h"
|
||||
FBIO *fbiop = FBIO_NULL; /* Framebuffer interface ptr. */
|
||||
fb *fbiop = FB_NULL; /* Framebuffer interface ptr. */
|
||||
|
||||
/* Initialization for root of IR data base octree. */
|
||||
PtList ir_ptlist = { {0.0, 0.0, 0.0}, PTLIST_NULL };
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ ir_Chk_Table(void)
|
||||
static int
|
||||
adjust_Page(int y)
|
||||
{
|
||||
int scans_per_page = fbiop->if_ppixels/fbiop->if_width;
|
||||
int scans_per_page = fb_get_pagebuffer_pixel_size(fbiop)/fb_getwidth(fbiop);
|
||||
int newy = y - (y % scans_per_page);
|
||||
return newy;
|
||||
}
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ close_Output_Device(int frame)
|
||||
if ((movie.m_noframes > 1 && movie.m_fullscreen) ||
|
||||
(frame == movie.m_endframe)) {
|
||||
(void) fb_close(fbiop);
|
||||
fbiop = FBIO_NULL;
|
||||
fbiop = FB_NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -149,12 +149,12 @@ init_Icon_Texture(char *file, Mat_Db_Entry *entry)
|
||||
static struct fb_texture *
|
||||
init_Fb_Texture(char *file, Mat_Db_Entry *entry)
|
||||
{
|
||||
FBIO *txfbiop;
|
||||
fb *txfbiop;
|
||||
struct fb_texture *fbp;
|
||||
RGBpixel *fbmap;
|
||||
int wid = entry->df_rgb[0] << 3;
|
||||
int hgt = entry->df_rgb[1] << 3;
|
||||
if ( (txfbiop = fb_open( file, wid, hgt )) == FBIO_NULL )
|
||||
if ( (txfbiop = fb_open( file, wid, hgt )) == FB_NULL )
|
||||
return NULL;
|
||||
fbmap = (RGBpixel *) bu_malloc( wid*hgt*sizeof(RGBpixel), "fbmap" );
|
||||
#if DEBUG_TEXTURE
|
||||
|
||||
@@ -11,6 +11,7 @@ set(DM_INCLUDE_DIRS
|
||||
${TCL_INCLUDE_DIRS}
|
||||
${TK_INCLUDE_PATH}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${OPENTHREADS_INCLUDE_DIR}
|
||||
${OSG_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
@@ -67,7 +68,7 @@ if(BRLCAD_ENABLE_QT)
|
||||
endif(BRLCAD_ENABLE_QT)
|
||||
|
||||
if(BRLCAD_ENABLE_OSG)
|
||||
list(APPEND libdm_DEFINES DM_OSG)
|
||||
list(APPEND libdm_DEFINES DM_OSG IF_OSG)
|
||||
set(dmosg_srcs dm-osg.cpp)
|
||||
set(OSG_LIBRARIES
|
||||
${OSG_LIBRARY}
|
||||
@@ -109,10 +110,15 @@ set(LIBDM_SRCS
|
||||
tcl.c
|
||||
vers.c
|
||||
)
|
||||
|
||||
set_property(SOURCE dm_obj.c PROPERTY LANGUAGE CXX)
|
||||
set_property(SOURCE dm_obj.c APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
BRLCAD_ADDLIB(libdm "${LIBDM_SRCS}" "libged;librt;libfb;${DM_X_LIBS};${DM_TKLIB};${DM_EXTRA_LIBS}")
|
||||
set_target_properties(libdm PROPERTIES VERSION 20.0.1 SOVERSION 20)
|
||||
|
||||
if(BRLCAD_ENABLE_OSG)
|
||||
BRLCAD_ADDEXEC(osg-test osg-test.cpp "librt;libbu;${OSG_LIBRARIES}" NO_STRICT NO_INSTALL)
|
||||
endif(BRLCAD_ENABLE_OSG)
|
||||
|
||||
if(BRLCAD_BUILD_LOCAL_TK AND BRLCAD_ENABLE_TK)
|
||||
add_dependencies(libdm tk)
|
||||
endif(BRLCAD_BUILD_LOCAL_TK AND BRLCAD_ENABLE_TK)
|
||||
|
||||
@@ -58,6 +58,10 @@ dm_draw_data_axes(struct dm *dmp,
|
||||
DM_SET_FGCOLOR(dmp, gdasp->gdas_color[0], gdasp->gdas_color[1], gdasp->gdas_color[2], 1, 1.0);
|
||||
|
||||
#if defined(IF_OGL) || defined(IF_WGL)
|
||||
# ifdef HAVE_GL_GL_H
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
|
||||
if (gdasp->gdas_draw > 1) {
|
||||
if (dmp->dm_light)
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ null_makeCurrent(struct dm *UNUSED(dmp))
|
||||
|
||||
|
||||
int
|
||||
null_openFb(struct dm *UNUSED(dmp), FBIO *UNUSED(ifp))
|
||||
null_openFb(struct dm *UNUSED(dmp), fb *UNUSED(ifp))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+215
-15
@@ -25,14 +25,28 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef DM_OGL
|
||||
#ifdef DM_OSG
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "tk.h"
|
||||
#include <osg/GraphicsContext>
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <osgViewer/api/Win32/GraphicsWindowWin32>
|
||||
#else
|
||||
# include <osgViewer/api/X11/GraphicsWindowX11>
|
||||
#endif
|
||||
|
||||
#include <osg/PolygonMode>
|
||||
#include <osg/CullSettings>
|
||||
|
||||
extern "C" {
|
||||
#include "bio.h"
|
||||
|
||||
#include "bu.h"
|
||||
#include "vmath.h"
|
||||
@@ -42,8 +56,9 @@
|
||||
#include "dm/dm-osg.h"
|
||||
#include "dm/dm_xvars.h"
|
||||
#include "dm/dm-Null.h"
|
||||
#include "dm_util.h"
|
||||
}
|
||||
|
||||
#include "./dm_util.h"
|
||||
|
||||
/* For Tk, we need to offset when thinking about screen size in
|
||||
* order to allow for the Mac OSX top-of-screen toolbar - Tk
|
||||
@@ -212,14 +227,14 @@ osg_printglmat(struct bu_vls *tmp_vls, GLfloat *m) {
|
||||
bu_vls_printf(tmp_vls, "%g %g %g %g\n", m[3], m[7], m[11], m[15]);
|
||||
}
|
||||
|
||||
|
||||
extern "C" {
|
||||
void
|
||||
osg_fogHint(struct dm *dmp, int fastfog)
|
||||
{
|
||||
((struct osg_vars *)dmp->dm_vars.priv_vars)->mvars.fastfog = fastfog;
|
||||
glHint(GL_FOG_HINT, fastfog ? GL_FASTEST : GL_NICEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
osg_setBGColor(struct dm *dmp, unsigned char r, unsigned char g, unsigned char b)
|
||||
@@ -438,6 +453,30 @@ osg_reshape(struct dm *dmp, int width, int height)
|
||||
glLoadIdentity();
|
||||
glOrtho(-xlim_view, xlim_view, -ylim_view, ylim_view, dmp->dm_clipmin[2], dmp->dm_clipmax[2]);
|
||||
glMatrixMode(mm);
|
||||
|
||||
struct osg_vars *privvars = (struct osg_vars *)dmp->dm_vars.priv_vars;
|
||||
if (privvars->testviewer) {
|
||||
|
||||
osgViewer::Viewer::Windows windows;
|
||||
privvars->testviewer->getWindows(windows);
|
||||
for(osgViewer::Viewer::Windows::iterator itr = windows.begin();
|
||||
itr != windows.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setWindowRectangle(0, 0, dmp->dm_width, dmp->dm_height);
|
||||
}
|
||||
|
||||
privvars->testviewer->getCamera()->setViewport(0, 0, dmp->dm_width, dmp->dm_height);
|
||||
|
||||
osg::Matrixf orthom;
|
||||
orthom.makeIdentity();
|
||||
orthom.makeOrtho(-xlim_view, xlim_view, -ylim_view, ylim_view, dmp->dm_clipmin[2], dmp->dm_clipmax[2]);
|
||||
privvars->testviewer->getCamera()->setProjectionMatrix(orthom);
|
||||
|
||||
privvars->testviewer->frame();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -607,9 +646,6 @@ osg_open(Tcl_Interp *interp, int argc, char **argv)
|
||||
privvars->mvars.bound = dmp->dm_bound;
|
||||
privvars->mvars.boundFlag = dmp->dm_boundFlag;
|
||||
|
||||
/* this is important so that osg_configureWin knows to set the font */
|
||||
pubvars->fontstruct = NULL;
|
||||
|
||||
if (dmp->dm_top) {
|
||||
/* Make xtkwin a toplevel window */
|
||||
pubvars->xtkwin =
|
||||
@@ -739,13 +775,20 @@ osg_open(Tcl_Interp *interp, int argc, char **argv)
|
||||
// Check the QOSGWidget.cpp example for more logic relevant to this. Need to find
|
||||
// something showing how to handle Cocoa for the Mac, if that's possible
|
||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||
#if defined(DM_OSG) /* Will eventually change to DM_X11 */
|
||||
#if defined(_WIN32)
|
||||
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(Tk_GetHWND(((struct dm_xvars *)(dmp->dm_vars.pub_vars))->win));
|
||||
#else
|
||||
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowX11::WindowData(((struct dm_xvars *)(dmp->dm_vars.pub_vars))->win);
|
||||
#elif defined(DM_WIN32)
|
||||
/* win = ? OSG needs HWND for win... */
|
||||
osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData(win);
|
||||
#endif
|
||||
|
||||
// Although we are not making direct use of osgViewer currently, we need its
|
||||
// initialization to make sure we have all the libraries we need loaded and
|
||||
// ready. TODO Investigate whether GraphicsWindowEmbedded (specifically the version
|
||||
// that takes osg::GraphicsContext::Traits *traits as an argument) would work
|
||||
// better than a raw createGraphicsContext.
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer();
|
||||
delete viewer;
|
||||
|
||||
// Setup the traits parameters
|
||||
traits->x = 0;
|
||||
traits->y = 0;
|
||||
@@ -815,11 +858,24 @@ osg_open(Tcl_Interp *interp, int argc, char **argv)
|
||||
osg_setZBuffer(dmp, dmp->dm_zbuffer);
|
||||
osg_setLight(dmp, dmp->dm_light);
|
||||
|
||||
/* Set up a "real" scene graph view to operate in parallel with the ogl-ish view */
|
||||
privvars->testviewer = new osgViewer::Viewer();
|
||||
privvars->testviewer->setUpViewInWindow(0, 0, 1, 1);
|
||||
privvars->testviewer->realize();
|
||||
|
||||
privvars->osg_root = new osg::Group();
|
||||
privvars->testviewer->setSceneData(privvars->osg_root);
|
||||
privvars->testviewer->getCamera()->setCullingMode(osg::CullSettings::NO_CULLING);
|
||||
|
||||
privvars->testviewer->frame();
|
||||
|
||||
|
||||
|
||||
return dmp;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
extern "C" int
|
||||
osg_share_dlist(struct dm *UNUSED(dmp1), struct dm *UNUSED(dmp2))
|
||||
{
|
||||
#if 0
|
||||
@@ -1069,6 +1125,8 @@ osg_drawBegin(struct dm *dmp)
|
||||
HIDDEN int
|
||||
osg_drawEnd(struct dm *dmp)
|
||||
{
|
||||
struct osg_vars *privvars = (struct osg_vars *)dmp->dm_vars.priv_vars;
|
||||
|
||||
if (dmp->dm_debugLevel)
|
||||
bu_log("osg_drawEnd()\n");
|
||||
|
||||
@@ -1129,6 +1187,7 @@ osg_drawEnd(struct dm *dmp)
|
||||
bu_vls_free(&tmp_vls);
|
||||
}
|
||||
|
||||
privvars->testviewer->frame();
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
@@ -1229,6 +1288,37 @@ osg_loadMatrix(struct dm *dmp, fastf_t *mat, int which_eye)
|
||||
bu_vls_free(&tmp_vls);
|
||||
}
|
||||
|
||||
struct osg_vars *osp = (struct osg_vars *)dmp->dm_vars.priv_vars;
|
||||
mat_t glmat;
|
||||
glmat[0] = mat[0];
|
||||
glmat[4] = mat[1];
|
||||
glmat[8] = mat[2];
|
||||
glmat[12] = mat[3];
|
||||
|
||||
glmat[1] = mat[4] * dmp->dm_aspect;
|
||||
glmat[5] = mat[5] * dmp->dm_aspect;
|
||||
glmat[9] = mat[6] * dmp->dm_aspect;
|
||||
glmat[13] = mat[7] * dmp->dm_aspect;
|
||||
|
||||
glmat[2] = mat[8];
|
||||
glmat[6] = mat[9];
|
||||
glmat[10] = mat[10];
|
||||
glmat[14] = mat[11];
|
||||
|
||||
glmat[3] = mat[12];
|
||||
glmat[7] = mat[13];
|
||||
glmat[11] = mat[14];
|
||||
glmat[15] = mat[15];
|
||||
|
||||
osg::Matrix osg_mp(
|
||||
glmat[0], glmat[1], glmat[2], glmat[3],
|
||||
glmat[4], glmat[5], glmat[6], glmat[7],
|
||||
glmat[8], glmat[9], glmat[10], glmat[11],
|
||||
glmat[12], glmat[13], glmat[14], glmat[15]);
|
||||
|
||||
osp->testviewer->getCamera()->getViewMatrix().set(osg_mp);
|
||||
osp->testviewer->frame();
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -1285,6 +1375,38 @@ osg_loadPMatrix(struct dm *dmp, fastf_t *mat)
|
||||
glLoadIdentity();
|
||||
glLoadMatrixf(gtmat);
|
||||
|
||||
|
||||
struct osg_vars *osp = (struct osg_vars *)dmp->dm_vars.priv_vars;
|
||||
mat_t glmat;
|
||||
glmat[0] = mat[0];
|
||||
glmat[4] = mat[1];
|
||||
glmat[8] = mat[2];
|
||||
glmat[12] = mat[3];
|
||||
|
||||
glmat[1] = mat[4];
|
||||
glmat[5] = mat[5];
|
||||
glmat[9] = mat[6];
|
||||
glmat[13] = mat[7];
|
||||
|
||||
glmat[2] = mat[8];
|
||||
glmat[6] = mat[9];
|
||||
glmat[10] = -mat[10];
|
||||
glmat[14] = -mat[11];
|
||||
|
||||
glmat[3] = mat[12];
|
||||
glmat[7] = mat[13];
|
||||
glmat[11] = mat[14];
|
||||
glmat[15] = mat[15];
|
||||
|
||||
osg::Matrix osg_mp(
|
||||
glmat[0], glmat[1], glmat[2], glmat[3],
|
||||
glmat[4], glmat[5], glmat[6], glmat[7],
|
||||
glmat[8], glmat[9], glmat[10], glmat[11],
|
||||
glmat[12], glmat[13], glmat[14], glmat[15]);
|
||||
|
||||
osp->testviewer->getCamera()->setProjectionMatrix(osg_mp);
|
||||
osp->testviewer->frame();
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -1470,6 +1592,7 @@ osg_drawVList(struct dm *dmp, struct bn_vlist *vp)
|
||||
register int mflag = 1;
|
||||
static float black[4] = {0.0, 0.0, 0.0, 0.0};
|
||||
GLfloat originalPointSize, originalLineWidth;
|
||||
struct osg_vars *osp = (struct osg_vars *)dmp->dm_vars.priv_vars;
|
||||
|
||||
glGetFloatv(GL_POINT_SIZE, &originalPointSize);
|
||||
glGetFloatv(GL_LINE_WIDTH, &originalLineWidth);
|
||||
@@ -1608,6 +1731,81 @@ osg_drawVList(struct dm *dmp, struct bn_vlist *vp)
|
||||
glPointSize(originalPointSize);
|
||||
glLineWidth(originalLineWidth);
|
||||
|
||||
// create the osg containers to hold our data.
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode(); // Maybe create this at drawBegin?
|
||||
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
|
||||
osg::ref_ptr<osg::Vec3dArray> vertices = new osg::Vec3dArray;
|
||||
osg::ref_ptr<osg::Vec3dArray> normals = new osg::Vec3dArray;
|
||||
|
||||
// Set line color
|
||||
osg::Vec4Array* line_color = new osg::Vec4Array;
|
||||
line_color->push_back(osg::Vec4(255, 255, 100, 70));
|
||||
geom->setColorArray(line_color, osg::Array::BIND_OVERALL);
|
||||
|
||||
// Set wireframe state
|
||||
osg::StateSet *geom_state = geom->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::PolygonMode> geom_polymode = new osg::PolygonMode;
|
||||
geom_polymode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
|
||||
geom_state->setAttributeAndModes(geom_polymode);
|
||||
geom_state->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
|
||||
|
||||
/* Viewing region is from -1.0 to +1.0 */
|
||||
int begin = 0;
|
||||
int nverts = 0;
|
||||
first = 1;
|
||||
for (BU_LIST_FOR(tvp, bn_vlist, &vp->l)) {
|
||||
int i;
|
||||
int nused = tvp->nused;
|
||||
int *cmd = tvp->cmd;
|
||||
point_t *pt = tvp->pt;
|
||||
for (i = 0; i < nused; i++, cmd++, pt++) {
|
||||
switch (*cmd) {
|
||||
case BN_VLIST_LINE_MOVE:
|
||||
/* Move, start line */
|
||||
if (first == 0) {
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,begin,nverts));
|
||||
|
||||
} else
|
||||
first = 0;
|
||||
|
||||
vertices->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z]));
|
||||
normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
|
||||
begin += nverts;
|
||||
nverts = 1;
|
||||
break;
|
||||
case BN_VLIST_POLY_START:
|
||||
normals->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z]));
|
||||
begin += nverts;
|
||||
nverts = 0;
|
||||
break;
|
||||
case BN_VLIST_LINE_DRAW:
|
||||
case BN_VLIST_POLY_MOVE:
|
||||
case BN_VLIST_POLY_DRAW:
|
||||
vertices->push_back(osg::Vec3d((*pt)[X], (*pt)[Y], (*pt)[Z]));
|
||||
++nverts;
|
||||
break;
|
||||
case BN_VLIST_POLY_END:
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,begin,nverts));
|
||||
first = 1;
|
||||
break;
|
||||
case BN_VLIST_POLY_VERTNORM:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (first == 0) {
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,begin,nverts));
|
||||
}
|
||||
|
||||
geom->setVertexArray(vertices);
|
||||
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
|
||||
//geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE_SET);
|
||||
|
||||
geom->setUseDisplayList(true);
|
||||
geode->addDrawable(geom);
|
||||
osp->osg_root->addChild(geode);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -2034,8 +2232,9 @@ osg_genDLists(struct dm *dmp, size_t range)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
osg_getDisplayImage(struct dm *dmp, unsigned char **image)
|
||||
osg_getDisplayImage(struct dm *UNUSED(dmp), unsigned char **UNUSED(image))
|
||||
{
|
||||
#if 0
|
||||
unsigned char *idata = NULL;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
@@ -2119,6 +2318,7 @@ osg_getDisplayImage(struct dm *dmp, unsigned char **image)
|
||||
bu_log("osg_getDisplayImage: Display type not set as OGL or WGL\n");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TCL_OK; /* caller will need to bu_free(idata, "image data"); */
|
||||
}
|
||||
|
||||
+1
-1
@@ -709,7 +709,7 @@ qt_processEvents(struct dm *dmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
qt_openFb(struct dm *dmp, FBIO *ifp)
|
||||
qt_openFb(struct dm *dmp, fb *ifp)
|
||||
{
|
||||
struct qt_vars *privars = (struct qt_vars *)dmp->dm_vars.priv_vars;
|
||||
|
||||
|
||||
+1
-1
@@ -333,7 +333,7 @@ txt_makeCurrent(struct dm *UNUSED(dmp))
|
||||
|
||||
|
||||
HIDDEN int
|
||||
txt_openFb(struct dm *UNUSED(dmp), FBIO *UNUSED(ifp))
|
||||
txt_openFb(struct dm *UNUSED(dmp), fb *UNUSED(ifp))
|
||||
{
|
||||
bu_log("openFb called\n");
|
||||
return 0;
|
||||
|
||||
+78
-79
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern "C" {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "tcl.h"
|
||||
|
||||
#include "bu/cmd.h"
|
||||
#include "bu/cv.h"
|
||||
#include "vmath.h"
|
||||
#include "bn.h"
|
||||
#include "db.h"
|
||||
@@ -47,6 +49,12 @@
|
||||
#include "nurb.h"
|
||||
#include "solid.h"
|
||||
#include "dm.h"
|
||||
}
|
||||
|
||||
#ifdef DM_OSG
|
||||
# include "dm/dm_xvars.h"
|
||||
# include "dm/dm-osg.h"
|
||||
#endif /* DM_OSG */
|
||||
|
||||
#ifdef DM_X
|
||||
# include "dm/dm_xvars.h"
|
||||
@@ -75,6 +83,8 @@
|
||||
# include "fb.h"
|
||||
#endif
|
||||
|
||||
/* Embedding windows requires platform specific information */
|
||||
#include "fb/fb_platform_specific.h"
|
||||
|
||||
/**
|
||||
*@brief
|
||||
@@ -105,101 +115,76 @@ static struct dm_obj HeadDMObj; /* head of display manager object list */
|
||||
HIDDEN int
|
||||
dmo_openFb(struct dm_obj *dmop)
|
||||
{
|
||||
struct fb_platform_specific *fb_ps;
|
||||
#ifdef DM_X
|
||||
struct X24_fb_info *xfb_ps;
|
||||
#endif
|
||||
#ifdef DM_OGL
|
||||
struct ogl_fb_info *ofb_ps;
|
||||
#endif
|
||||
#ifdef DM_WGL
|
||||
struct wgl_fb_info *wfb_ps;
|
||||
#endif
|
||||
|
||||
if (!dmop || !dmop->interp)
|
||||
return TCL_ERROR;
|
||||
|
||||
/* already open */
|
||||
if (dmop->dmo_fbs.fbs_fbp != FBIO_NULL)
|
||||
if (dmop->dmo_fbs.fbs_fbp != FB_NULL)
|
||||
return TCL_OK;
|
||||
|
||||
/* don't use bu_calloc so we can fail slightly more gracefully */
|
||||
if ((dmop->dmo_fbs.fbs_fbp = (FBIO *)calloc(sizeof(FBIO), 1)) == FBIO_NULL) {
|
||||
Tcl_Obj *obj;
|
||||
|
||||
obj = Tcl_GetObjResult(dmop->interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
|
||||
Tcl_AppendStringsToObj(obj, "openfb: failed to allocate framebuffer memory\n",
|
||||
(char *)NULL);
|
||||
|
||||
Tcl_SetObjResult(dmop->interp, obj);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
switch (dmop->dmo_dmp->dm_type) {
|
||||
#ifdef DM_X
|
||||
case DM_TYPE_X:
|
||||
*dmop->dmo_fbs.fbs_fbp = X24_interface; /* struct copy */
|
||||
|
||||
dmop->dmo_fbs.fbs_fbp->if_name = (char *)bu_malloc((unsigned)strlen("/dev/X")+1, "if_name");
|
||||
bu_strlcpy(dmop->dmo_fbs.fbs_fbp->if_name, "/dev/X", strlen("/dev/X")+1);
|
||||
|
||||
/* Mark OK by filling in magic number */
|
||||
dmop->dmo_fbs.fbs_fbp->if_magic = FB_MAGIC;
|
||||
|
||||
_X24_open_existing(dmop->dmo_fbs.fbs_fbp,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->dpy,
|
||||
((struct x_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->pix,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->win,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->cmap,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->vip,
|
||||
dmop->dmo_dmp->dm_width,
|
||||
dmop->dmo_dmp->dm_height,
|
||||
((struct x_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->gc);
|
||||
fb_ps = fb_get_platform_specific(FB_X24_MAGIC);
|
||||
xfb_ps = (struct X24_fb_info *)fb_ps->data;
|
||||
xfb_ps->dpy = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->dpy;
|
||||
xfb_ps->win = ((struct x_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->pix;
|
||||
xfb_ps->cwinp = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.priv_vars)->win;
|
||||
xfb_ps->cmap = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.priv_vars)->cmap;
|
||||
xfb_ps->vip = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.priv_vars)->vip;
|
||||
xfb_ps->gc = ((struct x_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->gc;
|
||||
dmop->dmo_fbs.fbs_fbp = fb_open_existing("X", dmop->dmo_dmp->dm_width, dmop->dmo_dmp->dm_height, fb_ps);
|
||||
fb_put_platform_specific(fb_ps);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef DM_OGL
|
||||
case DM_TYPE_OGL:
|
||||
*dmop->dmo_fbs.fbs_fbp = ogl_interface; /* struct copy */
|
||||
|
||||
dmop->dmo_fbs.fbs_fbp->if_name = (char *)bu_malloc((unsigned)strlen("/dev/ogl")+1, "if_name");
|
||||
bu_strlcpy(dmop->dmo_fbs.fbs_fbp->if_name, "/dev/ogl", strlen("/dev/ogl")+1);
|
||||
|
||||
/* Mark OK by filling in magic number */
|
||||
dmop->dmo_fbs.fbs_fbp->if_magic = FB_MAGIC;
|
||||
|
||||
_ogl_open_existing(dmop->dmo_fbs.fbs_fbp,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->dpy,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->win,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->cmap,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->vip,
|
||||
dmop->dmo_dmp->dm_width,
|
||||
dmop->dmo_dmp->dm_height,
|
||||
((struct ogl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->glxc,
|
||||
((struct ogl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->mvars.doublebuffer,
|
||||
0);
|
||||
fb_ps = fb_get_platform_specific(FB_OGL_MAGIC);
|
||||
ofb_ps = (struct ogl_fb_info *)fb_ps->data;
|
||||
ofb_ps->dpy = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->dpy;
|
||||
ofb_ps->win = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->win;
|
||||
ofb_ps->cmap = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->cmap;
|
||||
ofb_ps->vip = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->vip;
|
||||
ofb_ps->glxc = ((struct ogl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->glxc;
|
||||
ofb_ps->double_buffer = ((struct ogl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->mvars.doublebuffer;
|
||||
ofb_ps->soft_cmap = 0;
|
||||
dmop->dmo_fbs.fbs_fbp = fb_open_existing("ogl", dmop->dmo_dmp->dm_width, dmop->dmo_dmp->dm_height, fb_ps);
|
||||
fb_put_platform_specific(fb_ps);
|
||||
break;
|
||||
#endif
|
||||
#ifdef DM_WGL
|
||||
case DM_TYPE_WGL:
|
||||
*dmop->dmo_fbs.fbs_fbp = wgl_interface; /* struct copy */
|
||||
|
||||
dmop->dmo_fbs.fbs_fbp->if_name = bu_malloc((unsigned)strlen("/dev/wgl")+1, "if_name");
|
||||
bu_strlcpy(dmop->dmo_fbs.fbs_fbp->if_name, "/dev/wgl", strlen("/dev/wgl")+1);
|
||||
|
||||
/* Mark OK by filling in magic number */
|
||||
dmop->dmo_fbs.fbs_fbp->if_magic = FB_MAGIC;
|
||||
|
||||
_wgl_open_existing(dmop->dmo_fbs.fbs_fbp,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->dpy,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->win,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->cmap,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->vip,
|
||||
((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->hdc,
|
||||
dmop->dmo_dmp->dm_width,
|
||||
dmop->dmo_dmp->dm_height,
|
||||
((struct wgl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->glxc,
|
||||
((struct wgl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->mvars.doublebuffer,
|
||||
0);
|
||||
fb_ps = fb_get_platform_specific(FB_OGL_MAGIC);
|
||||
wfb_ps = (struct wgl_fb_info *)fb_ps->data;
|
||||
wfb_ps->dpy = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->dpy;
|
||||
wfb_ps->win = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->win;
|
||||
wfb_ps->cmap = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->cmap;
|
||||
wfb_ps->vip = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->vip;
|
||||
wfb_ps->hdc = ((struct dm_xvars *)dmop->dmo_dmp->dm_vars.pub_vars)->hdc;
|
||||
wfb_ps->glxc = ((struct wgl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->glxc;
|
||||
wfb_ps->double_buffer = ((struct wgl_vars *)dmop->dmo_dmp->dm_vars.priv_vars)->mvars.doublebuffer;
|
||||
wfb_ps->soft_cmap = 0;
|
||||
dmop->dmo_fbs.fbs_fbp = fb_open_existing("wgl", dmop->dmo_dmp->dm_width, dmop->dmo_dmp->dm_height, fb_ps);
|
||||
fb_put_platform_specific(fb_ps);
|
||||
break;
|
||||
#endif
|
||||
default: {
|
||||
Tcl_Obj *obj;
|
||||
|
||||
free((void*)dmop->dmo_fbs.fbs_fbp);
|
||||
dmop->dmo_fbs.fbs_fbp = FBIO_NULL;
|
||||
dmop->dmo_fbs.fbs_fbp = FB_NULL;
|
||||
|
||||
obj = Tcl_GetObjResult(dmop->interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
@@ -213,6 +198,20 @@ dmo_openFb(struct dm_obj *dmop)
|
||||
}
|
||||
}
|
||||
|
||||
if (dmop->dmo_fbs.fbs_fbp == FB_NULL) {
|
||||
Tcl_Obj *obj;
|
||||
|
||||
obj = Tcl_GetObjResult(dmop->interp);
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
|
||||
Tcl_AppendStringsToObj(obj, "openfb: failed to allocate framebuffer memory\n",
|
||||
(char *)NULL);
|
||||
|
||||
Tcl_SetObjResult(dmop->interp, obj);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -227,13 +226,13 @@ dmo_openFb(struct dm_obj *dmop)
|
||||
HIDDEN int
|
||||
dmo_closeFb(struct dm_obj *dmop)
|
||||
{
|
||||
if (dmop->dmo_fbs.fbs_fbp == FBIO_NULL)
|
||||
if (dmop->dmo_fbs.fbs_fbp == FB_NULL)
|
||||
return TCL_OK;
|
||||
|
||||
fb_flush(dmop->dmo_fbs.fbs_fbp);
|
||||
fb_close_existing(dmop->dmo_fbs.fbs_fbp);
|
||||
|
||||
dmop->dmo_fbs.fbs_fbp = FBIO_NULL;
|
||||
dmop->dmo_fbs.fbs_fbp = FB_NULL;
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
@@ -262,7 +261,7 @@ dmo_listen_tcl(void *clientData, int argc, const char **argv)
|
||||
if (Tcl_IsShared(obj))
|
||||
obj = Tcl_DuplicateObj(obj);
|
||||
|
||||
if (dmop->dmo_fbs.fbs_fbp == FBIO_NULL) {
|
||||
if (dmop->dmo_fbs.fbs_fbp == FB_NULL) {
|
||||
bu_vls_printf(&vls, "%s listen: framebuffer not open!\n", argv[0]);
|
||||
Tcl_AppendStringsToObj(obj, bu_vls_addr(&vls), (char *)NULL);
|
||||
bu_vls_free(&vls);
|
||||
@@ -327,7 +326,7 @@ dmo_refreshFb_tcl(void *clientData, int argc, const char **argv)
|
||||
if (!dmop || !dmop->interp || argc < 1 || !argv)
|
||||
return TCL_ERROR;
|
||||
|
||||
if (dmop->dmo_fbs.fbs_fbp == FBIO_NULL) {
|
||||
if (dmop->dmo_fbs.fbs_fbp == FB_NULL) {
|
||||
Tcl_Obj *obj;
|
||||
|
||||
obj = Tcl_GetObjResult(dmop->interp);
|
||||
@@ -1729,8 +1728,8 @@ dmo_configure_tcl(void *clientData, int argc, const char **argv)
|
||||
|
||||
#ifdef USE_FBSERV
|
||||
/* configure the framebuffer window */
|
||||
if (dmop->dmo_fbs.fbs_fbp != FBIO_NULL)
|
||||
fb_configureWindow(dmop->dmo_fbs.fbs_fbp,
|
||||
if (dmop->dmo_fbs.fbs_fbp != FB_NULL)
|
||||
(void)fb_configure_window(dmop->dmo_fbs.fbs_fbp,
|
||||
dmop->dmo_dmp->dm_width,
|
||||
dmop->dmo_dmp->dm_height);
|
||||
#endif
|
||||
@@ -3109,7 +3108,7 @@ dmo_open_tcl(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, char *
|
||||
dmop->dmo_fbs.fbs_listener.fbsl_fbsp = &dmop->dmo_fbs;
|
||||
dmop->dmo_fbs.fbs_listener.fbsl_fd = -1;
|
||||
dmop->dmo_fbs.fbs_listener.fbsl_port = -1;
|
||||
dmop->dmo_fbs.fbs_fbp = FBIO_NULL;
|
||||
dmop->dmo_fbs.fbs_fbp = FB_NULL;
|
||||
dmop->dmo_fbs.fbs_callback = dmo_fbs_callback;
|
||||
dmop->dmo_fbs.fbs_clientData = dmop;
|
||||
dmop->dmo_fbs.fbs_interp = interp;
|
||||
@@ -3143,7 +3142,7 @@ dmo_open_tcl(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, char *
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
extern "C" int
|
||||
Dmo_Init(Tcl_Interp *interp)
|
||||
{
|
||||
BU_LIST_INIT(&HeadDMObj.l);
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
|
||||
#include "./dm_util.h"
|
||||
|
||||
# ifdef HAVE_GL_GL_H
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
|
||||
#if defined(DM_OGL) || defined(DM_WGL) || defined(DM_RTGL)
|
||||
int
|
||||
drawLine3D(struct dm *dmp, point_t pt1, point_t pt2, const char *log_bu, float *wireColor)
|
||||
|
||||
@@ -0,0 +1,659 @@
|
||||
/* O S G - T E S T . C P P
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @file osg-test.cpp
|
||||
*
|
||||
* BRL-CAD test application for OpenSceneGraph integration, based off of
|
||||
* osghud example from OpenSceneGraph, which has the following license:
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include "common.h"
|
||||
#include "bu/log.h"
|
||||
#include "bu/list.h"
|
||||
#include "mater.h"
|
||||
#include "raytrace.h"
|
||||
#include "rtfunc.h"
|
||||
}
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgDB/ReadFile>
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
#include <osgViewer/CompositeViewer>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include <osgGA/TrackballManipulator>
|
||||
#include <osgGA/StateSetManipulator>
|
||||
|
||||
|
||||
#include <osg/Material>
|
||||
#include <osg/Geode>
|
||||
#include <osg/BlendFunc>
|
||||
#include <osg/Depth>
|
||||
#include <osg/PolygonOffset>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Camera>
|
||||
#include <osg/RenderInfo>
|
||||
#include <osg/LineStipple>
|
||||
|
||||
#include <osgDB/WriteFile>
|
||||
|
||||
#include <osgText/Text>
|
||||
|
||||
struct bu_list *
|
||||
obj_vlist(const struct directory *dp, const struct db_i *dbip, mat_t mat)
|
||||
{
|
||||
struct bu_list *plot_segments;
|
||||
struct rt_db_internal intern;
|
||||
const struct bn_tol tol = {BN_TOL_MAGIC, 0.0005, 0.0005 * 0.0005, 1e-6, 1 - 1e-6};
|
||||
const struct rt_tess_tol rttol = {RT_TESS_TOL_MAGIC, 0.0, 0.01, 0};
|
||||
RT_DB_INTERNAL_INIT(&intern);
|
||||
if (rt_db_get_internal(&intern, dp, dbip, mat, &rt_uniresource) < 0) {
|
||||
bu_exit(1, "ERROR: Unable to get internal representation of %s\n", dp->d_namep);
|
||||
}
|
||||
BU_GET(plot_segments, struct bu_list);
|
||||
BU_LIST_INIT(plot_segments);
|
||||
|
||||
if (rt_obj_plot(plot_segments, &intern, &rttol, &tol) < 0) {
|
||||
bu_exit(1, "ERROR: Unable to get plot segment list from %s\n", dp->d_namep);
|
||||
}
|
||||
rt_db_free_internal(&intern);
|
||||
return plot_segments;
|
||||
}
|
||||
|
||||
void
|
||||
add_vlist_to_geom(osg::Geometry *geom, struct bu_list *plot_segments)
|
||||
{
|
||||
std::vector<int>startIndexes;
|
||||
std::vector<int>stopIndexes;
|
||||
osg::Vec3Array *vertArray = (osg::Vec3Array *)geom->getVertexArray();
|
||||
struct bn_vlist *vp;
|
||||
|
||||
if (!vertArray) {
|
||||
osg::ref_ptr<osg::Vec3Array> new_vertArray = new osg::Vec3Array();
|
||||
geom->setVertexArray(new_vertArray);
|
||||
vertArray = (osg::Vec3Array *)geom->getVertexArray();
|
||||
}
|
||||
int currentVertex = vertArray->getNumElements();
|
||||
|
||||
geom->setUseDisplayList(true);
|
||||
|
||||
for (BU_LIST_FOR(vp, bn_vlist, plot_segments))
|
||||
{
|
||||
int j;
|
||||
int nused = vp->nused;
|
||||
const int *cmd = vp->cmd;
|
||||
point_t *pt = vp->pt;
|
||||
|
||||
for (j=0 ; j < nused ; j++, cmd++, pt++, currentVertex++)
|
||||
{
|
||||
switch (*cmd)
|
||||
{
|
||||
case BN_VLIST_POLY_START:
|
||||
break;
|
||||
case BN_VLIST_POLY_MOVE: // fallthrough
|
||||
case BN_VLIST_LINE_MOVE:
|
||||
if (startIndexes.size() > 0)
|
||||
{
|
||||
// finish off the last linestrip
|
||||
stopIndexes.push_back(currentVertex-1);
|
||||
}
|
||||
// remember where the new linestrip begins
|
||||
startIndexes.push_back(currentVertex);
|
||||
|
||||
// start a new linestrip
|
||||
vertArray->push_back(osg::Vec3((float)((*pt)[X]), (float)((*pt)[Y]),(float)(*pt)[Z]));
|
||||
|
||||
break;
|
||||
case BN_VLIST_POLY_DRAW: // fallthrough
|
||||
case BN_VLIST_POLY_END: // fallthrough
|
||||
case BN_VLIST_LINE_DRAW:
|
||||
// continue existing linestrip
|
||||
vertArray->push_back(osg::Vec3((float)((*pt)[X]), (float)((*pt)[Y]),(float)(*pt)[Z]));
|
||||
break;
|
||||
case BN_VLIST_POINT_DRAW:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (startIndexes.size() > 0)
|
||||
stopIndexes.push_back(--currentVertex);
|
||||
|
||||
|
||||
for (unsigned j=0 ; j < startIndexes.size() ; j++) {
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, startIndexes[j], (stopIndexes[j]-startIndexes[j])+1 ));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Group>
|
||||
solid_node(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
const struct directory *dp, const struct db_i *dbip)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> wrapper;
|
||||
if ((*osg_nodes).find(dp) == (*osg_nodes).end()) {
|
||||
wrapper = new osg::Group;
|
||||
(*osg_nodes)[dp] = wrapper.get();
|
||||
} else {
|
||||
wrapper = (*osg_nodes)[dp];
|
||||
}
|
||||
|
||||
/* Clear the children from the wrapper, if it has any */
|
||||
unsigned int children_cnt = wrapper->getNumChildren();
|
||||
wrapper->removeChildren(0, children_cnt);
|
||||
|
||||
/* Set up the OSG superstructure for the solid geometry node */
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
|
||||
wrapper->setName(dp->d_namep);
|
||||
geode->setName(dp->d_namep);
|
||||
geom->setName(dp->d_namep); // set drawable to same name as region
|
||||
geode->addDrawable(geom);
|
||||
osg::StateSet* state = geode->getOrCreateStateSet();
|
||||
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
wrapper->addChild(geode);
|
||||
|
||||
/* Actually add the geometry from the vlist */
|
||||
mat_t mat;
|
||||
MAT_IDN(mat);
|
||||
struct bu_list *plot_segments = obj_vlist(dp, dbip, mat);
|
||||
add_vlist_to_geom(geom, plot_segments);
|
||||
|
||||
/* Cleanup */
|
||||
RT_FREE_VLIST(plot_segments);
|
||||
BU_PUT(plot_segments, struct bu_list);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
void
|
||||
create_solid_nodes(std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
struct directory *dp, struct db_i *dbip)
|
||||
{
|
||||
const char *solid_search = "! -type comb";
|
||||
struct bu_ptbl solids = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(&solids, DB_SEARCH_RETURN_UNIQ_DP, solid_search, 1, &dp, dbip);
|
||||
|
||||
for (int i = (int)BU_PTBL_LEN(&solids) - 1; i >= 0; i--) {
|
||||
/* Get the vlist associated with this particular object */
|
||||
struct directory *curr_dp = (struct directory *)BU_PTBL_GET(&solids, i);
|
||||
if ((*osg_nodes).find(curr_dp) == (*osg_nodes).end()) {
|
||||
osg::ref_ptr<osg::Group> node = solid_node(osg_nodes, curr_dp, dbip);
|
||||
(*osg_nodes)[curr_dp] = node.get();
|
||||
}
|
||||
}
|
||||
db_search_free(&solids);
|
||||
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Group>
|
||||
bare_comb_node(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
const struct directory *dp, const struct db_i *dbip)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> comb;
|
||||
if ((*osg_nodes).find(dp) == (*osg_nodes).end()) {
|
||||
comb = new osg::Group;
|
||||
(*osg_nodes)[dp] = comb.get();
|
||||
} else {
|
||||
comb = (*osg_nodes)[dp];
|
||||
}
|
||||
|
||||
comb->setName(dp->d_namep);
|
||||
|
||||
struct rt_db_internal intern;
|
||||
(void)rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, &rt_uniresource);
|
||||
struct rt_comb_internal *comb_internal= (struct rt_comb_internal *)intern.idb_ptr;
|
||||
/* Set color for this comb */
|
||||
float color[3] = {-1.0, -1.0, -1.0};
|
||||
if (comb_internal->rgb_valid) {
|
||||
VSCALE(color, comb_internal->rgb, (1.0/255.0) );
|
||||
} else {
|
||||
struct mater *mp = MATER_NULL;
|
||||
for (mp = rt_material_head(); mp != MATER_NULL; mp = mp->mt_forw) {
|
||||
if (comb_internal->region_id <= mp->mt_high && comb_internal->region_id >= mp->mt_low) {
|
||||
color[0] = mp->mt_r/255.0;
|
||||
color[1] = mp->mt_g/255.0;
|
||||
color[2] = mp->mt_b/255.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (color[0] > -1) {
|
||||
osg::ref_ptr<osg::Material> mtl = new osg::Material;
|
||||
mtl->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(color[0], color[1], color[2], 1.0f));
|
||||
osg::StateSet* state = comb->getOrCreateStateSet();
|
||||
if (comb_internal->inherit || comb_internal->region_flag) {
|
||||
state->setAttributeAndModes(mtl.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
|
||||
} else {
|
||||
state->setAttributeAndModes(mtl.get(), osg::StateAttribute::ON);
|
||||
}
|
||||
}
|
||||
rt_db_free_internal(&intern);
|
||||
|
||||
return comb;
|
||||
}
|
||||
|
||||
int
|
||||
subtracted_solid(struct db_full_path *path)
|
||||
{
|
||||
int ret = 0;
|
||||
for (unsigned int i = 0; i < path->fp_len; i++) {
|
||||
if(path->fp_bool[i] == 4) ret = 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
add_comb_child(osg::Group *comb, osg::Group *child, struct db_full_path *child_path, struct db_i *dbip)
|
||||
{
|
||||
mat_t m = MAT_INIT_IDN;
|
||||
mat_t m_idn = MAT_INIT_IDN;
|
||||
const struct bn_tol tol = {BN_TOL_MAGIC, 0.0005, 0.0005 * 0.0005, 1e-6, 1 - 1e-6};
|
||||
(void)db_path_to_mat(dbip, child_path, (matp_t)(&m), child_path->fp_len, &rt_uniresource);
|
||||
if (!bn_mat_is_equal(m, m_idn, &tol)) {
|
||||
mat_t mt = MAT_INIT_IDN;
|
||||
MAT_TRANSPOSE(mt, m);
|
||||
osg::Matrixd osgMat(mt);
|
||||
osg::ref_ptr<osg::MatrixTransform> osgmt = new osg::MatrixTransform(osgMat);
|
||||
osgmt->addChild(child);
|
||||
comb->addChild(osgmt);
|
||||
|
||||
/* If this child_path is subtracted in this comb, stipple the line drawings */
|
||||
if (child_path->fp_bool[child_path->fp_len - 1] == 4) {
|
||||
osg::StateSet* state = osgmt->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::LineStipple> ls = new osg::LineStipple();
|
||||
ls->setPattern(0xCF33);
|
||||
ls->setFactor(1);
|
||||
state->setAttributeAndModes(ls.get());
|
||||
}
|
||||
} else {
|
||||
if (child_path->fp_bool[child_path->fp_len - 1] == 4) {
|
||||
osg::ref_ptr<osg::Group> property_wrapper = new osg::Group;
|
||||
property_wrapper->setName(DB_FULL_PATH_CUR_DIR(child_path)->d_namep);
|
||||
osg::StateSet* state = property_wrapper->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::LineStipple> ls = new osg::LineStipple();
|
||||
ls->setPattern(0xCF33);
|
||||
ls->setFactor(1);
|
||||
state->setAttributeAndModes(ls.get());
|
||||
property_wrapper->addChild(child);
|
||||
comb->addChild(property_wrapper);
|
||||
} else {
|
||||
comb->addChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* In the case of regions, we need to be able to remove and restore the individual
|
||||
* comb children, because for normal display (as opposed to editing mode) we need to
|
||||
* use a single compositite wireframe for regions */
|
||||
osg::ref_ptr<osg::Group>
|
||||
full_comb_node(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
struct directory *dp, struct db_i *dbip)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> comb = bare_comb_node(osg_nodes, dp, dbip);
|
||||
|
||||
/* Clear the immediate children from this node, if it has any */
|
||||
unsigned int children_cnt = comb->getNumChildren();
|
||||
comb->removeChildren(0, children_cnt);
|
||||
|
||||
const char *comb_search = "-type comb";
|
||||
struct bu_ptbl combs = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(&combs, DB_SEARCH_RETURN_UNIQ_DP, comb_search, 1, &dp, dbip);
|
||||
for (int i = (int)BU_PTBL_LEN(&combs) - 1; i >= 0; i--) {
|
||||
struct directory *curr_dp = (struct directory *)BU_PTBL_GET(&combs, i);
|
||||
osg::ref_ptr<osg::Group> sub_comb = bare_comb_node(osg_nodes, curr_dp, dbip);
|
||||
const char *comb_children_search = "-mindepth 1 -maxdepth 1";
|
||||
struct bu_ptbl comb_children = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(&comb_children, DB_SEARCH_TREE, comb_children_search, 1, &curr_dp, dbip);
|
||||
for (int j = (int)BU_PTBL_LEN(&comb_children) - 1; j >= 0; j--) {
|
||||
struct db_full_path *curr_path = (struct db_full_path *)BU_PTBL_GET(&comb_children, j);
|
||||
struct directory *curr_child_dp = DB_FULL_PATH_CUR_DIR(curr_path);
|
||||
if (curr_child_dp->d_flags & RT_DIR_COMB) {
|
||||
osg::ref_ptr<osg::Group> new_node = bare_comb_node(osg_nodes, curr_child_dp, dbip);
|
||||
(*osg_nodes)[curr_child_dp] = new_node.get();
|
||||
}
|
||||
if (curr_child_dp->d_flags & RT_DIR_SOLID) {
|
||||
osg::ref_ptr<osg::Group> new_node = solid_node(osg_nodes, curr_child_dp, dbip);
|
||||
(*osg_nodes)[curr_child_dp] = new_node.get();
|
||||
}
|
||||
add_comb_child(sub_comb, (*osg_nodes)[curr_child_dp], curr_path, dbip);
|
||||
}
|
||||
db_search_free(&comb_children);
|
||||
}
|
||||
db_search_free(&combs);
|
||||
|
||||
return comb;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Group>
|
||||
full_region_node(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
struct directory *dp, struct db_i *dbip)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> region = bare_comb_node(osg_nodes, dp, dbip);
|
||||
|
||||
/* Clear the immediate children from this node, if it has any */
|
||||
unsigned int children_cnt = region->getNumChildren();
|
||||
region->removeChildren(0, children_cnt);
|
||||
|
||||
/* We now create up to two pseudo-solid nodes holding the full region drawable info - one for non-subtracted
|
||||
* elements (no stipple) and one (if needed) for subtracted elements (stipple)*/
|
||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
|
||||
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
|
||||
geode->setName(dp->d_namep);
|
||||
geom->setName(dp->d_namep); // set drawable to same name as region
|
||||
geode->addDrawable(geom);
|
||||
osg::StateSet* state = geode->getOrCreateStateSet();
|
||||
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
region->addChild(geode);
|
||||
|
||||
/* Define the subtraction container, but don't add it as a child of the region unless we actually need it.*/
|
||||
osg::ref_ptr<osg::Group> subtraction_wrapper = new osg::Group;
|
||||
osg::ref_ptr<osg::Geode> subtraction_geode = new osg::Geode;
|
||||
osg::ref_ptr<osg::Geometry> subtraction_geom = new osg::Geometry;
|
||||
subtraction_wrapper->setName(dp->d_namep);
|
||||
subtraction_geode->setName(dp->d_namep);
|
||||
subtraction_geom->setName(dp->d_namep);
|
||||
osg::StateSet* subtraction_geode_state = subtraction_geode->getOrCreateStateSet();
|
||||
subtraction_geode_state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||
osg::StateSet* subtraction_state = subtraction_wrapper->getOrCreateStateSet();
|
||||
osg::ref_ptr<osg::LineStipple> ls = new osg::LineStipple();
|
||||
ls->setPattern(0xCF33);
|
||||
ls->setFactor(1);
|
||||
subtraction_state->setAttributeAndModes(ls.get());
|
||||
subtraction_geode->addDrawable(subtraction_geom);
|
||||
subtraction_wrapper->addChild(subtraction_geode);
|
||||
|
||||
/*Search for all the solids (using full paths) below the region - that's the list of vlists we need for this particular region,
|
||||
*using the full paths below the current region to place them in their final relative positions.
|
||||
*/
|
||||
const char *region_vlist_search = "! -type comb";
|
||||
struct bu_ptbl region_vlist_contributors = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(®ion_vlist_contributors, DB_SEARCH_TREE, region_vlist_search, 1, &dp, dbip);
|
||||
int have_subtraction = 0;
|
||||
for (int j = (int)BU_PTBL_LEN(®ion_vlist_contributors) - 1; j >= 0; j--) {
|
||||
struct db_full_path *curr_path = (struct db_full_path *)BU_PTBL_GET(®ion_vlist_contributors, j);
|
||||
|
||||
/* Find out how to draw this particular wireframe */
|
||||
int subtraction_path = subtracted_solid(curr_path);
|
||||
|
||||
/* Get the final matrix we will need for this vlist */
|
||||
mat_t tm;
|
||||
MAT_IDN(tm);
|
||||
(void)db_path_to_mat(dbip, curr_path, tm, curr_path->fp_len-1, &rt_uniresource);
|
||||
|
||||
/* Actually add the geometry from the vlist */
|
||||
struct bu_list *plot_segments = obj_vlist(DB_FULL_PATH_CUR_DIR(curr_path), dbip, tm);
|
||||
if (subtraction_path) {
|
||||
have_subtraction++;
|
||||
add_vlist_to_geom(subtraction_geom, plot_segments);
|
||||
} else {
|
||||
add_vlist_to_geom(geom, plot_segments);
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
RT_FREE_VLIST(plot_segments);
|
||||
BU_PUT(plot_segments, struct bu_list);
|
||||
|
||||
}
|
||||
db_search_free(®ion_vlist_contributors);
|
||||
if (have_subtraction) {
|
||||
region->addChild(subtraction_wrapper);
|
||||
}
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
|
||||
/* In the case of regions, we need to be able to remove and restore the individual
|
||||
* comb children, because for normal display (as opposed to editing mode) we need to
|
||||
* use a single compositite wireframe for regions */
|
||||
osg::ref_ptr<osg::Group>
|
||||
full_assembly_node(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
struct directory *dp, struct db_i *dbip)
|
||||
{
|
||||
osg::ref_ptr<osg::Group> assembly = bare_comb_node(osg_nodes, dp, dbip);
|
||||
|
||||
/* Clear the immediate children from this node, if it has any */
|
||||
unsigned int children_cnt = assembly->getNumChildren();
|
||||
assembly->removeChildren(0, children_cnt);
|
||||
|
||||
const char *assembly_search = "-type comb ! -below -type region ! -type region";
|
||||
struct bu_ptbl assemblies = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(&assemblies, DB_SEARCH_RETURN_UNIQ_DP, assembly_search, 1, &dp, dbip);
|
||||
for (int i = (int)BU_PTBL_LEN(&assemblies) - 1; i >= 0; i--) {
|
||||
struct directory *curr_dp = (struct directory *)BU_PTBL_GET(&assemblies, i);
|
||||
osg::ref_ptr<osg::Group> sub_comb = bare_comb_node(osg_nodes, curr_dp, dbip);
|
||||
const char *comb_children_search = "-mindepth 1 -maxdepth 1";
|
||||
struct bu_ptbl comb_children = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(&comb_children, DB_SEARCH_TREE, comb_children_search, 1, &curr_dp, dbip);
|
||||
for (int j = (int)BU_PTBL_LEN(&comb_children) - 1; j >= 0; j--) {
|
||||
struct db_full_path *curr_path = (struct db_full_path *)BU_PTBL_GET(&comb_children, j);
|
||||
struct directory *curr_child_dp = DB_FULL_PATH_CUR_DIR(curr_path);
|
||||
if (curr_child_dp->d_flags & RT_DIR_COMB && !(curr_child_dp->d_flags & RT_DIR_REGION)) {
|
||||
int is_assembly = 0;
|
||||
for (int k = (int)BU_PTBL_LEN(&assemblies) - 1; k >= 0; k--) {
|
||||
struct directory *assembly_dp = (struct directory *)BU_PTBL_GET(&assemblies, k);
|
||||
if (assembly_dp == curr_child_dp) is_assembly = 1;
|
||||
}
|
||||
osg::ref_ptr<osg::Group> new_node;
|
||||
if (is_assembly) {
|
||||
new_node = bare_comb_node(osg_nodes, curr_child_dp, dbip);
|
||||
} else {
|
||||
new_node = full_comb_node(osg_nodes, curr_child_dp, dbip);
|
||||
}
|
||||
(*osg_nodes)[DB_FULL_PATH_CUR_DIR(curr_path)] = new_node.get();
|
||||
}
|
||||
if (curr_child_dp->d_flags & RT_DIR_REGION) {
|
||||
osg::ref_ptr<osg::Group> new_node = full_region_node(osg_nodes, curr_child_dp, dbip);
|
||||
(*osg_nodes)[curr_child_dp] = new_node.get();
|
||||
}
|
||||
if (curr_child_dp->d_flags & RT_DIR_SOLID) {
|
||||
osg::ref_ptr<osg::Group> new_node = solid_node(osg_nodes, curr_child_dp, dbip);
|
||||
(*osg_nodes)[curr_child_dp] = new_node.get();
|
||||
}
|
||||
add_comb_child(sub_comb, (*osg_nodes)[curr_child_dp], curr_path, dbip);
|
||||
}
|
||||
db_search_free(&comb_children);
|
||||
}
|
||||
db_search_free(&assemblies);
|
||||
|
||||
return assembly;
|
||||
}
|
||||
|
||||
|
||||
/* Determine what type of dp we're dealing with:
|
||||
*
|
||||
* -1 - not drawable
|
||||
* 0 - solid
|
||||
* 1 - comb
|
||||
* 2 - region
|
||||
* 3 - assembly (comb with regions below it)
|
||||
*/
|
||||
int
|
||||
characterize_dp(struct directory *dp, struct db_i *dbip)
|
||||
{
|
||||
int ret = -1;
|
||||
const char *is_assembly_search = "-type region";
|
||||
if (dp->d_flags & RT_DIR_COMB) {
|
||||
ret = 1;
|
||||
if (dp->d_flags & RT_DIR_REGION) {
|
||||
ret = 2;
|
||||
} else {
|
||||
/* TODO - db_search should let us know the results without needing the table,
|
||||
* but that doesn't seem to be working... */
|
||||
struct bu_ptbl search_results = BU_PTBL_INIT_ZERO;
|
||||
(void)db_search(&search_results, DB_SEARCH_QUIET, is_assembly_search, 1, &dp, dbip);
|
||||
if (BU_PTBL_LEN(&search_results) > 0) ret = 3;
|
||||
db_search_free(&search_results);
|
||||
}
|
||||
} else {
|
||||
if (dp->d_flags & RT_DIR_SOLID) ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
add_dp_to_scene(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
struct directory *dp, struct db_i *dbip)
|
||||
{
|
||||
int dp_type = characterize_dp(dp, dbip);
|
||||
switch (dp_type) {
|
||||
case 0:
|
||||
(void)solid_node(osg_nodes, dp, dbip);
|
||||
break;
|
||||
case 1:
|
||||
full_comb_node(osg_nodes, dp, dbip);
|
||||
break;
|
||||
case 2:
|
||||
full_region_node(osg_nodes, dp, dbip);
|
||||
break;
|
||||
case 3:
|
||||
full_assembly_node(osg_nodes, dp, dbip);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
add_path_to_scene(
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > *osg_nodes,
|
||||
const struct db_full_path *path, struct db_i *dbip)
|
||||
{
|
||||
/* Whatever the path looks like, we're going to have to add the
|
||||
* current directory */
|
||||
struct db_full_path working_path;
|
||||
db_full_path_init(&working_path);
|
||||
db_dup_full_path(&working_path, path);
|
||||
|
||||
add_dp_to_scene(osg_nodes, DB_FULL_PATH_CUR_DIR(&working_path), dbip);
|
||||
|
||||
while (working_path.fp_len > 1) {
|
||||
struct directory *curr_dp = DB_FULL_PATH_CUR_DIR(&working_path);
|
||||
struct directory *parent_dp = working_path.fp_names[working_path.fp_len - 2];
|
||||
|
||||
osg::ref_ptr<osg::Group> comb = bare_comb_node(osg_nodes, parent_dp, dbip);
|
||||
osg::ref_ptr<osg::Group> child = (*osg_nodes)[curr_dp];
|
||||
|
||||
add_comb_child(comb, child, &working_path, dbip);
|
||||
|
||||
DB_FULL_PATH_POP(&working_path);
|
||||
}
|
||||
|
||||
db_free_full_path(&working_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
std::map<const struct directory *, osg::ref_ptr<osg::Group> > osg_nodes;
|
||||
struct db_i *dbip = DBI_NULL;
|
||||
struct directory *dp = RT_DIR_NULL;
|
||||
struct db_full_path path;
|
||||
|
||||
if (argc != 3 || !argv) {
|
||||
bu_exit(1, "Error - please specify a .g file and an object\n");
|
||||
}
|
||||
if (!bu_file_exists(argv[1], NULL)) {
|
||||
bu_exit(1, "Cannot stat file %s\n", argv[1]);
|
||||
}
|
||||
|
||||
if ((dbip = db_open(argv[1], DB_OPEN_READONLY)) == DBI_NULL) {
|
||||
bu_exit(1, "Cannot open geometry database file %s\n", argv[1]);
|
||||
}
|
||||
RT_CK_DBI(dbip);
|
||||
if (db_dirbuild(dbip) < 0) {
|
||||
db_close(dbip);
|
||||
bu_exit(1, "db_dirbuild failed on geometry database file %s\n", argv[1]);
|
||||
}
|
||||
|
||||
/* argv[2] may be a full path, not just an object name - handle it */
|
||||
if (db_string_to_path(&path, dbip, argv[2])) {
|
||||
bu_exit(1, "ERROR: Unable to find object %s in %s\n", argv[2], argv[1]);
|
||||
}
|
||||
|
||||
/* Need to initialize this for rt_obj_plot, which may call RT_ADD_VLIST */
|
||||
BU_LIST_INIT(&RTG.rtg_vlfree);
|
||||
|
||||
add_path_to_scene(&(osg_nodes), &path, dbip);
|
||||
|
||||
// construct the viewer.
|
||||
osgViewer::Viewer viewer;
|
||||
viewer.setUpViewInWindow(0, 0, 640, 480);
|
||||
|
||||
// add the state manipulator
|
||||
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
|
||||
|
||||
// add the thread model handler
|
||||
viewer.addEventHandler(new osgViewer::ThreadingHandler);
|
||||
|
||||
// add the window size toggle handler
|
||||
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
|
||||
|
||||
// add the stats handler
|
||||
viewer.addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
// The settings below do not seem to improve FPS, and the latter results in no geometry being
|
||||
// visible without improving the FPS.
|
||||
//viewer.getCamera()->setCullingMode(osg::CullSettings::NO_CULLING);
|
||||
//viewer.getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
|
||||
|
||||
osgUtil::Optimizer optimizer;
|
||||
osg::ref_ptr<osg::Group> toplevel = new osg::Group;
|
||||
toplevel->addChild(osg_nodes[DB_FULL_PATH_ROOT_DIR(&path)]);
|
||||
optimizer.optimize(toplevel);
|
||||
viewer.setSceneData(toplevel);
|
||||
|
||||
viewer.realize();
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
// Local Variables:
|
||||
// tab-width: 8
|
||||
// mode: C++
|
||||
// c-basic-offset: 4
|
||||
// indent-tabs-mode: t
|
||||
// c-file-style: "stroustrup"
|
||||
// End:
|
||||
// ex: shiftwidth=4 tabstop=8
|
||||
Regular → Executable
@@ -9,20 +9,32 @@ set(FB_INCLUDE_DIRS
|
||||
${TCL_INCLUDE_DIRS}
|
||||
${TK_INCLUDE_PATH}
|
||||
${OPENNURBS_INCLUDE_DIR}
|
||||
${OPENTHREADS_INCLUDE_DIR}
|
||||
${OSG_INCLUDE_DIR}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
)
|
||||
BRLCAD_LIB_INCLUDE_DIRS(fb FB_INCLUDE_DIRS "")
|
||||
|
||||
set(LINKLIBS "")
|
||||
|
||||
if(BRLCAD_ENABLE_OSG)
|
||||
set(FBOSGDEFS "-DIF_OSG")
|
||||
set(LINKLIBS ${LINKLIBS} ${OSG_LIBRARIES})
|
||||
set(fbosg_srcs if_osg.cpp)
|
||||
set_property(SOURCE if_osg.cpp APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
endif()
|
||||
|
||||
if(BRLCAD_ENABLE_X11 AND X11_FOUND)
|
||||
set(FBX11DEFS "-DIF_X")
|
||||
set(LINKLIBS ${LINKLIBS} ${X11_LIBRARIES})
|
||||
set(fbX11_srcs if_X.c if_X24.c)
|
||||
set(fbX11_srcs if_X24.c)
|
||||
set_property(SOURCE if_X24.c APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
endif()
|
||||
if(BRLCAD_ENABLE_OPENGL AND OPENGL_FOUND AND NOT MSVC)
|
||||
set(FBOGLDEFS "-DIF_OGL")
|
||||
set(LINKLIBS ${LINKLIBS} ${OPENGL_LIBRARIES})
|
||||
set(fbogl_srcs if_ogl.c)
|
||||
set_property(SOURCE if_ogl.c APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
endif()
|
||||
if(WIN32)
|
||||
add_definitions(
|
||||
@@ -30,11 +42,13 @@ if(WIN32)
|
||||
)
|
||||
set(LINKLIBS ${LINKLIBS} opengl32.lib ${TCL_TK_LIBRARY})
|
||||
set(fbwgl_srcs if_wgl.c)
|
||||
set_property(SOURCE if_wgl.c APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
endif(WIN32)
|
||||
if(BRLCAD_ENABLE_TK)
|
||||
set(FBTKDEFS "-DIF_TK")
|
||||
set(LINKLIBS ${LINKLIBS} ${TK_LIBRARY})
|
||||
set(fbtk_srcs if_tk.c)
|
||||
set_property(SOURCE if_tk.c APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
endif(BRLCAD_ENABLE_TK)
|
||||
if(BRLCAD_ENABLE_QT)
|
||||
CHECK_CXX_FLAG(Wno-float-equal)
|
||||
@@ -45,9 +59,11 @@ if(BRLCAD_ENABLE_QT)
|
||||
add_definitions(${Qt5Widgets_DEFINITIONS})
|
||||
set(LINKLIBS ${LINKLIBS} ${Qt5Widgets_LIBRARIES})
|
||||
set(fbqt_srcs if_qt.cpp)
|
||||
set_property(SOURCE if_qt.cpp APPEND PROPERTY COMPILE_DEFINITIONS FB_USE_INTERNAL_API)
|
||||
endif(BRLCAD_ENABLE_QT)
|
||||
|
||||
set(LIBFB_SOURCES
|
||||
${fbosg_srcs}
|
||||
${fbX11_srcs}
|
||||
${fbogl_srcs}
|
||||
${fbwgl_srcs}
|
||||
@@ -74,6 +90,7 @@ set(LIBFB_SOURCES
|
||||
add_definitions(
|
||||
-DIF_REMOTE
|
||||
-DIF_AB
|
||||
${FBOSGDEFS}
|
||||
${FBX11DEFS}
|
||||
${FBOGLDEFS}
|
||||
${FBTKDEFS}
|
||||
@@ -89,12 +106,13 @@ endif(BRLCAD_BUILD_LOCAL_TK AND BRLCAD_ENABLE_TK)
|
||||
|
||||
set(libfb_ignore_files
|
||||
if_TEMPLATE.c
|
||||
if_X.c
|
||||
if_X24.c
|
||||
if_ogl.c
|
||||
if_osg.cpp
|
||||
if_qt.cpp
|
||||
if_tk.c
|
||||
if_wgl.c
|
||||
fb_private.h
|
||||
)
|
||||
CMAKEFILES(${libfb_ignore_files})
|
||||
|
||||
|
||||
+302
-161
@@ -1,4 +1,4 @@
|
||||
/* F B _ `gG E N E R I C . C
|
||||
/* F B _ G E N E R I C . C
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 1986-2014 United States Government as represented by
|
||||
@@ -45,20 +45,284 @@
|
||||
#include "bu/malloc.h"
|
||||
#include "bu/str.h"
|
||||
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
/**
|
||||
* First element of list is default device when no name given
|
||||
*/
|
||||
static
|
||||
fb *_if_list[] = {
|
||||
#ifdef IF_OSG
|
||||
&osg_interface,
|
||||
#endif
|
||||
#ifdef IF_WGL
|
||||
&wgl_interface,
|
||||
#endif
|
||||
#ifdef IF_OGL
|
||||
&ogl_interface,
|
||||
#endif
|
||||
#ifdef IF_X
|
||||
&X24_interface,
|
||||
#endif
|
||||
#ifdef IF_TK
|
||||
&tk_interface,
|
||||
#endif
|
||||
#ifdef IF_QT
|
||||
&qt_interface,
|
||||
#endif
|
||||
|
||||
extern int X24_close_existing(FBIO *ifp);
|
||||
extern int ogl_close_existing(FBIO *ifp);
|
||||
extern int wgl_close_existing(FBIO *ifp);
|
||||
extern int qt_close_existing(FBIO *ifp);
|
||||
&debug_interface,
|
||||
/* never get any of the following by default */
|
||||
&stk_interface,
|
||||
&memory_interface,
|
||||
&null_interface,
|
||||
(fb *) 0
|
||||
};
|
||||
|
||||
fb *fb_get()
|
||||
{
|
||||
struct fb_internal *new_fb = FB_NULL;
|
||||
BU_GET(new_fb, struct fb_internal);
|
||||
new_fb->if_name = NULL;
|
||||
return new_fb;
|
||||
}
|
||||
|
||||
void fb_put(fb *ifp)
|
||||
{
|
||||
if (ifp != FB_NULL)
|
||||
BU_PUT(ifp, struct fb_internal);
|
||||
}
|
||||
|
||||
void fb_set_interface(fb *ifp, const char *interface)
|
||||
{
|
||||
int i = 0;
|
||||
if (!ifp) return;
|
||||
while (_if_list[i] != FB_NULL) {
|
||||
if (bu_strncmp(interface, _if_list[i]->if_name+5,
|
||||
strlen(_if_list[i]->if_name-5)) == 0) {
|
||||
/* found it, copy its struct in */
|
||||
*ifp = *(_if_list[i]);
|
||||
return;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct fb_platform_specific *
|
||||
fb_get_platform_specific(uint32_t magic)
|
||||
{
|
||||
int i = 0;
|
||||
if (!magic) return NULL;
|
||||
while (_if_list[i] != FB_NULL) {
|
||||
if (magic == _if_list[i]->type_magic) {
|
||||
/* found it, get its specific struct */
|
||||
return (*(_if_list[i])).if_existing_get(magic);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
fb_put_platform_specific(struct fb_platform_specific *fb_p)
|
||||
{
|
||||
int i = 0;
|
||||
if (!fb_p) return;
|
||||
while (_if_list[i] != FB_NULL) {
|
||||
if (fb_p->magic == _if_list[i]->type_magic) {
|
||||
/* found it, clear its specific struct */
|
||||
(*(_if_list[i])).if_existing_put(fb_p);
|
||||
return;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
fb *
|
||||
fb_open_existing(const char *file, int width, int height, struct fb_platform_specific *fb_p)
|
||||
{
|
||||
fb *ifp = (fb *) calloc(sizeof(fb), 1);
|
||||
fb_set_interface(ifp, file);
|
||||
fb_set_magic(ifp, FB_MAGIC);
|
||||
ifp->if_open_existing(ifp, width, height, fb_p);
|
||||
return ifp;
|
||||
}
|
||||
|
||||
int
|
||||
fb_refresh(fb *ifp, int x, int y, int w, int h)
|
||||
{
|
||||
return ifp->if_refresh(ifp, x, y, w, h);
|
||||
}
|
||||
|
||||
int
|
||||
fb_configure_window(fb *ifp, int width, int height)
|
||||
{
|
||||
/* unknown/unset framebuffer */
|
||||
if (!ifp || !ifp->if_configure_window || width < 0 || height < 0) {
|
||||
return 0;
|
||||
}
|
||||
return ifp->if_configure_window(ifp, width, height);
|
||||
}
|
||||
|
||||
void fb_set_name(fb *ifp, const char *name)
|
||||
{
|
||||
if (!ifp) return;
|
||||
/*if (ifp->if_name) bu_free(ifp->if_name, "free pre-existing fb name");*/
|
||||
ifp->if_name = (char *)bu_malloc((unsigned)strlen(name)+1, "if_name");
|
||||
bu_strlcpy(ifp->if_name, name, strlen(name)+1);
|
||||
}
|
||||
|
||||
char *fb_get_name(fb *ifp)
|
||||
{
|
||||
if (!ifp) return NULL;
|
||||
return ifp->if_name;
|
||||
}
|
||||
|
||||
long fb_get_pagebuffer_pixel_size(fb *ifp)
|
||||
{
|
||||
if (!ifp) return 0;
|
||||
return ifp->if_ppixels;
|
||||
}
|
||||
|
||||
|
||||
int fb_is_set_fd(fb *ifp, fd_set *infds)
|
||||
{
|
||||
if (!ifp) return 0;
|
||||
if (!infds) return 0;
|
||||
if (!ifp->if_selfd) return 0;
|
||||
if (ifp->if_selfd <= 0) return 0;
|
||||
return FD_ISSET(ifp->if_selfd, infds);
|
||||
}
|
||||
|
||||
int fb_set_fd(fb *ifp, fd_set *select_list)
|
||||
{
|
||||
if (!ifp) return 0;
|
||||
if (!select_list) return 0;
|
||||
if (!ifp->if_selfd) return 0;
|
||||
if (ifp->if_selfd <= 0) return 0;
|
||||
FD_SET(ifp->if_selfd, select_list);
|
||||
return ifp->if_selfd;
|
||||
}
|
||||
|
||||
int fb_clear_fd(fb *ifp, fd_set *list)
|
||||
{
|
||||
if (!ifp) return 0;
|
||||
if (!list) return 0;
|
||||
if (!ifp->if_selfd) return 0;
|
||||
if (ifp->if_selfd <= 0) return 0;
|
||||
FD_CLR(ifp->if_selfd, list);
|
||||
return ifp->if_selfd;
|
||||
}
|
||||
|
||||
void fb_set_magic(fb *ifp, uint32_t magic)
|
||||
{
|
||||
ifp->if_magic = magic;
|
||||
}
|
||||
|
||||
|
||||
char *fb_gettype(fb *ifp)
|
||||
{
|
||||
return ifp->if_type;
|
||||
}
|
||||
|
||||
int fb_getwidth(fb *ifp)
|
||||
{
|
||||
return ifp->if_width;
|
||||
}
|
||||
int fb_getheight(fb *ifp)
|
||||
{
|
||||
return ifp->if_height;
|
||||
}
|
||||
|
||||
int fb_get_max_width(fb *ifp)
|
||||
{
|
||||
return ifp->if_max_width;
|
||||
}
|
||||
int fb_get_max_height(fb *ifp)
|
||||
{
|
||||
return ifp->if_max_height;
|
||||
}
|
||||
|
||||
|
||||
int fb_poll(fb *ifp)
|
||||
{
|
||||
return (*ifp->if_poll)(ifp);
|
||||
}
|
||||
int fb_help(fb *ifp)
|
||||
{
|
||||
return (*ifp->if_help)(ifp);
|
||||
}
|
||||
int fb_free(fb *ifp)
|
||||
{
|
||||
return (*ifp->if_free)(ifp);
|
||||
}
|
||||
int fb_clear(fb *ifp, unsigned char *pp)
|
||||
{
|
||||
return (*ifp->if_clear)(ifp, pp);
|
||||
}
|
||||
ssize_t fb_read(fb *ifp, int x, int y, unsigned char *pp, size_t count)
|
||||
{
|
||||
return (*ifp->if_read)(ifp, x, y, pp, count);
|
||||
}
|
||||
ssize_t fb_write(fb *ifp, int x, int y, const unsigned char *pp, size_t count)
|
||||
{
|
||||
return (*ifp->if_write)(ifp, x, y, pp, count);
|
||||
}
|
||||
int fb_rmap(fb *ifp, ColorMap *cmap)
|
||||
{
|
||||
return (*ifp->if_rmap)(ifp, cmap);
|
||||
}
|
||||
int fb_wmap(fb *ifp, const ColorMap *cmap)
|
||||
{
|
||||
return (*ifp->if_wmap)(ifp, cmap);
|
||||
}
|
||||
int fb_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
return (*ifp->if_view)(ifp, xcenter, ycenter, xzoom, yzoom);
|
||||
}
|
||||
int fb_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
return (*ifp->if_getview)(ifp, xcenter, ycenter, xzoom, yzoom);
|
||||
}
|
||||
int fb_setcursor(fb *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo)
|
||||
{
|
||||
return (*ifp->if_setcursor)(ifp, bits, xb, yb, xo, yo);
|
||||
}
|
||||
int fb_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
return (*ifp->if_cursor)(ifp, mode, x, y);
|
||||
}
|
||||
int fb_getcursor(fb *ifp, int *mode, int *x, int *y)
|
||||
{
|
||||
return (*ifp->if_getcursor)(ifp, mode, x, y);
|
||||
}
|
||||
int fb_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
return (*ifp->if_readrect)(ifp, xmin, ymin, width, height, pp);
|
||||
}
|
||||
int fb_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
return (*ifp->if_writerect)(ifp, xmin, ymin, width, height, pp);
|
||||
}
|
||||
int fb_bwreadrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
return (*ifp->if_bwreadrect)(ifp, xmin, ymin, width, height, pp);
|
||||
}
|
||||
int fb_bwwriterect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
return (*ifp->if_bwwriterect)(ifp, xmin, ymin, width, height, pp);
|
||||
}
|
||||
|
||||
|
||||
#define Malloc_Bomb(_bytes_) \
|
||||
fb_log("\"%s\"(%d) : allocation of %lu bytes failed.\n", \
|
||||
__FILE__, __LINE__, _bytes_)
|
||||
|
||||
|
||||
/**
|
||||
* True if the non-null string s is all digits
|
||||
*/
|
||||
@@ -86,12 +350,12 @@ int _fb_disk_enable = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Filler for FBIO function slots not used by a particular device
|
||||
* Filler for fb function slots not used by a particular device
|
||||
*/
|
||||
int fb_null(FBIO *ifp)
|
||||
int fb_null(fb *ifp)
|
||||
{
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -101,60 +365,30 @@ int fb_null(FBIO *ifp)
|
||||
/**
|
||||
* Used by if_*.c routines that don't have programmable cursor patterns.
|
||||
*/
|
||||
int fb_null_setcursor(FBIO *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
int fb_null_setcursor(fb *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
{
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* First element of list is default device when no name given
|
||||
*/
|
||||
static
|
||||
FBIO *_if_list[] = {
|
||||
#ifdef IF_WGL
|
||||
&wgl_interface,
|
||||
#endif
|
||||
#ifdef IF_OGL
|
||||
&ogl_interface,
|
||||
#endif
|
||||
#ifdef IF_X
|
||||
&X24_interface,
|
||||
&X_interface,
|
||||
#endif
|
||||
#ifdef IF_TK
|
||||
&tk_interface,
|
||||
#endif
|
||||
#ifdef IF_QT
|
||||
&qt_interface,
|
||||
#endif
|
||||
|
||||
&debug_interface,
|
||||
/* never get any of the following by default */
|
||||
&stk_interface,
|
||||
&memory_interface,
|
||||
&null_interface,
|
||||
(FBIO *) 0
|
||||
};
|
||||
|
||||
|
||||
FBIO *
|
||||
fb *
|
||||
fb_open(const char *file, int width, int height)
|
||||
{
|
||||
register FBIO *ifp;
|
||||
register fb *ifp;
|
||||
int i;
|
||||
|
||||
if (width < 0 || height < 0)
|
||||
return FBIO_NULL;
|
||||
return FB_NULL;
|
||||
|
||||
ifp = (FBIO *) calloc(sizeof(FBIO), 1);
|
||||
if (ifp == FBIO_NULL) {
|
||||
Malloc_Bomb(sizeof(FBIO));
|
||||
return FBIO_NULL;
|
||||
ifp = (fb *) calloc(sizeof(fb), 1);
|
||||
if (ifp == FB_NULL) {
|
||||
Malloc_Bomb(sizeof(fb));
|
||||
return FB_NULL;
|
||||
}
|
||||
if (file == NULL || *file == '\0') {
|
||||
/* No name given, check environment variable first. */
|
||||
@@ -176,7 +410,7 @@ fb_open(const char *file, int width, int height)
|
||||
* device array. If we don't find it assume it's a file.
|
||||
*/
|
||||
i = 0;
|
||||
while (_if_list[i] != (FBIO *)NULL) {
|
||||
while (_if_list[i] != (fb *)NULL) {
|
||||
if (bu_strncmp(file, _if_list[i]->if_name,
|
||||
strlen(_if_list[i]->if_name)) == 0) {
|
||||
/* found it, copy its struct in */
|
||||
@@ -191,7 +425,7 @@ fb_open(const char *file, int width, int height)
|
||||
if (bu_strncmp(file, "/dev/", 5) == 0) {
|
||||
fb_log("fb_open: no such device \"%s\".\n", file);
|
||||
free((void *) ifp);
|
||||
return FBIO_NULL;
|
||||
return FB_NULL;
|
||||
}
|
||||
|
||||
#ifdef IF_REMOTE
|
||||
@@ -208,7 +442,7 @@ fb_open(const char *file, int width, int height)
|
||||
} else {
|
||||
fb_log("fb_open: no such device \"%s\".\n", file);
|
||||
free((void *) ifp);
|
||||
return FBIO_NULL;
|
||||
return FB_NULL;
|
||||
}
|
||||
|
||||
found_interface:
|
||||
@@ -217,7 +451,7 @@ found_interface:
|
||||
if (ifp->if_name == (char *)NULL) {
|
||||
Malloc_Bomb(strlen(file) + 1);
|
||||
free((void *) ifp);
|
||||
return FBIO_NULL;
|
||||
return FB_NULL;
|
||||
}
|
||||
bu_strlcpy(ifp->if_name, file, strlen(file)+1);
|
||||
|
||||
@@ -230,18 +464,18 @@ found_interface:
|
||||
ifp->if_magic = 0; /* sanity */
|
||||
free((void *) ifp->if_name);
|
||||
free((void *) ifp);
|
||||
return FBIO_NULL;
|
||||
return FB_NULL;
|
||||
}
|
||||
return ifp;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
fb_close(FBIO *ifp)
|
||||
fb_close(fb *ifp)
|
||||
{
|
||||
int i;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_flush(ifp);
|
||||
if ((i=(*ifp->if_close)(ifp)) <= -1) {
|
||||
fb_log("fb_close: can not close device \"%s\", ret=%d.\n",
|
||||
@@ -257,119 +491,26 @@ fb_close(FBIO *ifp)
|
||||
|
||||
|
||||
int
|
||||
fb_close_existing(FBIO *ifp)
|
||||
fb_close_existing(fb *ifp)
|
||||
{
|
||||
int status = 0;
|
||||
if (!ifp)
|
||||
return 0;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
fb_flush(ifp);
|
||||
|
||||
/* FIXME: these should be callbacks, not listed directly */
|
||||
|
||||
#ifdef IF_X
|
||||
{
|
||||
if (BU_STR_EQUIV(ifp->if_name, X24_interface.if_name)) {
|
||||
int status = -1;
|
||||
if ((status = X24_close_existing(ifp)) <= -1) {
|
||||
fb_log("fb_close_existing: cannot close device \"%s\", ret=%d.\n", ifp->if_name, status);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
if (ifp->if_pbase != PIXEL_NULL) {
|
||||
free((void *)ifp->if_pbase);
|
||||
}
|
||||
free((void *)ifp->if_name);
|
||||
free((void *)ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
status = ifp->if_close_existing(ifp);
|
||||
|
||||
if (status <= -1) {
|
||||
fb_log("fb_close_existing: cannot close device \"%s\", ret=%d.\n", ifp->if_name, status);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
#endif /* IF_X */
|
||||
|
||||
#ifdef IF_WGL
|
||||
{
|
||||
if (BU_STR_EQUIV(ifp->if_name, wgl_interface.if_name)) {
|
||||
int status = -1;
|
||||
if ((status = wgl_close_existing(ifp)) <= -1) {
|
||||
fb_log("fb_close_existing: cannot close device \"%s\", ret=%d.\n", ifp->if_name, status);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
if (ifp->if_pbase != PIXEL_NULL)
|
||||
free((void *)ifp->if_pbase);
|
||||
free((void *)ifp->if_name);
|
||||
free((void *)ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
}
|
||||
#endif /* IF_WGL */
|
||||
|
||||
#ifdef IF_OGL
|
||||
{
|
||||
if (BU_STR_EQUIV(ifp->if_name, ogl_interface.if_name)) {
|
||||
int status = -1;
|
||||
if ((status = ogl_close_existing(ifp)) <= -1) {
|
||||
fb_log("fb_close_existing: cannot close device \"%s\", ret=%d.\n", ifp->if_name, status);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
if (ifp->if_pbase != PIXEL_NULL)
|
||||
free((void *)ifp->if_pbase);
|
||||
free((void *)ifp->if_name);
|
||||
free((void *)ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
}
|
||||
#endif /* IF_OGL */
|
||||
|
||||
#ifdef IF_RTGL
|
||||
{
|
||||
if (BU_STR_EQUIV(ifp->if_name, ogl_interface.if_name)) {
|
||||
int status = -1;
|
||||
if ((status = ogl_close_existing(ifp)) <= -1) {
|
||||
fb_log("fb_close_existing: cannot close device \"%s\", ret=%d.\n", ifp->if_name, status);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
if (ifp->if_pbase != PIXEL_NULL)
|
||||
free((void *)ifp->if_pbase);
|
||||
free((void *)ifp->if_name);
|
||||
free((void *)ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
}
|
||||
#endif /* IF_RTGL */
|
||||
|
||||
#ifdef IF_TK
|
||||
{
|
||||
if (BU_STR_EQUIV(ifp->if_name, tk_interface.if_name)) {
|
||||
/* may need to close_existing here at some point */
|
||||
if (ifp->if_pbase != PIXEL_NULL)
|
||||
free((void *)ifp->if_pbase);
|
||||
free((void *)ifp->if_name);
|
||||
free((void *)ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
}
|
||||
#endif /* IF_TK */
|
||||
|
||||
#ifdef IF_QT
|
||||
{
|
||||
if (BU_STR_EQUIV(ifp->if_name, qt_interface.if_name)) {
|
||||
int status = -1;
|
||||
if ((status = qt_close_existing(ifp)) <= -1) {
|
||||
fb_log("fb_close_existing: cannot close device \"%s\", ret=%d.\n", ifp->if_name, status);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
if (ifp->if_pbase != PIXEL_NULL)
|
||||
free((void *)ifp->if_pbase);
|
||||
free((void *)ifp->if_name);
|
||||
free((void *)ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
}
|
||||
#endif /* IF_QT */
|
||||
|
||||
fb_log("fb_close_existing: cannot close device\nifp: %s\n", ifp->if_name);
|
||||
|
||||
return BRLCAD_ERROR;
|
||||
fb_put(ifp);
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +524,7 @@ fb_genhelp(void)
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (_if_list[i] != (FBIO *)NULL) {
|
||||
while (_if_list[i] != (fb *)NULL) {
|
||||
fb_log("%-12s %s\n",
|
||||
_if_list[i]->if_name,
|
||||
_if_list[i]->if_type);
|
||||
@@ -453,7 +594,7 @@ fb_cmap_crunch(RGBpixel (*scan_buf), int pixel_ct, ColorMap *cmap)
|
||||
}
|
||||
|
||||
int
|
||||
fb_write_fp(FBIO *ifp, FILE *fp, int req_width, int req_height, int crunch, int inverse, struct bu_vls *result)
|
||||
fb_write_fp(fb *ifp, FILE *fp, int req_width, int req_height, int crunch, int inverse, struct bu_vls *result)
|
||||
{
|
||||
unsigned char *scanline; /* 1 scanline pixel buffer */
|
||||
int scanbytes; /* # of bytes of scanline */
|
||||
@@ -538,7 +679,7 @@ fb_skip_bytes(int fd, off_t num, int fileinput, int scanbytes, unsigned char *sc
|
||||
|
||||
|
||||
int
|
||||
fb_read_fd(FBIO *ifp, int fd, int file_width, int file_height, int file_xoff, int file_yoff, int scr_width, int scr_height, int scr_xoff, int scr_yoff, int fileinput, char *file_name, int one_line_only, int multiple_lines, int autosize, int inverse, int clear, int zoom, struct bu_vls *UNUSED(result))
|
||||
fb_read_fd(fb *ifp, int fd, int file_width, int file_height, int file_xoff, int file_yoff, int scr_width, int scr_height, int scr_xoff, int scr_yoff, int fileinput, char *file_name, int one_line_only, int multiple_lines, int autosize, int inverse, int clear, int zoom, struct bu_vls *UNUSED(result))
|
||||
{
|
||||
int y;
|
||||
int xout, yout, n, m, xstart, xskip;
|
||||
|
||||
+8
-7
@@ -38,12 +38,13 @@
|
||||
#include "bio.h"
|
||||
#include "tcl.h"
|
||||
#include "bu/cmd.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
#include "fbserv_obj.h"
|
||||
|
||||
|
||||
/* defined in libfb/tcl.c */
|
||||
extern int fb_refresh(FBIO *ifp, int x, int y, int w, int h);
|
||||
extern int fb_refresh(fb *ifp, int x, int y, int w, int h);
|
||||
|
||||
|
||||
#define FBO_CONSTRAIN(_v, _a, _b) \
|
||||
@@ -61,7 +62,7 @@ static struct fb_obj HeadFBObj; /* head of display manager object list */
|
||||
|
||||
|
||||
HIDDEN int
|
||||
fbo_coords_ok(FBIO *fbp, int x, int y)
|
||||
fbo_coords_ok(fb *fbp, int x, int y)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
@@ -323,7 +324,7 @@ fbo_listen_tcl(void *clientData, int argc, const char **argv)
|
||||
struct fb_obj *fbop = (struct fb_obj *)clientData;
|
||||
struct bu_vls vls = BU_VLS_INIT_ZERO;
|
||||
|
||||
if (fbop->fbo_fbs.fbs_fbp == FBIO_NULL) {
|
||||
if (fbop->fbo_fbs.fbs_fbp == FB_NULL) {
|
||||
bu_log("%s listen: framebuffer not open!\n", argv[0]);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
@@ -720,8 +721,8 @@ fbo_configure_tcl(void *clientData, int argc, const char **argv)
|
||||
}
|
||||
|
||||
/* configure the framebuffer window */
|
||||
if (fbop->fbo_fbs.fbs_fbp != FBIO_NULL)
|
||||
fb_configureWindow(fbop->fbo_fbs.fbs_fbp, width, height);
|
||||
if (fbop->fbo_fbs.fbs_fbp != FB_NULL)
|
||||
(void)fb_configure_window(fbop->fbo_fbs.fbs_fbp, width, height);
|
||||
|
||||
return BRLCAD_OK;
|
||||
}
|
||||
@@ -775,7 +776,7 @@ HIDDEN int
|
||||
fbo_open_tcl(void *UNUSED(clientData), Tcl_Interp *interp, int argc, const char **argv)
|
||||
{
|
||||
struct fb_obj *fbop;
|
||||
FBIO *ifp;
|
||||
fb *ifp;
|
||||
int width = 512;
|
||||
int height = 512;
|
||||
register int c;
|
||||
@@ -821,7 +822,7 @@ fbo_open_tcl(void *UNUSED(clientData), Tcl_Interp *interp, int argc, const char
|
||||
}
|
||||
}
|
||||
|
||||
if ((ifp = fb_open(argv[2], width, height)) == FBIO_NULL) {
|
||||
if ((ifp = fb_open(argv[2], width, height)) == FB_NULL) {
|
||||
bu_log("fb_open: bad device - %s", argv[2]);
|
||||
return BRLCAD_ERROR;
|
||||
}
|
||||
|
||||
+10
-9
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "bu/color.h"
|
||||
#include "bu/log.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
@@ -46,7 +47,7 @@
|
||||
|
||||
|
||||
static int
|
||||
_fb_pgout(register FBIO *ifp)
|
||||
_fb_pgout(register fb *ifp)
|
||||
{
|
||||
size_t scans, first_scan;
|
||||
|
||||
@@ -71,7 +72,7 @@ _fb_pgout(register FBIO *ifp)
|
||||
|
||||
|
||||
static int
|
||||
_fb_pgin(register FBIO *ifp, int pageno)
|
||||
_fb_pgin(register fb *ifp, int pageno)
|
||||
{
|
||||
size_t scans, first_scan;
|
||||
|
||||
@@ -98,7 +99,7 @@ _fb_pgin(register FBIO *ifp, int pageno)
|
||||
|
||||
|
||||
static int
|
||||
_fb_pgflush(register FBIO *ifp)
|
||||
_fb_pgflush(register fb *ifp)
|
||||
{
|
||||
if (ifp->if_debug & FB_DEBUG_BIO) {
|
||||
fb_log("_fb_pgflush(%p)\n", (void *)ifp);
|
||||
@@ -119,7 +120,7 @@ _fb_pgflush(register FBIO *ifp)
|
||||
* routines in this file are used.
|
||||
*/
|
||||
int
|
||||
fb_ioinit(register FBIO *ifp)
|
||||
fb_ioinit(register fb *ifp)
|
||||
{
|
||||
if (ifp->if_debug & FB_DEBUG_BIO) {
|
||||
fb_log("fb_ioinit(%p)\n", (void *)ifp);
|
||||
@@ -145,7 +146,7 @@ fb_ioinit(register FBIO *ifp)
|
||||
|
||||
|
||||
int
|
||||
fb_seek(register FBIO *ifp, int x, int y)
|
||||
fb_seek(register fb *ifp, int x, int y)
|
||||
{
|
||||
long pixelnum;
|
||||
long pagepixel;
|
||||
@@ -177,7 +178,7 @@ fb_seek(register FBIO *ifp, int x, int y)
|
||||
|
||||
|
||||
int
|
||||
fb_tell(register FBIO *ifp, int *xp, int *yp)
|
||||
fb_tell(register fb *ifp, int *xp, int *yp)
|
||||
{
|
||||
*yp = (int) (ifp->if_pixcur / ifp->if_width);
|
||||
*xp = (int) (ifp->if_pixcur % ifp->if_width);
|
||||
@@ -192,7 +193,7 @@ fb_tell(register FBIO *ifp, int *xp, int *yp)
|
||||
|
||||
|
||||
int
|
||||
fb_wpixel(register FBIO *ifp, unsigned char *pixelp)
|
||||
fb_wpixel(register fb *ifp, unsigned char *pixelp)
|
||||
{
|
||||
if (ifp->if_pno == -1)
|
||||
if (_fb_pgin(ifp, ifp->if_pixcur / ifp->if_ppixels) <= -1)
|
||||
@@ -212,7 +213,7 @@ fb_wpixel(register FBIO *ifp, unsigned char *pixelp)
|
||||
|
||||
|
||||
int
|
||||
fb_rpixel(register FBIO *ifp, unsigned char *pixelp)
|
||||
fb_rpixel(register fb *ifp, unsigned char *pixelp)
|
||||
{
|
||||
if (ifp->if_pno == -1)
|
||||
if (_fb_pgin(ifp, ifp->if_pixcur / ifp->if_ppixels) <= -1)
|
||||
@@ -232,7 +233,7 @@ fb_rpixel(register FBIO *ifp, unsigned char *pixelp)
|
||||
|
||||
|
||||
int
|
||||
fb_flush(register FBIO *ifp)
|
||||
fb_flush(register fb *ifp)
|
||||
{
|
||||
_fb_pgflush(ifp);
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/* F B _ P R I V A T E . H
|
||||
* BRL-CAD
|
||||
*
|
||||
* Copyright (c) 2008-2014 United States Government as represented by
|
||||
* the U.S. Army Research Laboratory.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public License
|
||||
* version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this file; see the file named COPYING for more
|
||||
* information.
|
||||
*/
|
||||
/** @file fb_private.h
|
||||
*
|
||||
* Private header for libfb.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LIBFB_FB_PRIVATE_H
|
||||
#define LIBFB_FB_PRIVATE_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <limits.h> /* For INT_MAX */
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "fb.h"
|
||||
|
||||
/* declare all the possible interfaces */
|
||||
#ifdef IF_X
|
||||
FB_EXPORT extern fb X24_interface;
|
||||
#endif
|
||||
#ifdef IF_OGL
|
||||
FB_EXPORT extern fb ogl_interface;
|
||||
#endif
|
||||
#ifdef IF_OSG
|
||||
FB_EXPORT extern fb osg_interface;
|
||||
#endif
|
||||
#ifdef IF_WGL
|
||||
FB_EXPORT extern fb wgl_interface;
|
||||
#endif
|
||||
#ifdef IF_TK
|
||||
FB_EXPORT extern fb tk_interface;
|
||||
#endif
|
||||
#ifdef IF_QT
|
||||
FB_EXPORT extern fb qt_interface;
|
||||
#endif
|
||||
#ifdef IF_REMOTE
|
||||
FB_EXPORT extern fb remote_interface; /* not in list[] */
|
||||
#endif
|
||||
|
||||
/* Always included */
|
||||
FB_EXPORT extern fb debug_interface, disk_interface, stk_interface;
|
||||
FB_EXPORT extern fb memory_interface, null_interface;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/**
|
||||
*@brief
|
||||
* A frame-buffer IO structure.
|
||||
*
|
||||
* One of these is allocated for each active framebuffer. A pointer
|
||||
* to this structure is the first argument to all the library
|
||||
* routines. The details of the structure are hidden behind function
|
||||
* calls in the fb.h API - no code external to libfb should work
|
||||
* directly with structure members.
|
||||
*/
|
||||
struct fb_internal {
|
||||
uint32_t if_magic;
|
||||
uint32_t type_magic;
|
||||
/* Static information: per device TYPE. */
|
||||
int (*if_open)(struct fb_internal *ifp, const char *file, int _width, int _height); /**< @brief open device */
|
||||
int (*if_open_existing)(struct fb_internal *ifp, int width, int height, struct fb_platform_specific *fb_p); /**< @brief open device */
|
||||
int (*if_close_existing)(struct fb_internal *ifp); /**< @brief close embedded fb */
|
||||
struct fb_platform_specific *(*if_existing_get)(uint32_t magic); /**< @brief allocate memory for platform specific container*/
|
||||
void (*if_existing_put)(struct fb_platform_specific *fb_p); /**< @brief free memory for platform specific container */
|
||||
int (*if_close)(struct fb_internal *ifp); /**< @brief close device */
|
||||
int (*if_clear)(struct fb_internal *ifp, unsigned char *pp); /**< @brief clear device */
|
||||
ssize_t (*if_read)(struct fb_internal *ifp, int x, int y, unsigned char *pp, size_t count); /**< @brief read pixels */
|
||||
ssize_t (*if_write)(struct fb_internal *ifp, int x, int y, const unsigned char *pp, size_t count); /**< @brief write pixels */
|
||||
int (*if_rmap)(struct fb_internal *ifp, ColorMap *cmap); /**< @brief read colormap */
|
||||
int (*if_wmap)(struct fb_internal *ifp, const ColorMap *cmap); /**< @brief write colormap */
|
||||
int (*if_view)(struct fb_internal *ifp, int xcent, int ycent, int xzoom, int yzoom); /**< @brief set view */
|
||||
int (*if_getview)(struct fb_internal *ifp, int *xcent, int *ycent, int *xzoom, int *yzoom); /**< @brief get view */
|
||||
int (*if_setcursor)(struct fb_internal *ifp, const unsigned char *bits, int xb, int yb, int xo, int yo); /**< @brief define cursor */
|
||||
int (*if_cursor)(struct fb_internal *ifp, int mode, int x, int y); /**< @brief set cursor */
|
||||
int (*if_getcursor)(struct fb_internal *ifp, int *mode, int *x, int *y); /**< @brief get cursor */
|
||||
int (*if_readrect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp); /**< @brief read rectangle */
|
||||
int (*if_writerect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp); /**< @brief write rectangle */
|
||||
int (*if_bwreadrect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp); /**< @brief read monochrome rectangle */
|
||||
int (*if_bwwriterect)(struct fb_internal *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp); /**< @brief write rectangle */
|
||||
int (*if_configure_window)(struct fb_internal *ifp, int width, int height); /**< @brief configure window */
|
||||
int (*if_refresh)(struct fb_internal *ifp, int x, int y, int w, int h); /**< @brief refresh window */
|
||||
int (*if_poll)(struct fb_internal *ifp); /**< @brief handle events */
|
||||
int (*if_flush)(struct fb_internal *ifp); /**< @brief flush output */
|
||||
int (*if_free)(struct fb_internal *ifp); /**< @brief free resources */
|
||||
int (*if_help)(struct fb_internal *ifp); /**< @brief print useful info */
|
||||
char *if_type; /**< @brief what "open" calls it */
|
||||
int if_max_width; /**< @brief max device width */
|
||||
int if_max_height; /**< @brief max device height */
|
||||
/* Dynamic information: per device INSTANCE. */
|
||||
char *if_name; /**< @brief what the user called it */
|
||||
int if_width; /**< @brief current values */
|
||||
int if_height;
|
||||
int if_selfd; /**< @brief select(fd) for input events if >= 0 */
|
||||
/* Internal information: needed by the library. */
|
||||
int if_fd; /**< @brief internal file descriptor */
|
||||
int if_xzoom; /**< @brief zoom factors */
|
||||
int if_yzoom;
|
||||
int if_xcenter; /**< @brief pan position */
|
||||
int if_ycenter;
|
||||
int if_cursmode; /**< @brief cursor on/off */
|
||||
int if_xcurs; /**< @brief cursor position */
|
||||
int if_ycurs;
|
||||
unsigned char *if_pbase;/**< @brief Address of malloc()ed page buffer. */
|
||||
unsigned char *if_pcurp;/**< @brief Current pointer into page buffer. */
|
||||
unsigned char *if_pendp;/**< @brief End of page buffer. */
|
||||
int if_pno; /**< @brief Current "page" in memory. */
|
||||
int if_pdirty; /**< @brief Page modified flag. */
|
||||
long if_pixcur; /**< @brief Current pixel number in framebuffer. */
|
||||
long if_ppixels; /**< @brief Sizeof page buffer (pixels). */
|
||||
int if_debug; /**< @brief Buffered IO debug flag. */
|
||||
/* State variables for individual interface modules */
|
||||
union {
|
||||
char *p;
|
||||
size_t l;
|
||||
} u1, u2, u3, u4, u5, u6;
|
||||
};
|
||||
|
||||
/*
|
||||
* Some functions and variables we couldn't hide.
|
||||
* Not for general consumption.
|
||||
*/
|
||||
FB_EXPORT extern int _fb_disk_enable;
|
||||
FB_EXPORT extern int fb_sim_readrect(fb *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_writerect(fb *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_bwreadrect(fb *ifp, int xmin, int ymin, int _width, int _height, unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_bwwriterect(fb *ifp, int xmin, int ymin, int _width, int _height, const unsigned char *pp);
|
||||
FB_EXPORT extern int fb_sim_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom);
|
||||
FB_EXPORT extern int fb_sim_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom);
|
||||
FB_EXPORT extern int fb_sim_cursor(fb *ifp, int mode, int x, int y);
|
||||
FB_EXPORT extern int fb_sim_getcursor(fb *ifp, int *mode, int *x, int *y);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* LIBFB_FB_PRIVATE_H */
|
||||
|
||||
/** @} */
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "stroustrup"
|
||||
* End:
|
||||
* ex: shiftwidth=4 tabstop=8
|
||||
*/
|
||||
+5
-4
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "bu/color.h"
|
||||
#include "bu/log.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
@@ -41,7 +42,7 @@
|
||||
* particular display does not handle it.
|
||||
*/
|
||||
int
|
||||
fb_sim_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
fb_sim_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
register int y;
|
||||
register int tot;
|
||||
@@ -74,7 +75,7 @@ fb_sim_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned c
|
||||
* Clipping to the screen may reduce the total if caller was sloppy.
|
||||
*/
|
||||
int
|
||||
fb_sim_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
fb_sim_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
register int y;
|
||||
register int tot;
|
||||
@@ -98,7 +99,7 @@ fb_sim_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const uns
|
||||
|
||||
#define SIMBUF_SIZE (24*1024)
|
||||
int
|
||||
fb_sim_bwreadrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
fb_sim_bwreadrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
register int y;
|
||||
register int tot;
|
||||
@@ -128,7 +129,7 @@ fb_sim_bwreadrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned
|
||||
|
||||
|
||||
int
|
||||
fb_sim_bwwriterect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
fb_sim_bwwriterect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
register int y;
|
||||
register int tot;
|
||||
|
||||
+23
-22
@@ -31,17 +31,18 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
/*
|
||||
* A routine to simulate the effect of fb_view() by simply
|
||||
* storing this information into the FBIO structure.
|
||||
* storing this information into the fb structure.
|
||||
*/
|
||||
int
|
||||
fb_sim_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
fb_sim_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
ifp->if_xcenter = xcenter;
|
||||
ifp->if_ycenter = ycenter;
|
||||
@@ -54,12 +55,12 @@ fb_sim_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
|
||||
/*
|
||||
* A routine to simulate the effect of fb_getview() by simply
|
||||
* reading this information from the FBIO structure.
|
||||
* reading this information from the fb structure.
|
||||
*/
|
||||
int
|
||||
fb_sim_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
fb_sim_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
*xcenter = ifp->if_xcenter;
|
||||
*ycenter = ifp->if_ycenter;
|
||||
@@ -72,12 +73,12 @@ fb_sim_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
|
||||
/*
|
||||
* A routine to simulate the effect of fb_cursor() by simply
|
||||
* storing this information into the FBIO structure.
|
||||
* storing this information into the fb structure.
|
||||
*/
|
||||
int
|
||||
fb_sim_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
fb_sim_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
ifp->if_cursmode = mode;
|
||||
ifp->if_xcurs = x;
|
||||
@@ -89,12 +90,12 @@ fb_sim_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
|
||||
/*
|
||||
* A routine to simulate the effect of fb_getcursor() by simply
|
||||
* reading this information from the FBIO structure.
|
||||
* reading this information from the fb structure.
|
||||
*/
|
||||
int
|
||||
fb_sim_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
fb_sim_getcursor(fb *ifp, int *mode, int *x, int *y)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
*mode = ifp->if_cursmode;
|
||||
*x = ifp->if_xcurs;
|
||||
@@ -107,10 +108,10 @@ fb_sim_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
/* Backward Compatibility Routines */
|
||||
|
||||
int
|
||||
fb_reset(FBIO *ifp)
|
||||
fb_reset(fb *ifp)
|
||||
{
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -118,10 +119,10 @@ fb_reset(FBIO *ifp)
|
||||
|
||||
|
||||
int
|
||||
fb_viewport(FBIO *ifp, int UNUSED(left), int UNUSED(top), int UNUSED(right), int UNUSED(bottom))
|
||||
fb_viewport(fb *ifp, int UNUSED(left), int UNUSED(top), int UNUSED(right), int UNUSED(bottom))
|
||||
{
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -129,13 +130,13 @@ fb_viewport(FBIO *ifp, int UNUSED(left), int UNUSED(top), int UNUSED(right), int
|
||||
|
||||
|
||||
int
|
||||
fb_window(FBIO *ifp, int x, int y)
|
||||
fb_window(fb *ifp, int x, int y)
|
||||
{
|
||||
int xcenter, ycenter;
|
||||
int xzoom, yzoom;
|
||||
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_getview(ifp, &xcenter, &ycenter, &xzoom, &yzoom);
|
||||
xcenter = x;
|
||||
ycenter = y;
|
||||
@@ -147,13 +148,13 @@ fb_window(FBIO *ifp, int x, int y)
|
||||
|
||||
|
||||
int
|
||||
fb_zoom(FBIO *ifp, int x, int y)
|
||||
fb_zoom(fb *ifp, int x, int y)
|
||||
{
|
||||
int xcenter, ycenter;
|
||||
int xzoom, yzoom;
|
||||
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
fb_getview(ifp, &xcenter, &ycenter, &xzoom, &yzoom);
|
||||
xzoom = x;
|
||||
@@ -166,10 +167,10 @@ fb_zoom(FBIO *ifp, int x, int y)
|
||||
|
||||
|
||||
int
|
||||
fb_scursor(FBIO *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
|
||||
fb_scursor(fb *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
|
||||
{
|
||||
if (ifp) {
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
}
|
||||
|
||||
/* We could actually implement this but it
|
||||
|
||||
@@ -51,9 +51,10 @@
|
||||
|
||||
#include "fbmsg.h"
|
||||
#include "fbserv_obj.h"
|
||||
#include "fb_private.h"
|
||||
|
||||
|
||||
static FBIO *curr_fbp; /* current framebuffer pointer */
|
||||
static fb *curr_fbp; /* current framebuffer pointer */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
+20
-20
@@ -56,127 +56,127 @@
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_open(FBIO *ifp, const char *file, int width, int height)
|
||||
DEVNAME_open(fb *ifp, const char *file, int width, int height)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_fb(ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_close(FBIO *ifp)
|
||||
DEVNAME_close(fb *ifp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_clear(FBIO *ifp, unsigned char *pp)
|
||||
DEVNAME_clear(fb *ifp, unsigned char *pp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
DEVNAME_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
{
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
DEVNAME_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
{
|
||||
return (int)count;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
DEVNAME_rmap(fb *ifp, ColorMap *cmp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
DEVNAME_wmap(fb *ifp, const ColorMap *cmp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
DEVNAME_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
DEVNAME_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
|
||||
DEVNAME_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
DEVNAME_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
DEVNAME_getcursor(fb *ifp, int *mode, int *x, int *y)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
DEVNAME_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
return width*height;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
DEVNAME_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
return width*height;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_poll(FBIO *ifp)
|
||||
DEVNAME_poll(fb *ifp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_flush(FBIO *ifp)
|
||||
DEVNAME_flush(fb *ifp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_free(FBIO *ifp)
|
||||
DEVNAME_free(fb *ifp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
DEVNAME_help(FBIO *ifp)
|
||||
DEVNAME_help(fb *ifp)
|
||||
{
|
||||
fb_log("Description: %s\n", DEVNAME_interface.if_type);
|
||||
fb_log("Device: %s\n", ifp->if_name);
|
||||
@@ -191,7 +191,7 @@ DEVNAME_help(FBIO *ifp)
|
||||
|
||||
|
||||
/* This is the ONLY thing that we normally "export" */
|
||||
FBIO DEVNAME_interface = {
|
||||
fb DEVNAME_interface = {
|
||||
0, /* magic number slot */
|
||||
DEVNAME_open, /* open device */
|
||||
DEVNAME_close, /* close device */
|
||||
|
||||
-1766
File diff suppressed because it is too large
Load Diff
+98
-98
@@ -76,8 +76,10 @@
|
||||
|
||||
#include "bu/color.h"
|
||||
#include "bu/file.h"
|
||||
#include "bu/malloc.h"
|
||||
#include "bu/str.h"
|
||||
#include "fb.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb/fb_platform_specific.h"
|
||||
|
||||
|
||||
#define SHMEM_KEY 42
|
||||
@@ -530,7 +532,7 @@ X24_createColorTables(struct xinfo *xi)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
x24_setup(FBIO *ifp, int width, int height)
|
||||
x24_setup(fb *ifp, int width, int height)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
|
||||
@@ -541,7 +543,7 @@ x24_setup(FBIO *ifp, int width, int height)
|
||||
XRectangle rect;
|
||||
char *xname;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* Save these in state structure */
|
||||
|
||||
@@ -1011,7 +1013,7 @@ x24_setup(FBIO *ifp, int width, int height)
|
||||
* x1, y1->w, h describes a Rectangle of changed bits (image space coord.)
|
||||
*/
|
||||
HIDDEN void
|
||||
X24_blit(FBIO *ifp, int x1, int y1, int w, int h, int flags /* BLIT_xxx flags */)
|
||||
X24_blit(fb *ifp, int x1, int y1, int w, int h, int flags /* BLIT_xxx flags */)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
|
||||
@@ -1042,7 +1044,7 @@ X24_blit(FBIO *ifp, int x1, int y1, int w, int h, int flags /* BLIT_xxx flags */
|
||||
unsigned int mask_blue = xi->xi_image->blue_mask << 6;
|
||||
size_t i;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*
|
||||
* Now that we know the mask, we shift a bit left, one bit at a
|
||||
@@ -1867,10 +1869,10 @@ X24_blit(FBIO *ifp, int x1, int y1, int w, int h, int flags /* BLIT_xxx flags */
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
X24_rmap(fb *ifp, ColorMap *cmp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
memcpy(cmp, xi->xi_rgb_cmap, sizeof (ColorMap));
|
||||
|
||||
@@ -1879,12 +1881,12 @@ X24_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
X24_wmap(fb *ifp, const ColorMap *cmp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
ColorMap *map = xi->xi_rgb_cmap;
|
||||
int waslincmap;
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* Did we have a linear colormap before this call? */
|
||||
|
||||
@@ -1987,7 +1989,7 @@ X24_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
* accessed again, even though the windows are transient, per-process.
|
||||
*/
|
||||
HIDDEN int
|
||||
X24_getmem(FBIO *ifp)
|
||||
X24_getmem(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
|
||||
@@ -1996,7 +1998,7 @@ X24_getmem(FBIO *ifp)
|
||||
off_t size;
|
||||
int isnew = 0;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
pixsize = ifp->if_max_height * ifp->if_max_width * sizeof(RGBpixel);
|
||||
size = pixsize + sizeof (*xi->xi_rgb_cmap);
|
||||
@@ -2084,7 +2086,7 @@ store\n Run shell command 'limit datasize unlimited' and try again.\n", size);
|
||||
|
||||
|
||||
HIDDEN void
|
||||
X24_updstate(FBIO *ifp)
|
||||
X24_updstate(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
|
||||
@@ -2096,7 +2098,7 @@ X24_updstate(FBIO *ifp)
|
||||
|
||||
int want, avail; /* Wanted/available image pixels */
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*
|
||||
* Set ?wp to the number of whole zoomed image pixels we could display
|
||||
@@ -2419,14 +2421,14 @@ X24_destroy(struct xinfo *xi)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_open(FBIO *ifp, const char *file, int width, int height)
|
||||
X24_open(fb *ifp, const char *file, int width, int height)
|
||||
{
|
||||
struct xinfo *xi;
|
||||
|
||||
unsigned long mode; /* local copy */
|
||||
int getmem_stat;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*
|
||||
* First, attempt to determine operating mode for this open,
|
||||
@@ -2548,21 +2550,20 @@ X24_open(FBIO *ifp, const char *file, int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
X24_configureWindow(FBIO *ifp, int width, int height)
|
||||
int
|
||||
X24_configureWindow(fb *ifp, int width, int height)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
XRectangle rect;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
if (!xi) {
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (width == xi->xi_xwidth && height == xi->xi_xheight) {
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ifp->if_width = ifp->if_max_width = width;
|
||||
@@ -2597,7 +2598,7 @@ X24_configureWindow(FBIO *ifp, int width, int height)
|
||||
if ((xi->xi_pix = (unsigned char *)calloc(sizeof(unsigned int),
|
||||
xi->xi_xwidth*xi->xi_xheight)) == NULL) {
|
||||
fb_log("X24: pix32 malloc failed in resize!\n");
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
xi->xi_image = XCreateImage(xi->xi_dpy, xi->xi_visual,
|
||||
@@ -2614,7 +2615,7 @@ X24_configureWindow(FBIO *ifp, int width, int height)
|
||||
/* Make new buffer and new image */
|
||||
if ((xi->xi_pix = (unsigned char *)calloc(2, xi->xi_xwidth*xi->xi_xheight)) == NULL) {
|
||||
fb_log("X24: pix32 malloc failed in resize!\n");
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
xi->xi_image = XCreateImage(xi->xi_dpy, xi->xi_visual,
|
||||
@@ -2633,7 +2634,7 @@ X24_configureWindow(FBIO *ifp, int width, int height)
|
||||
if ((xi->xi_pix = (unsigned char *)calloc(sizeof(char),
|
||||
xi->xi_xwidth * xi->xi_xheight)) == NULL) {
|
||||
fb_log("X24: pix8 malloc failed in resize!\n");
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
xi->xi_image = XCreateImage(xi->xi_dpy, xi->xi_visual,
|
||||
@@ -2652,7 +2653,7 @@ X24_configureWindow(FBIO *ifp, int width, int height)
|
||||
if ((xi->xi_pix = (unsigned char *)calloc(sizeof(char),
|
||||
xi->xi_image->bytes_per_line * xi->xi_xheight)) == NULL) {
|
||||
fb_log("X24: pix1 malloc failed in resize!\n");
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
xi->xi_image->data = (char *) xi->xi_pix;
|
||||
@@ -2662,11 +2663,14 @@ X24_configureWindow(FBIO *ifp, int width, int height)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_X24_open_existing(FBIO *ifp, Display *dpy, Window win, Window cwinp, Colormap cmap, XVisualInfo *vip, int width, int height, GC gc)
|
||||
_X24_open_existing(fb *ifp, Display *dpy, Window win, Window cwinp, Colormap cmap, XVisualInfo *vip, int width, int height, GC gc)
|
||||
{
|
||||
struct xinfo *xi;
|
||||
int getmem_stat;
|
||||
@@ -2831,57 +2835,46 @@ _X24_open_existing(FBIO *ifp, Display *dpy, Window win, Window cwinp, Colormap c
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
X24_open_existing(FBIO *ifp, int argc, const char **argv)
|
||||
HIDDEN struct fb_platform_specific *
|
||||
X24_get_fbps(uint32_t magic)
|
||||
{
|
||||
Display *dpy;
|
||||
Window win;
|
||||
Window cwinp;
|
||||
Colormap cmap;
|
||||
XVisualInfo *vip;
|
||||
int width;
|
||||
int height;
|
||||
GC gc;
|
||||
struct fb_platform_specific *fb_ps = NULL;
|
||||
struct X24_fb_info *data = NULL;
|
||||
BU_GET(fb_ps, struct fb_platform_specific);
|
||||
BU_GET(data, struct X24_fb_info);
|
||||
fb_ps->magic = magic;
|
||||
fb_ps->data = data;
|
||||
return fb_ps;
|
||||
}
|
||||
|
||||
if (argc != 9)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[1], "%p", (void **)&dpy) != 1)
|
||||
return -1;
|
||||
HIDDEN void
|
||||
X24_put_fbps(struct fb_platform_specific *fbps)
|
||||
{
|
||||
BU_CKMAG(fbps, FB_X24_MAGIC, "X24 framebuffer");
|
||||
BU_PUT(fbps->data, struct X24_fb_info);
|
||||
BU_PUT(fbps, struct fb_platform_specific);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sscanf(argv[2], "%p", (void **)&win) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[3], "%p", (void **)&cwinp) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[4], "%p", (void **)&cmap) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[5], "%p", (void **)&vip) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[6], "%d", &width) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[7], "%d", &height) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[8], "%p", (void **)&gc) != 1)
|
||||
return -1;
|
||||
|
||||
return _X24_open_existing(ifp, dpy, win, cwinp, cmap, vip, width, height, gc);
|
||||
HIDDEN int
|
||||
X24_open_existing(fb *ifp, int width, int height, struct fb_platform_specific *fb_p)
|
||||
{
|
||||
struct X24_fb_info *x24_internal = (struct X24_fb_info *)fb_p->data;
|
||||
BU_CKMAG(fb_p, FB_X24_MAGIC, "X24 framebuffer");
|
||||
return _X24_open_existing(ifp, x24_internal->dpy, x24_internal->win,
|
||||
x24_internal->cwinp, x24_internal->cmap, x24_internal->vip,
|
||||
width, height, x24_internal->gc);
|
||||
}
|
||||
|
||||
|
||||
static int alive = 1;
|
||||
|
||||
HIDDEN void
|
||||
X24_handle_event(FBIO *ifp, XEvent *event)
|
||||
X24_handle_event(fb *ifp, XEvent *event)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
switch ((int)event->type) {
|
||||
case Expose:
|
||||
@@ -3003,11 +2996,11 @@ X24_handle_event(FBIO *ifp, XEvent *event)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
x24_linger(FBIO *ifp)
|
||||
x24_linger(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
XEvent event;
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
if (fork() != 0)
|
||||
return 1; /* release the parent */
|
||||
@@ -3021,10 +3014,10 @@ x24_linger(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_close(FBIO *ifp)
|
||||
X24_close(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
XFlush(xi->xi_dpy);
|
||||
if ((xi->xi_mode & MODE1_MASK) == MODE1_LINGERING) {
|
||||
@@ -3039,10 +3032,10 @@ X24_close(FBIO *ifp)
|
||||
|
||||
|
||||
int
|
||||
X24_close_existing(FBIO *ifp)
|
||||
X24_close_existing(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
if (xi->xi_image)
|
||||
XDestroyImage(xi->xi_image);
|
||||
@@ -3064,7 +3057,7 @@ X24_close_existing(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_clear(FBIO *ifp, unsigned char *pp)
|
||||
X24_clear(fb *ifp, unsigned char *pp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
|
||||
@@ -3073,7 +3066,7 @@ X24_clear(FBIO *ifp, unsigned char *pp)
|
||||
int n;
|
||||
unsigned char *cp;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
if (pp == (unsigned char *)NULL) {
|
||||
red = grn = blu = 0;
|
||||
@@ -3106,11 +3099,11 @@ X24_clear(FBIO *ifp, unsigned char *pp)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
X24_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
X24_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
size_t maxcount;
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* check origin bounds */
|
||||
if (x < 0 || x >= xi->xi_iwidth || y < 0 || y >= xi->xi_iheight)
|
||||
@@ -3127,12 +3120,12 @@ X24_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
X24_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
X24_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
size_t maxcount;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* Check origin bounds */
|
||||
if (x < 0 || x >= xi->xi_iwidth || y < 0 || y >= xi->xi_iheight)
|
||||
@@ -3167,10 +3160,10 @@ X24_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
X24_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* bypass if no change */
|
||||
if (ifp->if_xcenter == xcenter && ifp->if_ycenter == ycenter
|
||||
@@ -3198,7 +3191,7 @@ X24_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
X24_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
|
||||
*xcenter = ifp->if_xcenter;
|
||||
@@ -3212,16 +3205,16 @@ X24_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
|
||||
/*ARGSUSED*/
|
||||
HIDDEN int
|
||||
X24_setcursor(FBIO *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
X24_setcursor(fb *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
X24_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
|
||||
@@ -3279,7 +3272,7 @@ X24_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
X24_getcursor(fb *ifp, int *mode, int *x, int *y)
|
||||
{
|
||||
fb_sim_getcursor(ifp, mode, x, y);
|
||||
|
||||
@@ -3288,10 +3281,10 @@ X24_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
X24_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* Clip arguments */
|
||||
|
||||
@@ -3331,10 +3324,10 @@ X24_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
X24_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* Clip arguments */
|
||||
|
||||
@@ -3377,12 +3370,12 @@ X24_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsign
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_poll(FBIO *ifp)
|
||||
X24_poll(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
XEvent event;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* Check for and dispatch event */
|
||||
while (XCheckMaskEvent(xi->xi_dpy, ~NoEventMask, &event))
|
||||
@@ -3393,10 +3386,10 @@ X24_poll(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_flush(FBIO *ifp)
|
||||
X24_flush(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
XFlush(xi->xi_dpy);
|
||||
return 0;
|
||||
@@ -3404,20 +3397,20 @@ X24_flush(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_free(FBIO *ifp)
|
||||
X24_free(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
X24_help(FBIO *ifp)
|
||||
X24_help(fb *ifp)
|
||||
{
|
||||
struct xinfo *xi = XI(ifp);
|
||||
struct modeflags *mfp;
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
fb_log("Description: %s\n", X24_interface.if_type);
|
||||
fb_log("Device: %s\n", ifp->if_name);
|
||||
@@ -3481,7 +3474,7 @@ X24_help(FBIO *ifp)
|
||||
|
||||
|
||||
int
|
||||
X24_refresh(FBIO *ifp, int x, int y, int w, int h)
|
||||
X24_refresh(fb *ifp, int x, int y, int w, int h)
|
||||
{
|
||||
if (w < 0) {
|
||||
w = -w;
|
||||
@@ -3500,9 +3493,14 @@ X24_refresh(FBIO *ifp, int x, int y, int w, int h)
|
||||
|
||||
|
||||
/* This is the ONLY thing that we normally "export" */
|
||||
FBIO X24_interface = {
|
||||
fb X24_interface = {
|
||||
0, /* magic number slot */
|
||||
FB_X24_MAGIC,
|
||||
X24_open, /* open device */
|
||||
X24_open_existing, /* existing device_open */
|
||||
X24_close_existing, /* existing device_close */
|
||||
X24_get_fbps, /* get platform specific memory */
|
||||
X24_put_fbps, /* free platform specific memory */
|
||||
X24_close, /* close device */
|
||||
X24_clear, /* clear device */
|
||||
X24_read, /* read pixels */
|
||||
@@ -3518,6 +3516,8 @@ FBIO X24_interface = {
|
||||
X24_writerect, /* write rectangle */
|
||||
fb_sim_bwreadrect,
|
||||
fb_sim_bwwriterect,
|
||||
X24_configureWindow,
|
||||
X24_refresh,
|
||||
X24_poll, /* process events */
|
||||
X24_flush, /* flush output */
|
||||
X24_free, /* free resources */
|
||||
|
||||
+83
-40
@@ -33,12 +33,13 @@
|
||||
|
||||
#include "bu/color.h"
|
||||
#include "bu/log.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
HIDDEN int
|
||||
deb_open(FBIO *ifp, const char *file, int width, int height)
|
||||
deb_open(fb *ifp, const char *file, int width, int height)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
if (file == (char *)NULL)
|
||||
fb_log("fb_open(%p, NULL, %d, %d)\n",
|
||||
(void *)ifp, width, height);
|
||||
@@ -69,20 +70,55 @@ deb_open(FBIO *ifp, const char *file, int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN struct fb_platform_specific *
|
||||
deb_get_fbps(uint32_t UNUSED(magic))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN void
|
||||
deb_put_fbps(struct fb_platform_specific *UNUSED(fbps))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
deb_close(FBIO *ifp)
|
||||
deb_open_existing(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height), struct fb_platform_specific *UNUSED(fb_p))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
deb_close_existing(fb *UNUSED(ifp))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
deb_close(fb *ifp)
|
||||
{
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_close(%p)\n", (void *)ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
deb_configure_window(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
deb_clear(FBIO *ifp, unsigned char *pp)
|
||||
deb_refresh(fb *UNUSED(ifp), int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(h))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
deb_clear(fb *ifp, unsigned char *pp)
|
||||
{
|
||||
FB_CK_FB(ifp);
|
||||
if (pp == 0)
|
||||
fb_log("fb_clear(%p, NULL)\n", (void *)ifp);
|
||||
else
|
||||
@@ -95,9 +131,9 @@ deb_clear(FBIO *ifp, unsigned char *pp)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
deb_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
deb_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_read(%p, %4d, %4d, %p, %lu)\n",
|
||||
(void *)ifp, x, y,
|
||||
(void *)pixelp, count);
|
||||
@@ -106,11 +142,11 @@ deb_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
deb_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
deb_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_write(%p, %4d, %4d, %p, %ld)\n",
|
||||
(void *)ifp, x, y,
|
||||
(void *)pixelp, (long)count);
|
||||
@@ -134,9 +170,9 @@ deb_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
deb_rmap(fb *ifp, ColorMap *cmp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_rmap(%p, %p)\n",
|
||||
(void *)ifp, (void *)cmp);
|
||||
return 0;
|
||||
@@ -144,11 +180,11 @@ deb_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
deb_wmap(fb *ifp, const ColorMap *cmp)
|
||||
{
|
||||
int i;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
if (cmp == NULL)
|
||||
fb_log("fb_wmap(%p, NULL)\n",
|
||||
(void *)ifp);
|
||||
@@ -171,9 +207,9 @@ deb_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
deb_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_view(%p, %4d, %4d, %4d, %4d)\n",
|
||||
(void *)ifp, xcenter, ycenter, xzoom, yzoom);
|
||||
fb_sim_view(ifp, xcenter, ycenter, xzoom, yzoom);
|
||||
@@ -182,9 +218,9 @@ deb_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
deb_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_getview(%p, %p, %p, %p, %p)\n",
|
||||
(void *)ifp, (void *)xcenter, (void *)ycenter, (void *)xzoom, (void *)yzoom);
|
||||
fb_sim_getview(ifp, xcenter, ycenter, xzoom, yzoom);
|
||||
@@ -195,9 +231,9 @@ deb_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
|
||||
deb_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_setcursor(%p, %p, %d, %d, %d, %d)\n",
|
||||
(void *)ifp, (void *)bits, xbits, ybits, xorig, yorig);
|
||||
return 0;
|
||||
@@ -205,7 +241,7 @@ deb_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xo
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
deb_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
fb_log("fb_cursor(%p, %d, %4d, %4d)\n",
|
||||
(void *)ifp, mode, x, y);
|
||||
@@ -215,9 +251,9 @@ deb_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
deb_getcursor(fb *ifp, int *mode, int *x, int *y)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_getcursor(%p, %p, %p, %p)\n",
|
||||
(void *)ifp, (void *)mode, (void *)x, (void *)y);
|
||||
fb_sim_getcursor(ifp, mode, x, y);
|
||||
@@ -227,9 +263,9 @@ deb_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
deb_readrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_readrect(%p, (%4d, %4d), %4d, %4d, %p)\n",
|
||||
(void *)ifp, xmin, ymin, width, height,
|
||||
(void *)pp);
|
||||
@@ -238,9 +274,9 @@ deb_readrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
deb_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_writerect(%p, %4d, %4d, %4d, %4d, %p)\n",
|
||||
(void *)ifp, xmin, ymin, width, height,
|
||||
(void *)pp);
|
||||
@@ -249,9 +285,9 @@ deb_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsign
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_bwreadrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
deb_bwreadrect(fb *ifp, int xmin, int ymin, int width, int height, unsigned char *pp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_bwreadrect(%p, (%4d, %4d), %4d, %4d, %p)\n",
|
||||
(void *)ifp, xmin, ymin, width, height,
|
||||
(void *)pp);
|
||||
@@ -260,9 +296,9 @@ deb_bwreadrect(FBIO *ifp, int xmin, int ymin, int width, int height, unsigned ch
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_bwwriterect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
deb_bwwriterect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_bwwriterect(%p, %4d, %4d, %4d, %4d, %p)\n",
|
||||
(void *)ifp, xmin, ymin, width, height,
|
||||
(void *)pp);
|
||||
@@ -271,27 +307,27 @@ deb_bwwriterect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsi
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_poll(FBIO *ifp)
|
||||
deb_poll(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_poll(%p)\n", (void *)ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_flush(FBIO *ifp)
|
||||
deb_flush(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("if_flush(%p)\n", (void *)ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
deb_free(FBIO *ifp)
|
||||
deb_free(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("fb_free(%p)\n", (void *)ifp);
|
||||
return 0;
|
||||
}
|
||||
@@ -299,9 +335,9 @@ deb_free(FBIO *ifp)
|
||||
|
||||
/*ARGSUSED*/
|
||||
HIDDEN int
|
||||
deb_help(FBIO *ifp)
|
||||
deb_help(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
fb_log("Description: %s\n", debug_interface.if_type);
|
||||
fb_log("Device: %s\n", ifp->if_name);
|
||||
fb_log("Max width/height: %d %d\n",
|
||||
@@ -323,9 +359,14 @@ Usage: /dev/debug[#]\n\
|
||||
|
||||
|
||||
/* This is the ONLY thing that we "export" */
|
||||
FBIO debug_interface = {
|
||||
fb debug_interface = {
|
||||
0,
|
||||
FB_DEBUG_MAGIC,
|
||||
deb_open,
|
||||
deb_open_existing,
|
||||
deb_close_existing,
|
||||
deb_get_fbps,
|
||||
deb_put_fbps,
|
||||
deb_close,
|
||||
deb_clear,
|
||||
deb_read,
|
||||
@@ -341,6 +382,8 @@ FBIO debug_interface = {
|
||||
deb_writerect,
|
||||
deb_bwreadrect,
|
||||
deb_bwwriterect,
|
||||
deb_configure_window,
|
||||
deb_refresh,
|
||||
deb_poll,
|
||||
deb_flush,
|
||||
deb_free,
|
||||
|
||||
+56
-12
@@ -32,6 +32,7 @@
|
||||
#include "bu/file.h"
|
||||
#include "bu/log.h"
|
||||
#include "bu/str.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
@@ -46,11 +47,11 @@
|
||||
|
||||
|
||||
HIDDEN int
|
||||
dsk_open(FBIO *ifp, const char *file, int width, int height)
|
||||
dsk_open(fb *ifp, const char *file, int width, int height)
|
||||
{
|
||||
static char zero = 0;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* check for default size */
|
||||
if (width == 0)
|
||||
@@ -99,16 +100,52 @@ dsk_open(FBIO *ifp, const char *file, int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN struct fb_platform_specific *
|
||||
dsk_get_fbps(uint32_t UNUSED(magic))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN void
|
||||
dsk_put_fbps(struct fb_platform_specific *UNUSED(fbps))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
dsk_close(FBIO *ifp)
|
||||
dsk_open_existing(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height), struct fb_platform_specific *UNUSED(fb_p))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
dsk_close_existing(fb *UNUSED(ifp))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
dsk_configure_window(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
dsk_refresh(fb *UNUSED(ifp), int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(h))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
dsk_close(fb *ifp)
|
||||
{
|
||||
return close(ifp->if_fd);
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
dsk_free(FBIO *ifp)
|
||||
dsk_free(fb *ifp)
|
||||
{
|
||||
close(ifp->if_fd);
|
||||
if (bu_file_delete(ifp->if_name)) {
|
||||
@@ -123,7 +160,7 @@ dsk_free(FBIO *ifp)
|
||||
* Clear the disk file to the given color.
|
||||
*/
|
||||
HIDDEN int
|
||||
disk_color_clear(FBIO *ifp, register unsigned char *bpp)
|
||||
disk_color_clear(fb *ifp, register unsigned char *bpp)
|
||||
{
|
||||
static unsigned char pix_buf[DISK_DMA_BYTES] = {0};
|
||||
register unsigned char *pix_to;
|
||||
@@ -159,7 +196,7 @@ disk_color_clear(FBIO *ifp, register unsigned char *bpp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
dsk_clear(FBIO *ifp, unsigned char *bgpp)
|
||||
dsk_clear(fb *ifp, unsigned char *bgpp)
|
||||
{
|
||||
static RGBpixel black = { 0, 0, 0 };
|
||||
|
||||
@@ -171,7 +208,7 @@ dsk_clear(FBIO *ifp, unsigned char *bgpp)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
dsk_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
dsk_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
{
|
||||
size_t bytes = count * sizeof(RGBpixel);
|
||||
size_t todo;
|
||||
@@ -219,7 +256,7 @@ dsk_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
dsk_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
dsk_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
{
|
||||
register ssize_t bytes = count * sizeof(RGBpixel);
|
||||
ssize_t todo;
|
||||
@@ -250,7 +287,7 @@ dsk_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
dsk_rmap(FBIO *ifp, ColorMap *cmap)
|
||||
dsk_rmap(fb *ifp, ColorMap *cmap)
|
||||
{
|
||||
int fd = ifp->if_fd;
|
||||
|
||||
@@ -275,7 +312,7 @@ dsk_rmap(FBIO *ifp, ColorMap *cmap)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
dsk_wmap(FBIO *ifp, const ColorMap *cmap)
|
||||
dsk_wmap(fb *ifp, const ColorMap *cmap)
|
||||
{
|
||||
if (cmap == (ColorMap *) NULL)
|
||||
/* Do not write default map to file. */
|
||||
@@ -297,7 +334,7 @@ dsk_wmap(FBIO *ifp, const ColorMap *cmap)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
dsk_help(FBIO *ifp)
|
||||
dsk_help(fb *ifp)
|
||||
{
|
||||
fb_log("Description: %s\n", disk_interface.if_type);
|
||||
fb_log("Device: %s\n", ifp->if_name);
|
||||
@@ -318,9 +355,14 @@ dsk_help(FBIO *ifp)
|
||||
}
|
||||
|
||||
|
||||
FBIO disk_interface = {
|
||||
fb disk_interface = {
|
||||
0,
|
||||
FB_DISK_MAGIC,
|
||||
dsk_open,
|
||||
dsk_open_existing,
|
||||
dsk_close_existing,
|
||||
dsk_get_fbps,
|
||||
dsk_put_fbps,
|
||||
dsk_close,
|
||||
dsk_clear,
|
||||
dsk_read,
|
||||
@@ -336,6 +378,8 @@ FBIO disk_interface = {
|
||||
fb_sim_writerect,
|
||||
fb_sim_bwreadrect,
|
||||
fb_sim_bwwriterect,
|
||||
dsk_configure_window,
|
||||
dsk_refresh,
|
||||
fb_null, /* poll */
|
||||
fb_null, /* flush */
|
||||
dsk_free,
|
||||
|
||||
+68
-24
@@ -36,12 +36,13 @@
|
||||
#include "bu/color.h"
|
||||
#include "bu/log.h"
|
||||
#include "bu/str.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
/* Per connection private info */
|
||||
struct mem_info {
|
||||
FBIO *fbp; /* attached frame buffer (if any) */
|
||||
fb *fbp; /* attached frame buffer (if any) */
|
||||
unsigned char *mem; /* memory frame buffer */
|
||||
ColorMap cmap; /* color map buffer */
|
||||
int mem_dirty; /* !0 implies unflushed written data */
|
||||
@@ -74,17 +75,17 @@ static struct modeflags {
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_open(FBIO *ifp, const char *file, int width, int height)
|
||||
mem_open(fb *ifp, const char *file, int width, int height)
|
||||
{
|
||||
int mode;
|
||||
const char *cp;
|
||||
FBIO *fbp;
|
||||
fb *fbp;
|
||||
char modebuf[80];
|
||||
char *mp;
|
||||
int alpha;
|
||||
struct modeflags *mfp;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/* This function doesn't look like it will work if file
|
||||
* is NULL - stop before we start, if that's the case.*/
|
||||
@@ -142,7 +143,7 @@ mem_open(FBIO *ifp, const char *file, int width, int height)
|
||||
|
||||
if (*cp) {
|
||||
/* frame buffer device specified */
|
||||
if ((fbp = fb_open(cp, width, height)) == FBIO_NULL) {
|
||||
if ((fbp = fb_open(cp, width, height)) == FB_NULL) {
|
||||
free(MIL(ifp));
|
||||
return -1;
|
||||
}
|
||||
@@ -164,7 +165,7 @@ mem_open(FBIO *ifp, const char *file, int width, int height)
|
||||
(void)free(MIL(ifp));
|
||||
return -1;
|
||||
}
|
||||
if ((MI(ifp)->fbp != FBIO_NULL)
|
||||
if ((MI(ifp)->fbp != FB_NULL)
|
||||
&& (mode & MODE_2MASK) == MODE_2PREREAD) {
|
||||
/* Pre read all of the image data and cmap */
|
||||
int got;
|
||||
@@ -185,14 +186,50 @@ mem_open(FBIO *ifp, const char *file, int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN struct fb_platform_specific *
|
||||
mem_get_fbps(uint32_t UNUSED(magic))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN void
|
||||
mem_put_fbps(struct fb_platform_specific *UNUSED(fbps))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
mem_close(FBIO *ifp)
|
||||
mem_open_existing(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height), struct fb_platform_specific *UNUSED(fb_p))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
mem_close_existing(fb *UNUSED(ifp))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
mem_configure_window(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
mem_refresh(fb *UNUSED(ifp), int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(h))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
mem_close(fb *ifp)
|
||||
{
|
||||
/*
|
||||
* Flush memory/cmap to attached frame buffer if any
|
||||
*/
|
||||
if (MI(ifp)->fbp != FBIO_NULL) {
|
||||
if (MI(ifp)->fbp != FB_NULL) {
|
||||
if (MI(ifp)->cmap_dirty) {
|
||||
fb_wmap(MI(ifp)->fbp, &(MI(ifp)->cmap));
|
||||
}
|
||||
@@ -201,7 +238,7 @@ mem_close(FBIO *ifp)
|
||||
ifp->if_width, ifp->if_height, (unsigned char *)MI(ifp)->mem);
|
||||
}
|
||||
fb_close(MI(ifp)->fbp);
|
||||
MI(ifp)->fbp = FBIO_NULL;
|
||||
MI(ifp)->fbp = FB_NULL;
|
||||
}
|
||||
(void)free((char *)MI(ifp)->mem);
|
||||
(void)free((char *)MIL(ifp));
|
||||
@@ -211,7 +248,7 @@ mem_close(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_clear(FBIO *ifp, unsigned char *pp)
|
||||
mem_clear(fb *ifp, unsigned char *pp)
|
||||
{
|
||||
RGBpixel v;
|
||||
register int n;
|
||||
@@ -249,7 +286,7 @@ mem_clear(FBIO *ifp, unsigned char *pp)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
mem_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
mem_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
{
|
||||
size_t pixels_to_end;
|
||||
|
||||
@@ -268,7 +305,7 @@ mem_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
mem_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
mem_write(fb *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
{
|
||||
size_t pixels_to_end;
|
||||
|
||||
@@ -292,7 +329,7 @@ mem_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
mem_rmap(fb *ifp, ColorMap *cmp)
|
||||
{
|
||||
*cmp = MI(ifp)->cmap; /* struct copy */
|
||||
return 0;
|
||||
@@ -300,7 +337,7 @@ mem_rmap(FBIO *ifp, ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
mem_wmap(fb *ifp, const ColorMap *cmp)
|
||||
{
|
||||
if (cmp == COLORMAP_NULL) {
|
||||
fb_make_linear_cmap(&(MI(ifp)->cmap));
|
||||
@@ -318,7 +355,7 @@ mem_wmap(FBIO *ifp, const ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
mem_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
fb_sim_view(ifp, xcenter, ycenter, xzoom, yzoom);
|
||||
if (MI(ifp)->write_thru) {
|
||||
@@ -330,7 +367,7 @@ mem_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
mem_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
if (MI(ifp)->write_thru) {
|
||||
return fb_getview(MI(ifp)->fbp, xcenter, ycenter,
|
||||
@@ -342,7 +379,7 @@ mem_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
|
||||
mem_setcursor(fb *ifp, const unsigned char *bits, int xbits, int ybits, int xorig, int yorig)
|
||||
{
|
||||
if (MI(ifp)->write_thru) {
|
||||
return fb_setcursor(MI(ifp)->fbp,
|
||||
@@ -353,7 +390,7 @@ mem_setcursor(FBIO *ifp, const unsigned char *bits, int xbits, int ybits, int xo
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
mem_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
fb_sim_cursor(ifp, mode, x, y);
|
||||
if (MI(ifp)->write_thru) {
|
||||
@@ -364,7 +401,7 @@ mem_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
mem_getcursor(fb *ifp, int *mode, int *x, int *y)
|
||||
{
|
||||
if (MI(ifp)->write_thru) {
|
||||
return fb_getcursor(MI(ifp)->fbp, mode, x, y);
|
||||
@@ -375,7 +412,7 @@ mem_getcursor(FBIO *ifp, int *mode, int *x, int *y)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_poll(FBIO *ifp)
|
||||
mem_poll(fb *ifp)
|
||||
{
|
||||
if (MI(ifp)->write_thru) {
|
||||
return fb_poll(MI(ifp)->fbp);
|
||||
@@ -385,12 +422,12 @@ mem_poll(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_flush(FBIO *ifp)
|
||||
mem_flush(fb *ifp)
|
||||
{
|
||||
/*
|
||||
* Flush memory/cmap to attached frame buffer if any
|
||||
*/
|
||||
if (MI(ifp)->fbp != FBIO_NULL) {
|
||||
if (MI(ifp)->fbp != FB_NULL) {
|
||||
if (MI(ifp)->cmap_dirty) {
|
||||
fb_wmap(MI(ifp)->fbp, &(MI(ifp)->cmap));
|
||||
MI(ifp)->cmap_dirty = 0;
|
||||
@@ -410,7 +447,7 @@ mem_flush(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
mem_help(FBIO *ifp)
|
||||
mem_help(fb *ifp)
|
||||
{
|
||||
struct modeflags *mfp;
|
||||
|
||||
@@ -431,9 +468,14 @@ mem_help(FBIO *ifp)
|
||||
|
||||
|
||||
/* This is the ONLY thing that we normally "export" */
|
||||
FBIO memory_interface = {
|
||||
fb memory_interface = {
|
||||
0,
|
||||
FB_MEMORY_MAGIC,
|
||||
mem_open, /* device_open */
|
||||
mem_open_existing, /* existing device_open */
|
||||
mem_close_existing, /* existing device_close */
|
||||
mem_get_fbps,
|
||||
mem_put_fbps,
|
||||
mem_close, /* device_close */
|
||||
mem_clear, /* device_clear */
|
||||
mem_read, /* buffer_read */
|
||||
@@ -449,6 +491,8 @@ FBIO memory_interface = {
|
||||
fb_sim_writerect, /* rectangle write */
|
||||
fb_sim_bwreadrect,
|
||||
fb_sim_bwwriterect,
|
||||
mem_configure_window,
|
||||
mem_refresh,
|
||||
mem_poll, /* poll */
|
||||
mem_flush, /* flush */
|
||||
mem_close, /* free */
|
||||
|
||||
+81
-37
@@ -33,13 +33,14 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "bu/log.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_open(FBIO *ifp, const char *UNUSED(file), int width, int height)
|
||||
null_open(fb *ifp, const char *UNUSED(file), int width, int height)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
if (width > 0)
|
||||
ifp->if_width = width;
|
||||
@@ -49,65 +50,101 @@ null_open(FBIO *ifp, const char *UNUSED(file), int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN struct fb_platform_specific *
|
||||
null_get_fbps(uint32_t UNUSED(magic))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN void
|
||||
null_put_fbps(struct fb_platform_specific *UNUSED(fbps))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
null_close(FBIO *ifp)
|
||||
null_open_existing(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height), struct fb_platform_specific *UNUSED(fb_p))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
null_close_existing(fb *UNUSED(ifp))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
null_configure_window(fb *UNUSED(ifp), int UNUSED(width), int UNUSED(height))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
null_refresh(fb *UNUSED(ifp), int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(h))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
HIDDEN int
|
||||
null_close(fb *ifp)
|
||||
{
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_clear(FBIO *ifp, unsigned char *UNUSED(pp))
|
||||
null_clear(fb *ifp, unsigned char *UNUSED(pp))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
null_read(FBIO *ifp, int UNUSED(x), int UNUSED(y), unsigned char *UNUSED(pixelp), size_t count)
|
||||
null_read(fb *ifp, int UNUSED(x), int UNUSED(y), unsigned char *UNUSED(pixelp), size_t count)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN ssize_t
|
||||
null_write(FBIO *ifp, int UNUSED(x), int UNUSED(y), const unsigned char *UNUSED(pixelp), size_t count)
|
||||
null_write(fb *ifp, int UNUSED(x), int UNUSED(y), const unsigned char *UNUSED(pixelp), size_t count)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_rmap(FBIO *ifp, ColorMap *UNUSED(cmp))
|
||||
null_rmap(fb *ifp, ColorMap *UNUSED(cmp))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_wmap(FBIO *ifp, const ColorMap *UNUSED(cmp))
|
||||
null_wmap(fb *ifp, const ColorMap *UNUSED(cmp))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_view(FBIO *ifp, int UNUSED(xcenter), int UNUSED(ycenter), int UNUSED(xzoom), int UNUSED(yzoom))
|
||||
null_view(fb *ifp, int UNUSED(xcenter), int UNUSED(ycenter), int UNUSED(xzoom), int UNUSED(yzoom))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*fb_sim_view(ifp, xcenter, ycenter, xzoom, yzoom);*/
|
||||
return 0;
|
||||
@@ -115,9 +152,9 @@ null_view(FBIO *ifp, int UNUSED(xcenter), int UNUSED(ycenter), int UNUSED(xzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_getview(FBIO *ifp, int *UNUSED(xcenter), int *UNUSED(ycenter), int *UNUSED(xzoom), int *UNUSED(yzoom))
|
||||
null_getview(fb *ifp, int *UNUSED(xcenter), int *UNUSED(ycenter), int *UNUSED(xzoom), int *UNUSED(yzoom))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*fb_sim_getview(ifp, xcenter, ycenter, xzoom, yzoom);*/
|
||||
return 0;
|
||||
@@ -125,18 +162,18 @@ null_getview(FBIO *ifp, int *UNUSED(xcenter), int *UNUSED(ycenter), int *UNUSED(
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_setcursor(FBIO *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
null_setcursor(fb *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_cursor(FBIO *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
|
||||
null_cursor(fb *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*fb_sim_cursor(ifp, mode, x, y);*/
|
||||
return 0;
|
||||
@@ -144,9 +181,9 @@ null_cursor(FBIO *ifp, int UNUSED(mode), int UNUSED(x), int UNUSED(y))
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_getcursor(FBIO *ifp, int *UNUSED(mode), int *UNUSED(x), int *UNUSED(y))
|
||||
null_getcursor(fb *ifp, int *UNUSED(mode), int *UNUSED(x), int *UNUSED(y))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*fb_sim_getcursor(ifp, mode, x, y);*/
|
||||
return 0;
|
||||
@@ -154,54 +191,54 @@ null_getcursor(FBIO *ifp, int *UNUSED(mode), int *UNUSED(x), int *UNUSED(y))
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_readrect(FBIO *ifp, int UNUSED(xmin), int UNUSED(ymin), int width, int height, unsigned char *UNUSED(pp))
|
||||
null_readrect(fb *ifp, int UNUSED(xmin), int UNUSED(ymin), int width, int height, unsigned char *UNUSED(pp))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return width*height;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_writerect(FBIO *ifp, int UNUSED(xmin), int UNUSED(ymin), int width, int height, const unsigned char *UNUSED(pp))
|
||||
null_writerect(fb *ifp, int UNUSED(xmin), int UNUSED(ymin), int width, int height, const unsigned char *UNUSED(pp))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return width*height;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_poll(FBIO *ifp)
|
||||
null_poll(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_flush(FBIO *ifp)
|
||||
null_flush(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_free(FBIO *ifp)
|
||||
null_free(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
null_help(FBIO *ifp)
|
||||
null_help(fb *ifp)
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
fb_log("Description: %s\n", null_interface.if_type);
|
||||
fb_log("Device: %s\n", ifp->if_name);
|
||||
@@ -217,9 +254,14 @@ null_help(FBIO *ifp)
|
||||
|
||||
|
||||
/* This is the ONLY thing that we normally "export" */
|
||||
FBIO null_interface = {
|
||||
fb null_interface = {
|
||||
0,
|
||||
FB_NULL_MAGIC,
|
||||
null_open, /* device_open */
|
||||
null_open_existing, /* existing device_open */
|
||||
null_close_existing,/* existing device_close */
|
||||
null_get_fbps,
|
||||
null_put_fbps,
|
||||
null_close, /* device_close */
|
||||
null_clear, /* device_clear */
|
||||
null_read, /* buffer_read */
|
||||
@@ -235,6 +277,8 @@ FBIO null_interface = {
|
||||
null_writerect, /* rectangle write */
|
||||
null_readrect, /* bw rectangle read */
|
||||
null_writerect, /* bw rectangle write */
|
||||
null_configure_window,
|
||||
null_refresh,
|
||||
null_poll, /* handle events */
|
||||
null_flush, /* flush output */
|
||||
null_free, /* free resources */
|
||||
|
||||
+74
-77
@@ -84,6 +84,8 @@
|
||||
#include "bio.h"
|
||||
|
||||
#include "bu.h"
|
||||
#include "fb_private.h"
|
||||
#include "fb/fb_platform_specific.h"
|
||||
#include "fb.h"
|
||||
|
||||
|
||||
@@ -285,7 +287,7 @@ sigkid(int UNUSED(pid))
|
||||
* screen if one_y equals -1.
|
||||
*/
|
||||
HIDDEN void
|
||||
backbuffer_to_screen(register FBIO *ifp, int one_y)
|
||||
backbuffer_to_screen(register fb *ifp, int one_y)
|
||||
{
|
||||
struct ogl_clip *clp;
|
||||
|
||||
@@ -360,7 +362,7 @@ backbuffer_to_screen(register FBIO *ifp, int one_y)
|
||||
* rectangle of the frame buffer
|
||||
*/
|
||||
HIDDEN void
|
||||
ogl_xmit_scanlines(register FBIO *ifp, int ybase, int nlines, int xbase, int npix)
|
||||
ogl_xmit_scanlines(register fb *ifp, int ybase, int nlines, int xbase, int npix)
|
||||
{
|
||||
register int y;
|
||||
register int n;
|
||||
@@ -480,7 +482,7 @@ ogl_xmit_scanlines(register FBIO *ifp, int ybase, int nlines, int xbase, int npi
|
||||
|
||||
|
||||
HIDDEN void
|
||||
ogl_cminit(register FBIO *ifp)
|
||||
ogl_cminit(register fb *ifp)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -524,7 +526,7 @@ ogl_cminit(register FBIO *ifp)
|
||||
* might need to be increased.
|
||||
*/
|
||||
HIDDEN int
|
||||
ogl_getmem(FBIO *ifp)
|
||||
ogl_getmem(fb *ifp)
|
||||
{
|
||||
#define SHMEM_KEY 42
|
||||
int pixsize;
|
||||
@@ -643,7 +645,7 @@ ogl_zapmem(void)
|
||||
* (xpixmin, xpixmax, ypixmin, ypixmax)
|
||||
*/
|
||||
void
|
||||
ogl_clipper(register FBIO *ifp)
|
||||
ogl_clipper(register fb *ifp)
|
||||
{
|
||||
register struct ogl_clip *clp;
|
||||
register int i;
|
||||
@@ -704,7 +706,7 @@ ogl_clipper(register FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN void
|
||||
expose_callback(FBIO *ifp)
|
||||
expose_callback(fb *ifp)
|
||||
{
|
||||
XWindowAttributes xwa;
|
||||
struct ogl_clip *clp;
|
||||
@@ -830,12 +832,12 @@ expose_callback(FBIO *ifp)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ogl_configureWindow(FBIO *ifp, int width, int height)
|
||||
int
|
||||
ogl_configureWindow(fb *ifp, int width, int height)
|
||||
{
|
||||
if (width == OGL(ifp)->win_width &&
|
||||
height == OGL(ifp)->win_height)
|
||||
return;
|
||||
return 1;
|
||||
|
||||
ifp->if_width = ifp->if_max_width = width;
|
||||
ifp->if_height = ifp->if_max_height = height;
|
||||
@@ -851,11 +853,12 @@ ogl_configureWindow(FBIO *ifp, int width, int height)
|
||||
|
||||
ogl_getmem(ifp);
|
||||
ogl_clipper(ifp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN void
|
||||
ogl_do_event(FBIO *ifp)
|
||||
ogl_do_event(fb *ifp)
|
||||
{
|
||||
XEvent event;
|
||||
|
||||
@@ -959,7 +962,7 @@ ogl_do_event(FBIO *ifp)
|
||||
* Return NULL on failure.
|
||||
*/
|
||||
HIDDEN XVisualInfo *
|
||||
fb_ogl_choose_visual(FBIO *ifp)
|
||||
fb_ogl_choose_visual(fb *ifp)
|
||||
{
|
||||
|
||||
XVisualInfo *vip, *vibase, *maxvip, _template;
|
||||
@@ -1071,7 +1074,7 @@ fb_ogl_choose_visual(FBIO *ifp)
|
||||
* linear map, 0 for non-linear map (i.e., non-identity map).
|
||||
*/
|
||||
HIDDEN int
|
||||
is_linear_cmap(register FBIO *ifp)
|
||||
is_linear_cmap(register fb *ifp)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -1085,14 +1088,14 @@ is_linear_cmap(register FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
fb_ogl_open(FBIO *ifp, const char *file, int width, int height)
|
||||
fb_ogl_open(fb *ifp, const char *file, int width, int height)
|
||||
{
|
||||
static char title[128];
|
||||
int mode, i, direct;
|
||||
long valuemask;
|
||||
XSetWindowAttributes swa;
|
||||
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
/*
|
||||
* First, attempt to determine operating mode for this open,
|
||||
@@ -1358,8 +1361,9 @@ fb_ogl_open(FBIO *ifp, const char *file, int width, int height)
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
_ogl_open_existing(FBIO *ifp, Display *dpy, Window win, Colormap cmap, XVisualInfo *vip, int width, int height, GLXContext glxc, int double_buffer, int soft_cmap)
|
||||
_ogl_open_existing(fb *ifp, Display *dpy, Window win, Colormap cmap, XVisualInfo *vip, int width, int height, GLXContext glxc, int double_buffer, int soft_cmap)
|
||||
{
|
||||
|
||||
/*XXX for now use private memory */
|
||||
@@ -1423,57 +1427,43 @@ _ogl_open_existing(FBIO *ifp, Display *dpy, Window win, Colormap cmap, XVisualIn
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ogl_open_existing(FBIO *ifp, int argc, const char **argv)
|
||||
HIDDEN struct fb_platform_specific *
|
||||
ogl_get_fbps(uint32_t magic)
|
||||
{
|
||||
Display *dpy;
|
||||
Window win;
|
||||
Colormap cmap;
|
||||
XVisualInfo *vip;
|
||||
int width;
|
||||
int height;
|
||||
GLXContext glxc;
|
||||
int double_buffer;
|
||||
int soft_cmap;
|
||||
struct fb_platform_specific *fb_ps = NULL;
|
||||
struct ogl_fb_info *data = NULL;
|
||||
BU_GET(fb_ps, struct fb_platform_specific);
|
||||
BU_GET(data, struct ogl_fb_info);
|
||||
fb_ps->magic = magic;
|
||||
fb_ps->data = data;
|
||||
return fb_ps;
|
||||
}
|
||||
|
||||
if (argc != 10)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[1], "%p", (void **)&dpy) != 1)
|
||||
return -1;
|
||||
HIDDEN void
|
||||
ogl_put_fbps(struct fb_platform_specific *fbps)
|
||||
{
|
||||
BU_CKMAG(fbps, FB_OGL_MAGIC, "ogl framebuffer");
|
||||
BU_PUT(fbps->data, struct ogl_fb_info);
|
||||
BU_PUT(fbps, struct fb_platform_specific);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sscanf(argv[2], "%p", (void **)&win) != 1)
|
||||
return -1;
|
||||
HIDDEN int
|
||||
ogl_open_existing(fb *ifp, int width, int height, struct fb_platform_specific *fb_p)
|
||||
{
|
||||
struct ogl_fb_info *ogl_internal = (struct ogl_fb_info *)fb_p->data;
|
||||
BU_CKMAG(fb_p, FB_OGL_MAGIC, "ogl framebuffer");
|
||||
return _ogl_open_existing(ifp, ogl_internal->dpy, ogl_internal->win,
|
||||
ogl_internal->cmap, ogl_internal->vip, width, height, ogl_internal->glxc,
|
||||
ogl_internal->double_buffer, ogl_internal->soft_cmap);
|
||||
|
||||
if (sscanf(argv[3], "%p", (void **)&cmap) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[4], "%p", (void **)&vip) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[5], "%d", &width) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[6], "%d", &height) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[7], "%p", (void **)&glxc) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[8], "%d", &double_buffer) != 1)
|
||||
return -1;
|
||||
|
||||
if (sscanf(argv[9], "%d", &soft_cmap) != 1)
|
||||
return -1;
|
||||
|
||||
return _ogl_open_existing(ifp, dpy, win, cmap, vip, width, height,
|
||||
glxc, double_buffer, soft_cmap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_final_close(FBIO *ifp)
|
||||
ogl_final_close(fb *ifp)
|
||||
{
|
||||
|
||||
if (CJDEBUG) {
|
||||
@@ -1515,7 +1505,7 @@ ogl_final_close(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_flush(FBIO *ifp)
|
||||
ogl_flush(fb *ifp)
|
||||
{
|
||||
if ((ifp->if_mode & MODE_12MASK) == MODE_12DELAY_WRITES_TILL_FLUSH) {
|
||||
if (glXMakeCurrent(OGL(ifp)->dispp, OGL(ifp)->wind, OGL(ifp)->glxc)==False) {
|
||||
@@ -1540,7 +1530,7 @@ ogl_flush(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
fb_ogl_close(FBIO *ifp)
|
||||
fb_ogl_close(fb *ifp)
|
||||
{
|
||||
|
||||
ogl_flush(ifp);
|
||||
@@ -1587,7 +1577,7 @@ fb_ogl_close(FBIO *ifp)
|
||||
|
||||
|
||||
int
|
||||
ogl_close_existing(FBIO *ifp)
|
||||
ogl_close_existing(fb *ifp)
|
||||
{
|
||||
if (OGL(ifp)->cursor)
|
||||
XDestroyWindow(OGL(ifp)->dispp, OGL(ifp)->cursor);
|
||||
@@ -1623,7 +1613,7 @@ ogl_close_existing(FBIO *ifp)
|
||||
* Handle any pending input events
|
||||
*/
|
||||
HIDDEN int
|
||||
ogl_poll(FBIO *ifp)
|
||||
ogl_poll(fb *ifp)
|
||||
{
|
||||
ogl_do_event(ifp);
|
||||
|
||||
@@ -1638,7 +1628,7 @@ ogl_poll(FBIO *ifp)
|
||||
* Free shared memory resources, and close.
|
||||
*/
|
||||
HIDDEN int
|
||||
ogl_free(FBIO *ifp)
|
||||
ogl_free(fb *ifp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -1655,7 +1645,7 @@ ogl_free(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_clear(FBIO *ifp, unsigned char *pp)
|
||||
ogl_clear(fb *ifp, unsigned char *pp)
|
||||
{
|
||||
struct ogl_pixel bg;
|
||||
register struct ogl_pixel *oglp;
|
||||
@@ -1728,7 +1718,7 @@ ogl_clear(FBIO *ifp, unsigned char *pp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
ogl_view(fb *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
{
|
||||
struct ogl_clip *clp;
|
||||
|
||||
@@ -1800,7 +1790,7 @@ ogl_view(FBIO *ifp, int xcenter, int ycenter, int xzoom, int yzoom)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
ogl_getview(fb *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
{
|
||||
if (CJDEBUG) printf("entering ogl_getview\n");
|
||||
|
||||
@@ -1815,7 +1805,7 @@ ogl_getview(FBIO *ifp, int *xcenter, int *ycenter, int *xzoom, int *yzoom)
|
||||
|
||||
/* read count pixels into pixelp starting at x, y */
|
||||
HIDDEN ssize_t
|
||||
ogl_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
ogl_read(fb *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
{
|
||||
size_t n;
|
||||
size_t scan_count; /* # pix on this scanline */
|
||||
@@ -1866,7 +1856,7 @@ ogl_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
|
||||
|
||||
/* write count pixels from pixelp starting at xstart, ystart */
|
||||
HIDDEN ssize_t
|
||||
ogl_write(FBIO *ifp, int xstart, int ystart, const unsigned char *pixelp, size_t count)
|
||||
ogl_write(fb *ifp, int xstart, int ystart, const unsigned char *pixelp, size_t count)
|
||||
{
|
||||
size_t scan_count; /* # pix on this scanline */
|
||||
register unsigned char *cp;
|
||||
@@ -1995,7 +1985,7 @@ ogl_write(FBIO *ifp, int xstart, int ystart, const unsigned char *pixelp, size_t
|
||||
* separately.
|
||||
*/
|
||||
HIDDEN int
|
||||
ogl_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
ogl_writerect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
register int x;
|
||||
register int y;
|
||||
@@ -2059,7 +2049,7 @@ ogl_writerect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsign
|
||||
* separately.
|
||||
*/
|
||||
HIDDEN int
|
||||
ogl_bwwriterect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
ogl_bwwriterect(fb *ifp, int xmin, int ymin, int width, int height, const unsigned char *pp)
|
||||
{
|
||||
register int x;
|
||||
register int y;
|
||||
@@ -2118,7 +2108,7 @@ ogl_bwwriterect(FBIO *ifp, int xmin, int ymin, int width, int height, const unsi
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_rmap(register FBIO *ifp, register ColorMap *cmp)
|
||||
ogl_rmap(register fb *ifp, register ColorMap *cmp)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -2135,7 +2125,7 @@ ogl_rmap(register FBIO *ifp, register ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_wmap(register FBIO *ifp, register const ColorMap *cmp)
|
||||
ogl_wmap(register fb *ifp, register const ColorMap *cmp)
|
||||
{
|
||||
register int i;
|
||||
int prev; /* !0 = previous cmap was non-linear */
|
||||
@@ -2195,7 +2185,7 @@ ogl_wmap(register FBIO *ifp, register const ColorMap *cmp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_help(FBIO *ifp)
|
||||
ogl_help(fb *ifp)
|
||||
{
|
||||
struct modeflags *mfp;
|
||||
XVisualInfo *visual = OGL(ifp)->vip;
|
||||
@@ -2259,16 +2249,16 @@ ogl_help(FBIO *ifp)
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_setcursor(FBIO *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
ogl_setcursor(fb *ifp, const unsigned char *UNUSED(bits), int UNUSED(xbits), int UNUSED(ybits), int UNUSED(xorig), int UNUSED(yorig))
|
||||
{
|
||||
FB_CK_FBIO(ifp);
|
||||
FB_CK_FB(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN int
|
||||
ogl_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
ogl_cursor(fb *ifp, int mode, int x, int y)
|
||||
{
|
||||
if (mode) {
|
||||
register int xx, xy;
|
||||
@@ -2331,7 +2321,7 @@ ogl_cursor(FBIO *ifp, int mode, int x, int y)
|
||||
|
||||
|
||||
int
|
||||
ogl_refresh(FBIO *ifp, int x, int y, int w, int h)
|
||||
ogl_refresh(fb *ifp, int x, int y, int w, int h)
|
||||
{
|
||||
int mm;
|
||||
struct ogl_clip *clp;
|
||||
@@ -2378,10 +2368,15 @@ ogl_refresh(FBIO *ifp, int x, int y, int w, int h)
|
||||
|
||||
|
||||
/* This is the ONLY thing that we normally "export" */
|
||||
FBIO ogl_interface =
|
||||
fb ogl_interface =
|
||||
{
|
||||
0, /* magic number slot */
|
||||
FB_OGL_MAGIC,
|
||||
fb_ogl_open, /* open device */
|
||||
ogl_open_existing, /* existing device_open */
|
||||
ogl_close_existing, /* existing device_close */
|
||||
ogl_get_fbps, /* get platform specific memory */
|
||||
ogl_put_fbps, /* free platform specific memory */
|
||||
fb_ogl_close, /* close device */
|
||||
ogl_clear, /* clear device */
|
||||
ogl_read, /* read pixels */
|
||||
@@ -2397,6 +2392,8 @@ FBIO ogl_interface =
|
||||
ogl_writerect, /* write rectangle */
|
||||
fb_sim_bwreadrect,
|
||||
ogl_bwwriterect, /* write rectangle */
|
||||
ogl_configureWindow,
|
||||
ogl_refresh,
|
||||
ogl_poll, /* process events */
|
||||
ogl_flush, /* flush output */
|
||||
ogl_free, /* free resources */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user