Exemple #1
0
int main()
{
  unsigned char* ret1=init1();

  if(ret1!=0)
  {
    unsigned char r1=ret1[0];
    assert(r1==0);
  }

  unsigned char* ret2=init2();

  if(ret2!=0)
  {
    unsigned char r2=ret2[0];
    assert(r2==0);
  }

  unsigned char* ret3=init3();

  if(ret3!=0)
  {
    unsigned char r3=ret3[0];
    assert(r3==0);
  }

  return 0;
}
Exemple #2
0
void initM3(double complex* f, double complex* g,
            unsigned int mx, unsigned int my, unsigned int mz,
            unsigned int M)
{
    unsigned int stride=mx*my*mz;
    for(unsigned int s=0; s < M; ++s)
        init3(f+s*stride,g+s*stride,mx,my,mz);
}
Exemple #3
0
//#define _SUBR		0x06	// 引数評価・C
//#define _EXPR		0x04	// 引数評価
//#define _FSUBR	0x02	// 引数評価しない・C
// 組み込み関数の登録
void init_subr()
{
	init0();
	init1();
	init2();
	init3();
	init4();
}
Exemple #4
0
void main(){
  int i;
  scanf("%d", &i);
  if (i < 10){
    init1(i);
    printf("%d\n",add());
  }
  
  init2(i+1);
  init3(i+1);
  printf("glob1=%d\n",sub());
}
void main() {
    int i,j;
    scanf("%d", &i);

    if (i<10) {
        init1(1);
        init2(1);
        printf("%d\n", g1+g2+j);
    }


    init3(1);
    i = sub();
    i = add();
}
    test* getOneofTestInstance()
    {
        test *t = new test;
        ScopeExitGuard onSuccessRollback([&] { delete t; t = NULL; });

        if(!init1(t))     // init1 failure
            return NULL;  // 直接return,t 会自动析构
        if(!init2(t))     // init2 failure
            return NULL;
        if(!init3(t) || !init4(t))  // init3 or init4 failure
            return NULL;

        // now t must be available
        onSuccessRollback.dismiss(); // dismiss, t不会析构,直接返回
        return t;
    }
