Beispiel #1
0
//------------------------------------------------------------------------------
// Purpose :	Draw a grid around the s_vGridPosition
// Input   :
// Output  :
//------------------------------------------------------------------------------
void DrawGridOverlay(void)
{
    static int gridSpacing		= 100;
    static int numHorzSpaces	= 16;
    static int numVertSpaces	= 3;

    Vector startGrid;
    startGrid[0] = gridSpacing*((int)s_vGridPosition[0]/gridSpacing);
    startGrid[1] = gridSpacing*((int)s_vGridPosition[1]/gridSpacing);
    startGrid[2] = s_vGridPosition[2];

    // Shift to the left
    startGrid[0] -= (numHorzSpaces/2)*gridSpacing;
    startGrid[1] -= (numHorzSpaces/2)*gridSpacing;

    Vector color(20,180,190);
    for (int i=1; i<numVertSpaces+1; i++)
    {
        // Draw x axis lines
        Vector startLine;
        VectorCopy(startGrid,startLine);
        for (int j=0; j<numHorzSpaces+1; j++)
        {
            Vector endLine;
            VectorCopy(startLine,endLine);
            endLine[0] += gridSpacing*numHorzSpaces;
            Draw_Line( startLine, endLine, color[0], color[1], color[2], false);

            Vector bottomStartLine;
            VectorCopy(startLine,bottomStartLine);
            for (int k=0; k<numHorzSpaces+1; k++)
            {
                Vector bottomEndLine;
                VectorCopy(bottomStartLine,bottomEndLine);
                bottomEndLine[2] -= gridSpacing;
                Draw_Line( bottomStartLine, bottomEndLine, color[0], color[1], color[2], false);
                bottomStartLine[0] += gridSpacing;
            }
            startLine[1] += gridSpacing;
        }

        // Draw y axis lines
        VectorCopy(startGrid,startLine);
        for (j=0; j<numHorzSpaces+1; j++)
        {
            Vector endLine;
            VectorCopy(startLine,endLine);

            endLine[1] += gridSpacing*numHorzSpaces;
            Draw_Line( startLine, endLine, color[0], color[1], color[2], false);
            startLine[0] += gridSpacing;
        }
        VectorScale( color, 0.7, color );
        startGrid[2]-= gridSpacing;
    }
    s_bDrawGrid				= false;
}
//---------------------------------------------------------
void CDLG_Colors_Control::On_Mouse_Motion(wxMouseEvent &event)
{
	if( m_selBox >= 0 )
	{
		Draw_Line(m_Mouse_Down, m_Mouse_Move);
		m_Mouse_Move	= event.GetPosition();
		KeepInBoxRect(m_Mouse_Move, m_selBox);
		Draw_Line(m_Mouse_Down, m_Mouse_Move);
	}
}
Beispiel #3
0
//Drawing 1 cube
void draw_cube(SDL_Surface *surf, int x, int y, Uint32 color) {
	SDL_Rect box;
	box.x = x;
	box.y = y;
	box.w = box.h = CUBE_S;
	SDL_FillRect(surf, &box, color);
	Draw_Line(surf, (box.x), (box.y), (box.x + box.w - 1), (box.y), 0x000000);
	Draw_Line(surf, (box.x + box.w - 1), (box.y), (box.x + box.w - 1), (box.y + box.h - 1), 0x000000);
	Draw_Line(surf, (box.x + box.w - 1), (box.y + box.h - 1), (box.x), (box.y + box.h - 1), 0x000000);
	Draw_Line(surf, (box.x), (box.y + box.h - 1), (box.x), (box.y), 0x000000);
}
void Draw_Square (int X_1, int Y_1, int Direction_1, COLORREF COLOR_1, int X_2, int Y_2, int Direction_2, COLORREF COLOR_2,int Delay, HDC DeviceContext)
{
 int Cnt_1, Cnt_2;
 for (Cnt_1 = 0; Cnt_1 < 4; Cnt_1++)
 {
  for (Cnt_2 = 0; Cnt_2 < 6; Cnt_2++)
  {
   if (!(X_1 < 0 || X_1 > 24) || (Y_1 < 0 || Y_1 > 24))
   Draw_Line (X_1, Y_1, Direction_1, COLOR_1, Cnt_1*6+Cnt_2, DeviceContext);
   if (!(X_2 < 0 || X_2 > 24) || (Y_2 < 0 || Y_2 > 24))
   Draw_Line (X_2, Y_2, Direction_2, COLOR_2, Cnt_1*6+Cnt_2, DeviceContext);
  }
  Sleep (Delay);
 }
}
Beispiel #5
0
  void draw(Color color = 0xFFFFFFFF, int size = 1) const
  {
		Draw_Line(points_[0].ix(), points_[0].iy(),
              points_[1].ix(), points_[1].iy(),
              points_[0].z(),
              color, size); 
  }
