Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "plDevs.h"
00013
00014 #ifdef PLD_linuxvga // Only compile for Linux + Vgalib 1.2
00015
00016 #include "plplotP.h"
00017 #include "drivers.h"
00018 #include <vga.h>
00019
00020
00021 PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_linuxvga = "linuxvga:Linux VGA driver:0:linuxvga:8:vga\n";
00022
00023
00024
00025
00026 void plD_init_vga( PLStream * );
00027 void plD_line_vga( PLStream *, short, short, short, short );
00028 void plD_polyline_vga( PLStream *, short *, short *, PLINT );
00029 void plD_eop_vga( PLStream * );
00030 void plD_bop_vga( PLStream * );
00031 void plD_tidy_vga( PLStream * );
00032 void plD_state_vga( PLStream *, PLINT );
00033 void plD_esc_vga( PLStream *, PLINT, void * );
00034
00035 static void lxvga_text( PLStream *pls );
00036 static void lxvga_graph( PLStream *pls );
00037 static void lxvga_pause( PLStream *pls );
00038
00039 static PLINT vgax = 639;
00040 static PLINT vgay = 479;
00041
00042
00043
00044 #define TEXT_MODE 0
00045 #define GRAPHICS_MODE 1
00046
00047
00048
00049
00050 static int mode = TEXT_MODE;
00051 static int col = 1;
00052 static int totcol = 16;
00053
00054 #define CLEAN 0
00055 #define DIRTY 1
00056
00057 static page_state;
00058
00059 void plD_dispatch_init_vga( PLDispatchTable *pdt )
00060 {
00061 #ifndef ENABLE_DYNDRIVERS
00062 pdt->pl_MenuStr = "Linux console VGA Screen";
00063 pdt->pl_DevName = "vga";
00064 #endif
00065 pdt->pl_type = plDevType_Interactive;
00066 pdt->pl_seq = 8;
00067 pdt->pl_init = (plD_init_fp) plD_init_vga;
00068 pdt->pl_line = (plD_line_fp) plD_line_vga;
00069 pdt->pl_polyline = (plD_polyline_fp) plD_polyline_vga;
00070 pdt->pl_eop = (plD_eop_fp) plD_eop_vga;
00071 pdt->pl_bop = (plD_bop_fp) plD_bop_vga;
00072 pdt->pl_tidy = (plD_tidy_fp) plD_tidy_vga;
00073 pdt->pl_state = (plD_state_fp) plD_state_vga;
00074 pdt->pl_esc = (plD_esc_fp) plD_esc_vga;
00075 }
00076
00077
00078
00079
00080
00081
00082
00083 void
00084 plD_init_vga( PLStream *pls )
00085 {
00086 pls->termin = 1;
00087 pls->graphx = TEXT_MODE;
00088
00089 if ( !pls->colorset )
00090 pls->color = 1;
00091
00092
00093
00094
00095 mode = G640x480x16;
00096 if ( vga_hasmode( mode ) )
00097 vga_setmode( mode );
00098 else
00099 {
00100 printf( "Error: Video mode not supported by graphics card\n" );
00101 exit( -1 );
00102 }
00103
00104
00105
00106 vgax = vga_getxdim() - 1;
00107 vgay = vga_getydim() - 1;
00108
00109 totcol = vga_getcolors();
00110
00111 plP_setpxl( 2.5, 2.5 );
00112 plP_setphy( 0, vgax, 0, vgay );
00113 }
00114
00115
00116
00117
00118
00119
00120
00121 void
00122 plD_line_vga( PLStream *pls, short x1a, short y1a, short x2a, short y2a )
00123 {
00124 int x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
00125
00126 y1 = vgay - y1;
00127 y2 = vgay - y2;
00128
00129 vga_drawline( x1, y1, x2, y2 );
00130
00131 page_state = DIRTY;
00132 }
00133
00134
00135
00136
00137
00138
00139
00140 void
00141 plD_polyline_vga( PLStream *pls, short *xa, short *ya, PLINT npts )
00142 {
00143 PLINT i;
00144
00145 for ( i = 0; i < npts - 1; i++ )
00146 plD_line_vga( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 void
00156 plD_eop_vga( PLStream *pls )
00157 {
00158 if ( page_state == DIRTY )
00159 lxvga_pause( pls );
00160
00161
00162 vga_clear();
00163
00164 page_state = CLEAN;
00165 }
00166
00167
00168
00169
00170
00171
00172
00173
00174 void
00175 plD_bop_vga( PLStream *pls )
00176 {
00177 pls->page++;
00178 plD_eop_vga( pls );
00179 }
00180
00181
00182
00183
00184
00185
00186
00187 void
00188 plD_tidy_vga( PLStream *pls )
00189 {
00190 lxvga_text( pls );
00191 }
00192
00193
00194
00195
00196
00197
00198
00199 void
00200 plD_state_vga( PLStream *pls, PLINT op )
00201 {
00202 switch ( op )
00203 {
00204 case PLSTATE_WIDTH:
00205 break;
00206
00207 case PLSTATE_COLOR0:
00208 if ( pls->color )
00209 {
00210
00211
00212
00213 col = ( pls->icol0 ) % totcol;
00214
00215 vga_setcolor( col );
00216 }
00217 break;
00218
00219 case PLSTATE_COLOR1:
00220 break;
00221 }
00222 }
00223
00224
00225
00226
00227
00228
00229
00230 void
00231 plD_esc_vga( PLStream *pls, PLINT op, void *ptr )
00232 {
00233 switch ( op )
00234 {
00235 case PLESC_TEXT:
00236 lxvga_text( pls );
00237 break;
00238
00239 case PLESC_GRAPH:
00240 lxvga_graph( pls );
00241 break;
00242 }
00243 }
00244
00245
00246
00247
00248
00249
00250
00251 static void
00252 lxvga_text( PLStream *pls )
00253 {
00254 if ( pls->graphx == GRAPHICS_MODE )
00255 {
00256 if ( page_state == DIRTY )
00257 lxvga_pause( pls );
00258 vga_setmode( TEXT );
00259 pls->graphx = TEXT_MODE;
00260 }
00261 }
00262
00263
00264
00265
00266
00267
00268
00269 static void
00270 lxvga_graph( PLStream *pls )
00271 {
00272 if ( pls->graphx == TEXT_MODE )
00273 {
00274 vga_setmode( mode );
00275 pls->graphx = GRAPHICS_MODE;
00276 page_state = CLEAN;
00277 }
00278 }
00279
00280
00281
00282
00283
00284
00285
00286 static void
00287 lxvga_pause( PLStream *pls )
00288 {
00289 if ( pls->nopause )
00290 return;
00291
00292 vga_getch();
00293 }
00294
00295 #else
00296 int
00297 pldummy_vga()
00298 {
00299 return 0;
00300 }
00301
00302 #endif // PLD_linuxvga