Exemple #7
0
int main()
{
    printf("Example of calling fftw++ convolutions from C:\n");

    unsigned int nthreads=2;

    unsigned int M=2; /* dimension of dot product */
    double overM=1.0/(double) M;

    double complex *pf[M];
    double complex *pg[M];

    int returnflag=0;

    set_fftwpp_maxthreads(nthreads);

    {
        printf("Complex, non-centered 1D example:\n");
        unsigned int nx = 8;

        /* ImplicitConvolution *cconv=fftwpp_create_conv1d(m); */
        ImplicitConvolution *cconv = fftwpp_create_conv1d(nx);

        double complex *f = create_complexAlign(nx);
        double complex *g = create_complexAlign(nx);

        init(f, g, nx); /* set the input data */
        printf("Input f:\n");
        show(f, nx);
        printf("Input g:\n");
        show(g, nx);

        fftwpp_conv1d_convolve(cconv, f, g);
        //fftwpp_conv1d_correlate(cconv, f, g);

        printf("Output f:\n");
        show(f, nx);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_conv1d_delete(cconv);
        printf("\n");
    }

    {
        printf("Complex, Hermitian-symmetric, centered 1D example:\n");
        unsigned int nx = 8;

        ImplicitHConvolution *hconv = fftwpp_create_hconv1d(nx);

        double complex *f = create_complexAlign(nx);
        double complex *g = create_complexAlign(nx);

        init(f, g, nx); /* set the input data */
        printf("Input f:\n");
        show(f, nx);
        printf("Input g:\n");
        show(g, nx);

        fftwpp_hconv1d_convolve(hconv, f, g);

        printf("Output f:\n");
        show(f, nx);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_hconv1d_delete(hconv);
        printf("\n");
    }

    {
        printf("Complex, non-centered 2D example:\n");
        unsigned int nx = 4;
        unsigned int ny = 4;

        ImplicitConvolution2 *cconv2 = fftwpp_create_conv2d(nx, ny );

        double complex *f = create_complexAlign(nx * ny);
        double complex *g = create_complexAlign(nx * ny);

        init2(f, g, nx, ny); /* set the input data */
        printf("Input f:\n");
        show2(f, nx, ny);
        printf("Input g:\n");
        show2(g, nx, ny);

        fftwpp_conv2d_convolve(cconv2, f, g);

        printf("Output f:\n");
        show2(f, nx, ny);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_conv2d_delete(cconv2);
        printf("\n");
    }

    {
        printf("Complex, Hermitian-symmertic, centered 2D example:\n");
        unsigned int nx = 4;
        unsigned int ny = 4;

        ImplicitHConvolution2 *hconv2 = fftwpp_create_hconv2d(nx, ny );

        unsigned int nxp = 2 * nx - 1;
        double complex *f = create_complexAlign(nxp * ny);
        double complex *g = create_complexAlign(nxp * ny);

        init2(f, g, nxp, ny); /* set the input data */
        printf("Input f:\n");
        show2(f, nxp, ny);
        printf("Input g:\n");
        show2(g, nxp, ny);

        fftwpp_hconv2d_convolve(hconv2, f, g);

        printf("Output f:\n");
        show2(f, nxp, ny);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_hconv2d_delete(hconv2);
        printf("\n");
    }

    {
        printf("Complex, non-centered 3D example:\n");
        unsigned int nx = 4;
        unsigned int ny = 4;
        unsigned int nz = 4;

        ImplicitConvolution3 *cconv3 = fftwpp_create_conv3d(nx, ny, nz);

        double complex *f = create_complexAlign(nx * ny * nz);
        double complex *g = create_complexAlign(nx * ny * nz);

        init3(f, g, nx, ny, nz); /* set the input data */
        printf("Input f:\n");
        show3(f, nx, ny, nz);
        printf("Input g:\n");
        show3(g, nx, ny, nz);

        fftwpp_conv3d_convolve(cconv3, f, g);

        printf("Output f:\n");
        show3(f, nx, ny, nz);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_conv3d_delete(cconv3);
        printf("\n");
    }


    {
        printf("Complex, non-centered 3D example:\n");
        unsigned int nx = 4;
        unsigned int ny = 4;
        unsigned int nz = 4;

        ImplicitConvolution3 *cconv3 = fftwpp_create_conv3d(nx, ny, nz);

        double complex *f = create_complexAlign(nx * ny * nz);
        double complex *g = create_complexAlign(nx * ny * nz);

        init3(f, g, nx, ny, nz); /* set the input data */
        printf("Input f:\n");
        show3(f, nx, ny, nz);
        printf("Input g:\n");
        show3(g, nx, ny, nz);

        fftwpp_conv3d_convolve(cconv3, f, g);

        printf("Output f:\n");
        show3(f, nx, ny, nz);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_conv3d_delete(cconv3);
        printf("\n");
    }

    {
        printf("Complex, Hermitian-symmetric, centered 3D example:\n");
        unsigned int nx = 4;
        unsigned int ny = 4;
        unsigned int nz = 4;

        ImplicitHConvolution3 *hconv3 = fftwpp_create_hconv3d(nx, ny, nz);

        unsigned int nxp = 2 * nx - 1;
        unsigned int nyp = 2 * ny - 1;

        double complex *f = create_complexAlign(nxp * nyp * nz);
        double complex *g = create_complexAlign(nxp * nyp * nz);

        init3(f, g, nxp, nyp, nz); /* set the input data */
        printf("Input f:\n");
        show3(f, nxp, nyp, nz);
        printf("Input g:\n");
        show3(g, nxp, nyp, nz);

        fftwpp_hconv3d_convolve(hconv3, f, g);

        printf("Output f:\n");
        show3(f, nxp, nyp, nz);

        delete_complexAlign(g);
        delete_complexAlign(f);

        fftwpp_hconv3d_delete(hconv3);
        printf("\n");
    }
}
Exemple #8
0
Segment3::Segment3(glm::vec4& startVertex, glm::vec4& midVertex, glm::vec4& endVertex) : Segment2(startVertex, endVertex) {
	this->midVertex = midVertex;
	init3();
}
Exemple #9
0
void OnMouseClick(int button, int state, int x, int y)
{     
  if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) 
  { 
     
     if(x>25&&x<275&&y>15&&y<45)
     {      
            glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
          glutInitWindowSize(700,600);
          glutInitWindowPosition(400,100);
          glutCreateWindow("3DGasKet");
            glutDisplayFunc(display2);
          init();
          glEnable(GL_DEPTH_TEST);
          glClearColor(1.0,1.0,1.0,1.0);
          glutMainLoop();            
     }
     if(x>25&&x<275&&y>69&&y<99)
     {                      
        glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB|GLUT_DEPTH);
      glutInitWindowSize(700,600);
      glutInitWindowPosition(400,100);
      glutCreateWindow("TEAPOT");
      glutDisplayFunc(display3);
      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      glShadeModel(GL_SMOOTH);
      glEnable(GL_DEPTH_TEST);
      glEnable(GL_NORMALIZE);
      glClearColor(0.1,0.1,0.1,0.0);
    glViewport(0,0,700,600);
     glutMainLoop();
     }
     if(x>25&&x<275&&y>123&&y<153)
     {                      
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
        glutInitWindowSize(700, 600);
        glutInitWindowPosition(400,100);
        glutCreateWindow("colorcube");
        glutReshapeFunc(myReshape);
        glutDisplayFunc(display4);
        glutIdleFunc(spinCube);
        glutMouseFunc(mouse);
        glEnable(GL_DEPTH_TEST); 
               glEnableClientState(GL_COLOR_ARRAY);
               glEnableClientState(GL_NORMAL_ARRAY);
               glEnableClientState(GL_VERTEX_ARRAY);
               glVertexPointer(3,GL_FLOAT,0,vertices);
               glColorPointer(3,GL_FLOAT,0,colors);
               glNormalPointer(GL_FLOAT,0,normals);
               glClearColor(0.0,0.0,0.0,0.0);
               glColor3f(1.0,1.0,1.0);
        glutMainLoop();
           
     }
     if(x>25&&x<275&&y>177&&y<207)
     {                      
        theta1=theta1*(3.14/180);
      glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
      glutInitWindowSize(700,600);
      glutInitWindowPosition(400,100);
      glutCreateWindow("House");
      glutDisplayFunc(display1);
      myinit();
      glutMainLoop();
     }
     if(x>25&&x<275&&y>231&&y<261)
     {               
      xmin=50;ymin=50;
      xmax=100;ymax=100;
      xvmin=200,yvmin=200;
      xvmax=300;yvmax=300;
      glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
      glutInitWindowSize(700,600);
      glutInitWindowPosition(400,100);
      glutCreateWindow("COHEN SutherLand");
      glutDisplayFunc(display5);
      myinit1();
      glutMainLoop();
     }      
     if(x>25&&x<275&&y>285&&y<315)
     { 
        glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
      glutInitWindowSize(700,600);
      glutInitWindowPosition(400,100);
      glutCreateWindow("Filling a Polygon using Scan-line Algorithm");
      glutDisplayFunc(display6);
      myinit2();
      glutMainLoop();
      
     }
     if(x>25&&x<275&&y>339&&y<369)
     {                      
        glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
      glutInitWindowSize(700,600);
      glutInitWindowPosition(400,100);
      glutCreateWindow("Rectangular mesh");
      glutDisplayFunc(display7);
      init2();
      glutMainLoop();
     }
     if(x>25&&x<275&&y>393&&y<423)
     {                      
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
        glutInitWindowSize(700, 600);
        glutInitWindowPosition(400,100);
        glutCreateWindow("CAMERA");
        glutReshapeFunc(myReshape);
        glutDisplayFunc(display12);
      //  glutIdleFunc(spinCube);
        glutMouseFunc(mymouse);
        glutKeyboardFunc(keys);
        glEnable(GL_DEPTH_TEST); 
        glutMainLoop();  
     }
     if(x>25&&x<275&&y>447&&y<477)
     {                     
         glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
       glutInitWindowPosition(400,100);
       glutInitWindowSize(700,600);
       glutCreateWindow("Cylinder & ParralelPiped");
       init3();
       glutDisplayFunc(display9);
     }
    if(x>25&&x<275&&y>501&&y<531)
    {   
        glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
        glutInitWindowSize(700,600);
        glutInitWindowPosition(400,100);
        glutCreateWindow("liang barsky line clipping algorithm");
        myinit10();
      glutDisplayFunc(display10);
        glutMainLoop();
     }
                                                           
     if(x>25&&x<275&&y>555&&y<585)
     {                             
         glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGB);
         glutInitWindowSize(700,600);
         glutInitWindowPosition(400,100);
         glutCreateWindow("EXIT");
         glutDisplayFunc(display11);
     }
  } 
}
Exemple #10
0
/* start():
 * Called at the end of reset.s as the first C function after processor
 * bootup.  It is passed a state that is used to determine whether or not
 * the CPU is restarting as a result of a warmstart or a coldstart.  If
 * the restart is a coldstart, then state will be INITIALIZE.  if the
 * restart is a warmstart, then there are a few typical values of state,
 * the most common of which are APP_EXIT and EXCEPTION.
 *
 * The bss_start and bss_end variables are usually defined in the
 * target-specific linker memory-map definition file.  They symbolically
 * identify the beginning and end of the .bss section.  Many compilers
 * support intrinsic tags for this; however, since it is apparently not
 * consistent from one toolset to the next; I chose to make up my own
 * tags so that this file never changes from one toolset to the next.
 *
 * The FORCE_BSS_INIT definition can be established in the target-specific
 * config.h file to force .bss space initialization regardless of warm/cold
 * start.
 */