Beispiel #6
0
void RXLCD_DrawLine(unsigned short XS,unsigned short YS,unsigned short XE ,unsigned short YE,unsigned short color)
{
Draw_Line(XS,XE,YS,YE);//画矩形
    Text_Foreground_Color1(color);//颜色设定
	Write_Dir(0X90,0X30);//设定参数
    Write_Dir(0X90,0XB0);//开始画
}
Beispiel #7
0
static
void Draw_Line_Init(SDL_Surface *super,
                    Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
                    Uint32 color)
{
  Draw_Init();
  Draw_Line(super, x1, y1, x2, y2, color);
}
// draw function point
void set_point ( float_t x_real, float_t y_real )
{
	if ((x_real> window_left) & (x_real < window_right) & (y_real > window_down) & (y_real <window_up))
	{
		Text_Foreground_Color( COLOR_WHITE );
		Draw_Line( scale_x( x_real ), scale_y( y_real ), scale_x( x_real ), scale_y( y_real ) );
		RAIO_StartDrawing( LINE );
	}
}
void example_DrawFunction( int16_t function )
{
	float_t x_real, y_real;
	int16_t count;

	RAIO_clear_screen();

	// draw x-axis
	draw_coords_line ( window_left, 0, window_right, 0 );
	for( count = (int16_t)window_left; count < (int16_t)window_right; count++ )
	{
		Draw_Line ( scale_x( count ), scale_y( window_up*0.01 ), scale_x( count ), scale_y( window_down*0.01 ) );
		Text_Foreground_Color ( COLOR_WHITE );
		RAIO_StartDrawing ( LINE );
	}

	// draw y-axis
	draw_coords_line ( 0, window_up, 0, window_down );
	for( count = (int16_t)window_down; count < (int16_t)window_up; count++ )
	{
		Draw_Line ( scale_x( window_left*0.01 ), scale_y( count ), scale_x( window_right*0.01 ), scale_y( count ) );
		Text_Foreground_Color ( COLOR_WHITE );
		RAIO_StartDrawing ( LINE );
	}


	// draw function
	for( x_real = window_left; x_real < window_right; x_real=x_real+0.02 )
	{
		switch (function) // -> see FUNCTIONS
		{
			case SIN:      y_real = sin( x_real );   break;
			case COS:      y_real = cos( x_real );   break;
			case TAN:      y_real = tan( x_real );   break;
			case PARABOLA: y_real = x_real * x_real; break;
			case EXPONENT: y_real = exp( x_real );   break;
			case LOGN    : y_real = log( x_real );   break;
			default: break;
		};
		set_point( x_real, y_real);
	}
}
Beispiel #10
0
void focusline(roteface * activeface)
{
    static double angel=0;
    float csize=30;
#ifdef GL

    glBegin(GL_LINES);
    glColor3f(1,1,0);
    glVertex2i(0,0);
//    glVertex2f(activeface->x, activeface->y);
    glVertex2f(csize*sin(angel)+activeface->x,csize*cos(angel)+activeface->y);
    angel+=0.1;
    if(angel>2*3.14159265358979323846264)angel=0;
    glEnd();
#else
    Draw_Line(gltextsdlsurface,activeface->x,activeface->y,activeface->x+100,activeface->y,barvicka);
    Draw_Line(gltextsdlsurface,activeface->x,activeface->y+100,activeface->x,activeface->y,barvicka);
#endif

}
Beispiel #11
0
void VanKoch (float x1, float y1, float x5, float y5, int ordre, SDL_Surface* f, int couleur)
{
    if (ordre == 0) {
    Draw_Line(f,10,0,300,50,couleur);
        Draw_Line(f,x1,y1,x5,y5, couleur);
    } else {
        float x2, y2, x3, y3 , x4, y4;
        x2 = (x1* 2 +x5)/ 3.f;
        y2 = (y1* 2 +y5)/ 3.f;
        x4 = (x1+x5* 2)/ 3.f;
        y4 =(y1+y5* 2)/ 3.f;
        x3 = x2/2.f - cos(M_PI/ 6)*y2+x4/ 2 +cos(M_PI/ 6)*y4;
        y3 = cos( M_PI/ 6)*x2+y2/ 2. - cos(M_PI/ 6)*x4+y4/ 2.f;

        VanKoch (x1, y1, x2, y2, ordre-1, f, couleur);
        VanKoch (x2, y2, x3, y3, ordre-1, f, couleur);
        VanKoch (x3, y3, x4, y4, ordre-1, f, couleur);
        VanKoch (x4, y4, x5, y5, ordre-1, f, couleur);
    }
}
Beispiel #12
0
void drawCandlestick(SubWin sw,int x, float lowprice, float highprice, DayData data){

	//start postion for rectangle. it will be drawn from start to right down corner 
	int startx = x;
	int starty;

	//length of shadow line; hl mean up shadow line, ll mean down shadow line
	int hl, ll;
	float yunit = (highprice - lowprice)/sw->height;
	int length;
	Uint32 color;
	//get the abs value of the candle
	data->start > data->end ? (starty  = data->start, color = GREEN
	):(starty = data->end,color = RED); 
	length = data->start - data->end;
	if(length<0){
		length*=(-1);
	}
	printf("length = %d \n", length);

	//switch to the relative value
	hl = (int)((data->highest - starty)/yunit);
	ll = (int)((starty -length - data->lowest)/yunit);
	length = (int) (length/yunit);

	printf("length = %d pix\n", length);
	if(length <1){
		length = 1;
	}
	getRelativePosition(sw,&startx,&starty, lowprice, highprice);

	//draw
	Draw_Rect(sw->screen,startx,starty,10,length,color);

	Draw_Line(sw->screen,startx+5,starty,startx+5, starty - hl,color);
	Draw_Line(sw->screen,startx+5,starty+length,startx+5, starty+length+ll,color);
}
Beispiel #13
0
void drawline(double x1,double y1,double x2,double y2,double z)
{
   BITMAP4 black = {0,0,0,0};

   //~ if (x1 < 0 || x1 >= M || x2 < 0 || x2 > N)
      //~ fprintf(stderr,"Shouldn't get here, x out of bounds: %g %g\n",x1,x2);
   //~ if (y1 < 0 || y1 >= N || y2 < 0 || y2 > N)
      //~ fprintf(stderr,"Shouldn't get here, y out of bounds: %g %g\n",y1,y2);
  
  
   Draw_Line(image,SCALE*NGRID,SCALE*NGRID,(int)x1,(int)y1,(int)x2,(int)y2,black);

   
   vectorsdrawn++;
}
Beispiel #14
0
int main(int argc, char const *argv[])
{
	int dimy=800, dimx=1000;
	SDL_Surface*  ecran;

	fenetre = newfenetregraphique(dimx ,dimy);

	Draw_FillEllipse(fenetre, 300,200,20,50,SDL_PH_BLEU); 
    SDL_Flip(fenetre); // Mise à jour de l'écran
    printf("Tapez une touche pour continuer\n"); getchar();
    
	/* meme chose pour une ligne : attention au coordonnees, le point 0,0 est en haut a gauche */
    Draw_Line(fenetre, 10,20,300,200,0x7F000000);

	return 0;
}
Beispiel #15
0
int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

// make sure this isn't executed again
if (window_closed)
   return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
   {
   PostMessage(main_window_handle,WM_CLOSE,0,0);
   window_closed = 1;
   } // end if


// lock primary buffer
DDRAW_INIT_STRUCT(ddsd);

if (FAILED(lpddsprimary->Lock(NULL,&ddsd,
                              DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
                              NULL)))
return(0);

// draw 1000 random lines
for (int index=0; index < 1000; index++)
    {
    Draw_Line(rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
              rand()%SCREEN_WIDTH, rand()%SCREEN_HEIGHT,
              rand()%256,
              (UCHAR *)ddsd.lpSurface, ddsd.lPitch);

    } // end for index


// unlock primary buffer
if (FAILED(lpddsprimary->Unlock(NULL)))
   return(0);

// wait a sec
Sleep(33);

