[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DECWINDOWS 26-JAN-89 to 29-NOV-90 |
Notice: | See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit |
Moderator: | STAR::VATNE |
|
Created: | Mon Oct 30 1989 |
Last Modified: | Mon Dec 31 1990 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3726 |
Total number of notes: | 19516 |
1336.0. "Troubles on Firefox/VS3520" by OSAV03::NISHII (Koichi Nishii SWS/OS2/Unit2) Wed Aug 30 1989 04:05
Now we support our customer's Forefox (VS3520, 32mb Memory, 24 planes
VMS v5.1-1), and we have following problems.
1. Cannot Draw correct Circle with Dashed Line Type.
*** Program 1 ***
2. When I call XCopyArea with plane_mask, plane_mask does not effect.
*** Program 2 ***
3. Cannot use DirectColor Visual.
( This program works good at first time, but if we execute
many times, X_server process will be died)
*** Program 3 ***
I append these programs this notes.
May I have information to solve these problems ?
Regards.
- west/241 -
/*
*** Program 1 ***
Draw Circle Test
*/
#include <stdio.h>
#include <decw$include/Xlib.h>
#define defRootWin DefaultRootWindow( dpy )
#define defScreen DefaultScreen( dpy )
#define defVisual DefaultVisual( dpy, defScreen )
#define defGC DefaultGC( dpy, defScreen )
#define defDepth DefaultDepth( dpy, defScreen )
#define RootW RootWindow( dpy, defScreen )
#define Parent_Width 800
#define Parent_Height 800
Display *dpy;
Window Parent_Win;
Colormap cmap;
#define P_WHITE 0
#define P_BLACK 1
unsigned long Pixels[2];
unsigned char dash_list[][6] = {
{ 8, 4, 0, 0, 0, 0 },
{ 16, 2, 2, 2, 0, 0 },
{ 24, 2, 2, 2, 2, 2 },
};
int dash_len[] = {
2,
4,
6
};
main()
{
XEvent event;
unsigned long event_mask;
OpenWindow();
XSelectInput( dpy, Parent_Win, ButtonPressMask );
XFlush(dpy);
DrawArc();
while( 1 ) {
XNextEvent( dpy, &event );
if( event.type == ButtonPress ) {
break;
}
}
printf( "OK Good Bye!!\n" );
CloseWindow();
exit( 0 );
}
OpenWindow()
{
XEvent event;
unsigned long win_mask;
XSetWindowAttributes win_atr;
XColor vir,ext;
/*
Open Display ( Connect X-Server )
*/
if( ( dpy = XOpenDisplay( NULL ) ) == NULL ) {
printf( "Can't Open Display\n" );
exit( False );
}
/*
get colormap
*/
cmap = DefaultColormap( dpy, defScreen );
XAllocNamedColor( dpy, cmap, "white", &vir, &ext );
Pixels[P_WHITE] = vir.pixel;
XAllocNamedColor( dpy, cmap, "black", &vir, &ext );
Pixels[P_BLACK] = vir.pixel;
/*
* Create Window
*/
win_mask = CWBackPixel | CWEventMask | CWOverrideRedirect |
CWColormap ;
win_atr.background_pixel = Pixels[P_WHITE];
win_atr.event_mask = NoEventMask;
win_atr.override_redirect = False;
win_atr.colormap = cmap;
Parent_Win = XCreateWindow( dpy, defRootWin, 0, 0,
Parent_Width, Parent_Height, 0, defDepth,
InputOutput, defVisual, win_mask, &win_atr );
XStoreName( dpy, Parent_Win, "Arc-Test" );
/****************/
/* Map Window */
/****************/
XSelectInput( dpy, Parent_Win, ExposureMask );
XMapWindow( dpy, Parent_Win );
XFlush( dpy );
while( "expose loop" ) {
XNextEvent( dpy, &event );
if( event.type == Expose && event.xexpose.count == 0 )
break;
}
XSelectInput( dpy, Parent_Win, NoEventMask );
XSetForeground( dpy, defGC, Pixels[P_BLACK] );
XFlush(dpy);
}
CloseWindow()
{
XDestroyWindow(dpy, Parent_Win);
XCloseDisplay( dpy );
}
DrawArc()
{
int i,x,y,width,ang1,ang2;
ang1 = 0;
ang2 = 360 * 64;
/* Solid */
for( i = 0; i <200; i+=1 ) {
x = i;
y = i;
width = 400 - i*2;
XDrawArc( dpy, Parent_Win, defGC, x, y, width, width, ang1, ang2 );
}
/* Dash */
XSetLineAttributes( dpy,defGC, 0,
LineSolid, CapButt, JoinMiter );
XSetLineAttributes( dpy,defGC, 0,
LineOnOffDash, CapButt, JoinMiter );
XSetDashes( dpy, defGC, 0, dash_list[0], dash_len[0] );
for( i = 0; i <200; i+=1 ) {
x = i + 400;
y = i;
width = 400 - i*2;
XDrawArc( dpy, Parent_Win, defGC, x, y, width, width, ang1, ang2 );
}
/* Dash1 */
XSetLineAttributes( dpy,defGC, 0,
LineSolid, CapButt, JoinMiter );
XSetLineAttributes( dpy,defGC, 0,
LineOnOffDash, CapButt, JoinMiter );
XSetDashes( dpy, defGC, 0, dash_list[1], dash_len[1] );
for( i = 0; i <200; i+=1 ) {
x = i ;
y = i + 400;
width = 400 - i*2;
XDrawArc( dpy, Parent_Win, defGC, x, y, width, width, ang1, ang2 );
}
/* Dash2 */
XSetLineAttributes( dpy,defGC, 0,
LineSolid, CapButt, JoinMiter );
XSetLineAttributes( dpy,defGC, 0,
LineOnOffDash, CapButt, JoinMiter );
XSetDashes( dpy, defGC, 0, dash_list[2], dash_len[2] );
for( i = 0; i <200; i+=1 ) {
x = i + 400;
y = i + 400;
width = 400 - i*2;
XDrawArc( dpy, Parent_Win, defGC, x, y, width, width, ang1, ang2 );
}
XFlush(dpy);
}
/*
*** Program 2 ***
CopyArea Sample
*/
#define VS3520 1
#include <stdio.h>
#include <decw$include:Xlib.h>
#include <decw$include:Xutil.h>
#define defRootWin DefaultRootWindow( dpy )
#define defScreen DefaultScreen( dpy )
#define defVisual DefaultVisual( dpy, defScreen )
#define defGC DefaultGC( dpy, defScreen )
#define defDepth DefaultDepth( dpy, defScreen )
#define RootWin RootWindow( dpy, defScreen )
Display *dpy;
Colormap cmap;
Window Src_Win, Dst_Win;
int Src_Width, Src_Height;
#define MAX_COLOR 8
#define BG_PIXEL 0
#define FG_PIXEL 1
#define RED_PIXEL 2
#define GREEN_PIXEL 3
#define BLUE_PIXEL 4
#define CYAN_PIXEL 5
#define MAGENTA_PIXEL 6
#define YELLOW_PIXEL 7
unsigned long Pixels[MAX_COLOR];
static char *ColName[] = {
"black",
"white",
"red",
"green",
"blue",
"cyan",
"magenta",
"yellow" };
static void DrawFill();
static void CopyArea();
main()
{
int i;
XColor vir,ext;
unsigned long win_mask;
XSetWindowAttributes win_atr;
XEvent event;
unsigned long event_mask, pix;
XImage *ximg;
/*
* connect display
*/
if( ( dpy = XOpenDisplay( NULL ) ) == NULL ) {
printf( "Can't open display.\n" );
exit( 1 );
}
XSetCloseDownMode( dpy, DestroyAll );
/*
* set color
*/
cmap = DefaultColormap( dpy, defScreen );
#ifdef VS3520
for( i = 0; i < MAX_COLOR; i++ ) {
XAllocNamedColor( dpy, cmap, ColName[i], &vir, &ext );
Pixels[i] = ext.pixel;
}
#else
if( ( XAllocColorCells( dpy, cmap, True, 0, 0, Pixels,
MAX_COLOR ) ) == False ) {
printf( "Can't Alloc Color Cell\n" );
exit( 1 );
}
for( i = 0; i < MAX_COLOR; i++ ) {
XStoreNamedColor( dpy, cmap, ColName[i], Pixels[i],
(DoRed|DoGreen|DoBlue) );
}
#endif VS3520
/*
* create window
*/
Src_Width = 320;
Src_Height = 320;
win_mask = CWBackPixel | CWBorderPixel | CWEventMask |
CWOverrideRedirect | CWColormap ;
win_atr.background_pixel = Pixels[BG_PIXEL];
win_atr.border_pixel = Pixels[BG_PIXEL];
win_atr.event_mask = NoEventMask;
win_atr.override_redirect = False;
win_atr.colormap = cmap;
Src_Win = XCreateWindow( dpy, defRootWin, 0, 0,
Src_Width, Src_Height, 0, defDepth,
InputOutput, defVisual, win_mask, &win_atr );
Dst_Win = XCreateWindow( dpy, defRootWin, Src_Width+10, 0,
Src_Width, Src_Height, 0, defDepth,
InputOutput, defVisual, win_mask, &win_atr );
/*
* map window
*/
XSelectInput( dpy, Src_Win, ExposureMask );
XMapWindow( dpy, Dst_Win );
XMapWindow( dpy, Src_Win );
XFlush( dpy );
while( "map loop" ) {
XNextEvent( dpy, &event );
if( event.type == Expose && event.xexpose.count == 0 )
break;
}
/*
* handle event
*/
event_mask = ButtonPressMask | ExposureMask;
XSelectInput( dpy, Src_Win, event_mask );
event_mask = ButtonPressMask;
XSelectInput( dpy, Dst_Win, event_mask );
DrawFill( Src_Win );
while( 1 ) {
XNextEvent( dpy, &event );
if( event.type == ButtonPress ) {
if( event.xbutton.button == Button1 ) {
CopyArea();
}
else if( event.xbutton.button == Button2 ) {
ximg = XGetImage(dpy, event.xbutton.window,
event.xbutton.x,
event.xbutton.y,
1, 1, AllPlanes, ZPixmap);
pix = XGetPixel( ximg,0,0 );
#ifdef VS3520
pix&=0x00ffffff;
#else
pix&=0x000000ff;
#endif VS3520
XDestroyImage( ximg );
XFlush( dpy );
printf( "** point pixel = %08x\n", pix );
}
else if( event.xbutton.button == Button3 ) {
break;
}
}
else if( event.type == Expose ) {
DrawFill( Src_Win );
}
}
}
static void DrawFill()
{
int i, x, width, height;
width = Src_Width / MAX_COLOR;
height = Src_Height;
for( i = x = 0; i < MAX_COLOR; i++ ) {
XSetForeground( dpy, defGC, Pixels[i] );
XFillRectangle( dpy, Src_Win, defGC, x, 0, width, height );
x += width;
}
}
static void CopyArea()
{
unsigned long mask;
printf( "\n------ set plane mask ------\n" );
printf( "input mask(hex)>> 0x" );
scanf( "%x", &mask );
XClearWindow( dpy, Dst_Win );
XSetPlaneMask( dpy, defGC, mask );
XCopyArea( dpy, Src_Win, Dst_Win, defGC, 0, 0,
Src_Width, Src_Height, 0, 0 );
XSetPlaneMask( dpy, defGC, AllPlanes );
XFlush( dpy );
}
/*
*** Program 3 ***
Direct Color Visual Sample
*/
#include <stdio.h>
#include <decw$include/Xlib.h>
#include <decw$include/Xutil.h>
#define defRootWin DefaultRootWindow( dpy )
#define defScreen DefaultScreen( dpy )
#define defVisual DefaultVisual( dpy, defScreen )
#define defGC DefaultGC( dpy, defScreen )
#define defDepth DefaultDepth( dpy, defScreen )
#define RootW RootWindow( dpy, defScreen )
#define Parent_Width 320
#define Parent_Height 320
#define MAX_CELLS 256
Display *dpy;
Window Parent_Win;
Colormap cmap;
Visual *CVisual;
unsigned long *Pixels;
static void OpenWindow();
static void CloseWindow();
static void DispColor();
static void ChangeColor();
main()
{
int i,count;
OpenWindow();
DispColor();
XFlush(dpy);
printf( "count=" );
scanf( "%d", &count );
for( i = 0; i < count; i++ ) {
printf( "count = %d\n", i );
ChangeColor();
XFlush(dpy);
}
CloseWindow();
exit( True );
}
static void OpenWindow()
{
XEvent event;
unsigned long win_mask;
unsigned long gc_mask;
XSetWindowAttributes win_atr;
XGCValues gc_value;
XVisualInfo vis;
/******************/
/* Open Display */
/******************/
if( ( dpy = XOpenDisplay( NULL ) ) == NULL ) {
printf( "Can't Open Display\n" );
exit( False );
}
/*********************/
/* Create Colormap */
/*********************/
if( XMatchVisualInfo( dpy, defScreen, defDepth,
DirectColor, &vis ) == True ) {
}
else {
printf( "Can't support Visual class\n" );
exit( False );
}
CVisual = vis.visual;
cmap = XCreateColormap( dpy, defRootWin,CVisual,AllocNone );
Pixels = NULL;
if( ( Pixels = malloc( MAX_CELLS * sizeof( unsigned long ) ) )
== NULL ) {
printf( "Can't allocate area for cell\n" );
exit( False );
}
if( ( XAllocColorCells( dpy, cmap, True, NULL, NULL, Pixels,
MAX_CELLS ) ) == False ) {
printf( "Can't allocate cell\n" );
exit( False );
}
win_mask = CWBackPixel | CWOverrideRedirect | CWColormap;
win_atr.background_pixel = 0;
win_atr.override_redirect = False;
win_atr.colormap = cmap;
if( ( Parent_Win = XCreateWindow( dpy, defRootWin, 0, 0,
Parent_Width, Parent_Height, 0, defDepth,
InputOutput, CVisual, win_mask, &win_atr ) )
== NULL ) {
printf( "Can't Create window\n" );
exit( False );
}
ChangeColor();
/****************/
/* Map Window */
/****************/
XSelectInput( dpy, Parent_Win, ExposureMask );
XMapWindow( dpy, Parent_Win );
XFlush( dpy );
while( "map loop" ) {
XNextEvent( dpy, &event );
if( event.type == Expose && event.xexpose.count == 0 )
break;
}
XSelectInput( dpy, Parent_Win, NoEventMask );
XInstallColormap( dpy, cmap );
XFlush(dpy);
return;
}
static void CloseWindow()
{
if( Pixels != NULL ) {
free( Pixels );
}
XDestroyWindow(dpy, Parent_Win);
XCloseDisplay( dpy );
return;
}
static void DispColor()
{
int x, y, i, j;
unsigned long no;
int wid,hei;
wid = Parent_Width / 16;
hei = Parent_Height / 16;
for( i = 0; i < 16; i++ ) {
for( j = 0; j < 16; j++ ) {
x = wid * j;
y = hei * i;
no = j+i*16;
XSetForeground( dpy, defGC, Pixels[no] );
XFillRectangle( dpy, Parent_Win, defGC, x, y, wid, hei );
}
}
return;
}
static void ChangeColor()
{
XColor col;
int i, id;
static int no = 1;
col.flags = DoRed;
no = ( ( no==0 )? 1 : 0 );
if( no == 0 ) {
for( i = 0; i < MAX_CELLS; i++ ) {
col.red = ( i+1 ) * 256 - 1;
col.pixel = Pixels[i];
XStoreColor( dpy, cmap, &col );
}
}
else {
for( i = 0, id = MAX_CELLS-1; i < MAX_CELLS; i++, id-- ) {
col.red = ( i + 1 ) * 256 - 1;
col.pixel = Pixels[id];
XStoreColor( dpy, cmap, &col );
}
}
return;
}
T.R | Title | User | Personal Name | Date | Lines |
---|
1336.1 | | STAR::ORGOVAN | Vince Orgovan | Wed Aug 30 1989 08:37 | 3 |
| This has been entered as QAR #3486 in the DECWINDOWS-IFT database
on TRIFID.
|
1336.2 | | PSW::WINALSKI | Meetings are our most important product | Wed Aug 30 1989 15:46 | 5 |
| I didn't know the Firefox had a DirectColor visual. I thought it was TrueColor
or PseudoColor?
--PSW
|
1336.3 | | OSAV03::NISHII | Koichi Nishii SWS/OS2/Unit2 | Wed Oct 11 1989 00:55 | 23 |
| >I didn't know the Firefox had a DirectColor visual. I thought it was TrueColor
>or PseudoColor?
No, I think as follows.
24 planes Firefox has two Visual Type, TrueColor and DirectColor.
^^^^^^^^^^^
Because its Hardware Colormap is for DirectColor.
(VS3100/3500 has Hardware Colormap for PseudoColor.)
And we can use it by True, Direct and Pseudo.
If want to use by TrueColor, Set Visual to TrueColor.
If want to use by DirectColor, Set Visual to DirectColor and
call XAllocColorPlanes.
^^^^^^^^^^^^^^^^^
If want to use by PseudoColor, Set Visual to DirectColor and
call XAllocColorCells. (MAX only 256 colors)
^^^^^^^^^^^^^^^^
Regards.
|
1336.4 | | DECWIN::FISHER | Burns Fisher 381-1466, ZKO3-4/W23 | Wed Oct 11 1989 16:00 | 9 |
| Sorry Koichi, but the FF really does have all three Visual types. Its
hardware is most like a direct color as you say, but it can simulate
all three types. You can use AllocColorCells or Planes from either Direct
or Pseudo visuals. It is just that Cells works most efficiently from
Pseudo and Planes works most efficiently from Direct.
Burns
|