void
start(int state)
{
    char    buf[48];

#ifdef FORCE_BSS_INIT
    state = INITIALIZE;
#endif

    /* Based on the incoming value of 'state' we may or may not initialize
     * monitor-owned ram.  Ideally, we only want to initialize
     * monitor-owned ram when 'state' is INITIALIZE (power-up or reset);
     * however, to support the case where the incoming state variable may
     * be corrupted, we also initialize monitor-owned ram when 'state'
     * is anything unexpected...
     */
    switch(state) {
    case EXCEPTION:
    case APP_EXIT:
        break;
    case INITIALIZE:
    default:
        umonBssInit();
        break;
    }

    /* Now that the BSS clear loop has been done, we can copy the
     * value of state (either a register or on stack) to the global
     * variable (in BSS) StateOfMonitor...
     */
    StateOfMonitor = state;

    /* Step through different phases of startup...
     */
    init0();
    init1();
    init2();

    /* Depending on the type of startup, alert the console and do
     * further initialization as needed...
     */
    switch(StateOfMonitor) {
    case INITIALIZE:
        reginit();
        init3();
        break;
    case APP_EXIT:
        EthernetStartup(0,0);
        if(!MFLAGS_NOEXITSTATUS()) {
            printf("\nApplication Exit Status: %d (0x%x)\n",
                   AppExitStatus,AppExitStatus);
        }
        break;
    case EXCEPTION:
        EthernetStartup(0,0);
        printf("\n%s: '%s'\n",EXCEPTION_HEADING,
               ExceptionType2String(ExceptionType));
        printf("           Occurred near 0x%lx",ExceptionAddr);
        if(AddrToSym(-1,ExceptionAddr,buf,0)) {
            printf(" (within %s)",buf);
        }
        printf("\n\n");
        exceptionAutoRestart(INITIALIZE);
        break;
    default:
        printf("Unexpected monitor state: 0x%x (sp @ 0x%x)\n",
               StateOfMonitor, buf);
        /* To attempt to recover from the bad state, just do
         * what INITIALIZE would do...
         */
        reginit();
        init3();
        break;
    }

#ifdef LOCK_FLASH_PROTECT_RANGE
    /* Issue the command that will cause the range of sectors
     * designated by FLASH_PROTECT_RANGE to be locked.  This only
     * works if the flash device is capable of being locked.
     */
    sprintf(buf,"flash lock %s",FLASH_PROTECT_RANGE);
    docommand(buf,0);
#endif

#ifdef PRE_COMMANDLOOP_HOOK
    PRE_COMMANDLOOP_HOOK();
#endif

    /* Enter the endless loop of command processing: */
    CommandLoop();

    printf("ERROR: CommandLoop() returned\n");
    monrestart(INITIALIZE);
}
Exemple #11
0
void keyscan()
{
	if(k1==0&&flag2!=0)
	{
		delay(5);
		if(k1==0&&flag2!=0)
		{
			flag=0;  flag2=0; write_com(0x0c); init(); if(num!=0&&TR0==0) ET0=0;
		}
		while(k1==0);
	} 
	if(k1==0)
	{
		delay(5);
		if(k1==0)
		{
			flag++;
			if(flag==1)
			{
				init2();
			}
			switch(flag)
			{
				case 6 : write_com(0x80+0x40+0x04); break;
				case 7 : write_com(0x80+0x40+0x07); break;
				case 8 : write_com(0x80+0x40+0x0a); break;
				case 2 : init(); write_com(0x80+0x01); write_com(0x0f); break;
				case 3 : write_com(0x80+0x06); break;
				case 4 : write_com(0x80+0x09); break;
				case 5 : write_com(0x80+0x0d); break;
				case 9 : init3(); break;
				case 10: write_com(0x80+0x09); break;
				case 11: flag=0; write_com(0x01); write_com(0x0c); break;
			}
		}
		while(k1==0);
	}
	if(k2==0)
	{
		delay(5);
		if(k2==0)
		{
			if(flag==1)
			{
				if(ET0==0)
				{
					min2=0;sec2=0;num=0;secp=0;
					for(i=0;i<max;i++)
					{
						mins[i]=0;secs[i]=0;secps[i]=0;
					}
					max=0;ET0=1;flag2++;
					while(k2==0);
				}
				if(TR0==1)
				{
					num++;
					mins[num]=min2;
					secs[num]=sec2;
					secps[num]=secp;
					TR0=0;
					ET0=0;
					max=num;
					flag2++;
					while(k2==0);
				}
			}
			switch(flag)
			{
				case 6 : if(hour<23) hour++; else hour=0; writehour; delay(5); displayhour; write_com(0x80+0x40+0x04); break;
				case 7 : if(minute<59) minute++; else minute=0;writeminute; delay(5); displayminute;  write_com(0x80+0x40+0x07); break;
				case 8 : if(second<59) second++; else second=0;writesecond; delay(5); displaysecond;  write_com(0x80+0x40+0x0a); break;
				case 2 : year++;  writeyear; delay(5); displayyear;write_com(0x80+0x01);  break;
				case 3 : if(month<12) month++; else month=1;writemonth;delay(5); displaymonth; write_com(0x80+0x06);  break;
				case 4 : if(day<31) day++; else day=1; writeday; delay(5); displayday; write_com(0x80+0x09); break;
				case 5 : if(week<8) week++; else week=2; writeweek;delay(5); displayweek; write_com(0x80+0x0d); break;
				case 9 : if(ahour<23) ahour++; else ahour=0; displaytwo(6,ahour); write_add(1,ahour); write_com(0x80+0x06); break;
				case 10: if(amin<59) amin++; else amin=0; displaytwo(9,amin); write_add(2,amin); write_com(0x80+0x09); break;
			}
		}
		while(k2==0);
	}
	if(k3==0&flag!=0)
	{
		delay(5);
		if(k3==0&flag!=0)
		{
			if(flag==1)
			{
				if(ET0==1&&TR0==1)
				{
					num++;
					flag2++;
					mins[num]=min2;
					secs[num]=sec2;
					secps[num]=secp;
					while(k3==0)
					{
						display2();
					}
				}
				if(ET0==1&&TR0==0)
					{
						TR0=1;
						flag2++;
					}
				if(ET0==0)
				{
					if(num>1)
					num--;
					min2=mins[num];
					sec2=secs[num];
					secp=secps[num];
					flag2++;
				}
			}
			switch(flag)
			{
				case 6 : if(hour>0) hour--; else hour=23; writehour;delay(5); displayhour; write_com(0x80+0x40+0x04); break;
				case 7 : if(minute>0) minute--; else minute=59; writeminute; delay(5); displayminute; write_com(0x80+0x40+0x07); break;
				case 8 : if(second>0) second--; else second=59; writesecond; delay(5); displaysecond; write_com(0x80+0x40+0x0a); break;
				case 2 : year--; writeyear; delay(5);  displayyear; write_com(0x80+0x01); break;
				case 3 : if(month>1) month--; else month=12; writemonth; delay(5); displaymonth;  write_com(0x80+0x06); break;
				case 4 : if(day>1) day--; else day=31;writeday; delay(5); displayday;  write_com(0x80+0x09); break;
				case 5 : if(week>1) week--; else week=7;writeweek; delay(5); displayweek;  write_com(0x80+0x0d); break;
				case 9 : if(ahour>0) ahour--; else ahour=23; displaytwo(6,ahour); write_add(1,ahour); write_com(0x80+0x06); break;
				case 10: if(amin>0) amin--; else amin=59; displaytwo(9,amin); write_add(2,amin); write_com(0x80+0x09); break;
			}
		}
		while(k3==0);		
	}
	if(k4==0)
	{
		delay(5);
		if(k4==0&&ET1==0&&flag!=0)
		{
			if(num<max)
			num++;
			min2=mins[num];
			sec2=secs[num];
			secp=secps[num];
			flag2++;
		}
		if(k4==0&&flag==0)
		{
			write_com(0x01);
			displaytemp(readtemp());		  
		}
	}
	while(k4==0);
}
Exemple #12
0
LRESULT CALLBACK
WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	PAINTSTRUCT	ps;
	HDC		hdc;