// return success or failure or your own return code here
return(1);

} // end Game_Main
Beispiel #16
0
void AlliesWhiteboard::DrawLine(int x1, int y1, int x2, int y2, char C, char *VidBuf, int Pitch)
{
	switch(C)
	{
	case 0:
		C = (char)227;
		break;
	case 1:
		C = (char)212;
		break;
	case 2:
		C = (char)80;
		break;
	case 3:
		C = (char)235;
		break;
	case 4:
		C = (char)108;
		break;
	case 5:
		C = (char)219;
		break;
	case 6:
		C = (char)208;
		break;
	case 7:
		C = (char)93;
		break;
	case 8:
		C = (char)130;
		break;
	case 9:
		C = (char)67;
		break;
	}

	x1 = x1 - *MapX;
	y1 = y1 - *MapY;
	x2 = x2 - *MapX;
	y2 = y2 - *MapY;

	if(Clip_Line(x1, y1, x2, y2))
		Draw_Line(x1, y1, x2, y2, C, (UCHAR*)VidBuf, Pitch);

	//Line(x1-*MapX, y1-*MapY, x2-*MapX, y2-*MapY, C, VidBuf, Pitch);
}
//---------------------------------------------------------
void CDLG_Colors_Control::On_Mouse_LUp(wxMouseEvent &event)
{
	if( m_selBox >= 0 )
	{
		Draw_Line(m_Mouse_Down, m_Mouse_Move);

		m_Mouse_Move	= event.GetPosition();

		Set_Colors(m_Mouse_Down, m_Mouse_Move, m_selBox);

		m_selBox		= -1;

		ReleaseMouse();

		Refresh(false);
	}
}
Beispiel #18
0
//---------------------------------------------------------
void CSG_3DView_Canvas::_Draw_Box(void)
{
	if( !m_bBox )
	{
		return;
	}

	int	color	= SG_GET_RGB(SG_GET_R(m_bgColor) + 128, SG_GET_G(m_bgColor) + 128, SG_GET_B(m_bgColor) + 128);

	TSG_Point_Z	p[2][4], Buffer;

	Buffer.x	= 0.01 * (m_Data_Max.x - m_Data_Min.x);
	Buffer.y	= 0.01 * (m_Data_Max.y - m_Data_Min.y);
	Buffer.z	= 0.01 * (m_Data_Max.z - m_Data_Min.z);

	for(int i=0; i<2; i++)
	{
		p[i][0].x	= m_Data_Min.x - Buffer.x;	p[i][0].y	= m_Data_Min.y - Buffer.y;
		p[i][1].x	= m_Data_Max.x + Buffer.x;	p[i][1].y	= m_Data_Min.y - Buffer.y;
		p[i][2].x	= m_Data_Max.x + Buffer.x;	p[i][2].y	= m_Data_Max.y + Buffer.y;
		p[i][3].x	= m_Data_Min.x - Buffer.x;	p[i][3].y	= m_Data_Max.y + Buffer.y;
		p[i][0].z	= p[i][1].z = p[i][2].z = p[i][3].z = i == 0
			? m_Data_Min.z - Buffer.z
			: m_Data_Max.z + Buffer.z;

		for(int j=0; j<4; j++)
		{
			m_Projector.Get_Projection(p[i][j]);
		}

		Draw_Line(p[i][0], p[i][1], color);
		Draw_Line(p[i][1], p[i][2], color);
		Draw_Line(p[i][2], p[i][3], color);
		Draw_Line(p[i][3], p[i][0], color);
	}

	Draw_Line(p[0][0], p[1][0], color);
	Draw_Line(p[0][1], p[1][1], color);
	Draw_Line(p[0][2], p[1][2], color);
	Draw_Line(p[0][3], p[1][3], color);
}
Beispiel #19
0
//------------------------------------------------------------------------------
// Draws a generic overlay
//------------------------------------------------------------------------------
void DrawOverlay( OverlayBase_t *pOverlay )
{
    switch( pOverlay->m_Type)
    {
    case OVERLAY_LINE:
    {
        // Draw the line
        OverlayLine_t *pLine = static_cast<OverlayLine_t*>(pOverlay);
        Draw_Line( pLine->origin, pLine->dest, pLine->r, pLine->g, pLine->b, pLine->noDepthTest);
    }
    break;

    case OVERLAY_BOX:
    {
        // Draw the box
        OverlayBox_t *pCurrBox = static_cast<OverlayBox_t*>(pOverlay);
        if (pCurrBox->a > 0.0)
        {
            Draw_AlphaBox( pCurrBox->origin, pCurrBox->mins, pCurrBox->maxs, pCurrBox->angles, pCurrBox->r, pCurrBox->g, pCurrBox->b, pCurrBox->a);
        }
        Draw_WireframeBox( pCurrBox->origin, pCurrBox->mins, pCurrBox->maxs, pCurrBox->angles, pCurrBox->r, pCurrBox->g, pCurrBox->b);
    }
    break;

    case OVERLAY_SWEPT_BOX:
    {
        OverlaySweptBox_t *pBox = static_cast<OverlaySweptBox_t*>(pOverlay);
        Draw_WireframeSweptBox( pBox );
    }
    break;

    case OVERLAY_TRIANGLE:
    {
        OverlayTriangle_t *pTriangle = static_cast<OverlayTriangle_t*>(pOverlay);
        Draw_Triangle( pTriangle->p1, pTriangle->p2, pTriangle->p3, pTriangle->r,
                       pTriangle->g, pTriangle->b, pTriangle->a, pTriangle->noDepthTest );
    }
    break;

    default:
        Assert(0);
    }
}
Beispiel #20
0
// draw with RAIO
// ---------------------------------------------
void example_DrawWithRAIO( void )
{
	// rectangle
	Draw_Square (0, 0, 319, 239);
	Text_Foreground_Color ( COLOR_BLACK );
	RAIO_StartDrawing ( SQUARE_FILL );
	Text_Foreground_Color ( COLOR_BLUE );
	Draw_Square (210, 150, 260, 200);

	// line
	Draw_Line ( 10, 230, 310, 10 );
	Text_Foreground_Color ( COLOR_GREEN );
	RAIO_StartDrawing ( LINE );

	// circle
	Draw_Circle ( 90, 65, 25 );
	Text_Foreground_Color ( COLOR_RED );
	RAIO_StartDrawing ( CIRCLE_FILL );
}
int Draw_Clip_Line(int x0,int y0, int x1, int y1,UCHAR color, 
                    UCHAR *dest_buffer, int lpitch)
{
// this helper function draws a clipped line

int cxs, cys,
	cxe, cye;

// clip and draw each line
cxs = x0;
cys = y0;
cxe = x1;
cye = y1;

// clip the line
if (Clip_Line(cxs,cys,cxe,cye))
	Draw_Line(cxs, cys, cxe,cye,color,dest_buffer,lpitch);

// return success
return(1);

} // end Draw_Clip_Line
Beispiel #22
0
int main(int argc, char** argv) { char s[512];
    double xmin=-5, xmax=5;
    ARBRE r=NULL;
    int dx=400,dy=200;
    SDL_Surface* f1;

    /* 
       Creation d'une fenetre graphique
       */
    f1=newfenetregraphique(dx,dy);
    Draw_Line(f1,0, 10, 200, 50,0xFFFFFFFF);
    /*
       Lecture d'une expression prefixe au clavier 
       */
    puts("Entrer une expression en notation prefixee"); gets(s);
    r=lire(s);

    /*
       Affichage de cette expression en notation classique
       */
    puts("Expression :"); affiche(r); puts("");


    puts("Entrer les bornes du trace (xmin et xmax): attention au domaine de definition");
    scanf("%lf %lf",&xmin,&xmax);

    /*
       Recherche du min et du max des ordonnees du graphe de la fonction 
       */
    trace1courbe(f1,r,dx,xmin,xmax);
    getchar(); getchar();

    /*
       Liberation de la memoire de l'arbre
       */
    r=libere(r);
    return 0;
}
Beispiel #23
0
void Show_VOLH(u8 val)// 显示低音值   -7 ~ 7
{
	char str[]="H: 00dB";
	u8 len = val*3;
	u8 tp;
	if(val<7)
	{
		str[2]=' ';
		tp = (7-val)*2;
	}
	else if(val==7)
	{
		str[2]=' ';
		tp = (7-val)*2;
	}
	else 
	{
		str[2]=' ';
		tp = (16-val)*2;//(val-7)*2;
	}

    if(val>7)
         tp = 23-val;// dB值
	else tp=val;

    len=tp*3;//Tiaoyin[tp]*3;

	str[3] += tp/10;
	str[4] += tp%10;
	Draw_String6X8(1,47,str);

	//Draw_String6X8(43+5-2   ,47,"-");
	Draw_Rect(49+5,47,      99+2,47+6,1);

	Draw_Line(50+5,49,      50+len+5, 49,1);
	Draw_Line(50+len+5,49,  97+3,49,0);

	Draw_Line(50+5,50,      50+len+5,50,1);
	Draw_Line(50+len+5,50,  97+3,50,0);

	Draw_Line(50+5,51,      50+len+5,51,1);
	Draw_Line(50+len+5,51,  97+3,51,0);
	//Draw_String6X8(49+51,47,"+");
}
Beispiel #24
0
void Show_VOLB(u8 val)// 显示高音值   -7 ~ 7
{
	char str[]="B: 00dB";
	u8 len = val*3;
	u8 tp;
	if(val<7)
	{
		str[2]=' ';
		tp = (7-val)*2;
	}
	else if(val==7)
	{
		str[2]=' ';
		tp = (7-val)*2;
	}
	else
	{
		str[2]=' ';
		tp = (16-val)*2;//(val-7)*2;
	}

    if(val>7)
         tp = 23-val;// dB值
	else tp=val;

	len=tp*3;

	str[3] += tp/10;
	str[4] += tp%10;
	Draw_String6X8(1,55,str);

	//Draw_String6X8(43-2+5   ,55,"-");
	Draw_Rect(49+5,55,      99+2,55+6,1);

	Draw_Line(50+5,57,      50+len+5,57,1);
	Draw_Line(50+len+5,57,  100,57,0);

	Draw_Line(50+5,58,      50+len+5,58,1);
	Draw_Line(50+len+5,58,  100,58,0);

	Draw_Line(50+5,59,      50+len+5,59,1);
	Draw_Line(50+len+5,59,  100,59,0);
	//Draw_String6X8(49+46+5,55,"+");
}
Beispiel #25
0
Datei: sdlfn.c Projekt: 8l/bcpl
BCPLWORD sdlfn(BCPLWORD *a, BCPLWORD *g, BCPLWORD *W) {
  char tmpstr[256];

  //printf("sdlfn: fno=%d a1=%d a2=%d a3=%d a4=%d\n",
  //        a[0], a[1], a[2], a[3], a[4]);

  switch(a[0]) {
  default:
    printf("sdlfn: Unknown op: fno=%d a1=%d a2=%d a3=%d a4=%d\n",
            a[0], a[1], a[2], a[3], a[4]);
    return 0;

  case sdl_avail: // Test whether SDL is available
    return -1;    // SDL is available

  case gl_avail:  // Test whether OpenGL is available
#ifdef GLavail
    return -1;    // OpenGL is available
#else
    return  0;    // OpenGL is not available
#endif

  case sdl_init:  // Initialise all SDL features
  { BCPLWORD res = (BCPLWORD) SDL_Init(SDL_INIT_EVERYTHING);
      // Enable Unicode translation of keyboard events.
    SDL_EnableUNICODE(1);
    SDL_JoystickEventState(SDL_ENABLE);
    //printf("sdl_init\n");
    return res;
  }

  case sdl_setvideomode:  // width, height, bbp, flags
  { SDL_Surface *scr;
    //printf("Calling SetVideoMode(%d, %d, %d, %8x)\n", a[1], a[2], a[3], a[4]);
    scr = SDL_SetVideoMode((int)a[1], (int)a[2], (int)a[3], (Uint32)a[4]);
    SDL_Flip(scr);
    return (BCPLWORD) scr;
    //return (BCPLWORD) SDL_SetVideoMode((int)a[1], (int)a[2], (int)a[3], (Uint32)a[4]);
  }

  case sdl_quit:      // Shut down SDL
    printf("sdl_quit\n");
    SDL_Quit();
    return -1;

  case sdl_locksurface: // surf
    // Return 0 on success
    // Return -1 on failure
    return (BCPLWORD) SDL_LockSurface((SDL_Surface*) a[1]);

  case sdl_unlocksurface: // surf
    SDL_UnlockSurface((SDL_Surface*) a[1]);
    return 0;

  case sdl_getsurfaceinfo:
  // surf, surfinfo -> [flag, format, w, h, pitch, pixels, cliprect, refcount]
  { SDL_Surface *surf = (SDL_Surface*)a[1];
    BCPLWORD *info = &W[a[2]];
    info[ 0] = (BCPLWORD) (surf->flags);
    info[ 1] = (BCPLWORD) (surf->format);
    info[ 2] = (BCPLWORD) (surf->w);
    info[ 3] = (BCPLWORD) (surf->h);
    info[ 4] = (BCPLWORD) (surf->pitch);
    info[ 5] = (BCPLWORD) (surf->pixels);
    //info[ 6] = (BCPLWORD) (surf->clip_rect); // fields: x,y, w, h
    info[ 7] = (BCPLWORD) (surf->refcount);
    //printf("getsurfaceinfo: format=%d\n", info[1]);
    return 0;        
  }

  case sdl_getfmtinfo:
  // fmt, pxlinfo -> [palette, bitspp, bytespp, rmask, gmask, rmask, amask,
  //                  rloss, rshift, gloss, gshift, bloss, bshift, aloss, ashift,
  //                  colorkey, alpha]
  { SDL_PixelFormat *fmt = (SDL_PixelFormat*)(a[1]);
    BCPLWORD *info = &(W[a[2]]);
    //printf("getfmtinfo: format=%d\n", (BCPLWORD)fmt);
    info[ 0] = (BCPLWORD) (fmt->palette);
    info[ 1] = (BCPLWORD) (fmt->BitsPerPixel);
    info[ 2] = (BCPLWORD) (fmt->BytesPerPixel);
    info[ 3] = (BCPLWORD) (fmt->Rmask);
    info[ 4] = (BCPLWORD) (fmt->Gmask);
    info[ 5] = (BCPLWORD) (fmt->Bmask);
    info[ 6] = (BCPLWORD) (fmt->Amask);
    info[ 7] = (BCPLWORD) (fmt->Rshift);
    info[ 8] = (BCPLWORD) (fmt->Gshift);
    info[ 9] = (BCPLWORD) (fmt->Bshift);
    info[10] = (BCPLWORD) (fmt->Ashift);
    info[11] = (BCPLWORD) (fmt->Rloss);
    info[12] = (BCPLWORD) (fmt->Gloss);
    info[13] = (BCPLWORD) (fmt->Rloss);
    info[14] = (BCPLWORD) (fmt->Aloss);
    info[15] = (BCPLWORD) (fmt->colorkey);
    info[16] = (BCPLWORD) (fmt->alpha);

    return 0;        
  }

  case sdl_geterror:   // str -- fill str with BCPL string for the latest SDL error
  { char *str = SDL_GetError();
    printf("sdl_geterror: %s\n", str);
    return c2b_str(str, a[1]); // Convert to BCPL string format
  }

  case sdl_updaterect: // surf, left, top, right, bottom
    return 0;     // Not yet available

  case sdl_loadbmp:    // filename of a .bmp image
  { char tmpstr[256];
    b2c_str(a[1], tmpstr);
    return (BCPLWORD) SDL_LoadBMP(tmpstr);
  }

  case sdl_mksurface: //(format, w, h)
  { SDL_PixelFormat *fmt = (SDL_PixelFormat*)(a[1]);
    Uint32 rmask = fmt->Rmask;
    Uint32 gmask = fmt->Gmask;
    Uint32 bmask = fmt->Bmask;
    Uint32 amask = fmt->Amask;
    //printf("rmask=%8x gmask=%8x bmask=%8x amask=%8x\n", rmask, gmask, bmask, amask);
    return (BCPLWORD)SDL_CreateRGBSurface(
                         SDL_SWSURFACE,
                         a[2], a[3], // Width, Height
                         32,     // Not using a palette
                         rmask, gmask, bmask, amask);
  }

  case sdl_blitsurface: // src, srcrect, dest, destrect
    //printf("blitsurface: %d, %d, %d, %d)\n", a[1], a[2], a[3], a[4]);
  { BCPLWORD *p = &W[a[4]];
    SDL_Rect dstrect = {p[0],p[1],p[2],p[3]};
    //printf("x=%d, y=%d, w=%d, h=%d\n", p[0], p[1], p[2], p[3]);
    return (BCPLWORD) SDL_BlitSurface((SDL_Surface*) a[1],
                                      (SDL_Rect*)    0,
                                      (SDL_Surface*) a[3],
                                      &dstrect);
  }

  case sdl_setcolourkey: //(surf, key)
    // If key=-1 unset colour key
    // otherwise set colour key to given value.
    // key must be in the pixel format of the given surface
    //printf("sdl_setcolourkey: %8x\n", a[2]);
    if(a[2]==-1) {
      return (BCPLWORD)SDL_SetColorKey((SDL_Surface*)a[1], 0, (Uint32)a[2]);
    } else {
      return (BCPLWORD)SDL_SetColorKey((SDL_Surface*)a[1], SDL_SRCCOLORKEY, (Uint32)a[2]);
    }

  case sdl_freesurface: // surf
    SDL_FreeSurface((SDL_Surface*)a[1]);
    return 0;

  case sdl_setalpha:    // surf, flags, alpha
    return 0;     // Not yet available

  case sdl_imgload:     // filename -- using the SDL_image library
    return 0;     // Not yet available

  case sdl_delay:       // msecs -- the SDL delay function
    SDL_Delay((int)a[1]);
    return 0;

  case sdl_getticks:    // return msecs since initialisation
    return (BCPLWORD)SDL_GetTicks();

  case sdl_showcursor:  // Show the cursor
    return (BCPLWORD)SDL_ShowCursor(SDL_ENABLE);

  case sdl_hidecursor:  // Hide the cursor
    return (BCPLWORD)SDL_ShowCursor(SDL_DISABLE);

  case sdl_flip:        // surf -- Double buffered update of the screen
    return (BCPLWORD) SDL_Flip((SDL_Surface*)a[1]);

  case sdl_displayformat: // surf -- convert surf to display format
    return 0;     // Not yet available

  case sdl_waitevent:    // (pointer) to [type, args, ... ] to hold details of the next event
                 // return 0 if no events available
    return 0;     // Not yet available

  case sdl_pollevent:    // (pointer) to [type, args, ... ] to hold details of
			 // the next event
    { SDL_Event test_event;
      if (SDL_PollEvent(&test_event))
      { decodeevent(&test_event, &W[a[1]]);
        return -1;
      }
      decodeevent(0, &W[a[1]]);
      return 0;
    }

  case sdl_getmousestate: // pointer to [x, y] returns bit pattern of buttons currently pressed
    return 0;     // Not yet available

  case sdl_loadwav:      // file, spec, buff, len
    return 0;     // Not yet available

  case sdl_freewav:      // buffer
    return 0;     // Not yet available

  case sdl_wm_setcaption:      // surf, string
  { char tmpstr[256];
    b2c_str(a[1], tmpstr);
    SDL_WM_SetCaption(tmpstr, 0);
    return 0;
  }

  case sdl_videoinfo:      // buffer
  { const SDL_VideoInfo* p = SDL_GetVideoInfo();
    BCPLWORD *info = &W[a[1]];
    info[ 0] = (BCPLWORD) ((p->hw_available) |
                           (p->hw_available)<<1 |
                           (p->blit_hw)<<2 |
                           (p->blit_hw_CC)<<3 |
                           (p->blit_hw_A)<<4 |
                           (p->blit_sw)<<5 |
                           (p->blit_sw_CC)<<6 |
                           (p->blit_sw_A)<<7
                          );
    info[ 1] = (BCPLWORD) (p->blit_fill);
    info[ 2] = (BCPLWORD) (p->video_mem);
    info[ 3] = (BCPLWORD) (p->vfmt);
    info[ 4] = (BCPLWORD) (p->vfmt->BitsPerPixel);
    //printf("videoinfo: a[2]=%d %8X %8X %d %d %d\n",
    //          a[2], info[0], info[1], info[2], info[3], info[4]);
 
    return 0;
  }


  case sdl_maprgb:      // format, r, g, b
  { 
    return (BCPLWORD) SDL_MapRGB((SDL_PixelFormat*)(a[1]), a[2], a[3], a[4]); 
  }

  case sdl_drawline:
  { SDL_Surface *surf = (SDL_Surface*)(a[1]);
    //printf("\nDraw Line: %d %d %d %d %d %8x\n", a[1], a[2], a[3], a[4], a[5], a[6]);
    Draw_Line(surf, a[2], a[3], a[4], a[5], a[6]);
    return 0;
  }

  case sdl_drawhline:
  case sdl_drawvline:
  case sdl_drawcircle:
  case sdl_drawrect:
  case sdl_drawpixel:
  case sdl_drawellipse:
  case sdl_drawfillellipse:
  case sdl_drawround:
  case sdl_drawfillround:
    return 0;

  case sdl_drawfillcircle:
  { SDL_Surface *surf = (SDL_Surface*)(a[1]);
    Draw_FillCircle(surf, a[2], a[3], a[4], a[5]);
    return 0;
  }
    //  case sdl_drawfillrect:
    //return  Draw_FillRect((SDL_Surface*)a[1], 500,200, 50,70, 0xF0FF00);

  case sdl_fillrect:
  { SDL_Rect rect = {a[2],a[3],a[4],a[5]};
    //printf("\nfillrect: surface=%d rect=(%d,%d,%d,%d) col=%8x\n",
    //       a[1], a[2], a[3], a[4], a[5], a[6]);
    SDL_FillRect((SDL_Surface*)(a[1]), &rect, a[6]);
    return 0;
  }

  case sdl_fillsurf:
    //printf("\nfillsurf: surface=%d col=%8x\n",
    //        a[1], a[2]);
    SDL_FillRect((SDL_Surface*)(a[1]), 0, a[2]);
    return 0;

// Joystick functions
  case sdl_numjoysticks:
    return SDL_NumJoysticks();

  case sdl_joystickopen:       // 42 (index) => joy
    return (BCPLWORD)SDL_JoystickOpen(a[1]);

  case sdl_joystickclose:      // 43 (joy)
    SDL_JoystickClose((SDL_Joystick *)a[1]);
    return 0;

  case sdl_joystickname:       // 44 (index)
  { const char *name = SDL_JoystickName(a[1]);
    return c2b_str(name, a[1]);
  }

  case sdl_joysticknumaxes:    // 45 (joy)
    return SDL_JoystickNumAxes((SDL_Joystick*)a[1]);

  case sdl_joysticknumbuttons: // 46 (joy)
    return SDL_JoystickNumButtons((SDL_Joystick*)a[1]);

  case sdl_joysticknumballs:   // 47 (joy)
    return SDL_JoystickNumBalls((SDL_Joystick*)a[1]);

  case sdl_joysticknumhats:    // 47 (joy)
    return SDL_JoystickNumHats((SDL_Joystick*)a[1]);

  case sdl_joystickeventstate: //49  sdl_enable=1 or sdl_ignore=0
    return SDL_JoystickEventState(a[1]);

  case sdl_joystickgetbutton: // 55 (joy)
    return SDL_JoystickGetButton((SDL_Joystick*)a[1], a[2]);

  case sdl_joystickgetaxis: // 56 (joy)
    return SDL_JoystickGetAxis((SDL_Joystick*)a[1], a[2]);

  case sdl_joystickgethat: // 58 (joy)
    return SDL_JoystickGetHat((SDL_Joystick*)a[1], a[2]);

  case gl_setvideomode: // 200 (width, height)
  { // Setup minimum bit sizes, a depth buffer and double buffering.
    const SDL_VideoInfo* info = NULL;
    int bpp = 0;
    SDL_Surface *scr;

    info = SDL_GetVideoInfo();
    if(!info) return 0;
    bpp = info->vfmt->BitsPerPixel;
    printf("bpp=%d width=%d height=%d\n", bpp, a[1], a[2]);
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    printf("Calling SDL_SetVideoMode\n");
    scr = SDL_SetVideoMode((int)a[1], (int)a[2], bpp, SDL_OPENGL);
    return (BCPLWORD)scr;
  }

#ifdef GLavail
  case gl_ShadeModel:
    //printf("gl_ShadeModel: a[1]=%d GL_SMOOTH=%d\n", a[1], GL_SMOOTH);
    //glShadeModel((int)a[1]);
    //glShadeModel(GL_SMOOTH);
    return 0;
  case gl_CullFace:
    //printf("gl_CullFace: %d GL_BACK=%d\n", a[1], GL_BACK);
    //glCullFace(a[1]);
    glCullFace(GL_BACK);
    return 0;
  case gl_FrontFace:
    //printf("gl_FrontFace: %d\n", a[1]);
    //printf("   GL_CCW=%d\n", GL_CCW);
    //glFrontFace(a[1]);
    glFrontFace(GL_CCW);
    return 0;
  case gl_Enable:
    //printf("gl_Enable: %d\n", a[1]);
    //printf("   GL_CULLFACE=%d\n", GL_CULL_FACE);
    glEnable(a[1]);
    return 0;
  case gl_ClearColor:
    //printf("gl_ClearColor: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    glClearColor(a[1]/255.0, a[2]/255.0, a[3]/255.0, a[4]/255.0);
    return 0;
  case gl_ViewPort:
    //printf("gl_Viewport: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    glViewport(a[1], a[2], a[3], a[4]);
    //glViewport(0, 0, 800, 500);
    return 0;
  case gl_MatrixMode:
    //printf("gl_MatrixMode: %d\n", a[1]);
    //printf("   GL_PROJECTION=%d\n", GL_PROJECTION);
    //printf("   GL_MODELVIEW=%d\n", GL_MODELVIEW);
    glMatrixMode(a[1]);
    return 0;
  case gl_LoadIdentity:
    //printf("gl_LoadIdentity:\n");
    glLoadIdentity();
    return 0;
  case glu_Perspective:
    //printf("gl_Perspective: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    gluPerspective(((float)a[1])/1000000, ((float)a[2])/1000000,
                   ((float)a[3])/1000, ((float)a[4])/1000);  
    //gluPerspective(60.0, 800.0/500.0, 1.0, 1024.0);
    return 0;
  case gl_Clear:
    //printf("gl_Clear: #x%8X\n", a[1]);
    //printf("   GL_COLOR_BUFFER_BIT=%8X\n", GL_COLOR_BUFFER_BIT);
    //printf("   GL_DEPTH_BUFFER_BIT=%8X\n", GL_DEPTH_BUFFER_BIT);
    glClear(a[1]);
    //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    return 0;
  case gl_Translate:
    //printf("gl_Translate: %d %d %d\n", a[1], a[2], a[3]);
    glTranslatef(a[1]/1000.0, a[2]/1000.0, a[3]/1000.0);
    return 0;
  case gl_Rotate:
    //printf("gl_Rotate: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    glRotatef(a[1]/1000000.0, a[2]/1000.0, a[3]/1000.0, a[4]/1000.0);
    return 0;
  case gl_Begin:
    //printf("gl_Begin: %d\n", a[1]);
    //printf("   GL_TRIANGLES=%d\n", GL_TRIANGLES);
    glBegin(a[1]);
    return 0;
  case gl_End:
    //printf("gl_End:\n");
    glEnd();
    return 0;
  case gl_Color4v:
    //printf("gl_Color4v: %d\n", a[1]);
    glColor4ub(W[a[1]], W[a[1]+1], W[a[1]+2], W[a[1]+3]);
    return 0;
  case gl_Vertex3v:
    //printf("gl_Vertex3v: %d -> [%d %d %d]\n", a[1], W[a[1]], W[a[1]+1], W[a[1]+2]);
    glVertex3f(W[a[1]]/1000.0, W[a[1]+1]/1000.0, W[a[1]+2]/1000.0);
    return 0;
  case gl_SwapBuffers:
    //printf("gl_SwapBuffers:\n");
    SDL_GL_SwapBuffers();
    return 0;
#endif

// more to come ...

  }
}
Beispiel #26
0
/* Main program */
int main(){
        /* not Locals */
        lapack_complex_double *a, *temp, * u, *vt;
        lapack_int m = M, n = N, lda = LDA, ldu = LDU, ldvt = LDVT, info;
		
        /* Local arrays */
		//void prtdat();
		double *s;
        double *superb; 
        int svd_count=0;
		int i, j ,ix ,iy, index, ii, jj ;    
		double  x_min,
				x_max,
				y_min,
				y_max,
				stepx,						/* step size for finding gridpoints coordinates in x and y dimension.*/
				stepy;
		double e=0.1;        
		/* Array used for the ploting of
		* grid, as an input to the 
		* draw_pseudospectra function. */
		double *plot;
		//double plot[n][n]; 
		COLOUR colour;
		BITMAP4 col,grey = {128,128,128,0};
		
		       
        /* Memory alocations*/
		temp = malloc((lda*m)*sizeof(lapack_complex_double));
		a = malloc((lda*m)*sizeof(lapack_complex_double));
		u = malloc((ldu*m)*sizeof(lapack_complex_double));
		vt = malloc((ldvt*n)*sizeof(lapack_complex_double));
		s = malloc(m*sizeof(double));
		superb = malloc(min(m,n)*sizeof(double));
		plot = malloc((NGRID*NGRID)*sizeof(double));
		z = malloc((NGRID*NGRID)*sizeof(double _Complex));
		
	
		//allocating the 2D array data.
	  if ((data = malloc(SCALE*NGRID*sizeof(double *))) == NULL) {
      fprintf(stderr,"Failed to malloc space for the data\n");
      exit(-1);
   }
   for (i=0;i<SCALE*NGRID;i++) {
      if ((data[i] = malloc(SCALE*NGRID*sizeof(double))) == NULL) {
         fprintf(stderr,"Failed to malloc space for the data\n");
         exit(-1);
      }
   }
   for (i=0;i<SCALE*NGRID;i++){
      for (j=0;j<SCALE*NGRID;j++){
         data[i][j] = 0;
	 //   printf("%f\t",data[i][j]);
	 }
		  }
		
/*
		printf("-------------------------------------------------\n");
		printf("        ---------------------------------           \n");
		printf ("Starting Computing Pseudopsecta of grcar Matrix\n");
		printf("Give the doundaries of the 2-dimenional domain\n");
		printf("Insert the minimum value of x-axis\n");
		clearerr(stdin);
		scanf("%lf",&x_min);
		//getchar();
		printf("Insert the maximum value of x-axis\n");
		scanf("%lf",&x_max);
		printf("Insert the minimum value of y-axis\n");
		scanf("%lf",&y_min);
		printf("Insert the maximun value of y-axis\n");
		scanf("%lf",&y_max);
		//printf("Give the grid size you want:\n");
		//scanf("%d",&n);
*/ 	  
		/*if (x_min==0.0)*/  x_min=XMIN;
		/*if (x_max==0.0)*/  x_max=XMAX;
		/*if (y_min==0.0)*/  y_min=YMIN;
		/*if (y_max==0.0)*/  y_max=YMAX;
	
		/* Initialize grid */
		printf("The size of the domain is: X=[%f-%f]  Y=[%f-%f] \n",x_min,x_max,y_min,y_max);
	  
		stepx=(double)abs(x_max-x_min)/(NGRID-1);
		stepy=(double)abs(y_max-y_min)/(NGRID-1);
		printf("To stepx einai %f\n",stepx);
		printf("To stepy einai %f\n",stepy);	
	   

	
	   for (i =0; i <NGRID*NGRID; i++){
			z[i]=x_min+(i/n * stepx)+(y_min + (i%n * stepy))*I;
		 // z[i]=lapack_make_complex_double( i/n,i%n); just for testing
		//**	printf( " (%6.2f,%6.2f)", lapack_complex_double_real(z[i]), lapack_complex_double_imag(z[i]) );
		}

	   memset(temp,0,(lda*m)*sizeof(*temp));
	   memset(a,0,(lda*m)*sizeof(*a));
	   memset(u,0,(ldu*m)*sizeof(*u));
	   memset(vt,0,(ldvt*m)*sizeof(*vt));
		
		
	   j=0;
	   for (i = 0; i < lda*m ; i=i+n ){	
			if(i==0){
				a[i]=lapack_make_complex_double( 1,0);
				a[i+1]=lapack_make_complex_double( 1,0);
				a[i+2]=lapack_make_complex_double( 1,0);
				a[i+3]=lapack_make_complex_double( 1,0);
			}
			else if(i == (n-3)*n ){
				a[i+j]=lapack_make_complex_double( -1,0);
				a[i+(j+1)]=lapack_make_complex_double( 1,0);
				a[i+(j+2)]=lapack_make_complex_double( 1,0);
				a[i+(j+3)]=lapack_make_complex_double( 1,0);
				j++;
			}
			else if(i == (n-2)*n ){
				a[i+j]=lapack_make_complex_double( -1,0);
				a[i+(j+1)]=lapack_make_complex_double( 1,0);
				a[i+(j+2)]=lapack_make_complex_double( 1,0);
				j++;
			}
			else if(i == (n-1)*n ){
				a[i+j]=lapack_make_complex_double( -1,0);
				a[i+(j+1)]=lapack_make_complex_double( 1,0);
				j++;
			}
			else{
				a[i+j]=lapack_make_complex_double( -1,0);
				a[i+(j+1)]=lapack_make_complex_double( 1,0);
				a[i+(j+2)]=lapack_make_complex_double( 1,0);
				a[i+(j+3)]=lapack_make_complex_double( 1,0);
				a[i+(j+4)]=lapack_make_complex_double( 1,0);
				j++;
			}
		} 

		//print_matrix("Entry Matrix A", m, n, a, lda );
		for (iy = 0; iy < NGRID*NGRID; iy++){   
			 //printf("temp size %d, a size %d",(lda*m)*sizeof(*temp),(lda*m)*sizeof(*a));
			memcpy(temp, a ,(lda*m)*sizeof(*temp));
			 //~ print_matrix( "Entry Matrix Temp just after memcopy", m, n, temp, lda );
			 //~ print_matrix( "Entry Matrix A just after memcopy", m, n, a, lda );
			// printf( "To  z[%d](%6.4f,%6.4f)\n",iy,lapack_complex_double_real(z[iy]),lapack_complex_double_imag(z[iy]) );
			for (i = 0; i < lda*m ; i=i+(n+1)){	
				//~ printf("%d",i);
				//~ printf( "To  a[%d](%6.2f,%6.2f)\t",i, lapack_complex_double_real(a[i]), lapack_complex_double_imag(a[i]) );
				//~ printf( "To  z[%d](%6.2f,%6.2f)\n",iy,lapack_complex_double_real(z[iy]),lapack_complex_double_imag(z[iy]) );
				
				temp[i]=a[i]-z[iy];
				//~ temp[index] = lapack_make_complex_double(lapack_complex_double_real(a[index])-lapack_complex_double_real(z[iy]),  lapack_complex_double_imag(a[index])-lapack_complex_double_imag(z[iy])    );
				//~ printf( " temp[%d](%6.2f,%6.2f)", i,lapack_complex_double_real(temp[i]), lapack_complex_double_imag(temp[i]) );
				//~ printf( "\n");
			}
			//printf("GRCAR MATRIX AFTER SUBSTRACTION (%d,%d)\n",iy/n,iy%n);
			//~ print_matrix( "Entry Matrix Temp just before", m, n, temp, lda );
	
			/* Executable statements */
			//~ print_matrix( "AT THE BEGINING OF THE FOR LOOP", m, n, a, lda );
			printf( "LAPACKE_zgesvd (row-major, high-level) Example Program Results(%d,%d)\n",iy/NGRID,iy%NGRID);
			/* Compute SVD */
			info = LAPACKE_zgesvd( LAPACK_ROW_MAJOR, 'N', 'N', m, n, temp, lda, s, NULL, ldu, NULL, ldvt, superb );
			svd_count++;
			//~ 
			//~ print_matrix( "IN THE MIDDLE OF THE FOR LOOP", m, n, a, lda );
			//~ print_matrix( "IN THE MIDDLE OF THE FOR LOOP-TEMP", m, n, temp, lda );
			/* Check for convergence */
			if( info > 0 ) {
				printf( "The algorithm computing SVD failed to converge.\n" );
				exit( 1 );
			}
			/* Print singular values */
			if( info == 0){
//				printf("Solution\n");	
				for ( i= 0; i< m; i++ ) {
//					printf(" s[ %d ] = %f\n", i, s[ i ] );
				}
			}
			
			if(s[m-1] <= e){
				printf("THIS ELEMENT BELONGS TO PSEUDOSPECTRA (%d,%d):%6.10f\n",(iy/NGRID+1),(iy%NGRID+1),s[m-1]);
				/*to index tis parapanw ektupwshs anaferetai sto index tou antistoixou mhtrwou apo thn synarthsh ths matlab grcar_example.m*/
				//~ plot[iy/n][iy%n]=s[m-1];
				plot[iy]=s[m-1];
			 }
			 //~ else   plot[iy/n][iy%n]=0;
				else plot[iy]=0;
		
	
		
	//~ print_rmatrix( "Singular values", 1, m, s, 1 );
	
	/* Print left singular vectors */
	// print_matrix( "Left singular vectors (stored columnwise)", m, m, u, ldu );
	/* Print right singular vectors */
	// print_matrix( "Right singular vectors (stored rowwise)", m, n, vt, ldvt );
		}
		
		
		prtdat(NGRID, NGRID, plot, "svd.data");
		printf("Total number of svd evaluations in the %d,%d grid is:\t %d\n",NGRID,NGRID,svd_count);
		
		//giving values to data from plot
		for (i = 0; i<NGRID*NGRID; i++)  data[SCALE*(i/NGRID)][SCALE*(i%NGRID)] = plot[i];
	   /////////////////
    BITMAP4 black = {0,0,0,0};
    Draw_Line(image,NGRID,NGRID,x_min,y_min,x_max,y_min,black);
   //////////////////	
		//~ contours[0] = 0.1;
		//~ contours[1] = 0.01;
		//~ contours[2] = 0.001;
		//~ contours[3] = 0.0001;
		//~ contours[4] = 0.00001;
		if ((image = Create_Bitmap(SCALE*NGRID,SCALE*NGRID)) == NULL) {
      fprintf(stderr,"Malloc of bitmap failed\n");
      exit(-1);
   }
 Erase_Bitmap(image,SCALE*NGRID,SCALE*NGRID,grey); /* Not strictly necessary */
   for (j=0;j<SCALE*NGRID;j++) {
      for (i=0;i<SCALE*NGRID;i++) {
         colour = GetColour(data[i][j],0,0.1,1);      /////////////////////////////////////////////
         col.r = colour.r * 255;
        // col.b = colour.b * 255;
       //  Draw_Pixel(image,SCALE*NGRID,SCALE*NGRID,(double)i,(double)j,col);
        //          colour = GetColour(data[i][j],0,0.0001,1);      /////////////////////////////////////////////
       //  col.g = colour.g * 255;
         Draw_Pixel(image,SCALE*NGRID,SCALE*NGRID,(double)i,(double)j,col);
      }
   }

   /* Finally do the contouring */
   CONREC(data,0,SCALE*NGRID-1,0,SCALE*NGRID-1,
      z,NCONTOUR,contours,drawline);
   fprintf(stderr,"Drew %d vectors\n",vectorsdrawn);

   /* 
      Write the image as a TGA file 
      See bitmaplib.c for more details, or write "image"
      in your own prefered format.
   */
   if ((fp = fopen("image.tga","w")) == NULL) {
      fprintf(stderr,"Failed to open output image\n");
      exit(-1);
   }
   Write_Bitmap(fp,image,SCALE*NGRID,SCALE*NGRID,12);
   fclose(fp);

		
		
		
		exit(0);
} /* End of LAPACKE_zgesvd Example */
Beispiel #27
0
void drawLine(SubWin sw, Sint16 x, Sint16 y, Sint16 ex, Sint16 ey, Uint32 color){
	printf("%d  %d %d %d \n", x, y, ex, ey);
	Draw_Line(sw->screen,x,y,ex,ey,color);
}
Beispiel #28
0
// draw coordinate system
void draw_coords_line (float_t x1, float_t y1, float_t x2, float_t y2)
{
	Text_Foreground_Color( COLOR_WHITE );
	Draw_Line( scale_x( x1 ), scale_y( y1 ), scale_x( x2 ), scale_y( y2 ) );
	RAIO_StartDrawing( LINE );
}
Beispiel #29
0
void CSG_3DView_Canvas::Draw_Line(const TSG_Point_Z &a, const TSG_Point_Z &b, int Color)
{
	Draw_Line(a.x, a.y, a.z, b.x, b.y, b.z, Color);
}
Beispiel #30
0
/*----------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
  SDL_Surface *screen;
  int width, height;
  Uint8  video_bpp;
  Uint32 videoflags;
  int done;
  SDL_Event event;
  Uint32 then, now, frames;

  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "SDL_Init problem: %s", SDL_GetError());
    exit(1);
  }
  atexit(SDL_Quit);

  videoflags = SDL_SWSURFACE | SDL_ANYFORMAT;
  width = 640;
  height = 480;
  video_bpp = 0;

  while ( argc > 1 ) {
      --argc;
           if ( strcmp(argv[argc-1], "-width") == 0 ) {
      width = atoi(argv[argc]);
      --argc;
    } else if ( strcmp(argv[argc-1], "-height") == 0 ) {
      height = atoi(argv[argc]);
      --argc;
    } else if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
      video_bpp = atoi(argv[argc]);
      videoflags &= ~SDL_ANYFORMAT;
      --argc;
    } else if ( strcmp(argv[argc], "-fast") == 0 ) {
      videoflags = FastestFlags(videoflags, width, height, video_bpp);
    } else if ( strcmp(argv[argc], "-hw") == 0 ) {
      videoflags ^= SDL_HWSURFACE;
    } else if ( strcmp(argv[argc], "-flip") == 0 ) {
      videoflags ^= SDL_DOUBLEBUF;
    } else if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
      videoflags ^= SDL_FULLSCREEN;
    } else {
      fprintf(stderr, "Use: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen]\n",
              argv[0]);
      exit(1);
    }
  }/*while*/

  /*Video mode activation*/
  screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  if (!screen) {
    fprintf(stderr, "I can not activate video mode: %dx%d: %s\n",
            width, height, SDL_GetError());
    exit(2);
  }

