Digital Oscilloscope GUI base on SDL.

Digital Oscilloscope GUI base on SDL.

1.soure code:

 

 

 

2.X86上运行效果图:

 

 

 

3.How to use SDL APIs:


1).SDL_Init(SDL_INIT_VIDEO) .

Initialize the Video Devices such as Framebuffer ,DireactFB,X11 or OpenGL etc.


2).Set the Video device.

SDL_Surface *screen, *window;

screen = SDL_SetVideoMode(w, h, 32, SDL_SWSURFACE);


3).Draw some graphic data on the backbuffer(SWSurface). 

    uint32_t color;
    SDL_Rect rect;
    color = SDL_MapRGB(screen->format, 0x00, 0x00, 0xFF);  /* Generate the blue color*/
    rect.x = 0;
    rect.y = 0;
    rect.w = screen->w;
    rect.h = screen->h;
    SDL_FillRect(screen, &rect, color);   /* FillRect function */


4).If you want to show some on the screen,please call

SDL_UpdateRect(screen, 30, 30, 480, 320);


5).Create a new RGB surface. 

*window = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32,
            0xFF << 24, 0xff << 16, 0xFF << 8, 0xFF);


6).BitBlt function(Copy source surface to destination surface).

    if ( SDL_BlitSurface(src, NULL, dst, &update) < 0 ) {
        fprintf(stderr, "Blit failed: %s/n", SDL_GetError());
    }


7).How to get input events.

    while (!quit) { 
        render(window, screen);
        SDL_UpdateRect(screen, 30, 30, 480, 320);    
        SDL_Event    event;
        uint32_t ret = 0;    
        //j = 0;    
        while (ret = SDL_PollEvent(&event)) { 

            /* when get input events,this function return 1,or 0,

                and it's not blocked function */ 
            //printf("j = %d,ret = %d/n", j++, ret);
            switch(event.type) {
                /*case SDL_MOUSEBUTTONDOWN:
                    break;*/
                case SDL_KEYDOWN:
                    if (event.key.keysym.sym == SDLK_ESCAPE) {
                        quit = SDL_TRUE;
                    }
                    break;
                case SDL_QUIT:
                    quit = SDL_TRUE;
                    break;
            }
        }    
        SDL_Delay(50);
    }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值