#if CLIENT3D | IMAGE | GRAPH3D
	RECT		rc;
#endif
#if GRAPH3D
	static int	countup = 1;
	int		id;
	static vec1 	gx, gy;
#endif
#if TIMERDEMO
	static POINT	mousept;
#endif
#if ARCDEMO
	static int	startdegrees = 0;
	static int	enddegrees = 30;
#endif

	switch( msg) {
#if TIMERDEMO
	case WM_CREATE:
		SetTimer(hwnd, 1, 100, NULL);
		mousept.x = 60;
		mousept.y = 20;
		break;

	case WM_TIMER:
#if GRAPH3D
		GetClientRect(hwnd, &rc);
		if(countup) {
			mousept.y += 20;
			if(mousept.y >= rc.bottom) {
				mousept.y -= 20;
				countup = 0;
			}
		} else {
			mousept.y -= 20;
			if(mousept.y < 20) {
				mousept.y += 20;
				countup = 1;
			}
		}
		SendMessage(hwnd, WM_MOUSEMOVE, 0,
			MAKELONG(mousept.x, mousept.y));
#endif
#if ARCDEMO
		startdegrees += 10;
		if(startdegrees >= 360)
			startdegrees = 0;
		enddegrees += 15;
		if(enddegrees >= 360)
			enddegrees = 0;
		InvalidateRect(hwnd, NULL, TRUE);
#endif
		break;

	case WM_DESTROY:
		KillTimer(hwnd, 1);
		break;
#endif /* TIMERDEMO*/
	case WM_SIZE:
		break;

	case WM_MOVE:
		break;

#if CLIENT3D
	case WM_SETFOCUS:
		PostMessage((HWND)wp, WM_PAINT, 0, 0L);
		break;

	case WM_KILLFOCUS:
		PostMessage((HWND)wp, WM_PAINT, 0, 0L);
		break;
	case WM_ERASEBKGND:
		if(GetFocus() != hwnd)
			return DefWindowProc(hwnd, msg, wp, lp);
		return 1;
#endif
#if GRAPH3D
	case WM_ERASEBKGND:
		if((GetWindowLong(hwnd, GWL_ID) & 03) == 1)
			return 1;
		return DefWindowProc(hwnd, msg, wp, lp);
#endif
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);