{/*BEGIN*/
  Uint32 c_white = SDL_MapRGB(screen->format, 255,255,255);
  Uint32 c_gray = SDL_MapRGB(screen->format, 200,200,200);
  Uint32 c_dgray= SDL_MapRGB(screen->format, 64,64,64);
  Uint32 c_cyan = SDL_MapRGB(screen->format, 32,255,255);

  //SDL_Rect r = {100,300,50,50};
  //SDL_SetClipRect(screen, &r);  //Test of clipping code

  frames = 0;
  then = SDL_GetTicks();
  done = 0;
  while( !done ) {
  
  Draw_Line(screen, 100,100, 30,0, c_white);
  Draw_Line(screen, 30,0, 100,100, c_white);

  Draw_Line(screen, 100,100, 30,0, c_white);
  Draw_Line(screen, 30,0, 100,100, c_white);
  Draw_Line(screen, 0,0, 100,100, c_white);
  Draw_Line(screen, 100,100, 300,200, c_white);
  Draw_Line(screen, 200,300, 250,400,
                SDL_MapRGB(screen->format, 128,128,255));
  Draw_Line(screen, 500,50, 600,70,
                SDL_MapRGB(screen->format, 128,255,128));
  Draw_Line(screen, 500,50, 600,70,
                SDL_MapRGB(screen->format, 128,255,128));
  //Draw_Circle(screen, 100+frames%200, 100, 50, c_white);
  Draw_Circle(screen, 100+(frames/3)%200, 100+(frames/2)%173, 50,
              SDL_MapRGB(screen->format, 128+frames,255+frames,68+frames));

  /*-------------*/
  Draw_Circle(screen, 150,150, 5, c_white);
  Draw_Circle(screen, 150,150, 4,
                 SDL_MapRGB(screen->format, 64,64,64));
  Draw_Circle(screen, 150,150, 3,
                 SDL_MapRGB(screen->format, 255,0,0));
  Draw_Circle(screen, 150,150, 2,
                 SDL_MapRGB(screen->format, 0,255,0));
  Draw_Circle(screen, 150,150, 1,
                 SDL_MapRGB(screen->format, 0,0,255));
  /*-------------*/

  Draw_Line(screen, 500,100, 600,120,
                SDL_MapRGB(screen->format, 128,255,128));
  Draw_Circle(screen, 601,121, 2, c_white);

  Draw_Circle(screen, 400,200, 2, c_white);
  Draw_Line(screen, 400,200, 409,200, c_white);
  Draw_Circle(screen, 409,200, 2, c_white);
  Draw_Line(screen, 400,200, 400,250, c_white);
  Draw_Circle(screen, 400,250, 2, c_white);
  Draw_Line(screen, 409,200, 400,250, c_white);


  Draw_Line(screen, 400,300, 409,300, c_gray);
  Draw_Line(screen, 400,300, 400,350, c_gray);
  Draw_Line(screen, 409,300, 400,350, c_dgray);
  Draw_Rect(screen, 398,298, 4,4, c_cyan);
  Draw_Rect(screen, 407,298, 4,4, c_cyan);
  Draw_Rect(screen, 398,348, 4,4, c_cyan);

  Draw_HLine(screen, 10,400, 50, c_white);
  Draw_VLine(screen, 60,400, 360, c_white);
  Draw_Rect(screen, 500,400, 50,50, c_white);
  Draw_Pixel(screen, 510,410, c_white);
  Draw_Pixel(screen, 520,420,
             SDL_MapRGB(screen->format, 255,0,0));
  Draw_Pixel(screen, 530,430,
             SDL_MapRGB(screen->format, 0,255,0));
  Draw_Pixel(screen, 540,440,
             SDL_MapRGB(screen->format, 0,0,255));


  Draw_Ellipse(screen, 100,300, 60,30, c_white);
  
  Draw_FillEllipse(screen, 300,300, 30,60,
               SDL_MapRGB(screen->format, 64,64,200));
  Draw_Ellipse(screen, 300,300, 30,60,
               SDL_MapRGB(screen->format, 255,0,0));

  Draw_Round(screen, 200,20, 70,50, 10, c_white);
  Draw_Round(screen, 300,20, 70,50, 20,
             SDL_MapRGB(screen->format, 255,0,0));
  Draw_FillRound(screen, 390,20, 70,50, 20,
                 SDL_MapRGB(screen->format, 255,0,0));
  Draw_Round(screen, 390,20, 70,50, 20, c_cyan);

  /*Draw_Round(screen, 500,400, 5,3, 4, c_cyan);*/

  Draw_Rect(screen, 499,199, 52,72,
            SDL_MapRGB(screen->format, 255,255,0));
  //Draw_FillRect(screen, 500,200, 50,70,
  //              SDL_MapRGB(screen->format, 64,200,64));

  Draw_FillCircle(screen, 500,330, 30, c_cyan);

  SDL_UpdateRect(screen, 0, 0, 0, 0);



    ++frames;
    while ( SDL_PollEvent(&event) ) {
      switch (event.type) {
        case SDL_KEYDOWN:
        /*break;*/
        case SDL_QUIT:
          done = 1;
        break;
        default:
        break;
      }
    }/*while*/
  }/*while(!done)*/

}/*END*/

  now = SDL_GetTicks();
  if ( now > then ) {
    printf("%2.2f frames per second\n",
          ((double)frames*1000)/(now-then));
  }

  fprintf(stderr, "[END]\n");
  return 0;

}/*main*/