#if CLIENT3D
		if(GetFocus() == hwnd) {
			GetClientRect(hwnd, &rc);
			Draw3dShadow(hdc, rc.left, rc.top,
				rc.right-rc.left, rc.bottom-rc.top,
				GetSysColor(COLOR_3DDKSHADOW),
				GetSysColor(COLOR_3DLIGHT));
			InflateRect(&rc, -1, -1);
			FillRect(hdc, &rc, GetStockObject(GRAY_BRUSH));
		}
#endif
#if IMAGE
		GetClientRect(hwnd, &rc);
		DrawDIB(hdc, rc.left+2, rc.top+2, image2);
#endif
#if ARCDEMO
{
	int x, y, w, h;
	RECT rc;

	if(hdc != NULL) {
		GetWindowRect(hwnd, &rc);
		rc.top += 13;
		InflateRect(&rc, -3, -3);
		/*Ellipse(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top);*/
		/*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/
		/*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/

		x = rc.left;
		y = rc.top;
		w = rc.right - rc.left;
		h = rc.bottom - rc.top;
		w += 10;
		GdSetForeground(GdFindColor(RGB(0,255,0)));
		GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
			enddegrees*64, MWPIE);
		GdSetForeground(GdFindColor(RGB(0,0,0)));
		GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64,
			enddegrees*64, MWARCOUTLINE);
		/*GdSetForeground(GdFindColor(RGB(255,255,255)));*/
		/*GdPoint(hdc->psd, x+w/2, y+h/2);*/
	}
	EndPaint(hwnd, &ps);
	break;
}
#endif /* ARCDEMO*/
#if GRAPH3D
		id = (int)GetWindowLong(hwnd, GWL_ID) & 03;
		init3(hdc, id == 1? hwnd: NULL);
		switch(id) {
		case 0:
			rose(1.0, 7, 13);
			break;
		case 1:
			/*look3(0.5, 0.7, 1.5);*/
			/*look3(0.2, -2 * gy, 1.0+gx);*/
			look3(-2 * gx, -2 * gy, 1.2);
			drawgrid(-8.0, 8.0, 10, -8.0, 8.0, 10);
			break;
		case 2:
			setcolor3(BLACK);
			circle3(1.0);
			break;
		case 3:
			setcolor3(BLUE);
			daisy(1.0, 20);
			break;
		}

#if CLIPDEMO
		if(id == 1) {
			HRGN	hrgn, hrgn2;

			/* create circular clip region for effect*/
			GetClientRect(hwnd, &rc);
			InflateRect(&rc, -80, -80);
			switch((int)GetWindowLong(hwnd, GWL_ID)) {
			default:
				hrgn = CreateEllipticRgnIndirect(&rc);
				break;
			case 5:
				hrgn = CreateRoundRectRgn(rc.left, rc.top,
					rc.right, rc.bottom, 100, 100);
				break;
			case 1:
				hrgn = CreateRectRgnIndirect(&rc);
				break;
			}

			/* erase background, clip out blit area*/
			GetClientRect(hwnd, &rc);
			hrgn2 = CreateRectRgnIndirect(&rc);
			SelectClipRgn(hdc, hrgn2);
			ExtSelectClipRgn(hdc, hrgn, RGN_XOR);
			DeleteObject(hrgn2);

			GetClientRect(hwnd, &rc);
			FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH));

			/* clip in only blit area*/
			SelectClipRgn(hdc, hrgn);
			DeleteObject(hrgn);
		}
#endif /* CLIPDEMO*/

		paint3(hdc);

#endif /* GRAPH3D*/
		EndPaint(hwnd, &ps);
		break;

	case WM_LBUTTONDOWN:
		break;

	case WM_MOUSEMOVE:
#if GRAPH3D
		if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) {
			POINT pt;

			POINTSTOPOINT(pt, lp);
			GetClientRect(hwnd, &rc);
			gx = (vec1)pt.x / rc.right;
			gy = (vec1)pt.y / rc.bottom;
			InvalidateRect(hwnd, NULL, FALSE);
			mousept.x = pt.x;
			mousept.y = pt.y;
		}
#endif
		break;

	case WM_LBUTTONUP:
		break;

	case WM_RBUTTONDOWN:
		break;

	default:
		return DefWindowProc( hwnd, msg, wp, lp);
	}
	return( 0);
}